Browse Source

合并代码导致订单管理混乱,恢复正常

ltx529596 4 years ago
parent
commit
1edea06a88
3 changed files with 419 additions and 111 deletions
  1. 336 69
      src/pages/order/order.vue
  2. 12 4
      src/pages/order/orderdetail.vue
  3. 71 38
      src/pages/shop/shop.vue

+ 336 - 69
src/pages/order/order.vue

@@ -3,39 +3,62 @@
   <view class="order">
     <view class="header-warp">
       <view class="header-search">
-        <view class="uni-list-cell">
-          <view class="uni-list-cell-db">
-            <picker @change="bindPickerChange" :value="index" :range="array">
-              <view class="uni-input">{{ array[index] }}</view>
-            </picker>
-            <image
-              src="../../static/images/garydownicon.png"
-              mode=""
-               class="icon"
-            ></image>
-          </view>
-        </view>
         <view class="search">
           <input
             type="text"
             placeholder-style="color:#a3a8a8;font-size:10px;"
-            placeholder="请输入订单号或手机号、身份证号"
+            placeholder="请输入订单号或手机号"
             class="cellphone"
+            v-model="params.buyPhone"
           />
-          <text class="txt">搜索</text>
+          <text class="txt" @tap="orderByNum">搜索</text>
         </view>
-        <view class="btn-time">
+      </view>
+      <view class="uni-list-cell">
+        <view class="uni-list-cell-db">
+          <picker
+            style="width: 100%; height: 100%;"
+            @change="bindPickerChange"
+            :value="index"
+            :range="shopArray"
+            range-key="name"
+          >
+            <view class="uni-input">{{ shopArray[index].name }}</view>
+          </picker>
+          <view class="icon-warp">
+            <image
+              src="../../static/images/moreicon.png"
+              class="iconRight"
+            ></image>
+          </view>
+        </view>
+      </view>
+      <view class="btn-time">
+        <uni-calendar
+          ref="calendar"
+          :insert="false"
+          :range="true"
+          :startDate="'2020-01-01'"
+          :endDate="date"
+          @confirm="confirm"
+        />
+        <view class="opentime" @tap="openTime">
+          <view class="start">{{ startdate ? startdate : date }}</view>
+          <text class="guo">至</text>
+          <view class="end">{{ enddate ? enddate : date }}</view>
+          <text class="sundate">共:{{ sunday }}天</text>
+        </view>
+        <view style="width: 19upx;">
           <image
-            src="../../static/images/timeIcon.png"
-            class="timeicon"
+            src="../../static/images/moreicon.png"
+            class="iconRight"
           ></image>
-          <text class="screen">按时间</text>
         </view>
       </view>
       <view class="header-bar">
         <view
           class="item"
-          @tap="changeTab(1)"
+          @tap="changeTab(1, 'pay')"
           :class="{ active: isactive === 1 }"
         >
           <view class="ordertype">已付款</view>
@@ -43,7 +66,7 @@
         </view>
         <view
           class="item"
-          @tap="changeTab(2)"
+          @tap="changeTab(2, 'accomplish')"
           :class="{ active: isactive === 2 }"
         >
           <view class="ordertype">已完成</view>
@@ -51,7 +74,7 @@
         </view>
         <view
           class="item"
-          @tap="changeTab(3)"
+          @tap="changeTab(3, 'refundorder')"
           :class="{ active: isactive === 3 }"
         >
           <view class="ordertype">退款</view>
@@ -60,55 +83,273 @@
         <view class="line"></view>
       </view>
     </view>
-    <view style="height: 192upx;"></view>
+    <view style="height: 352upx;"></view>
+
     <view class="order-content" v-if="isactive === 1">
-      <view class="order-list" @tap='todetail'>
+      <view
+        class="order-list"
+        @tap="todetail(item.ordersNo)"
+        v-for="(item, index) in orderList"
+        :key="index"
+      >
         <view class="order-title">
           <text class="ordernum"
-            >订单号:<text class="num">15648464184616</text></text
+            >订单号:<text class="num">{{ item.ordersNo }}</text></text
           >
-          <text class="ordertime">09:26</text>
+          <text class="ordertime">{{ item.orderTime.substring(11) }}</text>
         </view>
         <view class="order-detail">
-          <view class="name">仙女山成人票</view>
-          <view class="door">门店:<text class="message">1</text></view>
-          <view class="num">门店:<text class="message">2</text></view>
-          <view class="status">门店:<text class="message">3</text></view>
-          <view class="playtime">门店:<text class="message">4</text></view>
+          <view class="name">{{ item.shopName }}</view>
+          <view class="door"
+            >门店:<text class="message">{{ item.goodsName }}</text></view
+          >
+          <view class="num"
+            >数量:<text class="message">{{ item.num }}</text></view
+          >
+          <view class="status"
+            >状态:<text class="message">{{ item.statusName }}</text></view
+          >
+          <view class="playtime"
+            >游玩时间:<text class="message">{{ item.palyTime }}</text></view
+          >
         </view>
       </view>
     </view>
+    <view class="order-content" v-if="isactive === 2">
+      <view
+        class="order-list"
+        @tap="todetail(item.ordersNo)"
+        v-for="(item, index) in orderList"
+        :key="index"
+      >
+        <view class="order-title">
+          <text class="ordernum"
+            >订单号:<text class="num">{{ item.ordersNo }}</text></text
+          >
+          <text class="ordertime">{{ item.orderTime.substring(11) }}</text>
+        </view>
+        <view class="order-detail">
+          <view class="name">{{ item.shopName }}</view>
+          <view class="door"
+            >门店:<text class="message">{{ item.goodsName }}</text></view
+          >
+          <view class="num"
+            >数量:<text class="message">{{ item.num }}</text></view
+          >
+          <view class="status"
+            >状态:<text class="message">{{ item.statusName }}</text></view
+          >
+          <view class="playtime"
+            >游玩时间:<text class="message">{{ item.palyTime }}</text></view
+          >
+        </view>
+      </view>
+    </view>
+    <view class="order-content" v-if="isactive === 3">
+      <view
+        class="order-list"
+        @tap="todetail(item.ordersNo)"
+        v-for="(item, index) in orderList"
+        :key="index"
+      >
+        <view class="order-title">
+          <text class="ordernum"
+            >订单号:<text class="num">{{ item.ordersNo }}</text></text
+          >
+          <text class="ordertime">{{ item.orderTime.substring(11) }}</text>
+        </view>
+        <view class="order-detail">
+          <view class="name">{{ item.shopName }}</view>
+          <view class="door"
+            >门店:<text class="message">{{ item.goodsName }}</text></view
+          >
+          <view class="num"
+            >数量:<text class="message">{{ item.num }}</text></view
+          >
+          <view class="status"
+            >状态:<text class="message">{{ item.statusName }}</text></view
+          >
+          <view class="playtime"
+            >游玩时间:<text class="message">{{ item.palyTime }}</text></view
+          >
+        </view>
+      </view>
+    </view>
+
+    <uni-load-more :status="more"> </uni-load-more>
+    <rf-loading v-if="loading"></rf-loading>
+    <view style="height: 250upx;"></view>
   </view>
 </template>
 
 <script>
+import moment from '@/common/moment';
+import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
+import uniCalendar from '@/components/uni-calendar/uni-calendar.vue';
 export default {
   name: 'order',
-  components: {},
+  components: { uniLoadMore, uniCalendar },
   data() {
     //这里存放数据
     return {
-      array: ['中国', '美国', '巴西', '日本'],
+      loading: false,
+      shopArray: [{ name: '全部', id: '' }],
       index: 0,
+      shopID: 0,
       isactive: 1,
+      more: 'loading', // more  loading noMore
+
+      date: moment().format('YYYY-MM-DD'),
+      yesdate: moment().subtract(1, 'day').format('YYYY-MM-DD'),
+      dateArr: [],
+      // startdate: moment().subtract(1, 'day').format('YYYY-MM-DD'),
+      startdate: '',
+      enddate: '',
+      sunday: 0,
+
+      orderFlag: 'pay', // pay accomplish refundorder
+
+      soleStatus: 1, // 触底状态
+
+      orderList: [],
+      params: {
+        orderFlag: 'pay', // pay accomplish refundorder
+        pageNum: 1,
+        pageSize: 10,
+        ordersNo: '',
+        buyPhone: '',
+        shopId: '',
+        overTimeArray: [],
+      },
     };
   },
+
+  // 下拉刷新page.json中要配置
+  onPullDownRefresh() {
+    this.startdate = '';
+    this.enddate = '';
+    this.sunday = 0;
+    this.dateArr = [];
+    this.pageNum = 1;
+    this.orderbynumber = '';
+    this.getOrderList();
+  },
+  // 页面触底加载
+  onReachBottom() {
+    if (this.soleStatus === 1) {
+      if (this.more === 'noMore') {
+        return;
+      }
+      this.loadMoreList();
+    }
+  },
+  onLoad() {
+    this.getShopList();
+    this.getOrderList();
+  },
   //方法集合
   methods: {
-    bindPickerChange: function (e) {
-      console.log('picker发送选择改变,携带值为', e.target.value);
-      this.index = e.target.value;
+    // 打开日历
+    openTime() {
+      this.$refs.calendar.open();
+    },
+    // 确认时间后
+    confirm(e) {
+      this.more = 'loading';
+      this.loading = true;
+
+      this.startdate = e.range.before;
+      this.enddate = e.range.after;
+      this.sunday = e.range.data.length;
+
+      this.params.overTimeArray.push(this.startdate, this.enddate);
+
+      this.getOrderList();
     },
+
+    // 根据订单号或者手机号查询
+    orderByNum() {
+      this.more = 'loading';
+      let num = '';
+      const pattern = /^1[345678]\d{9}$/;
+      if (pattern.test(this.params.buyPhone)) {
+        num = this.params.buyPhone;
+        this.params.buyPhone = num;
+        this.params.ordersNo = '';
+        this.getOrderList();
+      } else {
+        this.params.buyPhone = '';
+        this.getOrderList();
+      }
+    },
+
+    // 商铺选择
+    bindPickerChange(e) {
+      this.more = 'loading';
+      this.index = e.detail.value;
+      this.params.shopId = this.shopArray[this.index].id;
+      this.getOrderList();
+    },
+
     // tab
-    changeTab(type) {
+    changeTab(type, falg) {
+      this.more = 'loading';
+      this.params.pageNum = 1;
       this.isactive = type;
+      this.params.orderFlag = falg;
+      this.getOrderList();
     },
-
     // 跳转详情
-    todetail() {
-      console.log(1);
-      this.$mRouter.push({route: ""})
-    }
+    todetail(num) {
+      uni.setStorageSync('order', num);
+      this.$mRouter.push({ route: '/pages/order/orderdetail' });
+    },
+    // 获取店铺列表
+    async getShopList() {
+      await this.$http.get('/homePage/getShopByMerId').then((res) => {
+        if (res.data && res.code === 200) {
+          let newarr = [{ name: '全部', id: '' }];
+          this.shopArray = newarr.concat(res.data);
+        }
+      });
+    },
+    // 订单列表
+    async getOrderList() {
+      this.soleStatus = 1;
+      this.orderList = [];
+      this.loading = true;
+      await this.$http
+        .post('/orders/proList', this.params)
+        .then(async (res) => {
+          console.log(res);
+          if (res.data.list.length > 0) {
+            this.orderList = res.data.list;
+            if (res.data.nextPage === 0) {
+              this.more = 'noMore';
+            }
+          } else {
+            this.more = 'noMore';
+          }
+          this.loading = false;
+        });
+    },
+    // 上拉加载
+    async loadMoreList() {
+      this.params.pageNum++;
+      await this.$http
+        .post('/orders/proList', this.params)
+        .then(async (res) => {
+          if (res.data.list.length > 0) {
+            this.orderList = this.orderList.concat(res.data.list);
+            if (res.data.nextPage === 0) {
+              this.more = 'noMore';
+            }
+          } else {
+            this.more = 'noMore';
+            return;
+          }
+        });
+    },
   },
 };
 </script>
@@ -123,25 +364,8 @@ export default {
     .header-search {
       display: flex;
       align-items: center;
-      .uni-list-cell {
-        width: 92upx;
-        .uni-list-cell-db {
-          height: 80upx;
-          font-size: 28upx;
-          display: flex;
-          justify-content: center;
-          align-items: center;
-          background-color: #fff;
-          color: #8f8f8f;
-          .icon {
-            width: 17upx;
-            height: 12upx;
-            margin-left: 10upx;
-          }
-        }
-      }
       .search {
-        flex: 1;
+        width: 100%;
         display: flex;
         align-items: center;
         height: 80upx;
@@ -166,21 +390,64 @@ export default {
           font-size: 28upx;
         }
       }
-      .btn-time {
-        width: 130upx;
+    }
+    .uni-list-cell {
+      padding: 0 20upx;
+      border-bottom: 1px solid #f4f4f4;
+      .uni-list-cell-db {
+        height: 80upx;
+        font-size: 28upx;
         display: flex;
+        justify-content: space-between;
         align-items: center;
-        justify-content: center;
-        .timeicon {
-          width: 25upx;
-          height: 28upx;
+        background-color: #fff;
+        color: #8f8f8f;
+        font-size: 30upx;
+      }
+      .uni-input {
+        height: 100%;
+        line-height: 80upx;
+      }
+      .icon-warp {
+        width: 19upx;
+        .iconRight {
+          width: 19upx;
+          height: 27upx;
+        }
+      }
+    }
+    .btn-time {
+      width: 100%;
+      height: 80upx;
+      display: flex;
+      justify-content: center;
+      align-items: center;
+      border-bottom: 1px solid #f4f4f4;
+      padding: 0 20upx;
+      .opentime {
+        flex: 1;
+        display: flex;
+        align-items: center;
+        color: #8f8f8f;
+        .start {
+          font-size: 30upx;
+        }
+        .guo {
+          padding: 0 45upx;
+          font-size: 32upx;
+        }
+        .end {
+          font-size: 30upx;
         }
-        .screen {
-          margin-left: 5upx;
-          font-size: 24upx;
-          color: #8f8f8f;
+        .sundate {
+          font-size: 28upx;
+          padding-left: 80upx;
         }
       }
+      .iconRight {
+        width: 19upx;
+        height: 27upx;
+      }
     }
     .header-bar {
       display: flex;

+ 12 - 4
src/pages/order/orderdetail.vue

@@ -42,11 +42,13 @@
 		data() {
 			return {
 				title: '订单详情',
-				orderMessage: {}
+				orderMessage: {},
+				ordernum: ''
 			}
 		},
 		onLoad() {
 			this.ordernum = uni.getStorageSync('order')
+			console.log(this.ordernum);
 			this.getOrderDetail()
 		},
 		methods: {
@@ -55,9 +57,15 @@
 			async getOrderDetail () {
 				await this.$http.get('/orders/getOrdersByNo/'+this.ordernum).then(async (res)=>{
 					console.log(res);
-					if (res.data) {
+					if (res.code === 200) {
 						this.orderMessage = res.data
-					} 
+					}
+				}).catch(error=>{
+					if (error === '该订单已失效!') {
+						setTimeout(() => {
+							this.$mRouter.back()
+						}, 1000);
+					}
 				})
 			}
 		}
@@ -152,4 +160,4 @@
 			}
 		}
 	}
-</style>
+</style>

+ 71 - 38
src/pages/shop/shop.vue

@@ -96,7 +96,7 @@
           <view class="btn stick" id="one" @tap="sticktop(item.id)">置顶</view>
           <view class="btn sold" @tap="passGet(item.id)">审核</view>
           <view class="btn compile" @tap="topage">编辑</view>
-          <view class="btn delete">删除</view>
+          <view class="btn delete" @tap="deleteshop(item.id)">删除</view>
         </view>
       </view>
     </view>
@@ -129,7 +129,7 @@
           <view class="btn stick" id="one" @tap="sticktop(item.id)">置顶</view>
           <view class="btn sold" @tap="shopPutDown(item.id)">下架</view>
           <view class="btn compile" @tap="topage">编辑</view>
-          <view class="btn delete">删除</view>
+          <view class="btn delete" @tap="deleteshop(item.id)">删除</view>
         </view>
       </view>
     </view>
@@ -146,11 +146,17 @@
           <view class="center">
             <view class="shop-detail door">所属店铺:{{ item.shopName }}</view>
             <view class="shop-detail type">类型:{{ item.typeName }}</view>
-            <view class="shop-detail putaway">上下架状态:{{ item.upDown | putaway }}</view>
-            <view class="shop-detail status">状态:{{ item.status | state }}</view>
+            <view class="shop-detail putaway"
+              >上下架状态:{{ item.upDown | putaway }}</view
+            >
+            <view class="shop-detail status"
+              >状态:{{ item.status | state }}</view
+            >
           </view>
 
-          <view class="right">¥<text class="price">{{ item.price }}</text></view>
+          <view class="right"
+            >¥<text class="price">{{ item.price }}</text></view
+          >
         </view>
         <view class="operate">
           <view class="btn stick" id="one" @tap="sticktop(item.id)">置顶</view>
@@ -163,17 +169,30 @@
 
     <uni-load-more :status="more"> </uni-load-more>
     <rf-loading v-if="loading"></rf-loading>
+    <mask
+      :txt="masktxt"
+      :iconShow="iconShow"
+      v-if="isShowMask"
+      @isSureConver="isSureConver"
+    ></mask>
   </view>
 </template>
 
 <script>
 import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
+import mask from '../components/mask';
 export default {
   name: 'order',
-  components: { uniLoadMore },
+  components: { uniLoadMore, mask },
   data() {
     //这里存放数据
     return {
+      // 遮罩层
+      isShowMask: false,
+      iconShow: false,
+      masktxt: '',
+      deleteId: '',
+
       scenicID: 0, // 景区id 唯一(一个账号代表一个景区)
       loading: false,
       more: 'loading', // more  loading noMore
@@ -242,15 +261,27 @@ export default {
       this.$mRouter.push({ route: '/pages/shop/shopdetail' });
     },
     // 删除商品
-    async deleteshop (id) {
-      await this.$http.delete('/goods/del/'+id).then(async (res)=>{
-        if (res.code === 200 && res.msg === 'OK') {
-          this.$mHelper.toast('删除成功')
-          setTimeout(() => {
-            this.getTicketShopList()
-          }, 500);
-        }
-      })
+    async deleteshop(id) {
+      this.deleteId = id
+      this.masktxt = '是否删除该订单?';
+      this.isShowMask = true;
+
+      return;
+    },
+    // 监听遮罩层行为
+    isSureConver(e) {
+      console.log(e);
+      if (e) {
+        this.$http.delete('/goods/del/' + this.deleteId).then(async (res) => {
+          if (res.code === 200 && res.msg === 'OK') {
+            this.$mHelper.toast('删除成功');
+            setTimeout(() => {
+              this.getTicketShopList();
+            }, 500);
+          }
+        });
+      }
+      this.isShowMask = false;
     },
     // 根据名字搜索
     searchByname() {
@@ -282,7 +313,7 @@ export default {
     async getShopMessage() {
       await this.$http.get('/getUserInfo').then(async (res) => {
         if (res.data) {
-          uni.setStorageSync('scenicId', res.data.id)
+          uni.setStorageSync('scenicId', res.data.id);
           this.params.mid = res.data.id;
           this.getTicketShopList();
         }
@@ -295,7 +326,7 @@ export default {
       this.params.pageNum = 1;
       this.isactive = type;
       this.params.status = status;
-      this.status = status
+      this.status = status;
       delete this.params.upDown;
       this.getTicketShopList();
     },
@@ -305,19 +336,19 @@ export default {
       this.params.pageNum = 1;
       this.isactive = type;
       this.params.upDown = putaway;
-      this.putAwat = putaway
+      this.putAwat = putaway;
       delete this.params.status;
       this.getTicketShopList();
     },
     // 置顶
     sticktop(id) {
       console.log(id);
-      this.$http.PUT("/goods/changeSort?id="+id+'&sort=-1').then(res=>{
+      this.$http.PUT('/goods/changeSort?id=' + id + '&sort=-1').then((res) => {
         console.log(res);
         if (res.code === 200) {
-          this.getTicketShopList()
+          this.getTicketShopList();
         }
-      })
+      });
     },
     // 跳转详情
     topage() {
@@ -379,38 +410,40 @@ export default {
     },
     // 下架
     shopPutDown(id) {
-      this.changeShopStatus(id,this.params.upDown)
+      this.changeShopStatus(id, this.params.upDown);
     },
     // 上架
     shopPutUp(id) {
-      this.changeShopStatus(id,this.params.upDown)
+      this.changeShopStatus(id, this.params.upDown);
     },
     // 修改商品状态
-    async changeShopStatus(ids,upordown,state) {
-      let upstate = 0
+    async changeShopStatus(ids, upordown, state) {
+      let upstate = 0;
       if (upordown === '1') {
-        upstate = 0        
+        upstate = 0;
       } else {
-        upstate = 1
+        upstate = 1;
       }
 
       let data = {
         id: ids,
         upDown: upstate,
-        status: state
-      }
+        status: state,
+      };
       if (state) {
-        delete data.upDown
+        delete data.upDown;
       } else {
-        delete data.status
+        delete data.status;
       }
-      await this.$http.postBody('/goods/changeStatusOrUpDown',data).then( async(res)=>{
-        if (res.code === 200 && res.msg === 'OK') {
-          this.getTicketShopList()
-          this.$mHelper.toast('操作成功')
-        }
-      })
-    }
+      await this.$http
+        .postBody('/goods/changeStatusOrUpDown', data)
+        .then(async (res) => {
+          if (res.code === 200 && res.msg === 'OK') {
+            this.getTicketShopList();
+            this.$mHelper.toast('操作成功');
+          }
+        });
+    },
   },
 };
 </script>