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

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