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

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