Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

product-detail.vue 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  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;" @click="downAuthD()">《产品协议》</a>
  82. </view>
  83. </view>
  84. <view class="action">
  85. <button type="default" class="button" @click="savaHandle()">
  86. {{ "确认办理:¥" + state.allMoney }}
  87. </button>
  88. </view>
  89. </view>
  90. </template>
  91. <script setup lang="ts">
  92. import {
  93. onLoad,
  94. onShow
  95. } from "@dcloudio/uni-app";
  96. import {
  97. reactive,
  98. ref
  99. } from "vue";
  100. import {
  101. etcQueryProduct,
  102. addProduct,
  103. getOpenidApi,
  104. getAgreementApi,
  105. PAYDETECTION,
  106. envs
  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. const downAuthD = () => {
  165. // tools.showLoadingAlert("加载中");
  166. uni.downloadFile({
  167. url: state.agreeURL,
  168. filePath: wx.env.USER_DATA_PATH + '/' + '产品协议.docx',
  169. success(res) {
  170. const filePath = res.filePath
  171. uni.openDocument({
  172. filePath: filePath,
  173. fileType: 'docx',
  174. showMenu: true, //关键点
  175. success: function (res) {
  176. msg("打开文档成功");
  177. },
  178. fail: function (err) {
  179. msg("打开文档失败");
  180. }
  181. });
  182. },
  183. fail: function (err) {
  184. msg("下载文档失败");
  185. console.log("err", err)
  186. },
  187. complete(res) {
  188. }
  189. })
  190. }
  191. //获取微信小程序openid
  192. const getOpenID = () => {
  193. uni.login({
  194. provider: "weixin",
  195. success: function (e) {
  196. getOpenid(e.code);
  197. // uni.request({
  198. // url: `https://api.weixin.qq.com/sns/jscode2session?appid=${wechatAppID}&secret=${wechatSecret}&js_code=${e.code}&grant_type=authorization_code`,
  199. // success: (res: any) => {
  200. // state.openid = res.data.openid;
  201. // console.log("state.openid", state.openid);
  202. // },
  203. // });
  204. },
  205. });
  206. };
  207. const getOpenid = (code) => {
  208. const options = {
  209. type: 2,
  210. data: {
  211. "jsCode": code
  212. },
  213. method: "POST",
  214. showLoading: true,
  215. };
  216. // #ifdef MP-WEIXIN
  217. request(getOpenidApi, options).then((res) => {
  218. const result = stringToJson(res.bizContent);
  219. console.log("获取微信小程序openid", result);
  220. const openidData = stringToJson(result.data);
  221. state.openid = openidData.openid;
  222. });
  223. // #endif
  224. }
  225. //唤起微信支付
  226. const wxPayment = () => {
  227. // #ifdef MP-WEIXIN
  228. const options = {
  229. type: 2,
  230. data: {
  231. openid: state.openid,
  232. productId: state.id,
  233. orderId: state.orderId,
  234. payConfigId: wechatPayConfigId,
  235. },
  236. method: "POST",
  237. showLoading: true,
  238. };
  239. request(orderPay, options).then((res) => {
  240. const data = stringToJson(res.bizContent);
  241. uni.requestPayment({
  242. provider: "wxpay",
  243. orderInfo: "",
  244. timeStamp: data.timestamp,
  245. nonceStr: data.noncestr,
  246. package: data.wxPackage ? data.wxPackage : "",
  247. signType: data.signType,
  248. paySign: data.sign,
  249. success: function (e) {
  250. console.log("支付成功", e);
  251. checkOrder();
  252. },
  253. fail: function (err) {
  254. // checkOrder();
  255. confirm(err, () => { }, "支付失败", false);
  256. },
  257. });
  258. });
  259. // #endif
  260. };
  261. //支付成功改变订单状态
  262. const checkOrder = () => {
  263. const options = {
  264. type: 2,
  265. data: {
  266. orderId: state.orderId,
  267. payConfigId: wechatPayConfigId,
  268. },
  269. method: "POST",
  270. showLoading: true,
  271. };
  272. request(checkOrderStatus, options).then((res) => {
  273. msg("支付成功!");
  274. var pages = getCurrentPages().length;
  275. uni.$emit("refreshOrder");
  276. uni.switchTab({
  277. url: "/pages/order/order"
  278. })
  279. });
  280. };
  281. onLoad((option : any) => {
  282. state.orderId = option.orderId;
  283. state.isValueCard = option.isValueCard;
  284. // state.clientFee = option.clientFee / 100;
  285. state.id = option.id;
  286. getOpenID();
  287. queryAgreement();
  288. // const data = JSON.parse(decodeURIComponent(option.data));
  289. // for (var i = 0; i < data.length; i++) {
  290. // data['isOpened'] = 'node';
  291. // state.productMoney += data[i]['discountPrice'] / 100;
  292. // state.productId.push(data[i]['equityId'])
  293. // }
  294. // state.list = data;
  295. // queryDetailsData();
  296. refresh();
  297. });
  298. const state = reactive({
  299. openid: "",
  300. orderId: "",
  301. clientFee: undefined,
  302. id: "",
  303. options2: [{
  304. text: '删除',
  305. style: {
  306. backgroundColor: '#F56C6C'
  307. }
  308. }],
  309. isOpened: 'none',
  310. list: [],
  311. productMoney: 0,
  312. allMoney: 0,
  313. productId: [],
  314. // 弹框
  315. type: 'center',
  316. msgType: 'success',
  317. messageText: '这是一条成功提示',
  318. value: '',
  319. detailsObj: '',
  320. isValueCard: "",
  321. dataArray: [],
  322. checked: false,
  323. agreeURL: "",
  324. });
  325. const bindClick = (i) => {
  326. console.log(i);
  327. uni.showToast({
  328. title: "删除成功",
  329. icon: 'none'
  330. });
  331. state.list.splice(i, 1);
  332. state.productMoney = 0;
  333. state.productId = [];
  334. for (var k = 0; k < state.list.length; k++) {
  335. state.productMoney += state.list[k]['discountPrice'] / 100
  336. state.productId.push(state.list[k]['equityId'])
  337. }
  338. state.allMoney = (state.productMoney + state.clientFee).toFixed(2)
  339. console.log("state.productId", state.productId)
  340. };
  341. const setOpened = () => {
  342. if (state.isOpened === 'none') {
  343. state.isOpened = 'right';
  344. return;
  345. }
  346. if (state.isOpened === 'left') {
  347. state.isOpened = 'right';
  348. return;
  349. }
  350. if (state.isOpened === 'right') {
  351. state.isOpened = 'none';
  352. return;
  353. }
  354. }
  355. const change = (e) => {
  356. state.isOpened = e;
  357. }
  358. // 加购权益产品接口
  359. const queryAddProduct = () => {
  360. console.log("state.openid", state.openid);
  361. const options = {
  362. type: 2,
  363. data: {
  364. orderId: state.orderId, //订单编号
  365. openId: state.openid, //操作人 id
  366. equityId: state.productId.toString(), //权益Id
  367. totalAmount: state.allMoney * 100, //总金额
  368. isRepeatPurchase: 0
  369. },
  370. method: "POST",
  371. showLoading: true,
  372. };
  373. request(addProduct, options).then((res) => { });
  374. }
  375. const changeIsShow = (index) => {
  376. console.log(index, state.list[index]['isShow'], !state.list[index]['isShow'])
  377. state.list[index]['isShow'] = !state.list[index]['isShow']
  378. console.log("state.list", state.list)
  379. }
  380. const queryDetailsData = () => {
  381. const options = {
  382. type: 2,
  383. data: {
  384. orderId: state.orderId, //订单编号
  385. },
  386. method: "POST",
  387. showLoading: true,
  388. };
  389. request(queryDetails, options).then((res) => {
  390. state.detailsObj = stringToJson(res.bizContent);
  391. console.log("state.detailsObj", state.detailsObj)
  392. state.allMoney = (parseFloat(state.detailsObj.product.oncePrice * 0.01) + parseFloat(state.productMoney)).toFixed(2)
  393. });
  394. }
  395. // 查协议
  396. const queryAgreement = () => {
  397. const options = {
  398. type: 2,
  399. data: {
  400. // orderId: state.orderId, //订单编号
  401. orderId: "20231016180507480853307", //订单编号
  402. },
  403. method: "POST",
  404. showLoading: true,
  405. };
  406. request(getAgreementApi, options).then((res) => {
  407. let data = stringToJson(res.bizContent);
  408. state.agreeURL = envs[process.env.NODE_ENV].baseUrl + data.supAgree
  409. console.log("查协议", data)
  410. });
  411. }
  412. const checkboxChange = (e) => {
  413. state.checked = !state.checked;
  414. console.log(state.checked);
  415. };
  416. const refresh = () => {
  417. let source = ""
  418. // #ifdef MP-ALIPAY
  419. source = "ALI"
  420. // #endif
  421. // #ifdef MP-WEIXIN
  422. source = "WECHAT"
  423. // getOpenID();
  424. // #endif
  425. var data = {
  426. orderId: state.orderId,
  427. source: source //请求方来源
  428. };
  429. const options = {
  430. type: 2,
  431. data: data,
  432. method: "POST",
  433. showLoading: true,
  434. };
  435. console.log("输出内容", options);
  436. request(PAYDETECTION, options).then((res) => {
  437. // console.log(res.bizContent);
  438. const data = stringToJson(res.bizContent);
  439. console.log(data);
  440. // console.log(typeof(data));
  441. // if (data.paymentStatus == 'ALLSUCCESS') {
  442. // gotoEditUserOrUnitInfo()
  443. // }
  444. state.dataArray = data.datas;
  445. // HANDLE("办理费",1){},
  446. // MARGIN("保证金",2){},
  447. // PRESTORE("预存金",3){},
  448. // EQUITY("权益费",4){},
  449. for (let i = 0; i < state.dataArray.length; i++) {
  450. if (state.dataArray[i].payType === 'HANDLE') {
  451. state.dataArray[i].payName = '办理费'
  452. } else if (state.dataArray[i].payType === 'MARGIN') {
  453. state.dataArray[i].payName = '保证金'
  454. } else if (state.dataArray[i].payType === 'PRESTORE') {
  455. state.dataArray[i].payName = '预存金'
  456. } else if (state.dataArray[i].payType === 'EQUITY') {
  457. state.dataArray[i].payName = '权益费'
  458. } else {
  459. state.dataArray[i].payName = '未知费'
  460. }
  461. // SUCCESS("支付成功",1){},
  462. // PAYING("支付中",2){},
  463. // FAILED("支付失败",3){},
  464. // UNPAY("未支付",4){},
  465. // CLOSED("已关闭",5){},
  466. // CANCELED("已撤销",6){},
  467. // REFUND("转入退费",7){},
  468. if (state.dataArray[i].payStatus === 'SUCCESS') {
  469. state.dataArray[i].payStatusName = '已支付'
  470. } else if (state.dataArray[i].payStatus === 'PAYING') {
  471. state.dataArray[i].payStatusName = '支付中'
  472. } else if (state.dataArray[i].payStatus === 'FAILED') {
  473. state.dataArray[i].payStatusName = '支付失败'
  474. } else if (state.dataArray[i].payStatus === 'UNPAY') {
  475. state.dataArray[i].payStatusName = '未支付'
  476. } else if (state.dataArray[i].payStatus === 'CLOSED') {
  477. state.dataArray[i].payStatusName = '已关闭'
  478. } else if (state.dataArray[i].payStatus === 'CANCELED') {
  479. state.dataArray[i].payStatusName = '已撤销'
  480. } else if (state.dataArray[i].payStatus === 'REFUND') {
  481. state.dataArray[i].payStatusName = '转入退费'
  482. } else {
  483. state.dataArray[i].payStatusName = '未知'
  484. }
  485. state.allMoney += state.dataArray[i]["fee"] * 0.01
  486. }
  487. console.log("state.dataArray", state.dataArray)
  488. });
  489. }
  490. </script>
  491. <style lang="scss" scoped>
  492. .action {
  493. margin-top: 40rpx;
  494. padding-left: 20rpx;
  495. padding-right: 20rpx;
  496. padding-bottom: 30rpx;
  497. .button {
  498. height: 80rpx;
  499. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  500. border-radius: 40rpx;
  501. font-size: 32rpx;
  502. font-weight: 400;
  503. color: #ffffff;
  504. line-height: 80rpx;
  505. }
  506. }
  507. .value-wrapper {
  508. margin-top: 40rpx;
  509. padding: 0rpx 30rpx;
  510. .flex {
  511. padding: 20rpx 0rpx;
  512. display: flex;
  513. justify-content: space-between;
  514. align-items: center;
  515. .title {
  516. font-size: 28rpx;
  517. font-family: Microsoft YaHei;
  518. font-weight: 400;
  519. color: #777777;
  520. line-height: 28rpx;
  521. }
  522. .value {
  523. font-size: 28rpx;
  524. font-family: Microsoft YaHei;
  525. font-weight: 400;
  526. color: #333333;
  527. line-height: 28rpx;
  528. }
  529. .money {
  530. font-size: 36rpx;
  531. font-family: Microsoft YaHei;
  532. font-weight: 400;
  533. color: #00b38b;
  534. line-height: 36rpx;
  535. }
  536. }
  537. }
  538. .content-wrap {
  539. position: relative;
  540. margin-top: -50rpx;
  541. padding: 0rpx 30rpx;
  542. .ul-item {
  543. padding: 5px 20rpx;
  544. display: flex;
  545. align-items: center;
  546. .item-value {
  547. padding: 20rpx;
  548. position: absolute;
  549. display: flex;
  550. align-items: center;
  551. // justify-content: space-around;
  552. width: 80%;
  553. .content {
  554. width: 48%;
  555. .title {
  556. font-size: 32rpx;
  557. font-family: Microsoft YaHei;
  558. font-weight: 400;
  559. color: #ffffff;
  560. }
  561. .tip {
  562. font-size: 24rpx;
  563. font-family: Microsoft YaHei;
  564. font-weight: 400;
  565. color: #ffffff;
  566. }
  567. }
  568. }
  569. .icon-tip {
  570. width: 100rpx;
  571. height: 100rpx;
  572. }
  573. .content {
  574. margin-left: 40rpx;
  575. }
  576. }
  577. }
  578. .del_item {
  579. background-color: rgb(41, 199, 207) !important;
  580. }
  581. .content-box {
  582. background-color: rgb(41, 199, 207);
  583. line-height: 80rpx;
  584. color: white;
  585. font-size: 32rpx;
  586. border-radius: 10rpx 0 0 10rpx;
  587. padding: 20rpx;
  588. box-sizing: border-box;
  589. }
  590. ::v-deep.uni-swipe_button-text {
  591. font-size: 30rpx !important;
  592. }
  593. ::v-deep.uni-swipe_button-group {
  594. font-size: 28rpx !important;
  595. }
  596. .add_all {
  597. width: 95%;
  598. margin: 0 auto;
  599. }
  600. .uni-swipe_box {
  601. margin-bottom: 16rpx !important;
  602. }
  603. ::v-deep.uni-swipe {
  604. margin-bottom: 16rpx !important;
  605. }
  606. .imageDefault {
  607. height: 40rpx;
  608. width: 40rpx;
  609. transform: rotate(270deg);
  610. margin-right: 12rpx;
  611. color: white;
  612. }
  613. .imageChange {
  614. height: 40rpx;
  615. width: 40rpx;
  616. transform: rotate(90deg);
  617. margin-right: 12rpx;
  618. color: white;
  619. }
  620. .price {
  621. color: white;
  622. }
  623. .agreement {
  624. font-size: 30rpx;
  625. display: flex;
  626. flex-wrap: wrap;
  627. margin-top: 20rpx;
  628. align-items: center;
  629. }
  630. </style>