您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

product-detail.vue 13KB

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