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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  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. getOpenidApi,
  46. getAgreementApi,
  47. PAYDETECTION,
  48. envs,
  49. agreementConfirmApi,payQuery
  50. } from "@/utils/network/api.js";
  51. import {
  52. request,requestNew
  53. } from "@/utils/network/request.js";
  54. import {
  55. stringToJson
  56. } from "@/utils/network/encryption";
  57. import navBgCar from "./components/nav-bg-car5";
  58. import navBar from "@/components/nav-bar/nav-bar2.vue";
  59. import {
  60. msg
  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. uni.navigateTo({
  81. url: `/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. request(getOpenidApi, options).then((res) => {
  141. const result = stringToJson(res.bizContent);
  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 request(agreementConfirmApi, options);
  162. const data = stringToJson(res.bizContent);
  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. });
  184. const state = reactive({
  185. openid: "",
  186. orderId: "",
  187. clientFee: undefined,
  188. id: "",
  189. options2: [{
  190. text: '删除',
  191. style: {
  192. backgroundColor: '#F56C6C'
  193. }
  194. }],
  195. list: [],
  196. productMoney: 0,
  197. allMoney: 0,
  198. productId: [],
  199. // 弹框
  200. type: 'center',
  201. msgType: 'success',
  202. messageText: '这是一条成功提示',
  203. value: '',
  204. detailsObj: '',
  205. isValueCard: "",
  206. dataArray: [],
  207. checked: false,
  208. agreeURL: [],
  209. typeScanCode: 0,//扫码进来得
  210. vehicleId:"",
  211. agreements:[]
  212. });
  213. // 查协议
  214. const queryAgreement = () => {
  215. const options = {
  216. type: 2,
  217. data: {
  218. orderId: state.orderId, //订单编号
  219. status:1
  220. },
  221. method: "POST",
  222. showLoading: true,
  223. };
  224. request(getAgreementApi, options).then((res) => {
  225. let data = stringToJson(res.bizContent);
  226. let supAgreeArr=data.data
  227. console.log("data==",supAgreeArr)
  228. for(var m=0;m<supAgreeArr.length;m++){
  229. let obj={}
  230. obj['name']=supAgreeArr[m]['name']
  231. for(var k=0;k<supAgreeArr[m]['address'].length;k++){
  232. state.agreements.push(supAgreeArr[m]['address'][k]['id'])
  233. obj['url']=envs[process.env.NODE_ENV].baseUrl+supAgreeArr[m]['address'][k]['url']
  234. state.agreeURL.push(obj)
  235. }
  236. }
  237. console.log("查协议", state.agreeURL)
  238. });
  239. }
  240. const checkboxChange = (e) => {
  241. state.checked = !state.checked;
  242. console.log(state.checked);
  243. };
  244. const refresh = () => {
  245. let source = ""
  246. // #ifdef MP-ALIPAY
  247. source = "ALI"
  248. // #endif
  249. // #ifdef MP-WEIXIN
  250. source = "WECHAT"
  251. // getOpenID();
  252. // #endif
  253. var data = {
  254. orderId: state.orderId,
  255. source: source //请求方来源
  256. };
  257. const options = {
  258. type: 2,
  259. data: data,
  260. method: "POST",
  261. showLoading: true,
  262. };
  263. console.log("输出内容", options);
  264. requestNew(payQuery, options).then((res) => {
  265. // console.log(res.bizContent);
  266. const data = stringToJson(res.bizContent);
  267. console.log(data);
  268. // console.log(typeof(data));
  269. // if (data.paymentStatus == 'ALLSUCCESS') {
  270. // gotoEditUserOrUnitInfo()
  271. // }
  272. state.dataArray = data.datas;
  273. // HANDLE("办理费",1){},
  274. // MARGIN("保证金",2){},
  275. // PRESTORE("预存金",3){},
  276. // EQUITY("权益费",4){},
  277. for (let i = 0; i < state.dataArray.length; i++) {
  278. if (state.dataArray[i].payType === 'HANDLE') {
  279. state.dataArray[i].payName = '权益金'
  280. } else if (state.dataArray[i].payType === 'MARGIN') {
  281. state.dataArray[i].payName = '保证金'
  282. } else if (state.dataArray[i].payType === 'PRESTORE') {
  283. state.dataArray[i].payName = '预存金'
  284. } else if (state.dataArray[i].payType === 'EQUITY') {
  285. state.dataArray[i].payName = '权益费'
  286. } else {
  287. state.dataArray[i].payName = '未知费'
  288. }
  289. // SUCCESS("支付成功",1){},
  290. // PAYING("支付中",2){},
  291. // FAILED("支付失败",3){},
  292. // UNPAY("未支付",4){},
  293. // CLOSED("已关闭",5){},
  294. // CANCELED("已撤销",6){},
  295. // REFUND("转入退费",7){},
  296. if (state.dataArray[i].payStatus === 'SUCCESS') {
  297. state.dataArray[i].payStatusName = '已支付'
  298. } else if (state.dataArray[i].payStatus === 'PAYING') {
  299. state.dataArray[i].payStatusName = '支付中'
  300. } else if (state.dataArray[i].payStatus === 'FAILED') {
  301. state.dataArray[i].payStatusName = '支付失败'
  302. } else if (state.dataArray[i].payStatus === 'UNPAY') {
  303. state.dataArray[i].payStatusName = '未支付'
  304. } else if (state.dataArray[i].payStatus === 'CLOSED') {
  305. state.dataArray[i].payStatusName = '已关闭'
  306. } else if (state.dataArray[i].payStatus === 'CANCELED') {
  307. state.dataArray[i].payStatusName = '已撤销'
  308. } else if (state.dataArray[i].payStatus === 'REFUND') {
  309. state.dataArray[i].payStatusName = '转入退费'
  310. } else {
  311. state.dataArray[i].payStatusName = '未知'
  312. }
  313. state.allMoney += state.dataArray[i]["fee"] * 0.01
  314. }
  315. console.log("state.dataArray", state.dataArray)
  316. });
  317. }
  318. </script>
  319. <style lang="scss" scoped>
  320. .action {
  321. margin-top: 40rpx;
  322. padding-left: 20rpx;
  323. padding-right: 20rpx;
  324. padding-bottom: 30rpx;
  325. .button {
  326. height: 80rpx;
  327. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  328. border-radius: 40rpx;
  329. font-size: 32rpx;
  330. font-weight: 400;
  331. color: #ffffff;
  332. line-height: 80rpx;
  333. }
  334. }
  335. .value-wrapper {
  336. margin-top: 40rpx;
  337. padding: 0rpx 30rpx;
  338. .flex {
  339. padding: 20rpx 0rpx;
  340. display: flex;
  341. justify-content: space-between;
  342. align-items: center;
  343. .title {
  344. font-size: 28rpx;
  345. font-family: Microsoft YaHei;
  346. font-weight: 400;
  347. color: #777777;
  348. line-height: 28rpx;
  349. }
  350. .value {
  351. font-size: 28rpx;
  352. font-family: Microsoft YaHei;
  353. font-weight: 400;
  354. color: #333333;
  355. line-height: 28rpx;
  356. }
  357. .money {
  358. font-size: 36rpx;
  359. font-family: Microsoft YaHei;
  360. font-weight: 400;
  361. color: #00b38b;
  362. line-height: 36rpx;
  363. }
  364. }
  365. }
  366. .content-wrap {
  367. position: relative;
  368. margin-top: -50rpx;
  369. padding: 0rpx 30rpx;
  370. .ul-item {
  371. padding: 5px 20rpx;
  372. display: flex;
  373. align-items: center;
  374. .item-value {
  375. padding: 20rpx;
  376. position: absolute;
  377. display: flex;
  378. align-items: center;
  379. // justify-content: space-around;
  380. width: 80%;
  381. .content {
  382. width: 48%;
  383. .title {
  384. font-size: 32rpx;
  385. font-family: Microsoft YaHei;
  386. font-weight: 400;
  387. color: #ffffff;
  388. }
  389. .tip {
  390. font-size: 24rpx;
  391. font-family: Microsoft YaHei;
  392. font-weight: 400;
  393. color: #ffffff;
  394. }
  395. }
  396. }
  397. .icon-tip {
  398. width: 100rpx;
  399. height: 100rpx;
  400. }
  401. .content {
  402. margin-left: 40rpx;
  403. }
  404. }
  405. }
  406. .del_item {
  407. background-color: rgb(41, 199, 207) !important;
  408. }
  409. .content-box {
  410. background-color: rgb(41, 199, 207);
  411. line-height: 80rpx;
  412. color: white;
  413. font-size: 32rpx;
  414. border-radius: 10rpx 0 0 10rpx;
  415. padding: 20rpx;
  416. box-sizing: border-box;
  417. }
  418. ::v-deep.uni-swipe_button-text {
  419. font-size: 30rpx !important;
  420. }
  421. ::v-deep.uni-swipe_button-group {
  422. font-size: 28rpx !important;
  423. }
  424. .add_all {
  425. width: 95%;
  426. margin: 0 auto;
  427. }
  428. .uni-swipe_box {
  429. margin-bottom: 16rpx !important;
  430. }
  431. ::v-deep.uni-swipe {
  432. margin-bottom: 16rpx !important;
  433. }
  434. .imageDefault {
  435. height: 40rpx;
  436. width: 40rpx;
  437. transform: rotate(270deg);
  438. margin-right: 12rpx;
  439. color: white;
  440. }
  441. .imageChange {
  442. height: 40rpx;
  443. width: 40rpx;
  444. transform: rotate(90deg);
  445. margin-right: 12rpx;
  446. color: white;
  447. }
  448. .price {
  449. color: white;
  450. }
  451. .agreement {
  452. font-size: 30rpx;
  453. display: flex;
  454. flex-wrap: wrap;
  455. margin-top: 20rpx;
  456. align-items: center;
  457. }
  458. </style>