detail.vue 18 KB

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