Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

product-detail.vue 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  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. refresh();
  146. });
  147. // #endif
  148. }
  149. // 协议确认接口
  150. const agreementConfirm = () => {
  151. const options = {
  152. type: 2,
  153. data: {
  154. orderId: state.orderId,
  155. protocol: state.checked ? 1 : 0,
  156. agreements: state.agreements
  157. },
  158. method: "POST",
  159. showLoading: true,
  160. };
  161. return new Promise(async (resolve, reject) => {
  162. const res = await requestNew(agreeOrderProdcut, options);
  163. const data = res;
  164. console.log("确认协议", data)
  165. resolve(data);
  166. }).catch((error) => {
  167. reject(error);
  168. });
  169. };
  170. onLoad((option : any) => {
  171. state.orderId = option.orderId;
  172. state.isValueCard = option.isValueCard;
  173. console.log("传递过来的参数", option)
  174. console.log("查协议", envs[process.env.NODE_ENV].baseUrl)
  175. state.id = option.id;
  176. state.vehicleId = option.vehicleId;
  177. getOpenID();
  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,state.agreements)
  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. // #endif
  256. var data = {
  257. orderId: state.orderId,
  258. wxOpenId: state.openid,
  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. if (data.paymentStatus == 'ALLSUCCESS') {
  271. state.allMoney = data.sumFee * 0.01
  272. return;
  273. }
  274. state.dataArray = data.datas;
  275. // HANDLE("办理费",1){},
  276. // MARGIN("保证金",2){},
  277. // PRESTORE("预存金",3){},
  278. // EQUITY("权益费",4){},
  279. for (let i = 0; i < state.dataArray.length; i++) {
  280. if (state.dataArray[i].payType === 'HANDLE') {
  281. state.dataArray[i].payName = '权益金'
  282. } else if (state.dataArray[i].payType === 'MARGIN') {
  283. state.dataArray[i].payName = '保证金'
  284. } else if (state.dataArray[i].payType === 'PRESTORE') {
  285. state.dataArray[i].payName = '预存金'
  286. } else if (state.dataArray[i].payType === 'EQUITY') {
  287. state.dataArray[i].payName = '权益费'
  288. } else {
  289. state.dataArray[i].payName = '未知费'
  290. }
  291. // SUCCESS("支付成功",1){},
  292. // PAYING("支付中",2){},
  293. // FAILED("支付失败",3){},
  294. // UNPAY("未支付",4){},
  295. // CLOSED("已关闭",5){},
  296. // CANCELED("已撤销",6){},
  297. // REFUND("转入退费",7){},
  298. if (state.dataArray[i].payStatus === 'SUCCESS') {
  299. state.dataArray[i].payStatusName = '已支付'
  300. } else if (state.dataArray[i].payStatus === 'PAYING') {
  301. state.dataArray[i].payStatusName = '支付中'
  302. } else if (state.dataArray[i].payStatus === 'FAILED') {
  303. state.dataArray[i].payStatusName = '支付失败'
  304. } else if (state.dataArray[i].payStatus === 'UNPAY') {
  305. state.dataArray[i].payStatusName = '未支付'
  306. } else if (state.dataArray[i].payStatus === 'CLOSED') {
  307. state.dataArray[i].payStatusName = '已关闭'
  308. } else if (state.dataArray[i].payStatus === 'CANCELED') {
  309. state.dataArray[i].payStatusName = '已撤销'
  310. } else if (state.dataArray[i].payStatus === 'REFUND') {
  311. state.dataArray[i].payStatusName = '转入退费'
  312. } else {
  313. state.dataArray[i].payStatusName = '未知'
  314. }
  315. state.allMoney += state.dataArray[i]["fee"] * 0.01
  316. }
  317. console.log("state.dataArray", state.dataArray)
  318. });
  319. }
  320. // 去签署协议
  321. const sign=()=>{
  322. const options = {
  323. type: 2,
  324. data: {
  325. orderId: state.orderId, //订单编号
  326. },
  327. method: "POST",
  328. showLoading: true,
  329. };
  330. requestNew(accountSign, options).then((res) => {
  331. uni.navigateToMiniProgram({
  332. appId: 'wxeee4ac6e61915479',
  333. path: `/pages/externel/view/view?random=${res.random}&envType=product`,
  334. envVersion: 'release',
  335. fail:(error)=>{
  336. console.log(error);
  337. }
  338. })
  339. console.log("去签署协议", res)
  340. });
  341. }
  342. // 查询是否签署协议
  343. const contractRequest=()=>{
  344. const options = {
  345. type: 2,
  346. data: {
  347. orderId: state.orderId, //订单编号
  348. },
  349. method: "POST",
  350. showLoading: true,
  351. };
  352. requestNew(contractQuery, options).then((res) => {
  353. if(res.contractState==1){
  354. state.isSign=true
  355. }else{
  356. state.isSign=false
  357. }
  358. console.log("查询是否签署协议", res)
  359. });
  360. }
  361. </script>
  362. <style lang="scss" scoped>
  363. .action {
  364. position: absolute;
  365. bottom: 0rpx;
  366. left: 0;
  367. height: 128rpx;
  368. background-color: #fff;
  369. border-radius: 30rpx 30rpx 0 0;
  370. width: 100vw;
  371. display: flex;
  372. align-items: center;
  373. justify-content: center;
  374. .button {
  375. height: 88rpx;
  376. background: radial-gradient(at 0% 0%, #01243A 0%, #004576 100%);
  377. border-radius: 40rpx;
  378. font-size: 32rpx;
  379. font-weight: 400;
  380. color: #ffffff;
  381. line-height: 88rpx;
  382. width: 660rpx;
  383. margin: 0 auto;
  384. }
  385. }
  386. .value-wrapper {
  387. background-color: #fff;
  388. padding: 40rpx 30rpx;
  389. border-radius: 12rpx;
  390. font-family: SourceHanSansCN, SourceHanSansCN;
  391. .flex {
  392. padding: 20rpx 0rpx;
  393. display: flex;
  394. justify-content: space-between;
  395. align-items: center;
  396. .title {
  397. font-size: 28rpx;
  398. font-weight: 400;
  399. line-height: 28rpx;
  400. color: #666666;
  401. }
  402. .value {
  403. font-size: 30rpx;
  404. font-family: Microsoft YaHei;
  405. font-weight: 400;
  406. line-height: 36rpx;
  407. color: #111111;
  408. .unit {
  409. margin-right: 4rpx;
  410. font-size: 22rpx;
  411. color: #111111;
  412. }
  413. }
  414. }
  415. }
  416. .content-wrap {
  417. position: absolute;
  418. top: 370rpx;
  419. width: 100%;
  420. min-height: calc(100% - 370rpx);
  421. box-sizing: border-box;
  422. padding: 0 30rpx 210rpx;
  423. .ul-item {
  424. padding: 5px 20rpx;
  425. display: flex;
  426. align-items: center;
  427. .item-value {
  428. padding: 20rpx;
  429. position: absolute;
  430. display: flex;
  431. align-items: center;
  432. // justify-content: space-around;
  433. width: 80%;
  434. .content {
  435. width: 48%;
  436. .title {
  437. font-size: 32rpx;
  438. font-family: Microsoft YaHei;
  439. font-weight: 400;
  440. color: #ffffff;
  441. }
  442. .tip {
  443. font-size: 24rpx;
  444. font-family: Microsoft YaHei;
  445. font-weight: 400;
  446. color: #ffffff;
  447. }
  448. }
  449. }
  450. .icon-tip {
  451. width: 100rpx;
  452. height: 100rpx;
  453. }
  454. .content {
  455. margin-left: 40rpx;
  456. }
  457. }
  458. }
  459. .del_item {
  460. background-color: rgb(41, 199, 207) !important;
  461. }
  462. .content-box {
  463. background-color: rgb(41, 199, 207);
  464. line-height: 80rpx;
  465. color: white;
  466. font-size: 32rpx;
  467. border-radius: 10rpx 0 0 10rpx;
  468. padding: 20rpx;
  469. box-sizing: border-box;
  470. }
  471. ::v-deep.uni-swipe_button-text {
  472. font-size: 30rpx !important;
  473. }
  474. ::v-deep.uni-swipe_button-group {
  475. font-size: 28rpx !important;
  476. }
  477. .add_all {
  478. width: 95%;
  479. margin: 0 auto;
  480. }
  481. .uni-swipe_box {
  482. margin-bottom: 16rpx !important;
  483. }
  484. ::v-deep.uni-swipe {
  485. margin-bottom: 16rpx !important;
  486. }
  487. .imageDefault {
  488. height: 40rpx;
  489. width: 40rpx;
  490. transform: rotate(270deg);
  491. margin-right: 12rpx;
  492. color: white;
  493. }
  494. .imageChange {
  495. height: 40rpx;
  496. width: 40rpx;
  497. transform: rotate(90deg);
  498. margin-right: 12rpx;
  499. color: white;
  500. }
  501. .price {
  502. color: white;
  503. }
  504. .agreement {
  505. font-size: 30rpx;
  506. display: flex;
  507. flex-wrap: wrap;
  508. margin-top: 20rpx;
  509. align-items: center;
  510. .txt {
  511. font-size: 24rpx;
  512. font-family: SourceHanSansCN, SourceHanSansCN;
  513. font-weight: 400;
  514. color: #111111;
  515. }
  516. .xieyi {
  517. color: #999;
  518. }
  519. }
  520. </style>