Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

product-detail.vue 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  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,
  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. contractRequest()
  184. });
  185. const state = reactive({
  186. openid: "",
  187. orderId: "",
  188. clientFee: undefined,
  189. id: "",
  190. options2: [{
  191. text: '删除',
  192. style: {
  193. backgroundColor: '#F56C6C'
  194. }
  195. }],
  196. list: [],
  197. productMoney: 0,
  198. allMoney: 0,
  199. productId: [],
  200. // 弹框
  201. type: 'center',
  202. msgType: 'success',
  203. messageText: '这是一条成功提示',
  204. value: '',
  205. detailsObj: '',
  206. isValueCard: "",
  207. dataArray: [],
  208. checked: false,
  209. agreeURL: [],
  210. typeScanCode: 0,//扫码进来得
  211. vehicleId: "",
  212. agreements: [],
  213. isSign:false
  214. });
  215. // 查协议
  216. const queryAgreement = () => {
  217. const options = {
  218. type: 2,
  219. data: {
  220. orderId: state.orderId, //订单编号
  221. status: 1
  222. },
  223. method: "POST",
  224. showLoading: true,
  225. };
  226. requestNew(agreementInSertOrder, options).then((res) => {
  227. let data = res;
  228. let supAgreeArr = data.data
  229. console.log("data==", supAgreeArr)
  230. for (var m = 0; m < supAgreeArr.length; m++) {
  231. let obj = {}
  232. obj['name'] = supAgreeArr[m]['name']
  233. for (var k = 0; k < supAgreeArr[m]['address'].length; k++) {
  234. state.agreements.push(supAgreeArr[m]['address'][k]['id'])
  235. obj['url'] = envs[process.env.NODE_ENV].baseUrl + supAgreeArr[m]['address'][k]['url']
  236. state.agreeURL.push(obj)
  237. }
  238. }
  239. console.log("查协议", state.agreeURL)
  240. });
  241. }
  242. const checkboxChange = (e) => {
  243. state.checked = !state.checked;
  244. console.log(state.checked);
  245. };
  246. const refresh = () => {
  247. let source = ""
  248. // #ifdef MP-ALIPAY
  249. source = "ALI"
  250. // #endif
  251. // #ifdef MP-WEIXIN
  252. source = "WECHAT"
  253. // getOpenID();
  254. // #endif
  255. var data = {
  256. orderId: state.orderId
  257. };
  258. const options = {
  259. type: 2,
  260. data: data,
  261. method: "POST",
  262. showLoading: true,
  263. };
  264. console.log("输出内容", options);
  265. requestNew(payQuery, options).then((res) => {
  266. const data = res
  267. console.log(data);
  268. // console.log(typeof(data));
  269. if (data.paymentStatus == 'ALLSUCCESS') {
  270. state.allMoney = data.sumFee * 0.01
  271. return;
  272. }
  273. state.dataArray = data.datas;
  274. // HANDLE("办理费",1){},
  275. // MARGIN("保证金",2){},
  276. // PRESTORE("预存金",3){},
  277. // EQUITY("权益费",4){},
  278. for (let i = 0; i < state.dataArray.length; i++) {
  279. if (state.dataArray[i].payType === 'HANDLE') {
  280. state.dataArray[i].payName = '权益金'
  281. } else if (state.dataArray[i].payType === 'MARGIN') {
  282. state.dataArray[i].payName = '保证金'
  283. } else if (state.dataArray[i].payType === 'PRESTORE') {
  284. state.dataArray[i].payName = '预存金'
  285. } else if (state.dataArray[i].payType === 'EQUITY') {
  286. state.dataArray[i].payName = '权益费'
  287. } else {
  288. state.dataArray[i].payName = '未知费'
  289. }
  290. // SUCCESS("支付成功",1){},
  291. // PAYING("支付中",2){},
  292. // FAILED("支付失败",3){},
  293. // UNPAY("未支付",4){},
  294. // CLOSED("已关闭",5){},
  295. // CANCELED("已撤销",6){},
  296. // REFUND("转入退费",7){},
  297. if (state.dataArray[i].payStatus === 'SUCCESS') {
  298. state.dataArray[i].payStatusName = '已支付'
  299. } else if (state.dataArray[i].payStatus === 'PAYING') {
  300. state.dataArray[i].payStatusName = '支付中'
  301. } else if (state.dataArray[i].payStatus === 'FAILED') {
  302. state.dataArray[i].payStatusName = '支付失败'
  303. } else if (state.dataArray[i].payStatus === 'UNPAY') {
  304. state.dataArray[i].payStatusName = '未支付'
  305. } else if (state.dataArray[i].payStatus === 'CLOSED') {
  306. state.dataArray[i].payStatusName = '已关闭'
  307. } else if (state.dataArray[i].payStatus === 'CANCELED') {
  308. state.dataArray[i].payStatusName = '已撤销'
  309. } else if (state.dataArray[i].payStatus === 'REFUND') {
  310. state.dataArray[i].payStatusName = '转入退费'
  311. } else {
  312. state.dataArray[i].payStatusName = '未知'
  313. }
  314. state.allMoney += state.dataArray[i]["fee"] * 0.01
  315. }
  316. console.log("state.dataArray", state.dataArray)
  317. });
  318. }
  319. // 去签署协议
  320. const sign=()=>{
  321. const options = {
  322. type: 2,
  323. data: {
  324. orderId: state.orderId, //订单编号
  325. },
  326. method: "POST",
  327. showLoading: true,
  328. };
  329. requestNew(accountSign, options).then((res) => {
  330. console.log("查询是否签约", res)
  331. });
  332. }
  333. // 查询是否签约
  334. const contractRequest=()=>{
  335. const options = {
  336. type: 2,
  337. data: {
  338. orderId: state.orderId, //订单编号
  339. },
  340. method: "POST",
  341. showLoading: true,
  342. };
  343. requestNew(contractQuery, options).then((res) => {
  344. console.log("查询是否签约", res)
  345. });
  346. }
  347. </script>
  348. <style lang="scss" scoped>
  349. .action {
  350. position: absolute;
  351. bottom: 0rpx;
  352. left: 0;
  353. height: 128rpx;
  354. background-color: #fff;
  355. border-radius: 30rpx 30rpx 0 0;
  356. width: 100vw;
  357. display: flex;
  358. align-items: center;
  359. justify-content: center;
  360. .button {
  361. height: 88rpx;
  362. background: radial-gradient(at 0% 0%, #01243A 0%, #004576 100%);
  363. border-radius: 40rpx;
  364. font-size: 32rpx;
  365. font-weight: 400;
  366. color: #ffffff;
  367. line-height: 88rpx;
  368. width: 660rpx;
  369. margin: 0 auto;
  370. }
  371. }
  372. .value-wrapper {
  373. background-color: #fff;
  374. padding: 40rpx 30rpx;
  375. border-radius: 12rpx;
  376. font-family: SourceHanSansCN, SourceHanSansCN;
  377. .flex {
  378. padding: 20rpx 0rpx;
  379. display: flex;
  380. justify-content: space-between;
  381. align-items: center;
  382. .title {
  383. font-size: 28rpx;
  384. font-weight: 400;
  385. line-height: 28rpx;
  386. color: #666666;
  387. }
  388. .value {
  389. font-size: 30rpx;
  390. font-family: Microsoft YaHei;
  391. font-weight: 400;
  392. line-height: 36rpx;
  393. color: #111111;
  394. .unit {
  395. margin-right: 4rpx;
  396. font-size: 22rpx;
  397. color: #111111;
  398. }
  399. }
  400. }
  401. }
  402. .content-wrap {
  403. position: absolute;
  404. top: 370rpx;
  405. width: 100%;
  406. min-height: calc(100% - 370rpx);
  407. box-sizing: border-box;
  408. padding: 0 30rpx 210rpx;
  409. .ul-item {
  410. padding: 5px 20rpx;
  411. display: flex;
  412. align-items: center;
  413. .item-value {
  414. padding: 20rpx;
  415. position: absolute;
  416. display: flex;
  417. align-items: center;
  418. // justify-content: space-around;
  419. width: 80%;
  420. .content {
  421. width: 48%;
  422. .title {
  423. font-size: 32rpx;
  424. font-family: Microsoft YaHei;
  425. font-weight: 400;
  426. color: #ffffff;
  427. }
  428. .tip {
  429. font-size: 24rpx;
  430. font-family: Microsoft YaHei;
  431. font-weight: 400;
  432. color: #ffffff;
  433. }
  434. }
  435. }
  436. .icon-tip {
  437. width: 100rpx;
  438. height: 100rpx;
  439. }
  440. .content {
  441. margin-left: 40rpx;
  442. }
  443. }
  444. }
  445. .del_item {
  446. background-color: rgb(41, 199, 207) !important;
  447. }
  448. .content-box {
  449. background-color: rgb(41, 199, 207);
  450. line-height: 80rpx;
  451. color: white;
  452. font-size: 32rpx;
  453. border-radius: 10rpx 0 0 10rpx;
  454. padding: 20rpx;
  455. box-sizing: border-box;
  456. }
  457. ::v-deep.uni-swipe_button-text {
  458. font-size: 30rpx !important;
  459. }
  460. ::v-deep.uni-swipe_button-group {
  461. font-size: 28rpx !important;
  462. }
  463. .add_all {
  464. width: 95%;
  465. margin: 0 auto;
  466. }
  467. .uni-swipe_box {
  468. margin-bottom: 16rpx !important;
  469. }
  470. ::v-deep.uni-swipe {
  471. margin-bottom: 16rpx !important;
  472. }
  473. .imageDefault {
  474. height: 40rpx;
  475. width: 40rpx;
  476. transform: rotate(270deg);
  477. margin-right: 12rpx;
  478. color: white;
  479. }
  480. .imageChange {
  481. height: 40rpx;
  482. width: 40rpx;
  483. transform: rotate(90deg);
  484. margin-right: 12rpx;
  485. color: white;
  486. }
  487. .price {
  488. color: white;
  489. }
  490. .agreement {
  491. font-size: 30rpx;
  492. display: flex;
  493. flex-wrap: wrap;
  494. margin-top: 20rpx;
  495. align-items: center;
  496. .txt {
  497. font-size: 24rpx;
  498. font-family: SourceHanSansCN, SourceHanSansCN;
  499. font-weight: 400;
  500. color: #111111;
  501. }
  502. .xieyi {
  503. color: #999;
  504. }
  505. }
  506. </style>