Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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