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.1KB

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