detail.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. <template>
  2. <view>
  3. <block v-if="loading">
  4. <view class="skeleton">
  5. <view class="skeleton-line max animate" style="height: 200upx;"></view>
  6. <view class="skeleton-line animate"></view>
  7. <view class="skeleton-line min animate"></view>
  8. <view class="skeleton-line min animate"></view>
  9. <view class="skeleton-line max animate" style="height: 200upx;"></view>
  10. <view class="skeleton-line max animate" style="height: 200upx;"></view>
  11. </view>
  12. </block>
  13. <block v-else>
  14. <view class="order-status">
  15. <view class="status-name" v-if="orderData.status == 0 && orderTime">
  16. 待支付
  17. <template v-if="orderTime.min>0&&orderTime.sec>=0">
  18. ,剩余时间
  19. <uni-countdown :show-day="false" :showHour="false" :minute="orderTime.min" :second="orderTime.sec" splitorColor="#ff0000" color="#ff0000"></uni-countdown>
  20. </template>
  21. <template v-else>,已超时</template>
  22. </view>
  23. <view class="status-name" v-if="orderData.status == 1">待使用</view>
  24. <view class="status-name success" v-if="orderData.status == 2">已完成</view>
  25. <view class="status-name" v-if="orderData.status == 3">已退款</view>
  26. <view class="status-name" v-if="orderData.status == 4">退款中</view>
  27. <view class="status-name" v-if="orderData.status == 5">已关闭</view>
  28. <view class="status-desc" v-if="orderData.status == 0">超过30分钟未支付,订单将自动取消</view>
  29. <view class="status-desc" v-if="orderData.status == 1">待使用</view>
  30. <view class="status-desc success" v-if="orderData.status == 2">服务已完成,欢迎您再次使用</view>
  31. <view class="status-desc" v-if="orderData.status == 3">{{ $dialog.formatMoney(orderData.pay_money,true) }} 已原路退回</view>
  32. <view class="status-desc" v-if="orderData.status == 4">已申请退款,钱款预计1-3个自然日到账</view>
  33. <view class="status-name" v-if="orderData.status == 5">订单已取消或已关闭</view>
  34. </view>
  35. <view class="order-goods">
  36. <view class="goods-img"><image :src="orderData.img" mode="widthFix"></image></view>
  37. <view class="goods-info">
  38. <view class="name">{{ goodsData.product_name }}</view>
  39. <view class="desc">
  40. <view class="time" v-if="orderData.end_at">有效期至:{{ orderData.end_at }} </view>
  41. <view class="num">x {{ orderData.number }}</view>
  42. </view>
  43. <view class="total">合计:{{ $dialog.formatMoney(orderData.price,true) }}</view>
  44. </view>
  45. </view>
  46. <view class="goods-safe">
  47. <view class="safe-item"><image src="/static/image/check.png"></image>过期退</view>
  48. <view class="safe-item"><image src="/static/image/check.png"></image>随时退</view>
  49. </view>
  50. <view class="home-store" @click="showService(1)">
  51. <view class="left">
  52. <image src="/static/image/kefu.png"></image>
  53. <view class="name">联系客服</view>
  54. </view>
  55. <view class="right" v-if="storeData">
  56. <text class="status success">{{storeData.start_at}}-{{storeData.end_at}}</text>
  57. <image src="/static/image/right-black.png"></image>
  58. </view>
  59. </view>
  60. <view class="goods-store" v-if="poiData">
  61. <view class="title">适用门店</view>
  62. <view class="store-info">
  63. <view class="store-left">
  64. <view class="name">{{poiData.poi_name}}</view>
  65. <view class="address">{{poiData.poi_address}}</view>
  66. </view>
  67. <view class="store-right">
  68. <view class="right-item" @click="toMap">
  69. <image src="/static/image/amap.png"></image>
  70. <view class="desc">导航</view>
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. <view class="order-info">
  76. <view class="title">订单信息</view>
  77. <view class="info-item">
  78. <view class="name">来客订单号</view>
  79. <view class="right">{{ orderData.order_sn }} <text @click="copyOrder(orderData.order_sn)">复制</text></view>
  80. </view>
  81. <view class="info-item">
  82. <view class="name">订单编号</view>
  83. <view class="right">{{ orderData.out_order_no }} <text @click="copyOrder(orderData.out_order_no)">复制</text></view>
  84. </view>
  85. <view class="info-item">
  86. <view class="name">下单时间</view>
  87. <view class="right">{{ orderData.create_at }}</view>
  88. </view>
  89. <view class="info-item" v-if="orderData.status == 4">
  90. <view class="name">退款时间</view>
  91. <view class="right">{{ orderData.refund_at }}</view>
  92. </view>
  93. </view>
  94. <uni-popup ref="maskpopup" type="bottom" border-radius="10px 10px 0 0" background-color="#ffffff" :mask-click="false">
  95. <view class="service-popup">
  96. <view class="top">
  97. <view class="item">客服时间:{{storeData.start_at}}-{{storeData.end_at}}</view>
  98. <view class="item">
  99. <button class="btn" @click="$dialog.jumpUri('/pages/service/chat/chat?poi='+storeData.poi_id+'&source=detail&order='+orderData.order_sn,1);showService(2)">在线咨询商家</button>
  100. </view>
  101. <view class="item" v-if="storeData.service_mobile" @click="callMobile(storeData.service_mobile)">商家客服电话</view>
  102. </view>
  103. <view class="foot" @click="showService(2)">取消</view>
  104. </view>
  105. </uni-popup>
  106. <view class="line-footer"></view>
  107. <view class="footer">
  108. <view class="footer-op" v-if="orderData.status == 0">
  109. <view class="footer-left"><text>实付</text>{{ $dialog.formatMoney(orderData.price,true) }}</view>
  110. <view class="footer-right">
  111. <view class="btn" @click="toCancel(orderData.order_sn)">取消订单</view>
  112. <pay-button-sdk
  113. v-if="orderTime.min>0&&orderTime.sec>=0"
  114. class="btn full"
  115. :mode="1"
  116. :goods-type="1"
  117. :order-status="0"
  118. :order-id="orderData.out_order_no"
  119. :goods-id="orderData.life_goods_id"
  120. :refund-total-amount="orderData.pay_money"
  121. bind:pay="onPay"
  122. bind:error="onErrors"
  123. ></pay-button-sdk>
  124. <!-- <view class="btn" @click="payOrder">继续支付</view> -->
  125. </view>
  126. </view>
  127. <view class="footer-op" v-if="orderData.status == 1">
  128. <view class="footer-right">
  129. <!-- <navigator hover-class="none" :url="'/pages/order/refund?order='+orderData.order_sn" class="btn">申请退款</navigator> -->
  130. <pay-button-sdk
  131. class="btn"
  132. :mode="1"
  133. :goods-type="1"
  134. :order-status="1"
  135. :order-id="orderData.out_order_no"
  136. :goods-id="orderData.life_goods_id"
  137. :refund-total-amount="orderData.pay_money"
  138. bind:applyrefund="applyRefund"
  139. bind:error="onErrors"
  140. ></pay-button-sdk>
  141. <view class="btn full" @click="$dialog.jumpUri('/pages/service/chat/chat?poi='+storeData.poi_id+'&source=apply&order='+orderData.order_sn,1);">立即预约</view>
  142. </view>
  143. </view>
  144. <view class="footer-op" v-if="orderData.status == 2">
  145. <view class="footer-right">
  146. <view class="btn" @click="toGoods">再来一单</view>
  147. <view class="btn full" @click="toAfter">申请售后</view>
  148. </view>
  149. </view>
  150. <view class="footer-op" v-if="orderData.status == 5">
  151. <view class="footer-right">
  152. <view class="btn" @click="toGoods">再次购买</view>
  153. </view>
  154. </view>
  155. <view class="footer-op" v-if="orderData.status == 3 || orderData.status == 4">
  156. <view class="footer-right" @click="toGoods">
  157. <view class="btn">再次购买</view>
  158. </view>
  159. </view>
  160. <view class="footer-safe"></view>
  161. </view>
  162. </block>
  163. </view>
  164. </template>
  165. <script>
  166. var app;
  167. import * as Api from "@/static/api/order.js";
  168. export default {
  169. data() {
  170. return {
  171. loading:true,
  172. order:"",
  173. poiData:null,
  174. goodsData:null,
  175. orderData:null,
  176. storeData:null,
  177. orderTime:null
  178. }
  179. },
  180. created() {
  181. this.$scope.applyRefund = this.applyRefund;
  182. this.$scope.onPay = this.onPay;
  183. this.$scope.onErrors = this.onErrors;
  184. },
  185. onLoad({order}) {
  186. app = this;
  187. app.order = order;
  188. app.storeData = uni.getStorageSync("contact");
  189. app.getOrder()
  190. },
  191. methods: {
  192. onPay(event){
  193. console.log("event",event)
  194. const { status, outOrderNo, result } = event.detail;
  195. console.log(status, outOrderNo, result)
  196. if (status === 'success') {
  197. const { code } = result;
  198. if (code === 0) { // 支付成功
  199. app.$dialog.showSuccess("支付成功","none",function(){
  200. app.getOrder()
  201. })
  202. } else {
  203. app.$dialog.showSuccess("支付失败","none",function(){
  204. app.getOrder()
  205. })
  206. // 继续支付失败(超时、取消、关闭)
  207. }
  208. } else {}
  209. },
  210. applyRefund(event){
  211. console.log("applyRefund",event)
  212. const { orderId } = event.detail;
  213. const goodsDetail = [
  214. {
  215. itemOrderId:app.orderData.item_order_id //商品单,可在预下单回调itemOrderlist里获取,或通过查询券状态接口获取
  216. }
  217. ];
  218. const extra = { orderId , goodsDetail};
  219. // 开发者需要透传的参数,可自定义内容
  220. console.log(extra,"退款参数打印");
  221. return new Promise(resolve => {
  222. resolve(extra);
  223. });
  224. },
  225. onErrors(e){
  226. console.log("错误",e)
  227. },
  228. getOrder(){
  229. console.log(app.order)
  230. Api.detail({"order":app.order}).then((res)=>{
  231. app.loading = false;
  232. if (res.code && res.code !== 1) {
  233. app.$dialog.showSuccess(res.msg,"none",function(){
  234. uni.navigateBack()
  235. });
  236. return ;
  237. }
  238. console.log(res.data)
  239. app.poiData = res.data.poi;
  240. app.goodsData = res.data.product;
  241. app.orderData = res.data;
  242. app.orderTime = res.data.end_time
  243. })
  244. },
  245. toAfter(){
  246. uni.showModal({
  247. title: "提示",
  248. content: "当前阶段暂不支持退款,如遇特殊情况,请联系商家协商退款",
  249. confirmText: "联系商家",
  250. success(res) {
  251. if (res.confirm) {
  252. uni.navigateTo({
  253. url:'/pages/service/chat/chat?poi='+app.storeData.poi_id+'&source=detail&order='+app.orderData.order_sn
  254. })
  255. }
  256. }
  257. });
  258. },
  259. payOrder(){
  260. Api.toPay({"order":app.order}).then((res)=>{
  261. if (res.code !== 1) {
  262. return app.$dialog.showSuccess(res.msg);
  263. }
  264. uni.requestPayment({
  265. orderInfo:res.data.pay,
  266. service:5,
  267. success(resp){
  268. if (resp.code == 0) { // res.code=0时,才表示支付成功
  269. app.$dialog.showSuccess("支付成功","none",function(){
  270. app.getOrder()
  271. });
  272. }
  273. },
  274. fail(resp) {
  275. app.$dialog.showSuccess("支付失败,可再次重试");
  276. }
  277. })
  278. })
  279. },
  280. toCancel(order){
  281. app.$dialog.showError("确定要取消该订单吗?",function(res){
  282. if (res.confirm) {
  283. Api.del({"order":order,"type":"cancel"}).then((resp)=>{
  284. if (resp.code !== 1) {
  285. return app.$dialog.showSuccess(resp.msg)
  286. }
  287. app.$dialog.showSuccess(resp.msg)
  288. app.getOrder()
  289. })
  290. }
  291. })
  292. },
  293. delOrder(order){
  294. app.$dialog.showError("删除后数据不可恢复,确定要删除吗",function(res){
  295. if (res.confirm) {
  296. Api.del({"order":order,"type":"del"}).then((resp)=>{
  297. if (resp.code !== 1) {
  298. return app.$dialog.showSuccess(resp.msg)
  299. }
  300. app.$dialog.showSuccess(resp.msg)
  301. uni.switchTab({
  302. url:"/pages/order/order"
  303. })
  304. })
  305. }
  306. })
  307. },
  308. toGoods(){
  309. uni.navigateTo({
  310. url:"/pages/goods/detail?goods="+app.orderData.product_id+"&spm="+app.orderData.goods_id
  311. })
  312. },
  313. copyOrder(order){
  314. uni.setClipboardData({
  315. data:order,
  316. success() {
  317. app.$dialog.showSuccess("复制成功")
  318. },
  319. fail() {
  320. app.$dialog.showSuccess("复制失败")
  321. }
  322. })
  323. },
  324. callMobile(mobile){
  325. uni.makePhoneCall({
  326. phoneNumber:mobile,
  327. success(res) {
  328. console.log(res)
  329. },fail(res) {
  330. console.log(res)
  331. }
  332. })
  333. },
  334. toMap(){
  335. var poi = app.poiData;
  336. uni.openLocation({
  337. latitude:poi.latitude,
  338. longitude:poi.longitude,
  339. name:poi.poi_name,
  340. address:poi.poi_address,
  341. success() {
  342. console.log("open success")
  343. },
  344. fail(err) {
  345. app.$dialog.showSuccess("打开导航失败")
  346. console.log(err)
  347. }
  348. })
  349. },
  350. showService(type){
  351. if (type == 1) {
  352. app.$refs.maskpopup.open()
  353. } else {
  354. app.$refs.maskpopup.close()
  355. }
  356. }
  357. }
  358. }
  359. </script>
  360. <style>
  361. page{background-color: #f8f8f8;}
  362. .skeleton{width: 90%;margin: 20upx auto;}
  363. .line-footer{height: 200upx;}
  364. .footer{position: fixed;bottom: 0;background-color: #fff;padding: 20upx 20upx 0 20upx;border-top: 2upx solid #f8f8f8;left: 0;right: 0;}
  365. .footer .footer-op{display: flex;align-items: center;}
  366. .footer .footer-op .footer-left{display: flex;align-items: center;gap: 10upx;justify-content: center;font-size: 32upx;color: #f00;font-weight: bold;}
  367. .footer .footer-op .footer-left text{color: #666;font-size: 24upx;font-weight: normal;}
  368. .footer .footer-op .footer-left .item{flex-direction: column;display: flex;font-size: 24rpx;color: #333;align-items: center;}
  369. .footer .footer-op .footer-left image{width: 40upx;height: 40upx;}
  370. .footer .footer-op .footer-right{margin-left: auto;margin-right: 0;display: flex;align-items: center;gap: 20upx;}
  371. .footer .footer-op .footer-right .btn{font-size: 28rpx;height: 80upx;border-radius: 10upx;line-height: 80upx;text-align: center;width: 200upx;color: #333;border: 2upx solid #ccc;}
  372. .footer .footer-op .footer-right .btn.full{background-color: #007aff;color: #fff;border:2upx solid #007aff;}
  373. .footer .footer-safe {height: env(safe-area-inset-bottom);width: 100%;}
  374. .order-status{padding: 40upx 20upx;text-align: center;}
  375. .order-status .status-name{text-align: center;font-size: 32upx;color: #333;font-weight: bold;display: flex;align-items: center;justify-content: center;}
  376. .order-status .status-desc{font-size: 24upx;color: #666;margin-top: 20upx;}
  377. .order-info{background-color: #fff;padding: 20upx;margin-top: 20upx;}
  378. .order-info .title{font-size: 32upx;color: #333;font-weight: bold;margin-bottom: 20upx;}
  379. .order-info .info-item{height: 80upx;line-height: 80upx;font-size: 28upx;display: flex;align-items: center;}
  380. .order-info .info-item .right{color: #666;margin-left: auto;margin-right: 0;}
  381. .order-info .info-item .right text{border: 2upx solid #ccc;color: #333;font-size: 24upx;padding: 0 15upx;margin-left: 20upx;border-radius: 5upx;}
  382. .goods-safe{display: flex;align-items: center;font-size: 24rpx;color: #999;gap: 40upx;background: #fff;border-top: 2upx solid #f8f8f8;padding: 20upx;}
  383. .goods-safe .safe-item{display: flex;align-items: center;}
  384. .goods-safe image{width: 30upx;height: 30upx;margin-right: 10upx;}
  385. .order-goods{display: flex;align-items: flex-start;background-color: #fff;padding: 20upx;}
  386. .order-goods .goods-img{width: 200upx;overflow: hidden;}
  387. .order-goods image{width: 200upx;border-radius: 10upx;}
  388. .goods-info{margin-left: 20upx;font-size: 28upx;flex: 1;padding: 20upx 0;}
  389. .goods-info .name{font-size: 30upx;color: #333;}
  390. .goods-info .desc{font-size: 24upx;color: #999;display: flex;align-items: center;justify-content: space-between;margin: 20upx 0;}
  391. .goods-info .total{font-size: 30upx;color: #333;text-align: right;font-weight: bold;}
  392. .home-store{margin: 20upx auto;display: flex;align-items: center;background-color: #fff;border-radius: 10upx;display: flex;align-items: center;padding: 30upx;}
  393. .home-store .store-right{width: 120upx;height: 120upx;background-color: #fff;text-align: center;display: flex;align-items: center;justify-content: center;margin-left: auto;margin-right: 0;border-radius: 10upx;}
  394. .home-store .store-right image{width: 60upx;height: 60upx;}
  395. .home-store .left{display: flex;align-items: center;}
  396. .home-store .left image{width: 60upx;height: 60upx;margin-right: 20upx;}
  397. .home-store .right {margin-left: auto;margin-right: 0;display: flex;align-items: center;}
  398. .home-store .right image{width: 50upx;height: 50upx;}
  399. .home-store .name{font-size: 32upx;color: #000;font-weight: bold;}
  400. .home-store .desc{font-size: 26upx;color: #666;margin-top: 20upx;}
  401. .home-store .status{color: #333;font-size: 28upx;padding:5upx 15upx;border-radius: 10upx;margin-left: 10upx;}
  402. .home-store .status.error{background-color: #fef0f0;color: #f56c6c;}
  403. .service-popup .item{height: 100upx;line-height: 100upx;text-align: center;font-size: 28upx;color: #333;border-bottom: 2upx solid #f8f8f8;}
  404. .service-popup .item .btn{background-color: #fff;border: 0;height: 100upx;line-height: 100upx;text-align: center;font-size: 28upx;color: #333;}
  405. .service-popup .item .btn::after{border: 0;}
  406. .service-popup .foot{height: 100upx;line-height: 100upx;text-align: center;font-size: 28upx;color: #333;border-top: 20upx solid #f8f8f8;}
  407. .goods-store{background-color: #fff;padding: 0 20upx;margin-top: 20upx;}
  408. .goods-store .title{line-height: 80upx;font-size: 32rpx;color: #333;font-weight: bold;display: flex;align-items: center;border-bottom: 2upx solid #f8f8f8;}
  409. .goods-store .store-info{display: flex;align-items: center;padding: 20upx 0;}
  410. .goods-store .store-info .store-right{margin-left: auto;margin-right: 0;font-size: 24rpx;color: #999;}
  411. .goods-store .store-info .store-right image{width: 50upx;height: 50upx;margin-bottom: 10upx;}
  412. .goods-store .store-info .store-left .name{font-size: 30rpx;color: #333;font-weight: bold;line-height: 80upx;}
  413. .goods-store .store-info .store-left .address{font-size: 24rpx;color: #999;}
  414. </style>