detail.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800
  1. <template>
  2. <view class="order-detail">
  3. <view class="status-box">
  4. <view class="text-box">
  5. <view class="status" v-if="info.orderType == 'WAIT_PAYMENT' && !isNotTime">
  6. 等待支付,剩余<u-count-down :time="closeTime" format="mm:ss" @finish="finish"></u-count-down>
  7. </view>
  8. <view class="status" v-if="info.goodsList[0].goodsState != 'APPLY_REFUND' && info.goodsList[0].goodsState != 'REFUNDED'">
  9. {{ filterType(info.orderType) }}
  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. closeTime() {
  221. // if((this.info.createTime + 1000*60*15) - new Date().getTime()){
  222. // this.isNotTime = false
  223. // }else{
  224. // this.isNotTime = true
  225. // }
  226. return (this.info.createTime + 1000 * 60 * 30) - new Date().getTime()
  227. },
  228. },
  229. methods: {
  230. filterType: function (val) {
  231. if (val == "APPLY_REFUND") {
  232. return "退款审核中";
  233. } else if (val == "CLOSE") {
  234. return "关闭订单";
  235. } else if (val == "REFUNDED") {
  236. return "已退款";
  237. } else if (val == "REFUSAL_REFUND") {
  238. return "拒绝退款";
  239. } else if (val == "USED") {
  240. return "订单已完成";
  241. } else if (val == "WAIT_PAYMENT") {
  242. return "待付款";
  243. } else if (val == "HAVE_PAID") {
  244. return "待使用";
  245. } else if (val == "WAIT_USE") {
  246. return "待使用";
  247. }
  248. },
  249. filterPay(val) {
  250. if (val == "wx.unifiedOrder") {
  251. return "微信支付";
  252. } else if (val == "trade.create") {
  253. return "支付宝支付";
  254. } else if (val == "uac.miniOrder") {
  255. return "云闪付支付";
  256. } else if (val == "wx.miniPreOrder") {
  257. return "银联支付"
  258. } else {
  259. return "-";
  260. }
  261. },
  262. isRefund() {
  263. if (!this.info.goodsList[0].verifyModel) {
  264. //没核销
  265. return true;
  266. } else if (
  267. this.info.goodsList[0].verifyModel &&
  268. new Date().getTime() <
  269. this.info.goodsList[0].verifyModel.checkTime + 1000 * 60 * 60 * 48
  270. ) {
  271. // 已核销 并且没超过48小时
  272. return true;
  273. } else {
  274. return false;
  275. }
  276. },
  277. finish() {
  278. this.isNotTime = true;
  279. console.log(222222, this.isNotTime);
  280. this.payDetails(this.info.orderNo);
  281. },
  282. refundDetail() {
  283. uni.navigateTo({
  284. url: `/my/order/refundDetail?id=${this.info.orderNo}`,
  285. });
  286. },
  287. checkCode() {
  288. this.codeData = "";
  289. this.$nextTick(() => {
  290. this.show = true;
  291. this.loading = true;
  292. let that = this;
  293. // uni.getScreenBrightness({
  294. // success(res) {
  295. // // 获取用户手机亮度 保存起来
  296. // that.oldBright = res.value
  297. // setTimeout(()=>{
  298. // uni.setScreenBrightness({
  299. // value:1
  300. // })
  301. // },200)
  302. // }
  303. // })
  304. qrCode(this.info.goodsList[0].id).then((res) => {
  305. this.loading = false;
  306. if (res.state == "Success") {
  307. this.codeData = res.content;
  308. }
  309. });
  310. });
  311. },
  312. close() {
  313. this.show = false;
  314. // uni.setScreenBrightness({
  315. // value:this.oldBright
  316. // })
  317. },
  318. apply() {
  319. let that = this;
  320. uni.navigateTo({
  321. url: "./refund",
  322. success: function (res) {
  323. // 通过eventChannel向被打开页面传送数据
  324. res.eventChannel.emit("orderInfo", that.info);
  325. },
  326. });
  327. },
  328. // 获取订单详情
  329. payDetails(orderNo) {
  330. payDetails(orderNo).then((res) => {
  331. this.info = res.content;
  332. if (!this.info.payment) {
  333. this.info.payment = {
  334. paymentWay: "",
  335. pay: false
  336. }
  337. }
  338. queryPayOrder(this.info.orderNo).then(res => {
  339. // console.log('res111',res);
  340. if (res.state == "Fail") {
  341. uni.showToast({
  342. title: "支付信息获取失败,请稍后再试.",
  343. icon: "none",
  344. });
  345. }
  346. })
  347. this.info.extend = JSON.parse(this.info.goodsList[0].extend);
  348. if (this.isJumped) {
  349. this.isJumped = false;
  350. const that = this;
  351. let checkTime = 0;
  352. uni.showLoading({
  353. title: "支付中",
  354. });
  355. const checkOrder = setInterval(() => {
  356. queryPayOrder(that.info.orderNo)
  357. .then((res1) => {
  358. // 支付成功
  359. if (res1.content.status == "TRADE_SUCCESS") {
  360. that.payDetails(that.info.orderNo);
  361. uni.showToast({
  362. title: "支付成功!",
  363. icon: "none",
  364. });
  365. clearInterval(checkOrder)
  366. uni.hideLoading();
  367. that.btnLoading = false;
  368. } else {
  369. checkTime++;
  370. }
  371. if (checkTime > 5) {
  372. clearInterval(checkOrder)
  373. that.btnLoading = false;
  374. uni.showToast({
  375. title: "订单查询失败",
  376. icon: "none",
  377. });
  378. uni.hideLoading();
  379. }
  380. }).catch(() => {
  381. if (checkOrder) {
  382. clearInterval(checkOrder)
  383. checkOrder = null
  384. }
  385. that.btnLoading = false;
  386. uni.showToast({
  387. title: "订单查询失败",
  388. icon: "none",
  389. });
  390. uni.hideLoading();
  391. })
  392. }, 1000);
  393. }
  394. });
  395. },
  396. toMap() {
  397. uni.openLocation({
  398. latitude: 26.4401,
  399. longitude: 106.664,
  400. name: "印象贵大文创店",
  401. address: "贵州大学西校区西一区体育场楼下",
  402. });
  403. },
  404. // 支付
  405. pay() {
  406. if (this.btnLoading) return;
  407. this.btnLoading = true;
  408. uni.showLoading({
  409. title: "支付中",
  410. });
  411. let that = this;
  412. let miniPayRequest = this.info.payment.miniPayRequest;
  413. miniPayRequest = JSON.parse(miniPayRequest);
  414. let query = encodeURIComponent(JSON.stringify({
  415. sign: miniPayRequest.sign,
  416. prepayid: miniPayRequest.prepayid,
  417. }))
  418. // 打开银联小程序
  419. uni.navigateToMiniProgram({
  420. appId: miniPayRequest.miniuser,
  421. path: `${miniPayRequest.minipath}?appPayRequest=${query}`,
  422. success: (res) => {
  423. // 打开成功
  424. this.isJumped = true;
  425. },
  426. fail: (err) => {
  427. // console.log(err);
  428. uni.hideLoading();
  429. uni.showToast({
  430. title: "取消支付",
  431. icon: "none",
  432. });
  433. that.btnLoading = false
  434. },
  435. });
  436. },
  437. // 取消退款申请
  438. cancelReply() {
  439. if (this.btnLoading) return;
  440. this.btnLoading = true;
  441. uni.showLoading({
  442. title: "取消中",
  443. });
  444. unRefund({ id: this.info.goodsList[0].id }).then((res) => {
  445. this.btnLoading = false;
  446. uni.hideLoading();
  447. if (res.state == "Success") {
  448. this.payDetails(this.info.orderNo);
  449. uni.showToast({
  450. title: "取消成功",
  451. icon: "success",
  452. });
  453. }
  454. });
  455. },
  456. },
  457. onReady() { },
  458. onLoad(options) {
  459. this.info.orderNo = options.id;
  460. },
  461. onShow() {
  462. this.payDetails(this.info.orderNo);
  463. },
  464. created() {
  465. // this.info = JSON.parse(uni.getStorageSync('order'))
  466. },
  467. };
  468. </script>
  469. <style lang="scss">
  470. .order-detail {
  471. background: #f9f9f9;
  472. min-height: 100vh;
  473. // padding-bottom: 100rpx;
  474. .status-box {
  475. padding: 24rpx 24rpx 4rpx;
  476. display: flex;
  477. justify-content: space-between;
  478. .text-box {
  479. color: #181818;
  480. .status {
  481. font-weight: bold;
  482. font-size: 32rpx;
  483. display: flex;
  484. .u-count-down__text {
  485. color: #ff4d3a !important;
  486. }
  487. }
  488. .notice {
  489. font-size: 24rpx;
  490. margin-top: 20rpx;
  491. }
  492. }
  493. }
  494. .progress {
  495. .progress-title {
  496. font-weight: 600;
  497. font-size: 32rpx;
  498. color: #181818;
  499. }
  500. .progress-desc {
  501. font-weight: 300;
  502. font-size: 24rpx;
  503. color: #aaaaaa;
  504. margin-top: 15rpx;
  505. }
  506. }
  507. .shop-box {
  508. width: 690rpx;
  509. // margin: 0 30rpx;
  510. // padding: 24rpx 24rpx 30rpx;
  511. background: #fff;
  512. border-radius: 16rpx;
  513. margin-top: -30rpx;
  514. box-sizing: border-box;
  515. .shop-name {
  516. font-weight: 600;
  517. font-size: 32rpx;
  518. color: #181818;
  519. width: 100%;
  520. white-space: nowrap;
  521. overflow: hidden;
  522. text-overflow: ellipsis;
  523. }
  524. .address {
  525. font-weight: 300;
  526. font-size: 24rpx;
  527. color: #aaaaaa;
  528. margin-top: 20rpx;
  529. width: 100%;
  530. white-space: nowrap;
  531. overflow: hidden;
  532. text-overflow: ellipsis;
  533. }
  534. }
  535. .black {
  536. color: #222222 !important;
  537. }
  538. .red {
  539. color: red !important;
  540. }
  541. .fs28 {
  542. font-size: 28rpx !important;
  543. font-weight: bold;
  544. }
  545. .code-box {
  546. display: flex;
  547. align-items: center;
  548. justify-content: space-between;
  549. .left {
  550. .title {
  551. font-weight: 500;
  552. font-size: 28rpx;
  553. color: #222222;
  554. }
  555. .codeNum {
  556. font-weight: 300;
  557. font-size: 24rpx;
  558. color: #aaaaaa;
  559. margin-top: 15rpx;
  560. }
  561. }
  562. .code-btn {
  563. display: flex;
  564. align-items: center;
  565. font-weight: 300;
  566. font-size: 24rpx;
  567. color: #aaaaaa;
  568. .jiantou {
  569. width: 24rpx;
  570. height: 24rpx;
  571. }
  572. }
  573. }
  574. .input-box {
  575. margin: 20rpx 30rpx;
  576. padding: 28rpx 24rpx;
  577. background: #ffffff;
  578. border-radius: 16rpx 16rpx 16rpx 16rpx;
  579. display: flex;
  580. align-items: center;
  581. justify-content: space-between;
  582. .label {
  583. color: #222;
  584. font-size: 28rpx;
  585. }
  586. .value {
  587. font-size: 28rpx;
  588. color: #aaaaaa;
  589. }
  590. }
  591. .input-box-address {
  592. margin: 20rpx 30rpx;
  593. padding: 28rpx 24rpx;
  594. background: #ffffff;
  595. border-radius: 16rpx 16rpx 16rpx 16rpx;
  596. // display: flex;
  597. // align-items: center;
  598. // justify-content: space-between;
  599. .value {
  600. color: #222;
  601. font-size: 28rpx;
  602. }
  603. .label {
  604. font-size: 28rpx;
  605. margin: 10rpx 0;
  606. color: #aaaaaa;
  607. }
  608. }
  609. .content {
  610. margin: 20rpx 30rpx;
  611. padding: 28rpx 24rpx;
  612. border-radius: 16rpx;
  613. background: #fff;
  614. .title {
  615. font-weight: 600;
  616. font-size: 28rpx;
  617. color: #222222;
  618. }
  619. .item {
  620. display: flex;
  621. align-items: center;
  622. justify-content: space-between;
  623. margin-top: 28rpx;
  624. .label {
  625. color: #222222;
  626. font-size: 28rpx;
  627. }
  628. .value {
  629. color: #999999;
  630. font-size: 28rpx;
  631. }
  632. }
  633. }
  634. .pay-btn {
  635. background: $uni-color-primary;
  636. width: 688rpx;
  637. height: 80rpx;
  638. line-height: 80rpx;
  639. border-radius: 46rpx;
  640. color: #fff;
  641. margin-top: 50rpx;
  642. }
  643. .refund-box {
  644. .refund-msg {
  645. font-weight: 300;
  646. font-size: 24rpx;
  647. color: #222222;
  648. margin-top: 15rpx;
  649. line-height: 40rpx;
  650. }
  651. }
  652. .apply-box {
  653. position: relative;
  654. .label {
  655. font-weight: 600;
  656. font-size: 28rpx;
  657. color: #222222;
  658. }
  659. .value {
  660. color: #999999;
  661. font-size: 24rpx;
  662. margin-top: 15rpx;
  663. }
  664. .jiantou {
  665. position: absolute;
  666. top: 50%;
  667. right: 24rpx;
  668. transform: translateY(-50%);
  669. width: 24rpx;
  670. height: 24rpx;
  671. }
  672. }
  673. .info {
  674. .order-info {
  675. display: flex;
  676. .icon {
  677. width: 164rpx;
  678. height: 164rpx;
  679. border-radius: 16rpx;
  680. flex-shrink: 0;
  681. }
  682. .shop-info {
  683. display: flex;
  684. flex-direction: column;
  685. justify-content: space-between;
  686. padding-left: 24rpx;
  687. flex: 1;
  688. box-sizing: border-box;
  689. .title {
  690. color: #181818;
  691. font-size: 28rpx;
  692. width: 450rpx;
  693. white-space: nowrap;
  694. overflow: hidden;
  695. text-overflow: ellipsis;
  696. }
  697. .price-box {
  698. display: flex;
  699. align-items: center;
  700. justify-content: space-between;
  701. .price {
  702. color: #181818;
  703. font-size: 32rpx;
  704. font-weight: bold;
  705. }
  706. }
  707. .start-time,
  708. .goods-desc {
  709. font-size: 24rpx;
  710. color: #aaaaaa;
  711. width: 450rpx;
  712. white-space: nowrap;
  713. overflow: hidden;
  714. text-overflow: ellipsis;
  715. }
  716. }
  717. }
  718. }
  719. .wrap {
  720. display: flex;
  721. justify-content: center;
  722. align-items: center;
  723. height: 100vh;
  724. overflow: hidden;
  725. }
  726. }
  727. </style>