您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

product-detail.vue 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. <template>
  2. <navBar title="产品详情"></navBar>
  3. <navBgCar></navBgCar>
  4. <view class="content-wrap">
  5. <!-- <view class="ul-item">
  6. <image style="width: 100%; height: 170rpx; background-color: #eeeeee"
  7. :src="`${$imgUrl}applyCard/product-bg.png`"></image>
  8. <view class="item-value">
  9. <image class="icon-tip" :src="`${$imgUrl}applyCard/wechat.png`"></image>
  10. <view class="content">
  11. <view class="title"> {{state.detailsObj.productName}} </view>
  12. <view style="margin-top: 15rpx" class="tip"> {{state.detailsObj.releaseProduct.remarks}} </view>
  13. </view>
  14. <view class="price">
  15. ¥:{{state.detailsObj.product.oncePrice * 0.01}}
  16. </view>
  17. </view>
  18. </view> -->
  19. <!-- <view style="margin: 20rpx 0 10rpx 20rpx;font-size: 32rpx;">加购权益列表</view> -->
  20. <!-- <view class="add_all">
  21. <uni-swipe-action>
  22. <uni-swipe-action-item class="del_item" v-for="(item,index) in state.list"
  23. :right-options="state.options2" :show="item.isOpened" :auto-close="false" @change="change"
  24. @click="bindClick(index)">
  25. <view class="content-box">
  26. <view v-if='item.children' style="display: inline-block;">
  27. <image :class="item.isShow?'imageChange':'imageDefault'" @click="changeIsShow(index)"
  28. src="../../static/image/icon-back.png" alt="" srcset=""></image>
  29. </view>
  30. <text class="content-text" @tap="setOpened">{{item.productName}}
  31. &nbsp;¥{{item.discountPrice * 0.01}}</text>
  32. <view v-if="item.isShow" class="children" v-for="(itemChild,index) in item.children"
  33. :key='index'>
  34. <view>
  35. <text>{{itemChild.productName}}</text>&nbsp;&nbsp;<text>{{itemChild.discountPrice * 0.01}}</text>
  36. </view>
  37. </view>
  38. </view>
  39. </uni-swipe-action-item>
  40. </uni-swipe-action>
  41. </view> -->
  42. <view class="value-wrapper">
  43. <view class="flex" v-for="(item,index) in state.dataArray">
  44. <view class="title"> {{item.payName}} </view>
  45. <view class="value">
  46. {{ "¥" + item.fee * 0.01 }}
  47. </view>
  48. </view>
  49. <!-- <view class="flex">
  50. <view class="title"> 产品金额 </view>
  51. <view class="value">
  52. {{ "¥" + state.detailsObj.product.oncePrice * 0.01 }}
  53. </view>
  54. </view> -->
  55. <!-- <view class="flex">
  56. <view class="title"> 加购权益 </view>
  57. <view class="value">{{ "¥" + state.productMoney }} </view>
  58. </view> -->
  59. <view class="flex">
  60. <view class="title"> 运费 </view>
  61. <view class="value"> ¥0.00 </view>
  62. </view>
  63. <view class="flex">
  64. <view class="title"> 优惠券 </view>
  65. <view class="value"> 暂无优惠券 </view>
  66. </view>
  67. <view class="flex">
  68. <view class="title"> 积分兑换 </view>
  69. <view class="value"> 暂无积分 </view>
  70. </view>
  71. <view class="flex">
  72. <view class="title"> 实付款 </view>
  73. <view class="money">
  74. {{ "¥" + state.allMoney }}
  75. </view>
  76. </view>
  77. <view class="as-layout-horizontal agreement">
  78. <checkbox-group @change="checkboxChange">
  79. <checkbox :checked="state.checked" style="transform: scale(0.8)" />我已阅读并同意
  80. </checkbox-group>
  81. <a style="color:#007AFF;text-decoration: underline;">《ETC客户协议》</a>
  82. <a style="color:#007AFF;text-decoration: underline;">《风险提示告知书》</a>
  83. </view>
  84. </view>
  85. <view class="action">
  86. <button type="default" class="button" @click="savaHandle()">
  87. {{ "确认办理:¥" + state.allMoney }}
  88. </button>
  89. </view>
  90. </view>
  91. </template>
  92. <script setup lang="ts">
  93. import {
  94. onLoad,
  95. onShow
  96. } from "@dcloudio/uni-app";
  97. import {
  98. reactive,
  99. ref
  100. } from "vue";
  101. import {
  102. etcQueryProduct,
  103. addProduct,
  104. getOpenidApi,
  105. getAgreementApi,
  106. PAYDETECTION
  107. } from "@/utils/network/api.js";
  108. import {
  109. request
  110. } from "@/utils/network/request.js";
  111. import {
  112. stringToJson
  113. } from "@/utils/network/encryption";
  114. import {
  115. fileURL
  116. } from "@/datas/fileURL.js";
  117. import navBgCar from "./components/nav-bg-car5";
  118. import navBar from "@/components/nav-bar/nav-bar2.vue";
  119. import {
  120. getItem,
  121. StorageKeys
  122. } from "@/utils/storage.ts";
  123. import {
  124. checkOrderStatus,
  125. orderPay,
  126. wechatAppID,
  127. wechatPayConfigId,
  128. wechatSecret,
  129. queryDetails
  130. } from "@/utils/network/api";
  131. import {
  132. confirm,
  133. msg
  134. } from "@/utils/utils";
  135. const imgURL = `${fileURL}image/`;
  136. const savaHandle = () => {
  137. console.log("state.productId.length", state.productId.length)
  138. //判断是否有加购权益
  139. // if (state.productId.length > 0) {
  140. // queryAddProduct();
  141. // }
  142. // uni.showModal({
  143. // // title: '提示',
  144. // content: '确定支付',
  145. // success: function (res) {
  146. // if (res.confirm) {
  147. // console.log('用户点击确定');
  148. // wxPayment();
  149. // } else if (res.cancel) {
  150. // console.log('用户点击取消');
  151. // }
  152. // }
  153. // });
  154. // msg("确定绑定权益产品");
  155. // wxPayment();
  156. if (state.checked) {
  157. uni.navigateTo({
  158. url: `/subpackage/orders/order_payment?orderId=${state.orderId}&&clientFee=${state.clientFee}&&id=${state.id}&&isValueCard=${state.isValueCard}`,
  159. });
  160. } else {
  161. msg("请勾选协议");
  162. }
  163. };
  164. //获取微信小程序openid
  165. const getOpenID = () => {
  166. uni.login({
  167. provider: "weixin",
  168. success: function (e) {
  169. getOpenid(e.code);
  170. // uni.request({
  171. // url: `https://api.weixin.qq.com/sns/jscode2session?appid=${wechatAppID}&secret=${wechatSecret}&js_code=${e.code}&grant_type=authorization_code`,
  172. // success: (res: any) => {
  173. // state.openid = res.data.openid;
  174. // console.log("state.openid", state.openid);
  175. // },
  176. // });
  177. },
  178. });
  179. };
  180. const getOpenid = (code) => {
  181. const options = {
  182. type: 2,
  183. data: {
  184. "jsCode": code
  185. },
  186. method: "POST",
  187. showLoading: true,
  188. };
  189. // #ifdef MP-WEIXIN
  190. request(getOpenidApi, options).then((res) => {
  191. const result = stringToJson(res.bizContent);
  192. console.log("获取微信小程序openid", result);
  193. const openidData = stringToJson(result.data);
  194. state.openid = openidData.openid;
  195. });
  196. // #endif
  197. }
  198. //唤起微信支付
  199. const wxPayment = () => {
  200. // #ifdef MP-WEIXIN
  201. const options = {
  202. type: 2,
  203. data: {
  204. openid: state.openid,
  205. productId: state.id,
  206. orderId: state.orderId,
  207. payConfigId: wechatPayConfigId,
  208. },
  209. method: "POST",
  210. showLoading: true,
  211. };
  212. request(orderPay, options).then((res) => {
  213. const data = stringToJson(res.bizContent);
  214. uni.requestPayment({
  215. provider: "wxpay",
  216. orderInfo: "",
  217. timeStamp: data.timestamp,
  218. nonceStr: data.noncestr,
  219. package: data.wxPackage ? data.wxPackage : "",
  220. signType: data.signType,
  221. paySign: data.sign,
  222. success: function (e) {
  223. console.log("支付成功", e);
  224. checkOrder();
  225. },
  226. fail: function (err) {
  227. // checkOrder();
  228. confirm(err, () => { }, "支付失败", false);
  229. },
  230. });
  231. });
  232. // #endif
  233. };
  234. //支付成功改变订单状态
  235. const checkOrder = () => {
  236. const options = {
  237. type: 2,
  238. data: {
  239. orderId: state.orderId,
  240. payConfigId: wechatPayConfigId,
  241. },
  242. method: "POST",
  243. showLoading: true,
  244. };
  245. request(checkOrderStatus, options).then((res) => {
  246. msg("支付成功!");
  247. var pages = getCurrentPages().length;
  248. uni.$emit("refreshOrder");
  249. uni.switchTab({
  250. url: "/pages/order/order"
  251. })
  252. });
  253. };
  254. onLoad((option : any) => {
  255. state.orderId = option.orderId;
  256. state.isValueCard = option.isValueCard;
  257. // state.clientFee = option.clientFee / 100;
  258. state.id = option.id;
  259. getOpenID();
  260. queryAgreement();
  261. // const data = JSON.parse(decodeURIComponent(option.data));
  262. // for (var i = 0; i < data.length; i++) {
  263. // data['isOpened'] = 'node';
  264. // state.productMoney += data[i]['discountPrice'] / 100;
  265. // state.productId.push(data[i]['equityId'])
  266. // }
  267. // state.list = data;
  268. // queryDetailsData();
  269. refresh();
  270. });
  271. const state = reactive({
  272. openid: "",
  273. orderId: "",
  274. clientFee: undefined,
  275. id: "",
  276. options2: [{
  277. text: '删除',
  278. style: {
  279. backgroundColor: '#F56C6C'
  280. }
  281. }],
  282. isOpened: 'none',
  283. list: [],
  284. productMoney: 0,
  285. allMoney: 0,
  286. productId: [],
  287. // 弹框
  288. type: 'center',
  289. msgType: 'success',
  290. messageText: '这是一条成功提示',
  291. value: '',
  292. detailsObj: '',
  293. isValueCard: "",
  294. dataArray: [],
  295. checked: false
  296. });
  297. const bindClick = (i) => {
  298. console.log(i);
  299. uni.showToast({
  300. title: "删除成功",
  301. icon: 'none'
  302. });
  303. state.list.splice(i, 1);
  304. state.productMoney = 0;
  305. state.productId = [];
  306. for (var k = 0; k < state.list.length; k++) {
  307. state.productMoney += state.list[k]['discountPrice'] / 100
  308. state.productId.push(state.list[k]['equityId'])
  309. }
  310. state.allMoney = (state.productMoney + state.clientFee).toFixed(2)
  311. console.log("state.productId", state.productId)
  312. };
  313. const setOpened = () => {
  314. if (state.isOpened === 'none') {
  315. state.isOpened = 'right';
  316. return;
  317. }
  318. if (state.isOpened === 'left') {
  319. state.isOpened = 'right';
  320. return;
  321. }
  322. if (state.isOpened === 'right') {
  323. state.isOpened = 'none';
  324. return;
  325. }
  326. }
  327. const change = (e) => {
  328. state.isOpened = e;
  329. }
  330. // 加购权益产品接口
  331. const queryAddProduct = () => {
  332. console.log("state.openid", state.openid);
  333. const options = {
  334. type: 2,
  335. data: {
  336. orderId: state.orderId, //订单编号
  337. openId: state.openid, //操作人 id
  338. equityId: state.productId.toString(), //权益Id
  339. totalAmount: state.allMoney * 100, //总金额
  340. isRepeatPurchase: 0
  341. },
  342. method: "POST",
  343. showLoading: true,
  344. };
  345. request(addProduct, options).then((res) => { });
  346. }
  347. const changeIsShow = (index) => {
  348. console.log(index, state.list[index]['isShow'], !state.list[index]['isShow'])
  349. state.list[index]['isShow'] = !state.list[index]['isShow']
  350. console.log("state.list", state.list)
  351. }
  352. const queryDetailsData = () => {
  353. const options = {
  354. type: 2,
  355. data: {
  356. orderId: state.orderId, //订单编号
  357. },
  358. method: "POST",
  359. showLoading: true,
  360. };
  361. request(queryDetails, options).then((res) => {
  362. state.detailsObj = stringToJson(res.bizContent);
  363. console.log("state.detailsObj", state.detailsObj)
  364. state.allMoney = (parseFloat(state.detailsObj.product.oncePrice * 0.01) + parseFloat(state.productMoney)).toFixed(2)
  365. });
  366. }
  367. // 查协议
  368. const queryAgreement = () => {
  369. const options = {
  370. type: 2,
  371. data: {
  372. orderId: state.orderId, //订单编号
  373. },
  374. method: "POST",
  375. showLoading: true,
  376. };
  377. request(getAgreementApi, options).then((res) => {
  378. let data = stringToJson(res.bizContent);
  379. console.log("查协议", data)
  380. });
  381. }
  382. const checkboxChange = (e) => {
  383. state.checked = !state.checked;
  384. console.log(state.checked);
  385. };
  386. const refresh = () => {
  387. let source = ""
  388. // #ifdef MP-ALIPAY
  389. source = "ALI"
  390. // #endif
  391. // #ifdef MP-WEIXIN
  392. source = "WECHAT"
  393. // getOpenID();
  394. // #endif
  395. var data = {
  396. orderId: state.orderId,
  397. source: source //请求方来源
  398. };
  399. const options = {
  400. type: 2,
  401. data: data,
  402. method: "POST",
  403. showLoading: true,
  404. };
  405. console.log("输出内容", options);
  406. request(PAYDETECTION, options).then((res) => {
  407. // console.log(res.bizContent);
  408. const data = stringToJson(res.bizContent);
  409. console.log(data);
  410. // console.log(typeof(data));
  411. // if (data.paymentStatus == 'ALLSUCCESS') {
  412. // gotoEditUserOrUnitInfo()
  413. // }
  414. state.dataArray = data.datas;
  415. // HANDLE("办理费",1){},
  416. // MARGIN("保证金",2){},
  417. // PRESTORE("预存金",3){},
  418. // EQUITY("权益费",4){},
  419. for (let i = 0; i < state.dataArray.length; i++) {
  420. if (state.dataArray[i].payType === 'HANDLE') {
  421. state.dataArray[i].payName = '办理费'
  422. } else if (state.dataArray[i].payType === 'MARGIN') {
  423. state.dataArray[i].payName = '保证金'
  424. } else if (state.dataArray[i].payType === 'PRESTORE') {
  425. state.dataArray[i].payName = '预存金'
  426. } else if (state.dataArray[i].payType === 'EQUITY') {
  427. state.dataArray[i].payName = '权益费'
  428. } else {
  429. state.dataArray[i].payName = '未知费'
  430. }
  431. // SUCCESS("支付成功",1){},
  432. // PAYING("支付中",2){},
  433. // FAILED("支付失败",3){},
  434. // UNPAY("未支付",4){},
  435. // CLOSED("已关闭",5){},
  436. // CANCELED("已撤销",6){},
  437. // REFUND("转入退费",7){},
  438. if (state.dataArray[i].payStatus === 'SUCCESS') {
  439. state.dataArray[i].payStatusName = '已支付'
  440. } else if (state.dataArray[i].payStatus === 'PAYING') {
  441. state.dataArray[i].payStatusName = '支付中'
  442. } else if (state.dataArray[i].payStatus === 'FAILED') {
  443. state.dataArray[i].payStatusName = '支付失败'
  444. } else if (state.dataArray[i].payStatus === 'UNPAY') {
  445. state.dataArray[i].payStatusName = '未支付'
  446. } else if (state.dataArray[i].payStatus === 'CLOSED') {
  447. state.dataArray[i].payStatusName = '已关闭'
  448. } else if (state.dataArray[i].payStatus === 'CANCELED') {
  449. state.dataArray[i].payStatusName = '已撤销'
  450. } else if (state.dataArray[i].payStatus === 'REFUND') {
  451. state.dataArray[i].payStatusName = '转入退费'
  452. } else {
  453. state.dataArray[i].payStatusName = '未知'
  454. }
  455. state.allMoney += state.dataArray[i]["fee"] * 0.01
  456. }
  457. console.log("state.dataArray", state.dataArray)
  458. });
  459. }
  460. </script>
  461. <style lang="scss" scoped>
  462. .action {
  463. margin-top: 40rpx;
  464. padding-left: 20rpx;
  465. padding-right: 20rpx;
  466. padding-bottom: 30rpx;
  467. .button {
  468. height: 80rpx;
  469. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  470. border-radius: 40rpx;
  471. font-size: 32rpx;
  472. font-weight: 400;
  473. color: #ffffff;
  474. line-height: 80rpx;
  475. }
  476. }
  477. .value-wrapper {
  478. margin-top: 40rpx;
  479. padding: 0rpx 30rpx;
  480. .flex {
  481. padding: 20rpx 0rpx;
  482. display: flex;
  483. justify-content: space-between;
  484. align-items: center;
  485. .title {
  486. font-size: 28rpx;
  487. font-family: Microsoft YaHei;
  488. font-weight: 400;
  489. color: #777777;
  490. line-height: 28rpx;
  491. }
  492. .value {
  493. font-size: 28rpx;
  494. font-family: Microsoft YaHei;
  495. font-weight: 400;
  496. color: #333333;
  497. line-height: 28rpx;
  498. }
  499. .money {
  500. font-size: 36rpx;
  501. font-family: Microsoft YaHei;
  502. font-weight: 400;
  503. color: #00b38b;
  504. line-height: 36rpx;
  505. }
  506. }
  507. }
  508. .content-wrap {
  509. position: relative;
  510. margin-top: -50rpx;
  511. padding: 0rpx 30rpx;
  512. .ul-item {
  513. padding: 5px 20rpx;
  514. display: flex;
  515. align-items: center;
  516. .item-value {
  517. padding: 20rpx;
  518. position: absolute;
  519. display: flex;
  520. align-items: center;
  521. // justify-content: space-around;
  522. width: 80%;
  523. .content {
  524. width: 48%;
  525. .title {
  526. font-size: 32rpx;
  527. font-family: Microsoft YaHei;
  528. font-weight: 400;
  529. color: #ffffff;
  530. }
  531. .tip {
  532. font-size: 24rpx;
  533. font-family: Microsoft YaHei;
  534. font-weight: 400;
  535. color: #ffffff;
  536. }
  537. }
  538. }
  539. .icon-tip {
  540. width: 100rpx;
  541. height: 100rpx;
  542. }
  543. .content {
  544. margin-left: 40rpx;
  545. }
  546. }
  547. }
  548. .del_item {
  549. background-color: rgb(41, 199, 207) !important;
  550. }
  551. .content-box {
  552. background-color: rgb(41, 199, 207);
  553. line-height: 80rpx;
  554. color: white;
  555. font-size: 32rpx;
  556. border-radius: 10rpx 0 0 10rpx;
  557. padding: 20rpx;
  558. box-sizing: border-box;
  559. }
  560. ::v-deep.uni-swipe_button-text {
  561. font-size: 30rpx !important;
  562. }
  563. ::v-deep.uni-swipe_button-group {
  564. font-size: 28rpx !important;
  565. }
  566. .add_all {
  567. width: 95%;
  568. margin: 0 auto;
  569. }
  570. .uni-swipe_box {
  571. margin-bottom: 16rpx !important;
  572. }
  573. ::v-deep.uni-swipe {
  574. margin-bottom: 16rpx !important;
  575. }
  576. .imageDefault {
  577. height: 40rpx;
  578. width: 40rpx;
  579. transform: rotate(270deg);
  580. margin-right: 12rpx;
  581. color: white;
  582. }
  583. .imageChange {
  584. height: 40rpx;
  585. width: 40rpx;
  586. transform: rotate(90deg);
  587. margin-right: 12rpx;
  588. color: white;
  589. }
  590. .price {
  591. color: white;
  592. }
  593. .agreement {
  594. font-size: 30rpx;
  595. display: flex;
  596. flex-wrap: wrap;
  597. margin-top: 20rpx;
  598. align-items: center;
  599. }
  600. </style>