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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. <template>
  2. <navBar title="产品详情"></navBar>
  3. <navBgCar></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. {{ "¥" + item.fee * 0.01 }}
  10. </view>
  11. </view>
  12. <view class="flex">
  13. <view class="title"> 运费 </view>
  14. <view class="value"> ¥0.00 </view>
  15. </view>
  16. <view class="flex">
  17. <view class="title"> 实付款 </view>
  18. <view class="money">
  19. {{ "¥" + state.allMoney }}
  20. </view>
  21. </view>
  22. <view class="as-layout-horizontal agreement">
  23. <checkbox-group @change="checkboxChange">
  24. <checkbox :checked="state.checked" style="transform: scale(0.8)" />我已阅读并同意
  25. </checkbox-group>
  26. <text v-for="(item,index) in state.agreeURL" style="color:#007AFF;text-decoration: underline;" @click="downAuthD(item)">《{{item.name}}》</text>
  27. </view>
  28. </view>
  29. <view class="action">
  30. <button type="default" class="button" @click="savaHandle()">
  31. {{ "确认办理:¥" + state.allMoney }}
  32. </button>
  33. </view>
  34. </view>
  35. </template>
  36. <script setup lang="ts">
  37. import {
  38. onLoad,
  39. } from "@dcloudio/uni-app";
  40. import {
  41. reactive,
  42. ref
  43. } from "vue";
  44. import {
  45. getOpenId,
  46. envs,payQuery,agreementInSertOrder,agreeOrderProdcut
  47. } from "@/utils/network/api.js";
  48. import {
  49. request,requestNew
  50. } from "@/utils/network/request.js";
  51. import {
  52. stringToJson
  53. } from "@/utils/network/encryption";
  54. import navBgCar from "./components/nav-bg-car5";
  55. import navBar from "@/components/nav-bar/nav-bar2.vue";
  56. import {
  57. msg
  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. uni.navigateTo({
  78. url: `/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. margin-top: 40rpx;
  318. padding-left: 20rpx;
  319. padding-right: 20rpx;
  320. padding-bottom: 30rpx;
  321. .button {
  322. height: 80rpx;
  323. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  324. border-radius: 40rpx;
  325. font-size: 32rpx;
  326. font-weight: 400;
  327. color: #ffffff;
  328. line-height: 80rpx;
  329. }
  330. }
  331. .value-wrapper {
  332. margin-top: 40rpx;
  333. padding: 0rpx 30rpx;
  334. .flex {
  335. padding: 20rpx 0rpx;
  336. display: flex;
  337. justify-content: space-between;
  338. align-items: center;
  339. .title {
  340. font-size: 28rpx;
  341. font-family: Microsoft YaHei;
  342. font-weight: 400;
  343. color: #777777;
  344. line-height: 28rpx;
  345. }
  346. .value {
  347. font-size: 28rpx;
  348. font-family: Microsoft YaHei;
  349. font-weight: 400;
  350. color: #333333;
  351. line-height: 28rpx;
  352. }
  353. .money {
  354. font-size: 36rpx;
  355. font-family: Microsoft YaHei;
  356. font-weight: 400;
  357. color: #00b38b;
  358. line-height: 36rpx;
  359. }
  360. }
  361. }
  362. .content-wrap {
  363. position: relative;
  364. margin-top: -50rpx;
  365. padding: 0rpx 30rpx;
  366. .ul-item {
  367. padding: 5px 20rpx;
  368. display: flex;
  369. align-items: center;
  370. .item-value {
  371. padding: 20rpx;
  372. position: absolute;
  373. display: flex;
  374. align-items: center;
  375. // justify-content: space-around;
  376. width: 80%;
  377. .content {
  378. width: 48%;
  379. .title {
  380. font-size: 32rpx;
  381. font-family: Microsoft YaHei;
  382. font-weight: 400;
  383. color: #ffffff;
  384. }
  385. .tip {
  386. font-size: 24rpx;
  387. font-family: Microsoft YaHei;
  388. font-weight: 400;
  389. color: #ffffff;
  390. }
  391. }
  392. }
  393. .icon-tip {
  394. width: 100rpx;
  395. height: 100rpx;
  396. }
  397. .content {
  398. margin-left: 40rpx;
  399. }
  400. }
  401. }
  402. .del_item {
  403. background-color: rgb(41, 199, 207) !important;
  404. }
  405. .content-box {
  406. background-color: rgb(41, 199, 207);
  407. line-height: 80rpx;
  408. color: white;
  409. font-size: 32rpx;
  410. border-radius: 10rpx 0 0 10rpx;
  411. padding: 20rpx;
  412. box-sizing: border-box;
  413. }
  414. ::v-deep.uni-swipe_button-text {
  415. font-size: 30rpx !important;
  416. }
  417. ::v-deep.uni-swipe_button-group {
  418. font-size: 28rpx !important;
  419. }
  420. .add_all {
  421. width: 95%;
  422. margin: 0 auto;
  423. }
  424. .uni-swipe_box {
  425. margin-bottom: 16rpx !important;
  426. }
  427. ::v-deep.uni-swipe {
  428. margin-bottom: 16rpx !important;
  429. }
  430. .imageDefault {
  431. height: 40rpx;
  432. width: 40rpx;
  433. transform: rotate(270deg);
  434. margin-right: 12rpx;
  435. color: white;
  436. }
  437. .imageChange {
  438. height: 40rpx;
  439. width: 40rpx;
  440. transform: rotate(90deg);
  441. margin-right: 12rpx;
  442. color: white;
  443. }
  444. .price {
  445. color: white;
  446. }
  447. .agreement {
  448. font-size: 30rpx;
  449. display: flex;
  450. flex-wrap: wrap;
  451. margin-top: 20rpx;
  452. align-items: center;
  453. }
  454. </style>