detail.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807
  1. <template>
  2. <view class="order-detail">
  3. <view class="status-box">
  4. <view class="text-box">
  5. <view
  6. class="status"
  7. v-if="info.goodsList[0].goodsState == 'WAIT_PAYMENT' && !isNotTime"
  8. >
  9. 等待支付,剩余<u-count-down
  10. :time="closeTime"
  11. format="HH:mm:ss"
  12. @finish="finish"
  13. ></u-count-down>
  14. </view>
  15. <view class="status" v-else>
  16. {{ filterType(info.goodsList[0].goodsState) }}
  17. </view>
  18. </view>
  19. </view>
  20. <view
  21. class="content progress"
  22. v-if="
  23. info.goodsList[0].goodsState == 'APPLY_REFUND' ||
  24. info.goodsList[0].goodsState == 'REFUNDED'
  25. "
  26. @click="refundDetail"
  27. >
  28. <view class="progress-title"> 退款进度 </view>
  29. <view class="progress-desc"> 查看退款详情 </view>
  30. </view>
  31. <view class="content info">
  32. <view class="order-info">
  33. <image
  34. class="icon"
  35. :src="info.goodsList[0].goodsInfo.goodsPath"
  36. mode=""
  37. ></image>
  38. <view class="shop-info">
  39. <view class="title">
  40. {{ info.goodsList[0].goodsInfo.goodsName }}
  41. </view>
  42. <view class="goods-desc">
  43. {{ info.goodsList[0].goodsInfo.goodsDescribe }}
  44. </view>
  45. <view class="price-box">
  46. <view class="price">
  47. ¥{{ info.goodsList[0].goodsInfo.realPrice }}
  48. </view>
  49. </view>
  50. <!-- 有extend并且不是虚拟商品 -->
  51. <!-- <view class="start-time" v-if="info.extend&&!isVisual">
  52. 出发时间:{{info.extend}}
  53. </view> -->
  54. </view>
  55. </view>
  56. </view>
  57. <view class="input-box-address" @click="toMap()">
  58. <view class="label"> 到店自取地址 </view>
  59. <view class="value">
  60. <!-- {{ info.address }} -->
  61. 印象贵大文创店
  62. </view>
  63. <view class="label"> 贵州大学西校区西一区体育场楼下</view>
  64. </view>
  65. <view
  66. class="content code-box"
  67. v-if="
  68. info.goodsList[0].goodsState == 'WAIT_USE' &&
  69. info.goodsList[0].goodsName != '二维码支付'
  70. "
  71. >
  72. <view class="left">
  73. <view class="title"> 券码信息 </view>
  74. <view class="codeNum"> </view>
  75. </view>
  76. <view class="code-btn" @click="checkCode">
  77. 查看券码
  78. <image
  79. class="jiantou"
  80. src="../../static/jiantou-icon.png"
  81. mode=""
  82. ></image>
  83. </view>
  84. </view>
  85. <view class="content" v-if="info.goodsList[0].goodsState == 'USED'">
  86. <view class="title"> 消费记录 </view>
  87. <view class="item">
  88. <view class="label"> 消费时间 </view>
  89. <view class="value">
  90. {{
  91. $u.timeFormat(
  92. info.goodsList[0].verifyModel.checkTime,
  93. "yyyy-mm-dd hh:MM:ss"
  94. )
  95. }}
  96. </view>
  97. </view>
  98. <view class="item">
  99. <view class="label"> 消费门店 </view>
  100. <view class="value">
  101. {{ info.goodsList[0].verifyModel.shopName }}
  102. </view>
  103. </view>
  104. </view>
  105. <view class="content">
  106. <view class="title"> 订单信息 </view>
  107. <view class="item">
  108. <view class="label"> 订单编号 </view>
  109. <view class="value">
  110. {{ info.orderNo }}
  111. </view>
  112. </view>
  113. <view class="item">
  114. <view class="label"> 付款方式 </view>
  115. <view class="value">
  116. {{ filterPay(info.payment.paymentWay) || "未支付" }}
  117. </view>
  118. </view>
  119. <view class="item">
  120. <view class="label"> 下单时间 </view>
  121. <view class="value">
  122. {{
  123. $u.timeFormat(info.createTime, "yyyy-mm-dd hh:MM:ss") || "未支付"
  124. }}
  125. </view>
  126. </view>
  127. <view
  128. class="item"
  129. v-if="
  130. info.goodsList[0].goodsState != 'WAIT_PAYMENT' &&
  131. info.goodsList[0].goodsState != 'CLOSE'
  132. "
  133. >
  134. <view class="label"> 支付时间 </view>
  135. <view class="value">
  136. {{ $u.timeFormat(info.payment.paymentTime, "yyyy-mm-dd hh:MM:ss") }}
  137. </view>
  138. </view>
  139. <view class="item">
  140. <view class="label"> 订单备注 </view>
  141. <view class="value">
  142. {{
  143. info.extend.remark || "无"
  144. }}
  145. </view>
  146. </view>
  147. </view>
  148. <view class="content">
  149. <view class="title"> 交易信息 </view>
  150. <view class="item">
  151. <view class="label"> 商品金额 </view>
  152. <view class="value black">
  153. ¥{{ info.goodsList[0].goodsInfo.realPrice }}
  154. </view>
  155. </view>
  156. <view class="item">
  157. <view class="label"> 优惠券 </view>
  158. <view class="value red"> -¥{{ info.discountAmount }} </view>
  159. </view>
  160. <view class="item">
  161. <view class="label"> 合计 </view>
  162. <view class="value">
  163. <text class="red fs28">¥{{ info.payAmount }}</text>
  164. </view>
  165. </view>
  166. </view>
  167. <view class="input-box" v-if="isVisual">
  168. <view class="label"> 充值账号 </view>
  169. <view class="value">
  170. {{ JSON.parse(info.extend).account }}
  171. </view>
  172. </view>
  173. <template v-if="info.goodsList[0].goodsState == 'APPLY_REFUND'">
  174. <view class="content refund-box">
  175. <view class="title"> 退款原因 </view>
  176. <view class="refund-msg">
  177. {{ info.goodsList[0].refundLog.remark }}
  178. </view>
  179. </view>
  180. <button
  181. type="default"
  182. :loading="btnLoading"
  183. v-if="!info.payment.transferAll"
  184. class="pay-btn"
  185. @click="cancelReply"
  186. >
  187. 取消退款
  188. </button>
  189. </template>
  190. <button
  191. type="default"
  192. :loading="btnLoading"
  193. class="pay-btn"
  194. v-if="info.goodsList[0].goodsState == 'WAIT_PAYMENT'"
  195. @click="pay"
  196. >
  197. 立即支付
  198. </button>
  199. <view
  200. class="content apply-box"
  201. v-else-if="
  202. (info.goodsList[0].goodsState == 'WAIT_USE' ||
  203. info.goodsList[0].goodsState == 'USED') &&
  204. isRefund()
  205. "
  206. @click="apply"
  207. >
  208. <view class="label"> 退款申请 </view>
  209. <view class="value"> 如引发商品争议,可申请平台介入处理 </view>
  210. <image
  211. class="jiantou"
  212. src="../../static/jiantou-icon.png"
  213. mode=""
  214. ></image>
  215. </view>
  216. <!-- 二维码 -->
  217. <u-overlay :show="show" v-if="show" :opacity="0.6">
  218. <view class="wrap" @click.stop="close">
  219. <uqrcode
  220. ref="uqrcode"
  221. type="2d"
  222. auto
  223. canvas-id="qrcode"
  224. :value="codeData"
  225. :loading="loading"
  226. :options="{ margin: 20 }"
  227. >
  228. <template v-slot:loading>
  229. <text style="color: black">拼命加载中...</text>
  230. </template>
  231. </uqrcode>
  232. </view>
  233. </u-overlay>
  234. </view>
  235. </template>
  236. <script>
  237. import { qrCode } from "@/api/order.js";
  238. import { payDetails, queryPayOrder, unRefund } from "@/api/payment.js";
  239. import { encodeURI } from "js-base64";
  240. export default {
  241. data() {
  242. return {
  243. isVisual: false, //是否是虚拟商品
  244. codeData: "123",
  245. show: false,
  246. isJumped: false,
  247. loading: false,
  248. btnLoading: false,
  249. oldBright: 0,
  250. info: {
  251. goodsList: [{ goodsState: "" }],
  252. payment: {
  253. paymentWay: "",
  254. },
  255. extend: "",
  256. },
  257. isNotTime: false,
  258. };
  259. },
  260. watch: {
  261. // isNotTime(val) {
  262. // if(this.isNotTime){
  263. // this.payDetails(this.info.orderNo)
  264. // }
  265. // }
  266. },
  267. filters: {
  268. },
  269. computed: {
  270. },
  271. methods: {
  272. filterType: function (val) {
  273. if (val == "APPLY_REFUND") {
  274. return "退款审核中";
  275. } else if (val == "CLOSE") {
  276. return "关闭订单";
  277. } else if (val == "REFUNDED") {
  278. return "已退款";
  279. } else if (val == "REFUSAL_REFUND") {
  280. return "拒绝退款";
  281. } else if (val == "USED") {
  282. return "订单已完成";
  283. } else if (val == "WAIT_PAYMENT") {
  284. return "待付款";
  285. } else if (val == "WAIT_USE") {
  286. return "待使用";
  287. }
  288. },
  289. filterPay(val) {
  290. if (val == "wx.unifiedOrder") {
  291. return "微信支付";
  292. } else if (val == "trade.create") {
  293. return "支付宝支付";
  294. } else if (val == "uac.miniOrder") {
  295. return "云闪付支付";
  296. } else {
  297. return "-";
  298. }
  299. },
  300. isRefund() {
  301. if (!this.info.goodsList[0].verifyModel) {
  302. //没核销
  303. return true;
  304. } else if (
  305. this.info.goodsList[0].verifyModel &&
  306. new Date().getTime() <
  307. this.info.goodsList[0].verifyModel.checkTime + 1000 * 60 * 60 * 48
  308. ) {
  309. // 已核销 并且没超过48小时
  310. return true;
  311. } else {
  312. return false;
  313. }
  314. },
  315. finish() {
  316. this.isNotTime = true;
  317. console.log(222222, this.isNotTime);
  318. this.payDetails(this.info.orderNo);
  319. },
  320. refundDetail() {
  321. uni.navigateTo({
  322. url: `/my/order/refundDetail?id=${this.info.orderNo}`,
  323. });
  324. },
  325. checkCode() {
  326. this.codeData = "";
  327. this.$nextTick(() => {
  328. this.show = true;
  329. this.loading = true;
  330. let that = this;
  331. // uni.getScreenBrightness({
  332. // success(res) {
  333. // // 获取用户手机亮度 保存起来
  334. // that.oldBright = res.value
  335. // setTimeout(()=>{
  336. // uni.setScreenBrightness({
  337. // value:1
  338. // })
  339. // },200)
  340. // }
  341. // })
  342. qrCode(this.info.goodsList[0].id).then((res) => {
  343. this.loading = false;
  344. if (res.state == "Success") {
  345. this.codeData = res.content;
  346. }
  347. });
  348. });
  349. },
  350. close() {
  351. this.show = false;
  352. // uni.setScreenBrightness({
  353. // value:this.oldBright
  354. // })
  355. },
  356. apply() {
  357. let that = this;
  358. uni.navigateTo({
  359. url: "./refund",
  360. success: function (res) {
  361. // 通过eventChannel向被打开页面传送数据
  362. res.eventChannel.emit("orderInfo", that.info);
  363. },
  364. });
  365. },
  366. // 获取订单详情
  367. payDetails(orderNo) {
  368. payDetails(orderNo).then((res) => {
  369. this.info = res.content;
  370. // try {
  371. // let extend = JSON.parse(this.info.extend);
  372. // if (extend.account) {
  373. // this.isVisual = true;
  374. // }
  375. // } catch (e) {
  376. // //TODO handle the exception
  377. // }
  378. this.info.extend = JSON.parse(this.info.goodsList[0].extend);
  379. // 跳转了但是没支付
  380. if(this.isJumped && this.info.goodsList[0].goodsState == "WAIT_PAYMENT"){
  381. this.btnLoading = false;
  382. uni.showToast({
  383. title: "支付取消",
  384. icon: "warning",
  385. });
  386. }else{
  387. }
  388. });
  389. },
  390. toMap() {
  391. uni.openLocation({
  392. latitude: 26.4401,
  393. longitude: 106.664,
  394. name: "印象贵大文创店",
  395. address: "贵州大学西校区西一区体育场楼下",
  396. });
  397. },
  398. // 支付
  399. pay() {
  400. if (this.btnLoading) return;
  401. this.btnLoading = true;
  402. uni.showLoading({
  403. title: "支付中",
  404. });
  405. let that = this;
  406. let miniPayRequest = this.info.payment.miniPayRequest;
  407. miniPayRequest = JSON.parse(miniPayRequest);
  408. let query = encodeURIComponent(JSON.stringify({
  409. sign: miniPayRequest.sign,
  410. prepayid: miniPayRequest.prepayid,
  411. }))
  412. console.log('prepayid :>> ', miniPayRequest.prepayid);
  413. console.log('sign',miniPayRequest.sign);
  414. console.log('path+query :>> ', `${miniPayRequest.minipath}?appPayReqest=${query}`);
  415. console.log('appId', miniPayRequest.miniuser)
  416. // 打开银联小程序
  417. uni.navigateToMiniProgram({
  418. appId: miniPayRequest.miniuser,
  419. path: `${miniPayRequest.minipath}?appPayRequest=${query}`,
  420. success: (res) => {
  421. // 打开成功
  422. // console.log("打开成功", res);
  423. this.isJumped = true;
  424. },
  425. fail: (err) => {
  426. // console.log(err);
  427. uni.hideLoading();
  428. uni.showToast({
  429. title: "支付失败",
  430. icon: "none",
  431. });
  432. that.btnLoading = false
  433. },
  434. });
  435. // uni.requestPayment({
  436. // "provider": "wxpay",
  437. // "orderInfo": miniPayRequest,
  438. // "appid": "wxbc64403830bb13c5", // 微信开放平台 - 应用 - AppId,注意和微信小程序、公众号 AppId 可能不一致
  439. // "paySign": miniPayRequest.paySign,
  440. // "nonceStr": miniPayRequest.nonceStr, // 随机字符串
  441. // "package": miniPayRequest.package, // 固定值
  442. // // "prepayid": miniPayRequest.package, // 统一下单订单号
  443. // "timeStamp": miniPayRequest.timeStamp, // 时间戳(单位:秒)
  444. // "signType": miniPayRequest.signType, //签名算法
  445. // success(msg) {
  446. // console.log('msg', msg);
  447. // queryPayOrder(that.info.orderNo).then(res1 => {
  448. // if (res1.state == 'Success') {
  449. // uni.hideLoading()
  450. // uni.showToast({
  451. // title: '支付成功',
  452. // icon: 'success'
  453. // })
  454. // that.btnLoading = false
  455. // that.payDetails(that.info.orderNo)
  456. // }
  457. // })
  458. // },
  459. // fail(e) {
  460. // that.btnLoading = false
  461. // uni.hideLoading()
  462. // uni.showToast({
  463. // title: '取消支付',
  464. // icon: 'fail'
  465. // })
  466. // // 取消支付后,获取支付信息以备再次支付
  467. // that.payDetails(that.info.orderNo)
  468. // console.log('err', e,this);
  469. // }
  470. // })
  471. },
  472. // 取消退款申请
  473. cancelReply() {
  474. if (this.btnLoading) return;
  475. this.btnLoading = true;
  476. uni.showLoading({
  477. title: "取消中",
  478. });
  479. unRefund({ id: this.info.goodsList[0].id }).then((res) => {
  480. this.btnLoading = false;
  481. uni.hideLoading();
  482. if (res.state == "Success") {
  483. this.payDetails(this.info.orderNo);
  484. uni.showToast({
  485. title: "取消成功",
  486. icon: "success",
  487. });
  488. }
  489. });
  490. },
  491. },
  492. onReady() {},
  493. onLoad(options) {
  494. this.info.orderNo = options.id;
  495. },
  496. onShow() {
  497. this.payDetails(this.info.orderNo);
  498. },
  499. created() {
  500. // this.info = JSON.parse(uni.getStorageSync('order'))
  501. },
  502. };
  503. </script>
  504. <style lang="scss">
  505. .order-detail {
  506. background: #f9f9f9;
  507. min-height: 100vh;
  508. // padding-bottom: 100rpx;
  509. .status-box {
  510. padding: 24rpx 24rpx 4rpx;
  511. display: flex;
  512. justify-content: space-between;
  513. .text-box {
  514. color: #181818;
  515. .status {
  516. font-weight: bold;
  517. font-size: 32rpx;
  518. display: flex;
  519. .u-count-down__text {
  520. color: #ff4d3a !important;
  521. }
  522. }
  523. .notice {
  524. font-size: 24rpx;
  525. margin-top: 20rpx;
  526. }
  527. }
  528. }
  529. .progress {
  530. .progress-title {
  531. font-weight: 600;
  532. font-size: 32rpx;
  533. color: #181818;
  534. }
  535. .progress-desc {
  536. font-weight: 300;
  537. font-size: 24rpx;
  538. color: #aaaaaa;
  539. margin-top: 15rpx;
  540. }
  541. }
  542. .shop-box {
  543. width: 690rpx;
  544. // margin: 0 30rpx;
  545. // padding: 24rpx 24rpx 30rpx;
  546. background: #fff;
  547. border-radius: 16rpx;
  548. margin-top: -30rpx;
  549. box-sizing: border-box;
  550. .shop-name {
  551. font-weight: 600;
  552. font-size: 32rpx;
  553. color: #181818;
  554. width: 100%;
  555. white-space: nowrap;
  556. overflow: hidden;
  557. text-overflow: ellipsis;
  558. }
  559. .address {
  560. font-weight: 300;
  561. font-size: 24rpx;
  562. color: #aaaaaa;
  563. margin-top: 20rpx;
  564. width: 100%;
  565. white-space: nowrap;
  566. overflow: hidden;
  567. text-overflow: ellipsis;
  568. }
  569. }
  570. .black {
  571. color: #222222 !important;
  572. }
  573. .red {
  574. color: red !important;
  575. }
  576. .fs28 {
  577. font-size: 28rpx !important;
  578. font-weight: bold;
  579. }
  580. .code-box {
  581. display: flex;
  582. align-items: center;
  583. justify-content: space-between;
  584. .left {
  585. .title {
  586. font-weight: 500;
  587. font-size: 28rpx;
  588. color: #222222;
  589. }
  590. .codeNum {
  591. font-weight: 300;
  592. font-size: 24rpx;
  593. color: #aaaaaa;
  594. margin-top: 15rpx;
  595. }
  596. }
  597. .code-btn {
  598. display: flex;
  599. align-items: center;
  600. font-weight: 300;
  601. font-size: 24rpx;
  602. color: #aaaaaa;
  603. .jiantou {
  604. width: 24rpx;
  605. height: 24rpx;
  606. }
  607. }
  608. }
  609. .input-box {
  610. margin: 20rpx 30rpx;
  611. padding: 28rpx 24rpx;
  612. background: #ffffff;
  613. border-radius: 16rpx 16rpx 16rpx 16rpx;
  614. display: flex;
  615. align-items: center;
  616. justify-content: space-between;
  617. .label {
  618. color: #222;
  619. font-size: 28rpx;
  620. }
  621. .value {
  622. font-size: 28rpx;
  623. color: #aaaaaa;
  624. }
  625. }
  626. .input-box-address {
  627. margin: 20rpx 30rpx;
  628. padding: 28rpx 24rpx;
  629. background: #ffffff;
  630. border-radius: 16rpx 16rpx 16rpx 16rpx;
  631. // display: flex;
  632. // align-items: center;
  633. // justify-content: space-between;
  634. .value {
  635. color: #222;
  636. font-size: 28rpx;
  637. }
  638. .label {
  639. font-size: 28rpx;
  640. margin: 10rpx 0;
  641. color: #aaaaaa;
  642. }
  643. }
  644. .content {
  645. margin: 20rpx 30rpx;
  646. padding: 28rpx 24rpx;
  647. border-radius: 16rpx;
  648. background: #fff;
  649. .title {
  650. font-weight: 600;
  651. font-size: 28rpx;
  652. color: #222222;
  653. }
  654. .item {
  655. display: flex;
  656. align-items: center;
  657. justify-content: space-between;
  658. margin-top: 28rpx;
  659. .label {
  660. color: #222222;
  661. font-size: 28rpx;
  662. }
  663. .value {
  664. color: #999999;
  665. font-size: 28rpx;
  666. }
  667. }
  668. }
  669. .pay-btn {
  670. background: $uni-color-primary;
  671. width: 688rpx;
  672. height: 80rpx;
  673. line-height: 80rpx;
  674. border-radius: 46rpx;
  675. color: #fff;
  676. margin-top: 50rpx;
  677. }
  678. .refund-box {
  679. .refund-msg {
  680. font-weight: 300;
  681. font-size: 24rpx;
  682. color: #222222;
  683. margin-top: 15rpx;
  684. line-height: 40rpx;
  685. }
  686. }
  687. .apply-box {
  688. position: relative;
  689. .label {
  690. font-weight: 600;
  691. font-size: 28rpx;
  692. color: #222222;
  693. }
  694. .value {
  695. color: #999999;
  696. font-size: 24rpx;
  697. margin-top: 15rpx;
  698. }
  699. .jiantou {
  700. position: absolute;
  701. top: 50%;
  702. right: 24rpx;
  703. transform: translateY(-50%);
  704. width: 24rpx;
  705. height: 24rpx;
  706. }
  707. }
  708. .info {
  709. .order-info {
  710. display: flex;
  711. .icon {
  712. width: 164rpx;
  713. height: 164rpx;
  714. border-radius: 16rpx;
  715. flex-shrink: 0;
  716. }
  717. .shop-info {
  718. display: flex;
  719. flex-direction: column;
  720. justify-content: space-between;
  721. padding-left: 24rpx;
  722. flex: 1;
  723. box-sizing: border-box;
  724. .title {
  725. color: #181818;
  726. font-size: 28rpx;
  727. width: 450rpx;
  728. white-space: nowrap;
  729. overflow: hidden;
  730. text-overflow: ellipsis;
  731. }
  732. .price-box {
  733. display: flex;
  734. align-items: center;
  735. justify-content: space-between;
  736. .price {
  737. color: #181818;
  738. font-size: 32rpx;
  739. font-weight: bold;
  740. }
  741. }
  742. .start-time,
  743. .goods-desc {
  744. font-size: 24rpx;
  745. color: #aaaaaa;
  746. width: 450rpx;
  747. white-space: nowrap;
  748. overflow: hidden;
  749. text-overflow: ellipsis;
  750. }
  751. }
  752. }
  753. }
  754. .wrap {
  755. display: flex;
  756. justify-content: center;
  757. align-items: center;
  758. height: 100vh;
  759. overflow: hidden;
  760. }
  761. }
  762. </style>