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.

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