You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

interestsList.vue 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <view class="content">
  3. <view class="item" v-for="(item,index) in state.list" :key='index'>
  4. <view class="title" @click="addInterestsList(item)">
  5. <view>
  6. <view v-if='item.children' style="display: inline-block;">
  7. <image :class="item.isShow?'imageChange':'imageDefault'" @click="changeIsShow(index)"
  8. src="../../static/image/icon-back.png" alt="" srcset=""></image>
  9. </view>
  10. <text><text>{{item.productName}}</text>&nbsp;&nbsp;<text>¥{{item.discountPrice * 0.01}}</text></text>
  11. </view>
  12. <!-- <checkbox-group @change='getValue(index)'>
  13. <label>
  14. <checkbox :value="index" />
  15. </label>
  16. </checkbox-group> -->
  17. </view>
  18. <view v-if="item.isShow" class="children" v-for="(itemChild,index) in item.children" :key='index'>
  19. <view><text>{{itemChild.productName}}</text>&nbsp;&nbsp;<text>{{itemChild.discountPrice * 0.01}}</text>
  20. </view>
  21. </view>
  22. </view>
  23. <!-- <button type="default" class="button" @click="addInterestsList()">
  24. 加购权益
  25. </button> -->
  26. </view>
  27. </template>
  28. <script setup lang="ts">
  29. import { onLoad, onShow } from "@dcloudio/uni-app";
  30. import { reactive } from "vue";
  31. import { equityProductsApi } from "@/utils/network/api.js";
  32. import { stringToJson } from "@/utils/network/encryption";
  33. import { request } from "@/utils/network/request";
  34. import { etcQYAction } from "@/utils/network/api.js";
  35. import { fileURL } from "@/datas/fileURL.js";
  36. import navBar from "@/components/nav-bar/nav-bar2.vue";
  37. import navBgCar from "./components/nav-bg-car4";
  38. // import { setItem } from "@/utils/storage";
  39. import { msg } from "@/utils/utils";
  40. import {
  41. checkOrderStatus,
  42. wechatAppID,
  43. wechatPayConfigId,
  44. wechatSecret,
  45. addProduct,
  46. queryDetails,
  47. getOpenidApi
  48. } from "@/utils/network/api";
  49. import {
  50. getItem,
  51. StorageKeys,
  52. setItem
  53. } from "@/utils/storage";
  54. const imgURL = `${fileURL}image/`;
  55. const state = reactive({
  56. openid: "",
  57. orderId: "",
  58. id: "",
  59. clientFee: "",
  60. list: [], //权益数据
  61. choiceValue: [], //选择的权益数据的下标
  62. choiceValueComplete: [], //选择的权益数据的具体数据
  63. isValueCard: "",
  64. type: 0,
  65. userType: 0,
  66. promoteId: "", //产品id
  67. totalAmount: 0, //产品+权益产品金额
  68. })
  69. onLoad((option : any) => {
  70. // getList("promoteId", option);
  71. console.log("promoteId", option)
  72. state.orderId = option.orderId;
  73. state.clientFee = option.clientFee;
  74. state.id = option.id;
  75. state.userType = option.userType;
  76. state.type = option.type;
  77. state.isValueCard = option.isValueCard;
  78. state.promoteId = option.promoteId;
  79. state.totalAmount = option.fee;
  80. getList();
  81. getOpenID();
  82. console.log("option", option)
  83. })
  84. const addInterestsList = (item) => {
  85. console.log("item", item)
  86. state.totalAmount = Number(state.totalAmount) + Number(item.discountPrice)
  87. uni.redirectTo({
  88. url: `/subpackage/orders/essential-information?promoteId=${getItem("promoteId")}&userType=${state.userType}&type=${state.type}&isValueCard=${state.isValueCard}&totalAmount=${state.totalAmount}&equityId=${item.equityId}`,
  89. });
  90. }
  91. const getList = () => {
  92. const options = {
  93. type: 2,
  94. data: {
  95. "promoteId": state.promoteId,
  96. },
  97. method: 'POST',
  98. showLoading: true,
  99. }
  100. request(equityProductsApi, options).then((res) => {
  101. const data = stringToJson(res.bizContent);
  102. for (var i = 0; i < data.data.length; i++) {
  103. data.data[i]['isShow'] = false;
  104. }
  105. state.list = data.data
  106. console.log("222", data.data)
  107. })
  108. }
  109. const change = (e) => {
  110. console.log(e);
  111. }
  112. //获取微信小程序openid
  113. const getOpenID = () => {
  114. // #ifdef MP-WEIXIN
  115. uni.login({
  116. provider: "weixin",
  117. success: function (e) {
  118. console.log(e);
  119. getOpenid(e.code);
  120. },
  121. });
  122. //#endif
  123. };
  124. const getOpenid = (code) => {
  125. const options = {
  126. type: 2,
  127. data: {
  128. "jsCode": code
  129. },
  130. method: "POST",
  131. showLoading: true,
  132. };
  133. // #ifdef MP-WEIXIN
  134. request(getOpenidApi, options).then((res) => {
  135. const result = stringToJson(res.bizContent);
  136. console.log("获取微信小程序openid", result);
  137. const openidData = stringToJson(result.data);
  138. state.openid = openidData.openid;
  139. setItem("QYorder", state);
  140. // setItem("QYorder", result.data);
  141. // state.openid = result.data.openid
  142. });
  143. // #endif
  144. }
  145. const changeIsShow = (index) => {
  146. console.log(index, state.list[index]['isShow'], !state.list[index]['isShow'])
  147. state.list[index]['isShow'] = !state.list[index]['isShow']
  148. console.log("state.list", state.list)
  149. }
  150. const getValue = (value) => {
  151. if (state.choiceValue.length == 0) {
  152. console.log("第一次")
  153. state.choiceValue.push(value)
  154. console.log("state.choiceValue", state.choiceValue)
  155. } else {
  156. var index = state.choiceValue.indexOf(value);
  157. if (index > -1) {//大于0 代表存在,
  158. state.choiceValue.splice(index, 1);//存在就删除
  159. } else {
  160. state.choiceValue.push(value)
  161. }
  162. console.log("state.choiceValue", state.choiceValue)
  163. }
  164. }
  165. </script>
  166. <style scoped lang="scss">
  167. .content {
  168. width: 100%;
  169. height: 100vh;
  170. }
  171. .button {
  172. height: 80rpx;
  173. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  174. border-radius: 40rpx;
  175. font-size: 32rpx;
  176. font-weight: 400;
  177. color: #ffffff;
  178. line-height: 80rpx;
  179. margin: 20rpx;
  180. }
  181. .imageDefault {
  182. height: 40rpx;
  183. width: 40rpx;
  184. transform: rotate(270deg);
  185. margin-right: 12rpx;
  186. color: white;
  187. }
  188. .imageChange {
  189. height: 40rpx;
  190. width: 40rpx;
  191. transform: rotate(90deg);
  192. margin-right: 12rpx;
  193. color: white;
  194. }
  195. .item {
  196. width: 90%;
  197. margin: 20rpx auto;
  198. background-color: rgb(41, 199, 207);
  199. border-radius: 20rpx;
  200. padding: 20rpx;
  201. box-sizing: border-box;
  202. color: white;
  203. font-size: 32rpx;
  204. }
  205. .item>.title {
  206. width: 100%;
  207. display: flex;
  208. justify-content: space-between;
  209. align-items: center;
  210. }
  211. .title>checkbox-group {
  212. // float: right;
  213. }
  214. .children {
  215. margin-left: 50rpx;
  216. margin-top: 16rpx;
  217. }
  218. .children>view {
  219. height: 50rpx;
  220. line-height: 50rpx;
  221. }
  222. .show {
  223. display: inline-block;
  224. }
  225. .hide {
  226. display: none;
  227. }
  228. checkbox {
  229. transform: scale(0.8);
  230. }
  231. </style>