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 5.8KB

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