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

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