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

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