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.

пре 1 година
пре 2 година
пре 1 година
пре 2 година
пре 1 година
пре 2 година
пре 2 година
пре 1 година
пре 1 година
пре 2 година
пре 1 година
пре 2 година
пре 1 година
пре 2 година
пре 1 година
пре 1 година
пре 1 година
пре 2 година
пре 1 година
пре 2 година
пре 1 година
пре 1 година
пре 2 година
пре 1 година
пре 1 година
пре 1 година
пре 2 година
пре 1 година
пре 2 година
пре 1 година
пре 2 година
пре 1 година
пре 1 година
пре 1 година
пре 2 година
пре 1 година
пре 1 година
пре 2 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 2 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 2 година
пре 1 година
пре 2 година
пре 1 година
пре 1 година
пре 2 година
пре 1 година
пре 1 година
пре 2 година
пре 1 година
пре 2 година
пре 1 година
пре 2 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 2 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 2 година
пре 1 година
пре 2 година
пре 1 година
пре 2 година
пре 1 година
пре 2 година
пре 1 година
пре 2 година
пре 1 година
пре 2 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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. orderPay,
  43. wechatAppID,
  44. wechatPayConfigId,
  45. wechatSecret,
  46. addProduct,
  47. queryDetails,
  48. getOpenidApi
  49. } from "@/utils/network/api";
  50. import {
  51. getItem,
  52. StorageKeys,
  53. setItem
  54. } from "@/utils/storage";
  55. const imgURL = `${fileURL}image/`;
  56. const state = reactive({
  57. openid: "",
  58. orderId: "",
  59. id: "",
  60. clientFee: "",
  61. list: [], //权益数据
  62. choiceValue: [], //选择的权益数据的下标
  63. choiceValueComplete: [], //选择的权益数据的具体数据
  64. isValueCard: "",
  65. type: 0,
  66. userType: 0,
  67. promoteId: "", //产品id
  68. totalAmount: 0, //产品+权益产品金额
  69. })
  70. onLoad((option : any) => {
  71. // getList("promoteId", option);
  72. console.log("promoteId", option)
  73. state.orderId = option.orderId;
  74. state.clientFee = option.clientFee;
  75. state.id = option.id;
  76. state.userType = option.userType;
  77. state.type = option.type;
  78. state.isValueCard = option.isValueCard;
  79. state.promoteId = option.promoteId;
  80. state.totalAmount = option.fee;
  81. getList();
  82. getOpenID();
  83. console.log("option", option)
  84. })
  85. const addInterestsList = (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}`,
  89. });
  90. return;
  91. state.choiceValueComplete = [];
  92. for (var i = 0; i < state.choiceValue.length; i++) {
  93. state.choiceValueComplete.push(state.list[state.choiceValue[i]])
  94. }
  95. let items = encodeURIComponent(JSON.stringify(state.choiceValueComplete));
  96. console.log("state.openid", state);
  97. const data = JSON.parse(decodeURIComponent(items));
  98. let productId = [];
  99. state.productMoney = 0;
  100. for (var i = 0; i < data.length; i++) {
  101. data['isOpened'] = 'node';
  102. state.productMoney += data[i]['discountPrice'] / 100;
  103. productId.push(data[i]['equityId'])
  104. }
  105. const options = {
  106. type: 2,
  107. data: {
  108. orderId: state.orderId, //订单编号
  109. },
  110. method: "POST",
  111. showLoading: true,
  112. };
  113. console.log("options", options);
  114. request(queryDetails, options).then((res) => {
  115. state.detailsObj = stringToJson(res.bizContent);
  116. console.log("state.detailsObj", state.detailsObj)
  117. let allMoney = (parseFloat(state.detailsObj.product.oncePrice * 0.01) + parseFloat(state.productMoney)).toFixed(2)
  118. const optionss = {
  119. type: 2,
  120. data: {
  121. orderId: state.orderId, //订单编号
  122. openId: getItem(StorageKeys.OpenId), //操作人 id
  123. equityId: productId.toString(), //权益Id
  124. totalAmount: allMoney * 100, //总金额
  125. isRepeatPurchase: 0
  126. },
  127. method: "POST",
  128. showLoading: true,
  129. };
  130. console.log("optionss", optionss);
  131. request(addProduct, optionss).then((res) => {
  132. // uni.redirectTo({
  133. // url: `/subpackage/orders/product-detail?orderId=${state.orderId}&&clientFee=${state.clientFee}&&id=${state.id}&&data=${items}&&isValueCard=${state.detailsObj.isValueCard}`,
  134. // });
  135. uni.redirectTo({
  136. url: `/subpackage/orders/essential-information?promoteId=${getItem("promoteId")}&userType=${state.userType}&type=${state.type}&isValueCard=${state.isValueCard}`,
  137. });
  138. });
  139. });
  140. }
  141. const getList = () => {
  142. const options = {
  143. type: 2,
  144. data: {
  145. "promoteId": state.promoteId,
  146. },
  147. method: 'POST',
  148. showLoading: true,
  149. }
  150. request(equityProductsApi, options).then((res) => {
  151. const data = stringToJson(res.bizContent);
  152. for (var i = 0; i < data.data.length; i++) {
  153. data.data[i]['isShow'] = false;
  154. }
  155. state.list = data.data
  156. console.log("222", state)
  157. })
  158. }
  159. const change = (e) => {
  160. console.log(e);
  161. }
  162. //获取微信小程序openid
  163. const getOpenID = () => {
  164. // #ifdef MP-WEIXIN
  165. uni.login({
  166. provider: "weixin",
  167. success: function (e) {
  168. console.log(e);
  169. getOpenid(e.code);
  170. },
  171. });
  172. //#endif
  173. };
  174. const getOpenid = (code) => {
  175. const options = {
  176. type: 2,
  177. data: {
  178. "jsCode": code
  179. },
  180. method: "POST",
  181. showLoading: true,
  182. };
  183. // #ifdef MP-WEIXIN
  184. request(getOpenidApi, options).then((res) => {
  185. const result = stringToJson(res.bizContent);
  186. console.log("获取微信小程序openid", result);
  187. const openidData = stringToJson(result.data);
  188. state.openid = openidData.openid;
  189. setItem("QYorder", state);
  190. // setItem("QYorder", result.data);
  191. // state.openid = result.data.openid
  192. });
  193. // #endif
  194. }
  195. const changeIsShow = (index) => {
  196. console.log(index, state.list[index]['isShow'], !state.list[index]['isShow'])
  197. state.list[index]['isShow'] = !state.list[index]['isShow']
  198. console.log("state.list", state.list)
  199. }
  200. const getValue = (value) => {
  201. if (state.choiceValue.length == 0) {
  202. console.log("第一次")
  203. state.choiceValue.push(value)
  204. console.log("state.choiceValue", state.choiceValue)
  205. } else {
  206. var index = state.choiceValue.indexOf(value);
  207. if (index > -1) {//大于0 代表存在,
  208. state.choiceValue.splice(index, 1);//存在就删除
  209. } else {
  210. state.choiceValue.push(value)
  211. }
  212. console.log("state.choiceValue", state.choiceValue)
  213. }
  214. }
  215. </script>
  216. <style scoped lang="scss">
  217. .content {
  218. width: 100%;
  219. height: 100vh;
  220. }
  221. .button {
  222. height: 80rpx;
  223. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  224. border-radius: 40rpx;
  225. font-size: 32rpx;
  226. font-weight: 400;
  227. color: #ffffff;
  228. line-height: 80rpx;
  229. margin: 20rpx;
  230. }
  231. .imageDefault {
  232. height: 40rpx;
  233. width: 40rpx;
  234. transform: rotate(270deg);
  235. margin-right: 12rpx;
  236. color: white;
  237. }
  238. .imageChange {
  239. height: 40rpx;
  240. width: 40rpx;
  241. transform: rotate(90deg);
  242. margin-right: 12rpx;
  243. color: white;
  244. }
  245. .item {
  246. width: 90%;
  247. margin: 10rpx auto;
  248. background-color: rgb(41, 199, 207);
  249. // height: 150rpx;
  250. border-radius: 20rpx;
  251. padding: 20rpx;
  252. box-sizing: border-box;
  253. color: white;
  254. font-size: 32rpx;
  255. }
  256. .item>.title {
  257. width: 100%;
  258. display: flex;
  259. justify-content: space-between;
  260. align-items: center;
  261. }
  262. .title>checkbox-group {
  263. // float: right;
  264. }
  265. .children {
  266. margin-left: 50rpx;
  267. margin-top: 16rpx;
  268. }
  269. .children>view {
  270. height: 50rpx;
  271. line-height: 50rpx;
  272. }
  273. .show {
  274. display: inline-block;
  275. }
  276. .hide {
  277. display: none;
  278. }
  279. checkbox {
  280. transform: scale(0.8);
  281. }
  282. </style>