Procházet zdrojové kódy

feat(点餐系统)

xing.li před 4 roky
rodič
revize
d411c4ec64
6 změnil soubory, kde provedl 126 přidání a 71 odebrání
  1. 9 2
      app.js
  2. 26 15
      pages/food/food.js
  3. 25 30
      pages/index/index.js
  4. 21 2
      pages/order/order.wxml
  5. 30 22
      pages/personorder/personorder.wxml
  6. 15 0
      pages/prompt/prompt.js

+ 9 - 2
app.js

@@ -55,13 +55,12 @@ App({
     }
     let _self = this;
     let res = await wxp.login()
-    console.log(res)
     if (!res.code){
       return
     }
     data['code'] = res.code
-    console.log(data)
     let info =  await userApi.userLogin(data)
+    console.log(info)
     wx.setStorageSync('token', info.userInfo.token)
     requestApi.HEAD.token = info.userInfo.token
     this.setUserInfo(info.userInfo)
@@ -101,7 +100,15 @@ App({
     }
   },
   isAuth: async function(){
+    console.log(this.globalData.userInfo);
+    if (!this.globalData.userInfo){
+      console.log('您还没有授权');
+      return false;
+    }
+    return true;
+
     const auth = await wxp.getSetting()
+    console.log(auth);
     if (!auth.authSetting['scope.userInfo']){
       console.log('您还没有授权');
       return false

+ 26 - 15
pages/food/food.js

@@ -20,19 +20,21 @@ Page({
   },
 
 
-  onShow: function () {
-    var that = this;
-    var mobile = wx.getStorageSync('mobile');
-    console.log(mobile + "/////////" );
-      if (!mobile) {
-      that.setData({
-        check_mobile: false
-      })
-    } else {
-      that.setData({
-        check_mobile: true
-      })
-    }
+  onShow: async function () {
+   
+    
+    // var that = this;
+    // var mobile = wx.getStorageSync('mobile');
+    // console.log(mobile + "/////////" );
+    //   if (!mobile) {
+    //   that.setData({
+    //     check_mobile: false
+    //   })
+    // } else {
+    //   that.setData({
+    //     check_mobile: true
+    //   })
+    // }
    
   },
 
@@ -100,10 +102,19 @@ Page({
   },
 
   onLoad: async function (options) {
+    
     this.setData({
-      tableId:options.table_id,
-      storeId:options.store_id
+      tableId:options.tableId,
+      storeId:options.storeId
     })
+
+    const isAuth = await app.isAuth()
+    if (!isAuth) {
+      wx.redirectTo({
+        url: '/pages/prompt/prompt?page=' + this.route+"&tableId="+options.tableId+"&storeId="+options.storeId,
+      })
+      return
+    }
     await this.getCart();
     await this.productTypeList();
     await this.getProductList();

+ 25 - 30
pages/index/index.js

@@ -360,39 +360,34 @@ Page({
       url: '../appointment/appointment?' + 'shopId=' + shopId + '&productId=' + productId + '&address=' + address + "&shopName=" + shopName,
     })
   },
-  goSmdd: function () {
-    console.log("11");
+  goSmdd: async function () {
         wx.scanCode({
         // onlyFromCamera: true,
         success: (res) => {
           console.log(res);
-          wx.request({
-            url: app.globalData.base_url + '/member/index/checkTable', //仅为示例,并非真实的接口地址
-            data: {
-              bloc_code: app.globalData.bloc_code,
-              "requestUrl": res.result
-            },
-            method: "POST",
-            header: app.globalData.header,
-            complete: function (ress) {
-            },
-
-            //接入接口
-            success: function (ress) {
-              if (ress.data.code == '200') {
-                wx.navigateTo({
-                  url: '/pages/food/food?store_id=' + ress.data.data.store_id + '&table_id=' + ress.data.data.table_id
-                })
-              }else{
-                wx.showModal({
-                  title: '',
-                  content: '二维码解析错误,重新扫描桌台码,谢谢!',
-                })
-              }
-            }
-          })
-         }
+          var temp1 = res.result.split('?');
+          var pram = temp1[1];
+          var keyValue = pram.split('&');
+          var obj = {};
+          for (var i = 0; i<keyValue.length; i++){
+              var item = keyValue[i].split('=');
+              var key = item[0];
+              var value = item[1];
+              obj[key] = value;
+          }
+  
+         console.log(obj);
+          if (obj.storeId && obj.tableId) {
+            wx.navigateTo({
+              url: '/pages/food/food?storeId=' + obj.storeId + '&tableId=' + obj.tableId
+            })
+          }else{
+            wx.showModal({
+              title: '',
+              content: '二维码解析错误,重新扫描桌台码,谢谢!',
+            })
+          }
       }
-)}
-
+    })
+  },
 })

+ 21 - 2
pages/order/order.wxml

@@ -4,7 +4,7 @@
     <view class="timer" wx:if="{{order.status==1}}">
         等待买家付款,剩余{{timer.minute}}分{{timer.second}}秒后自动关闭
     </view>
-    <view class="code-info" wx:if="{{order.status==2}}">
+    <view class="code-info" wx:if="{{order.status==2 && order.orderType !=3}}">
         <view class="code card">
             <canvas class="canvas-code" style="width:280rpx;height:280rpx" canvas-id="qrCode" />
             <view class="code-text f13 c-707070" wx:if="{{order.writeOffStatus==1}}">
@@ -21,7 +21,7 @@
                 <progress class="pro" active-mode="forwards" percent="{{percent}}" color="{{color}}" active stroke-width="3" />
             </view>
     </view>
-    <view class="order card">
+    <view class="order card" wx:if="{{order.orderType !=3}}">
         <view class="order-img">
             <image class="" src="{{order.productImg}}"></image>
         </view>
@@ -35,6 +35,25 @@
             </view>
         </view>
     </view>
+    <view class="order" wx:if="{{order.orderType ==3}}" style="height:120rpx">
+        <view class="order-info" style="padding-right: 20rpx;">
+            <view class="order-id f30 c-707070" style="font-size:30rpx;">{{order.orderSn}}</view>
+            <view class="order-id f30 c-707070" style="font-size:30rpx;">{{order.productList[0].createTime}}</view>
+        </view>
+    </view>
+    <view class="order card" wx:if="{{order.orderType ==3}}" wx:for="{{order.productList}}">
+        <view class="order-img">
+            <image class="" src="{{item.productImg}}"></image>
+        </view>
+        <view class="order-info">
+            <view class="order-id f30 c-707070" style="font-size:30rpx;"></view>
+            <view class="order-title c-202020">{{item.productName}}×{{item.productNum}}</view>
+            <view class="order-price f18">¥{{item.currentPrice}}</view>
+            <view class="order-date f13 c-707070">
+              
+            </view>
+        </view>
+    </view>
     <view class="shop-info card">
         <view class="shop f17">{{ order.storeName}}</view>
         <view class="address f14 c-707070 " bindtap="guide">

+ 30 - 22
pages/personorder/personorder.wxml

@@ -11,33 +11,41 @@
                             <view class="order-item" bindtap="showOrderInfo" data-orderid="{{item.id}}"
                                 data-status="{{item.status}}" data-writestatus="{{item.writeOffStatus}}">
                                 <view class="pay-text">{{item.orderSn}}</view>
-                                <view class="order-img">
-                                    <image class="" src="{{item.productImg}}">
-
-                                    </image>
-                                </view>
-                                <view class="order-desc">
-                                    <view class="order-id f30 c-707070">{{item.statusText}}</view>
-                                    <view class="order-title c-202020">
-                                        <view class="title">{{item.productName}}</view>
+                      
+                                    <view class="order-img" >
+                                        <image class="" src="{{item.productList[0].productImg}}">
 
+                                        </image>
                                     </view>
-                                    <view class="order-price f18">¥{{item.orderMoney}}</view>
+                                    <view class="order-desc" >
+                                        <view class="order-id f30 c-707070">{{item.statusText}}</view>
+                                        <view class="order-title c-202020">
+                                            <view class="title" wx:if="{{item.orderType !=3}}">{{item.productName}}</view>
+                                            <view class="title" wx:if="{{item.orderType ==3}}">{{item.productList[0].productName}}×{{item.productList[0].productNum}}</view>
 
-                                    <view class="order-date f13 c-707070">
-                                        <mp-icon icon="time" size="18" class="icon" color="#707070"></mp-icon>
-                                        {{item.appointmentTime}}
-                                    </view>
-                                    <view class="order-shop-address">
-                                        <view class="address f13 c-707070">
-                                            <mp-icon icon="location" size="18" class="icon" type="filled"
-                                                color="#707070"></mp-icon>
-                                            {{item.address}}
                                         </view>
-                                        <!-- <view class="distance f13 ">{{item.distance}}</view> -->
-                                    </view>
+                                        <view class="order-price f18"  wx:if="{{item.orderType !=3}}">¥{{item.orderMoney}}</view>
+                                        <view class="order-price f18"  wx:if="{{item.orderType ==3}}">¥{{item.productList[0].currentPrice}}</view>
 
-                                </view>
+                                        <view class="order-date f13 c-707070" wx:if="{{item.orderType !=3}}">
+                                            <mp-icon icon="time" size="18" class="icon" color="#707070"></mp-icon>
+                                            {{item.appointmentTime}}
+                                        </view>
+                                        <view class="order-date f13 c-707070" wx:if="{{item.orderType ==3}}">
+                                            <mp-icon icon="shop" size="18" class="icon" color="#707070"></mp-icon>
+                                            {{item.productList[0].productName}}等,共{{item.productList.length}}件
+                                        </view>
+                                        <view class="order-shop-address">
+                                            <view class="address f13 c-707070">
+                                                <mp-icon icon="location" size="18" class="icon" type="filled"
+                                                    color="#707070"></mp-icon>
+                                                {{item.address}}
+                                            </view>
+                                            <!-- <view class="distance f13 ">{{item.distance}}</view> -->
+                                        </view>
+
+                                    </view>
+                              
                             </view>
                             <view class="operate-btn">
                                 <view class="buy-again btn f14" data-shopid="{{item.storeId}}"

+ 15 - 0
pages/prompt/prompt.js

@@ -18,6 +18,12 @@ Page({
     if (options.page === 'pages/appointment/appointment') {
       page = `${page}?shopId=${options.shopId}&productId=${options.productId}`
     }
+    if(options.storeId && options.tableId){
+      this.setData({
+        storeId: options.storeId,
+        tableId: options.tableId,
+      })
+    }
     this.setData({
       fromPage: page
     })
@@ -100,6 +106,7 @@ Page({
       wx.switchTab({
         url: '/'+_self.data.fromPage,
       })
+      return;
     }/* else{
       wx.redirectTo({
         url: '/'+_self.data.fromPage,
@@ -109,6 +116,14 @@ Page({
       wx.redirectTo({
         url: '../comments/comments?title=我的评论&commentstype=my',
       })
+      return;
+    }
+
+    if(_self.data.fromPage=="pages/food/food"){
+      wx.redirectTo({
+        url: '/'+_self.data.fromPage+"?tableId="+this.data.tableId+"&storeId="+this.data.storeId,
+      })
+      return;
     }
 
     wx.redirectTo({