Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

product-detail.vue 17KB

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