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

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