order.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <view class="content">
  3. <view class="tab-menu">
  4. <view :class="orderState==0?'tab-item active':'tab-item'" @click="orderStatus(0)">全部</view>
  5. <view :class="orderState==1?'tab-item active':'tab-item'" @click="orderStatus(1)">待支付</view>
  6. <view :class="orderState==2?'tab-item active':'tab-item'" @click="orderStatus(2)">待使用</view>
  7. <view :class="orderState==3?'tab-item active':'tab-item'" @click="orderStatus(3)">已完成</view>
  8. <view :class="orderState==6?'tab-item active':'tab-item'" @click="orderStatus(6)">已关闭</view>
  9. </view>
  10. <view class="order-body">
  11. <view class="empty-body" v-if="loginState">
  12. <view class="img">
  13. <image src="/static/image/empty.png" mode="widthFix"></image>
  14. <view class="tip">请先登录</view>
  15. </view>
  16. <view class="re-btn" @click="reback">去登陆</view>
  17. </view>
  18. <block class="" v-else>
  19. <z-paging ref="paging" show-refresher-update-time v-model="dataList" @query="queryList" :fixed="false">
  20. <view class="order-item" v-for="(item,indx) in dataList" :key="indx">
  21. <view class="item-header" @click="toDetail(item.out_order_no)">
  22. <view class="order-status" v-if="item.status == 0">待支付</view>
  23. <view class="order-status" v-if="item.status == 1">待使用</view>
  24. <view class="order-status success" v-if="item.status == 2">已完成</view>
  25. <view class="order-status" v-if="item.status == 3">已退款</view>
  26. <view class="order-status" v-if="item.status == 4">退款中</view>
  27. <view class="order-status" v-if="item.status == 5">已关闭</view>
  28. <view class="order-time">订单号 :{{ item.out_order_no }}</view>
  29. </view>
  30. <view class="order-goods" @click="toDetail(item.out_order_no)">
  31. <view class="goods-img"><image :src="item.img"></image></view>
  32. <view class="goods-info">
  33. <view class="name">{{ item.product.product_name }}</view>
  34. <view class="desc">
  35. <view class="time" v-if="item.end_at">有效期至:{{ item.end_at }} </view>
  36. <view class="num">x {{ item.number }}</view>
  37. </view>
  38. <view class="total">合计:{{ $dialog.formatMoney(item.price,true) }}</view>
  39. </view>
  40. </view>
  41. <view class="order-footer">
  42. <view class="footer-l">{{item.create_at}}</view>
  43. <view class="footer-r">
  44. <view class="btn danger" v-if="item.status == 0" @click="toDetail(item.out_order_no)">继续支付</view>
  45. <view class="btn" v-if="item.status == 4" @click="delOrder(item.out_order_no)">删除</view>
  46. <view class="btn danger" v-if="item.status == 4||item.status == 3" @click="toGoods(item)">再次购买</view>
  47. <view class="btn blue" v-if="item.status == 1" @click="toDetail(item.out_order_no)">立即预约</view>
  48. <view class="btn danger" v-if="item.status == 1" @click="toDetail(item.out_order_no)">申请退款</view>
  49. <view class="btn danger" v-if="item.status == 2" @click="toGoods(item)">再来一单</view>
  50. </view>
  51. </view>
  52. </view>
  53. </z-paging>
  54. </block>
  55. </view>
  56. <view class="float-kefu" @click="showService(1)">
  57. <image src="/static/image/kf.png"></image>
  58. </view>
  59. <uni-popup ref="maskpopup" type="bottom" border-radius="10px 10px 0 0" background-color="#ffffff" :mask-click="false">
  60. <view class="kefu-popup">
  61. <view class="top">
  62. <view class="item">
  63. 客服时间:{{storeData.start_at}}-{{storeData.end_at}}
  64. </view>
  65. <view class="item">
  66. <button class="btn" @click="$dialog.jumpUri('/pages/service/chat/chat?poi='+storeData.poi_id+'&source=goods&goods='+goodsId,1);showService(2)">在线咨询商家</button>
  67. </view>
  68. <view class="item" v-if="storeData.service_mobile" @click="callMobile(storeData.service_mobile)">商家客服电话</view>
  69. </view>
  70. <view class="foot" @click="showService(2)">取消</view>
  71. </view>
  72. </uni-popup>
  73. </view>
  74. </template>
  75. <script>
  76. var app;
  77. import * as Api from "@/static/api/order.js";
  78. export default {
  79. data() {
  80. return {
  81. listState:false,
  82. orderState:0,
  83. dataList:[],
  84. loginState:true,
  85. storeData:null
  86. }
  87. },
  88. onShow() {
  89. var token = uni.getStorageSync("user_token")
  90. if (token) {
  91. this.loginState = false;
  92. }
  93. this.queryList(1,10)
  94. },
  95. onLoad() {
  96. app = this;
  97. app.storeData = uni.getStorageSync("contact");
  98. },
  99. methods: {
  100. callMobile(mobile){
  101. uni.makePhoneCall({
  102. phoneNumber:mobile,
  103. success(res) {
  104. console.log(res)
  105. },fail(res) {
  106. console.log(res)
  107. }
  108. })
  109. },
  110. showService(type){
  111. if (type == 1) {
  112. uni.hideTabBar()
  113. app.$refs.maskpopup.open()
  114. } else {
  115. this.$nextTick(() => {
  116. uni.showTabBar()
  117. })
  118. app.$refs.maskpopup.close()
  119. }
  120. },
  121. delOrder(order){
  122. app.$dialog.showError("删除后数据不可恢复,确定要删除吗",function(res){
  123. if (res.confirm) {
  124. Api.del({"order":order}).then((resp)=>{
  125. if (res.code !== 1) {
  126. return app.$dialog.showSuccess(resp.msg)
  127. }
  128. app.$dialog.showSuccess(resp.msg,function(){
  129. app.queryList(1,10)
  130. })
  131. })
  132. }
  133. })
  134. },
  135. toPay(order){
  136. uni.navigateTo({
  137. url:"/pages/order/confirm?order="+order
  138. })
  139. },
  140. toGoods(item){
  141. uni.navigateTo({
  142. url:"/pages/goods/detail?goods="+item.product_id+"&spm="+item.goods_id
  143. })
  144. },
  145. toDetail(order){
  146. uni.navigateTo({
  147. url:"/pages/order/detail?order="+order
  148. })
  149. },
  150. reback(){
  151. uni.navigateTo({
  152. url:"/pages/auth/login",
  153. animationType:"'slide-in-bottom'"
  154. })
  155. },
  156. orderStatus(state) {
  157. app.orderState = state;
  158. app.dataList = [];
  159. app.queryList(1,10)
  160. },
  161. queryList(pageNo, pageSize){
  162. var formData = {};
  163. var token = uni.getStorageSync("user_token")
  164. if (!token) {
  165. return false;
  166. }
  167. formData.page = pageNo;
  168. formData.size = pageSize;
  169. formData.status = app.orderState;
  170. app.listState = true;
  171. Api.list(formData).then((res)=>{
  172. app.listState = false;
  173. uni.hideLoading();
  174. if (res.code !== 1) {
  175. this.$refs.paging.complete(false);
  176. return app.$dialog.showSuccess(res.msg);
  177. }
  178. app.$refs.paging.complete(res.data.rows);
  179. })
  180. }
  181. }
  182. }
  183. </script>
  184. <style>
  185. .float-kefu{position: fixed;right: 20upx;bottom: 15%;width: 100upx;height: 100upx;background-color: #fff;border-radius: 100%;display: flex;align-items: center;justify-content: center;}
  186. .float-kefu image{width: 60upx;height: 60upx;}
  187. .kefu-popup .item{height: 100upx;line-height: 100upx;text-align: center;font-size: 28upx;color: #333;border-bottom: 2upx solid #f8f8f8;}
  188. .kefu-popup .item .btn{background-color: #fff;border: 0;height: 100upx;line-height: 100upx;text-align: center;font-size: 28upx;color: #333;}
  189. .kefu-popup .item .btn::after{border: 0;}
  190. .kefu-popup .foot{height: 100upx;line-height: 100upx;text-align: center;font-size: 28upx;color: #333;border-top: 20upx solid #f8f8f8;}
  191. .order-footer{display: flex;text-align: right;padding: 20upx 0;border-top: 2upx solid #f8f8f8;align-items: center;}
  192. .order-footer .footer-l{font-size: 28upx;color: #666;}
  193. .order-footer .footer-r{display: flex;margin-left: auto;margin-right: 0;flex: 1;justify-content: end;gap: 20upx;}
  194. .order-footer .btn{width: 160upx;height: 60upx;line-height: 60upx;text-align: center;border: 2upx solid #ccc;color: #333;font-size: 28upx;border-radius: 10upx;}
  195. .order-footer .btn.danger{border:2upx solid #f00;color: #f00;}
  196. .order-footer .btn.blue{border:2upx solid #007aff;color: #007aff;}
  197. .order-item{background-color: #fff;padding: 0 20upx;border-radius: 10upx;margin-top: 20upx;}
  198. .order-item .item-header{display: flex;align-items: center;height: 60upx;line-height: 60upx;}
  199. .order-item .item-header .order-status{font-size: 28upx;color: #f00;}
  200. .order-item .item-header .order-status.success{color: #007aff;}
  201. .order-item .item-header .order-time{font-size: 24upx;color: #999;margin-left: auto;margin-right: 0;}
  202. .order-item .order-goods{display: flex;align-items: center;}
  203. .order-item .order-goods image{width: 140upx;height: 140upx;}
  204. .order-item .goods-info{margin-left: 20upx;font-size: 28upx;flex: 1;padding: 20upx 0;}
  205. .order-item .goods-info .name{font-size: 30upx;color: #333;}
  206. .order-item .goods-info .desc{font-size: 24upx;color: #999;display: flex;align-items: center;justify-content: space-between;margin: 20upx 0;}
  207. .order-item .goods-info .total{font-size: 30upx;color: #333;text-align: right;font-weight: bold;}
  208. .content{height: 100vh;background-color: #f8f8f8;}
  209. .content .tab-menu{height: 80upx;line-height: 80upx;background-color: #fff;display: flex;align-items: center;font-size: 28upx;color: #666;justify-content: space-around;}
  210. .content .tab-menu .tab-item{position: relative;}
  211. .content .tab-menu .tab-item.active{color: #007aff;}
  212. .content .tab-menu .tab-item.active::after{position: absolute;content: "";width: 30%;left: 35%;height: 4upx;bottom: 0;background-color: #007aff;}
  213. .content .order-body{height: calc(100vh - 100upx); }
  214. .empty-body{display: flex;align-items: center;justify-content: center;flex-direction: column;height: calc(100vh - 100upx);}
  215. .empty-body .img{text-align: center;font-size: 28upx;color: #666;}
  216. .empty-body .img image{height: 160upx;width: 160upx;}
  217. .empty-body .img .tip{margin-top: 20upx;}
  218. .empty-body .re-btn{width: 180upx;height: 80upx;line-height: 80upx;text-align: center;font-size: 28upx;color: #fff;background-color: #007aff;border-radius: 10upx;margin-top: 60upx;}
  219. </style>