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.

product-detail.vue 16KB

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