Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

product-detail.vue 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  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 v-for="(item,index) in state.agreeURL" style="color:#007AFF;text-decoration: underline;" @click="downAuthD(item)">《{{item.name}}》</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 = (item) => {
  92. console.log('=======123',item)
  93. console.log("uni.env.USER_DATA_PATH '", uni.env.USER_DATA_PATH + '/' + '产品协议.docx')
  94. uni.downloadFile({
  95. url: item.url,
  96. filePath: uni.env.USER_DATA_PATH + '/' +item.name+ '.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. let supAgreeArr=option.url.split(';')
  174. for(var k=0;k<supAgreeArr.length;k++){
  175. let url=envs[process.env.NODE_ENV].baseUrl+supAgreeArr[k]
  176. let obj={
  177. 'url':url,
  178. 'name':getStringBetween(url,'_','.docx')
  179. }
  180. state.agreeURL.push(obj)
  181. }
  182. state.typeScanCode = option.typeScanCode
  183. console.log("state.agreeURL", state.agreeURL)
  184. } else {
  185. queryAgreement();
  186. }
  187. });
  188. const state = reactive({
  189. openid: "",
  190. orderId: "",
  191. clientFee: undefined,
  192. id: "",
  193. options2: [{
  194. text: '删除',
  195. style: {
  196. backgroundColor: '#F56C6C'
  197. }
  198. }],
  199. isOpened: 'none',
  200. list: [],
  201. productMoney: 0,
  202. allMoney: 0,
  203. productId: [],
  204. // 弹框
  205. type: 'center',
  206. msgType: 'success',
  207. messageText: '这是一条成功提示',
  208. value: '',
  209. detailsObj: '',
  210. isValueCard: "",
  211. dataArray: [],
  212. checked: false,
  213. agreeURL: [],
  214. typeScanCode: 0,//扫码进来得
  215. vehicleId:""
  216. });
  217. const bindClick = (i) => {
  218. console.log(i);
  219. uni.showToast({
  220. title: "删除成功",
  221. icon: 'none'
  222. });
  223. state.list.splice(i, 1);
  224. state.productMoney = 0;
  225. state.productId = [];
  226. for (var k = 0; k < state.list.length; k++) {
  227. state.productMoney += state.list[k]['discountPrice'] / 100
  228. state.productId.push(state.list[k]['equityId'])
  229. }
  230. state.allMoney = (state.productMoney + state.clientFee).toFixed(2)
  231. console.log("state.productId", state.productId)
  232. };
  233. const setOpened = () => {
  234. if (state.isOpened === 'none') {
  235. state.isOpened = 'right';
  236. return;
  237. }
  238. if (state.isOpened === 'left') {
  239. state.isOpened = 'right';
  240. return;
  241. }
  242. if (state.isOpened === 'right') {
  243. state.isOpened = 'none';
  244. return;
  245. }
  246. }
  247. const change = (e) => {
  248. state.isOpened = e;
  249. }
  250. // 加购权益产品接口
  251. const queryAddProduct = () => {
  252. console.log("state.openid", state.openid);
  253. const options = {
  254. type: 2,
  255. data: {
  256. orderId: state.orderId, //订单编号
  257. openId: state.openid, //操作人 id
  258. equityId: state.productId.toString(), //权益Id
  259. totalAmount: state.allMoney * 100, //总金额
  260. isRepeatPurchase: 0
  261. },
  262. method: "POST",
  263. showLoading: true,
  264. };
  265. request(addProduct, options).then((res) => { });
  266. }
  267. // 查协议
  268. const queryAgreement = () => {
  269. const options = {
  270. type: 2,
  271. data: {
  272. orderId: state.orderId, //订单编号
  273. },
  274. method: "POST",
  275. showLoading: true,
  276. };
  277. request(getAgreementApi, options).then((res) => {
  278. let data = stringToJson(res.bizContent);
  279. let supAgreeArr=data.supAgree.split(';')
  280. for(var k=0;k<supAgreeArr.length;k++){
  281. let url=envs[process.env.NODE_ENV].baseUrl+supAgreeArr[k]
  282. let obj={
  283. 'url':url,
  284. 'name':getStringBetween(url,'_','.docx')
  285. }
  286. state.agreeURL.push(obj)
  287. }
  288. console.log("查协议", state.agreeURL)
  289. });
  290. }
  291. const getStringBetween=(str, start, end)=> {
  292. const startIndex = str.indexOf(start) + start.length;
  293. const endIndex = str.indexOf(end);
  294. if (startIndex >= endIndex) return '';
  295. return str.substring(startIndex, endIndex);
  296. }
  297. const checkboxChange = (e) => {
  298. state.checked = !state.checked;
  299. console.log(state.checked);
  300. };
  301. const refresh = () => {
  302. let source = ""
  303. // #ifdef MP-ALIPAY
  304. source = "ALI"
  305. // #endif
  306. // #ifdef MP-WEIXIN
  307. source = "WECHAT"
  308. // getOpenID();
  309. // #endif
  310. var data = {
  311. orderId: state.orderId,
  312. source: source //请求方来源
  313. };
  314. const options = {
  315. type: 2,
  316. data: data,
  317. method: "POST",
  318. showLoading: true,
  319. };
  320. console.log("输出内容", options);
  321. request(PAYDETECTION, options).then((res) => {
  322. // console.log(res.bizContent);
  323. const data = stringToJson(res.bizContent);
  324. console.log(data);
  325. // console.log(typeof(data));
  326. // if (data.paymentStatus == 'ALLSUCCESS') {
  327. // gotoEditUserOrUnitInfo()
  328. // }
  329. state.dataArray = data.datas;
  330. // HANDLE("办理费",1){},
  331. // MARGIN("保证金",2){},
  332. // PRESTORE("预存金",3){},
  333. // EQUITY("权益费",4){},
  334. for (let i = 0; i < state.dataArray.length; i++) {
  335. if (state.dataArray[i].payType === 'HANDLE') {
  336. state.dataArray[i].payName = '权益金'
  337. } else if (state.dataArray[i].payType === 'MARGIN') {
  338. state.dataArray[i].payName = '保证金'
  339. } else if (state.dataArray[i].payType === 'PRESTORE') {
  340. state.dataArray[i].payName = '预存金'
  341. } else if (state.dataArray[i].payType === 'EQUITY') {
  342. state.dataArray[i].payName = '权益费'
  343. } else {
  344. state.dataArray[i].payName = '未知费'
  345. }
  346. // SUCCESS("支付成功",1){},
  347. // PAYING("支付中",2){},
  348. // FAILED("支付失败",3){},
  349. // UNPAY("未支付",4){},
  350. // CLOSED("已关闭",5){},
  351. // CANCELED("已撤销",6){},
  352. // REFUND("转入退费",7){},
  353. if (state.dataArray[i].payStatus === 'SUCCESS') {
  354. state.dataArray[i].payStatusName = '已支付'
  355. } else if (state.dataArray[i].payStatus === 'PAYING') {
  356. state.dataArray[i].payStatusName = '支付中'
  357. } else if (state.dataArray[i].payStatus === 'FAILED') {
  358. state.dataArray[i].payStatusName = '支付失败'
  359. } else if (state.dataArray[i].payStatus === 'UNPAY') {
  360. state.dataArray[i].payStatusName = '未支付'
  361. } else if (state.dataArray[i].payStatus === 'CLOSED') {
  362. state.dataArray[i].payStatusName = '已关闭'
  363. } else if (state.dataArray[i].payStatus === 'CANCELED') {
  364. state.dataArray[i].payStatusName = '已撤销'
  365. } else if (state.dataArray[i].payStatus === 'REFUND') {
  366. state.dataArray[i].payStatusName = '转入退费'
  367. } else {
  368. state.dataArray[i].payStatusName = '未知'
  369. }
  370. state.allMoney += state.dataArray[i]["fee"] * 0.01
  371. }
  372. console.log("state.dataArray", state.dataArray)
  373. });
  374. }
  375. </script>
  376. <style lang="scss" scoped>
  377. .action {
  378. margin-top: 40rpx;
  379. padding-left: 20rpx;
  380. padding-right: 20rpx;
  381. padding-bottom: 30rpx;
  382. .button {
  383. height: 80rpx;
  384. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  385. border-radius: 40rpx;
  386. font-size: 32rpx;
  387. font-weight: 400;
  388. color: #ffffff;
  389. line-height: 80rpx;
  390. }
  391. }
  392. .value-wrapper {
  393. margin-top: 40rpx;
  394. padding: 0rpx 30rpx;
  395. .flex {
  396. padding: 20rpx 0rpx;
  397. display: flex;
  398. justify-content: space-between;
  399. align-items: center;
  400. .title {
  401. font-size: 28rpx;
  402. font-family: Microsoft YaHei;
  403. font-weight: 400;
  404. color: #777777;
  405. line-height: 28rpx;
  406. }
  407. .value {
  408. font-size: 28rpx;
  409. font-family: Microsoft YaHei;
  410. font-weight: 400;
  411. color: #333333;
  412. line-height: 28rpx;
  413. }
  414. .money {
  415. font-size: 36rpx;
  416. font-family: Microsoft YaHei;
  417. font-weight: 400;
  418. color: #00b38b;
  419. line-height: 36rpx;
  420. }
  421. }
  422. }
  423. .content-wrap {
  424. position: relative;
  425. margin-top: -50rpx;
  426. padding: 0rpx 30rpx;
  427. .ul-item {
  428. padding: 5px 20rpx;
  429. display: flex;
  430. align-items: center;
  431. .item-value {
  432. padding: 20rpx;
  433. position: absolute;
  434. display: flex;
  435. align-items: center;
  436. // justify-content: space-around;
  437. width: 80%;
  438. .content {
  439. width: 48%;
  440. .title {
  441. font-size: 32rpx;
  442. font-family: Microsoft YaHei;
  443. font-weight: 400;
  444. color: #ffffff;
  445. }
  446. .tip {
  447. font-size: 24rpx;
  448. font-family: Microsoft YaHei;
  449. font-weight: 400;
  450. color: #ffffff;
  451. }
  452. }
  453. }
  454. .icon-tip {
  455. width: 100rpx;
  456. height: 100rpx;
  457. }
  458. .content {
  459. margin-left: 40rpx;
  460. }
  461. }
  462. }
  463. .del_item {
  464. background-color: rgb(41, 199, 207) !important;
  465. }
  466. .content-box {
  467. background-color: rgb(41, 199, 207);
  468. line-height: 80rpx;
  469. color: white;
  470. font-size: 32rpx;
  471. border-radius: 10rpx 0 0 10rpx;
  472. padding: 20rpx;
  473. box-sizing: border-box;
  474. }
  475. ::v-deep.uni-swipe_button-text {
  476. font-size: 30rpx !important;
  477. }
  478. ::v-deep.uni-swipe_button-group {
  479. font-size: 28rpx !important;
  480. }
  481. .add_all {
  482. width: 95%;
  483. margin: 0 auto;
  484. }
  485. .uni-swipe_box {
  486. margin-bottom: 16rpx !important;
  487. }
  488. ::v-deep.uni-swipe {
  489. margin-bottom: 16rpx !important;
  490. }
  491. .imageDefault {
  492. height: 40rpx;
  493. width: 40rpx;
  494. transform: rotate(270deg);
  495. margin-right: 12rpx;
  496. color: white;
  497. }
  498. .imageChange {
  499. height: 40rpx;
  500. width: 40rpx;
  501. transform: rotate(90deg);
  502. margin-right: 12rpx;
  503. color: white;
  504. }
  505. .price {
  506. color: white;
  507. }
  508. .agreement {
  509. font-size: 30rpx;
  510. display: flex;
  511. flex-wrap: wrap;
  512. margin-top: 20rpx;
  513. align-items: center;
  514. }
  515. </style>