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

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