選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

product-detail.vue 14KB

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