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 13KB

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