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

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