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

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