瀏覽代碼

feat(康道足浴) 添加点餐功能

xing.li 4 年之前
父節點
當前提交
cf3c4dedb8
共有 19 個文件被更改,包括 6694 次插入12 次删除
  1. 4 4
      api/product.js
  2. 9 1
      app.js
  3. 2 1
      app.json
  4. 二進制
      images/canju.png
  5. 二進制
      images/cart-jian.png
  6. 二進制
      images/cart.png
  7. 二進制
      images/jians.png
  8. 二進制
      images/jias.png
  9. 960 0
      pages/food/food.js
  10. 4 0
      pages/food/food.json
  11. 119 0
      pages/food/food.wxml
  12. 1153 0
      pages/food/food.wxss
  13. 38 3
      pages/index/index.js
  14. 3 1
      pages/index/index.wxml
  15. 20 0
      pages/index/index.wxss
  16. 1 1
      project.config.json
  17. 7 0
      project.private.config.json
  18. 9 1
      utils/util.js
  19. 4365 0
      weui-wxss/weui.wxss

+ 4 - 4
api/product.js

@@ -6,8 +6,8 @@ class product extends request {
     //     console.log(res);
     // }
 
-    static async getProductList(productType=1,page = 1, pageSize = 10) {
-        const res = await this.getRequest(`${this.BASE_URL}Product/index?productTypeId=${productType}&page=${page}&pageSize=${pageSize}`)
+    static async getProductList(productType=1,page = 1, pageSize = 10,type=1) {
+        const res = await this.getRequest(`${this.BASE_URL}Product/index?productTypeId=${productType}&page=${page}&pageSize=${pageSize}&type=${type}`)
         return res.data;
     }
     static async getProductById(id) {
@@ -15,8 +15,8 @@ class product extends request {
         return res.data;
     }
 
-    static async getProductTypeList(page = 1, pageSize = 10) {
-        const res = await this.getRequest(`${this.BASE_URL}Product/typeList?page=${page}&pageSize=${pageSize}`)
+    static async getProductTypeList(page = 1, pageSize = 10,type=1) {
+        const res = await this.getRequest(`${this.BASE_URL}Product/typeList?page=${page}&pageSize=${pageSize}&type=${type}`)
         return res.data;
     }
     

+ 9 - 1
app.js

@@ -35,7 +35,15 @@ App({
     await self.wxLogin(info.userInfo);
   },
   globalData: {
-    userInfo: null
+    userInfo: null,
+
+    base_url: "https://api.overseasdragon.com.cn",
+    base_img_url: "https://smdd.overseasdragon.com.cn",
+    // base_img_url:"https://smdd.overseasdragon.com.cn",
+    // base_url: "https://member.overseasdragon.com.cn",
+    bloc_code: "BAIXIONG",
+    header: { 'content-type': 'application/json' },
+    
   },
   wxLogin:async function(data){
     console.log(data)

+ 2 - 1
app.json

@@ -11,7 +11,8 @@
     "pages/personorder/personorder",
     "pages/shopinfo/shopinfo",
     "pages/shop/shop",
-    "pages/prompt/prompt"
+    "pages/prompt/prompt",
+    "pages/food/food"
    
   
   ],

二進制
images/canju.png


二進制
images/cart-jian.png


二進制
images/cart.png


二進制
images/jians.png


二進制
images/jias.png


+ 960 - 0
pages/food/food.js

@@ -0,0 +1,960 @@
+
+import {
+  default as productApi
+} from "../../api/product"
+
+const app = getApp()
+var utils = require('../../utils/util.js');
+let globalInterval = {};
+Page({
+  data: {
+    check_index:true,
+    toViewss:'',
+    userInfo: {},
+    hasUserInfo: false,
+    canIUse: wx.canIUse('button.open-type.getUserInfo'),
+    series: [],
+    scrollTop:"",
+    toView: 'series1',
+    toViews: '1',
+    showMyCar: 'false',
+    showSpec: true,
+    flavor: [
+    ],
+    plactice: [
+    ],
+    productList: [],//所有产品列表
+    remainDecMoney:0,
+    remainDecMoneyReduce:0,
+    remainDecMoneyHas: 0,
+    product_no: '',
+    array_flavore: [],//已选择的口味
+    array_plactice: [],//选择做法列表
+    choose_plactice: '',//选择的做法
+    choose_product_list: [],//已选择产品列表
+    chooseProduct: '',//当前选择的产品编号
+    chooseProductSpecPrice: '17',//有规格时的产品总价格
+    chooseProductPrice: '17',//有规格时产品单价
+    all_price: 0,//订单总价
+    haveChooseOrderDetail: [],//已点产品订单
+    haveChooseOrderDetailNum: '0',//已点产品的总数
+    canChooseProduct:true,
+    // showModal: true,
+    currentTab: 0,
+    base_img_url: app.globalData.base_img_url,
+
+    indicatorDots: true,
+    autoplay: true,
+    interval: 5000,
+    duration: 1000,
+    scroll_tops: 0,
+    heightTopSwiper: "35%",
+    topSeriesScroll: "37%",
+    topProductScroll: "37%",
+    heightSeriesScroll: "63%",
+    seriesBottom:"0",
+    menuBotDisplay:"none",
+    check_tying:false,
+    tyingOrderDetail:[],
+    check_mobile:false,//是否已有注册
+    scrollText:'',
+    viewStyle:{
+      second:0,
+      total:0
+    },
+    navActive:0,
+    loopLeft:-100,
+    activeTab:0,
+    showCart:false,
+    mask:true
+  },
+
+
+  onChooseTeacher:function(){
+     this.setData({
+       showModal: false,
+     })
+  },
+  onLoadImg: function () {
+    var productList = this.data.productList;
+    for (var i in productList) {
+      productList[i].img = (!productList[i].imgOrg) ? '/static/index/images/img02.jpg' : productList[i].imgOrg;
+    }
+    this.setData({
+      productList: productList,
+    });
+  },
+  onReady:function(){
+    
+  },
+  onHide:function(){
+    console.log('清理定时器');
+    clearInterval(globalInterval);
+  },
+  onShow: function () {
+
+    var order_no = wx.getStorageSync('order_no');
+    var that = this;
+
+    var mobile = wx.getStorageSync('mobile');
+    var member_openid = wx.getStorageSync('member_openid');
+    console.log(mobile + "/////////" + member_openid);
+    //if (!mobile || !member_openid) {
+      if (!mobile) {
+      that.setData({
+        check_mobile: false
+      })
+    } else {
+      that.setData({
+        check_mobile: true
+      })
+    }
+    console.log(order_no)
+    if (order_no) {
+      console.log(order_no);
+      wx.request({
+        url: app.globalData.base_url + '/smdd/index/getOrder',//上线的话必须是https,没有appId的本地请求貌似不受影响
+        data: {
+          check:true,//将加购产品删除
+          bloc_code: app.globalData.bloc_code,
+          order_no: order_no
+        },
+        method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
+        header: app.globalData.header, // 设置请求的 header
+        success: function (res) {
+          var list = res.data.data.productList;
+          // var list = JSON.stringify(list);
+          // console.log(list);
+          var order_no = res.data.data.order_no;
+          wx.setStorageSync('order_no', order_no);
+          console.log(res.data.data.productList);
+
+          that.setData({
+            haveChooseOrderDetail: list,
+            haveChooseOrderDetails: res.data.data.chooseProductList,
+            haveChooseNoCar: res.data.data.product,
+            haveChooseOrderDetailNum: res.data.data.count,
+            all_price: res.data.data.all_price,
+            remainDecMoney: res.data.data.remainDecMoney.remain,
+            remainDecMoneyReduce: res.data.data.remainDecMoney.dec,
+            remainDecMoneyHas: res.data.data.remainDecMoney.has
+          })
+          if (res.data.data.count > 0){
+           that.setData({
+             menuBotDisplay: "block",
+           })
+          }else{
+            that.setData({
+              menuBotDisplay: "none",
+            })
+          }
+        },
+        fail: function () {
+          // fail
+        },
+        complete: function () {
+          // complete
+        }
+      })
+    } else {
+      that.setData({
+        haveChooseOrderDetail: [],
+        haveChooseOrderDetails: [],
+        haveChooseNoCar:[],
+        haveChooseOrderDetailNum: 0
+      })
+    }
+
+    console.log(that.data.check_tying)
+    if (that.data.check_tying) {
+      var caont = that.data.tyingOrderDetail;
+      console.log(caont);
+      console.log("///");
+      if (caont.tips) {
+        var content = caont.tips;
+      } else {
+        var content = "亲," + caont.product_name + caont.tying_price + "元起~客官可随意挑选";
+      }
+      wx.showModal({
+        title: '',
+        content: content,
+        showCancel: true,
+        // cancelText:'cancel',
+        // confirmText:'sure',
+        success: function (e) {
+          if (!e.cancel) {
+            wx.navigateTo({
+              url: '../../pages/package/package?product_no=' + caont.tying_product_no +'&package_id='+caont.is_package
+            })
+          }
+        }
+      })
+    }
+
+    wx.showShareMenu({
+      withShareTicket: true
+    })
+  },
+
+
+  productTypeList: async function(){
+    let self = this
+    let rs = await productApi.getProductTypeList(1,10000,2)
+    console.log(rs.list);
+    self.setData({
+      series: rs.list
+    })
+  },
+  
+  getProductList: async function (refresh = false) {
+    const self = this
+    
+    let prolist = await productApi.getProductList(0,1,10000,2);
+    self.setData({
+      productList:prolist.list
+    })
+    
+  },
+  onLoad: async function (options) {
+    
+    if (options.store_id && options.table_id){
+      wx.removeStorageSync('order_no');
+      wx.setStorageSync("store_id", options.store_id);
+      wx.setStorageSync("table_id", options.table_id);
+    }
+
+    wx.showLoading({
+      title: 'loading',
+    });
+    var that = this;
+  
+    await this.productTypeList();
+    await this.getProductList();
+    await this.initProduct();
+
+    var order_no = wx.getStorageSync('order_no');
+
+    if (order_no) {
+      console.log(order_no);
+      wx.request({
+        url: app.globalData.base_url + '/smdd/index/getOrder',//上线的话必须是https,没有appId的本地请求貌似不受影响
+        data: {
+          bloc_code: app.globalData.bloc_code,
+          order_no: order_no
+        },
+        method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
+        header: app.globalData.header, // 设置请求的 header
+        success: function (res) {
+          var list = res.data.data.productList;
+          // var list = JSON.stringify(list);
+          // console.log(list);
+          var order_no = res.data.data.order_no;
+          wx.setStorageSync('order_no', order_no);
+          //console.log(res.data.data.productList);
+
+          that.setData({
+            haveChooseOrderDetail: list,
+            haveChooseOrderDetails: res.data.data.chooseProductList,
+            haveChooseOrderDetailNum: res.data.data.count,
+            all_price: res.data.data.all_price,
+            remainDecMoney: res.data.data.remainDecMoney.remain,
+            remainDecMoneyReduce: res.data.data.remainDecMoney.dec,
+            remainDecMoneyHas: res.data.data.remainDecMoney.has
+          })
+        },
+        fail: function () {
+          // fail
+        },
+        complete: function () {
+          // complete
+        }
+      })
+    } else {
+      that.setData({
+        haveChooseOrderDetail: [],
+        haveChooseOrderDetails: [],
+        haveChooseOrderDetailNum: 0
+      })
+    }
+    that.setData({
+      check_index:false
+    })
+  },
+  getUserInfo: function (e) {
+    console.log(e)
+    app.globalData.userInfo = e.detail.userInfo
+    this.setData({
+      userInfo: e.detail.userInfo,
+      hasUserInfo: true
+    })
+  },
+  loop:function(){
+    let millisecond = this.data.viewStyle.second*1000;
+    let total = this.data.viewStyle.total;
+    let speed = 1000;
+    let _self = this;
+
+    globalInterval = setInterval(function(){
+      let iv = total / (millisecond / speed);
+      _self.data.loopLeft -= iv;
+      if (Math.abs(_self.data.loopLeft) >= total){
+        _self.data.loopLeft = 300;
+      }
+
+      _self.setData({
+        loopLeft: _self.data.loopLeft
+      });
+    }, speed);
+  },
+  showMyCarClick: function (e) {
+    var istrue = e.target.dataset.istrue;
+    console.log(istrue);
+    this.setData({
+      showMyCar: !istrue,
+      showSpec: true,
+    })
+
+  },
+  goMember: function (e) {
+    wx.navigateTo({
+      url: '/pages/newIndexs/newIndexs',
+      // url:'/pages/memberIndex/memberIndex'
+    })
+  },
+
+  showSpecClick: function (e) {
+    var istrue = e.target.dataset.showspec;
+    var plactice = this.data.choose_plactice;
+    var flavor = this.data.flavor;
+
+    if (istrue == true) {
+      var price = e.target.dataset.price
+      var product_no = e.target.dataset.no;
+      var that = this;
+      wx.request({
+        url: app.globalData.base_url + '/smdd/index/getAddProduct',//上线的话必须是https,没有appId的本地请求貌似不受影响
+        data: {
+          bloc_code: app.globalData.bloc_code,
+          product_no: product_no,//大华店
+        },
+        method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
+        header: app.globalData.header, // 设置请求的 header
+        success: function (res) {
+          console.log(res.data.data)
+          console.log(res.data.code);
+          if (res.data.code == '200') {
+            if (res.data.data) {
+              var flavor = [];//口味
+              var plactice = [];//做法
+              var add_arr = res.data.data;
+              for (let i = 0; i < add_arr.length; i++) {
+                console.log(add_arr[i].img);
+                if (add_arr[i]['type'] == 1) {//口味
+                  flavor[i] = add_arr[i];
+                  flavor[i]['is_select'] = "false";
+                } else if (add_arr[i]['type'] == 2) {
+                  plactice[i] = add_arr[i];
+                  plactice[i]['is_select'] = "false";
+                }
+              }
+              that.setData({
+                flavor: flavor,
+                plactice: plactice,
+                chooseProductPrice: price,//有规格时产品单价
+                chooseProductSpecPrice: price,//有规格时的产品总价格
+                showSpec: !istrue,
+                chooseProduct: product_no,
+                choose_plactice: '',
+                array_plactice: []
+              })
+            }
+          }
+
+        },
+      })
+    } else {
+      this.setData({
+        showSpec: !istrue,
+      })
+      var product_no = e.target.dataset.no;
+      var arr = this.getChooseAdd();
+      console.log(arr);
+      if (product_no > 0) {
+        // 不可以重复下单
+        this.setData({
+          canChooseProduct:false
+        })
+        this.chooseProduct(product_no, arr);
+      }
+
+    }
+  },
+  tap: function (e) {
+    var id = e.currentTarget.dataset.id;
+    var index = e.currentTarget.dataset.index;
+    this.setData({
+      toView: id,
+      navActive: index
+    });
+  },
+  clickScroll: function (e) {
+    var id = e.currentTarget.dataset.id
+    var action = e.currentTarget.dataset.action
+    console.log(e);
+    this.setData({
+      toView: id,
+      toViews: action,
+      seriesClickToView:id
+    })
+  },
+  scroll: function (e) {
+    var scrollTop = e.detail.scrollTop;
+    var scrollArr = this.data.hightArr;
+
+    var active = "";
+    for (var i = 0; i < scrollArr.length; i++) {
+      if (scrollTop >= 0 && scrollTop < scrollArr[1] - scrollArr[0]-50) {
+        active = 0;
+
+      } else if (scrollTop >= scrollArr[i] - scrollArr[0]-50 && scrollTop < scrollArr[i + 1] - scrollArr[0]-50) {
+        active = i;
+
+      } else if (scrollTop >= scrollArr[scrollArr.length - 1] - scrollArr[0]-50) {
+        active = scrollArr.length - 1;
+      }
+    }
+    console.log(active);
+    this.setData({
+      navActive: active
+    })
+  },
+  scrolls:function(e){
+     console.log(e);
+  },
+  onPageScroll: function (e) {
+  },
+  onPullDownRefresh: function (e) {
+    cosole.log(e)
+  },
+  leftMenu: function (rightId) {
+  },
+  flavorClick: function (e) {
+    console.log(e);
+    var arrs = this.data.array_flavore;
+    console.log(arrs);
+    var ids = e.target.dataset.id;
+    var chec = 2;
+    if (arrs) {
+      for (let i = 0; i < arrs.length; i++) {
+        console.log(arrs[i]);
+        if (arrs[i] == ids) {
+          arrs.splice(i, 1)
+          chec = 1;
+        }
+      }
+    }
+    if (chec == 2) {
+      arrs.push(ids);
+    }
+    if (arrs) {
+      var flavore_arr = [];
+      var flavore = this.data.flavor;
+      console.log(flavore);
+      for (let i = 0; i < flavore.length; i++) {
+        // console.log(1111);
+        var check_flo = 1;
+        for (let j = 0; j < arrs.length; j++) {
+          if (arrs[j] == flavore[i]["add_id"]) {
+            check_flo = 2;
+          }
+        }
+        if (check_flo == 1) {
+          flavore[i]["is_select"] = 'false';
+        } else {
+          flavore[i]["is_select"] = 'true';
+        }
+        flavore_arr[i] = flavore[i];
+      }
+      this.setData({
+        flavor: flavore_arr,
+      })
+    }
+    console.log(this.data.array_flavore);
+    this.colmProudtcPrice();
+  },
+  placticeClick: function (e) {
+    console.log(e);
+    var ids = e.target.dataset.id;
+    e.target.dataset.name = "check";
+    this.setData({
+      array_plactice: ["ids"],
+      choose_plactice: ids
+    })
+    this.colmProudtcPrice();
+  },
+  colmProudtcPrice: function () {//计算有规格的产品的价格
+    var spec_price = 0;//选择规则的价格
+    var chooseProductPrice = this.data.chooseProductPrice;//产品单价
+    var choose_plactice = this.data.choose_plactice;//选择的做法no【单选】
+    var flavore = this.data.flavor;//做法数组
+    var plactice = this.data.plactice;//口味数组
+    console.log(choose_plactice);
+    console.log(plactice);
+    if (flavore) {
+      for (let i = 0; i < flavore.length; i++) {
+        if (flavore[i]['is_select'] == "true") {
+          spec_price = spec_price * 1 + flavore[i]['price'] * 1;
+        }
+      }
+    }
+    if (plactice && choose_plactice) {
+      for (let j = 0; j < plactice.length; j++) {
+        if (plactice[j]['add_id'] == choose_plactice) {
+          spec_price = spec_price * 1 + plactice[j]['price'] * 1;
+        }
+      }
+    }
+    console.log(spec_price + "///" + chooseProductPrice);
+    this.setData({
+      chooseProductSpecPrice: spec_price * 1 + chooseProductPrice * 1
+    })
+  },
+  getChooseAdd: function () {
+    var flavore = this.data.flavor;//做法数组
+    var choose_plactice = this.data.choose_plactice;//选择的做法no【单选】
+    var plactice = this.data.plactice;//口味数组
+    console.log(choose_plactice);
+    console.log(plactice);
+    var arr = [];
+    var j = 0;
+    if (flavore) {
+      for (let i = 0; i < flavore.length; i++) {
+        if (flavore[i]['is_select'] == "true") {
+          arr[j] = flavore[i]['add_id'];
+          j++;
+        }
+      }
+    }
+    if (choose_plactice) {
+      arr.push(choose_plactice);
+    }
+    return arr;
+  },
+  productDetail:function(e){
+    var product_no = e.target.dataset.no;
+    wx.navigateTo({
+      url: '../indexbaixiong/productDetail/productDetail?product_no=' + product_no
+    })
+  },
+  packages: function (e) {
+    var package_id = e.target.dataset.id;
+    var product_no = e.target.dataset.no;
+    var haveChooseProduct = this.data.haveChooseOrderDetail;
+    var choose_num = 0;
+    var that = this;
+    if (package_id > 0) {
+      wx.navigateTo({
+        url: '../indexbaixiong/package/package?package_id=' + package_id + '&product_no=' + product_no
+      })
+    } else {
+      // 不可以重复下单
+      this.setData({
+        canChooseProduct:false
+      })
+      this.chooseProduct(product_no, '');
+    }
+
+  },
+  chooseProduct: function (product_no, add) {
+
+    var order_no = wx.getStorageSync('order_no');
+    var tableInfo = wx.getStorageSync('tableInfo');
+    var add = JSON.stringify(add);
+    wx.showLoading({
+      title: '加入购物车',
+      mask: true
+    });
+    console.log('<-----------here----------->');
+    var haveChooseProduct = this.data.haveChooseOrderDetail;
+    var that = this;
+    wx.request({
+      url: app.globalData.base_url + '/smdd/index/OrderDetail',//上线的话必须是https,没有appId的本地请求貌似不受影响
+      data: {
+        bloc_code: app.globalData.bloc_code,
+        product_no: product_no,
+        add_array: add,
+        order_no: order_no,
+        tableInfo: tableInfo,
+        store_id: wx.getStorageSync('store_id'),
+        mobile: wx.getStorageSync('mobile')
+      },
+      method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
+      header: app.globalData.header, // 设置请求的 header
+      success: function (res) {
+        wx.hideLoading();
+         console.log(res.data.data);
+        // console.log(res.data.code);
+        if (res.data.code == '200') {
+          var list = res.data.data.productList;
+          var order_no = res.data.data.order_no;
+          wx.setStorageSync('order_no', order_no);
+          console.log(res.data.data.productList);
+          that.setData({
+            haveChooseOrderDetails: res.data.data.chooseProductList,
+            haveChooseNoCar: res.data.data.product,
+            haveChooseOrderDetail: list,
+            haveChooseOrderDetailNum: res.data.data.count,
+            menuBotDisplay:"block",
+            all_price: res.data.data.all_price,
+            remainDecMoney: res.data.data.remainDecMoney.remain,
+            remainDecMoneyReduce: res.data.data.remainDecMoney.dec,
+            remainDecMoneyHas: res.data.data.remainDecMoney.has
+          })
+
+          if (res.data.data.check_tying == true){
+            // that.setData({
+            //   tyingProduct_no: res.data.data.tyingProductList.product_no,
+            //   tyingSeries_id: res.data.data.tyingProductList.series_id
+            // })
+            if (res.data.data.tyingProductList.tips) {
+              var content = res.data.data.tyingProductList.tips;
+            } else {
+              var content = "亲," + res.data.data.tyingProductList.product_name + res.data.data.tyingProductList.tying_price + "元起~客官可随意挑选";
+            }
+            wx.showModal({
+              title: '',
+              content: content,
+              showCancel:true,
+              // cancelText:'cancel',
+              // confirmText:'sure',
+              success:function(e){
+                if(!e.cancel){
+                  wx.navigateTo({
+                    url: '../../pages/productDetail/productDetail?product_no=' + res.data.data.tyingProductList.tying_product_no + '&check=1&tying_price=' + res.data.data.tyingProductList.tying_price
+                  })
+                }
+              }
+            })
+          }
+        }else{
+          wx.showModal({
+            title: '提示',
+            content: res.data.msg,
+            showCancel:false
+          })
+        }
+        that.setData({
+          canChooseProduct:true
+        })
+      },
+    })
+  },
+  deleteProduct: function (e) {
+    wx.showLoading({
+      title: 'loading',
+      mask: true
+    })
+    var no = e.target.dataset.no;
+    var id = e.target.dataset.id;
+    var order_no = wx.getStorageSync('order_no');
+    var that = this;
+    console.log(no);
+    wx.request({
+      url: app.globalData.base_url + '/smdd/index/deleteProduct',//上线的话必须是https,没有appId的本地请求貌似不受影响
+      data: {
+        bloc_code: app.globalData.bloc_code,
+        product_no: no,//
+        order_no: order_no,
+        id: id
+      },
+      method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
+      header: app.globalData.header, // 设置请求的 header
+      success: function (res) {
+        console.log(res);
+        if (res.data.code == '200') {
+          var list = res.data.data.productList;
+          that.setData({
+            haveChooseOrderDetail: list,
+            haveChooseOrderDetails: res.data.data.chooseProductList,
+            haveChooseNoCar: res.data.data.product,
+            haveChooseOrderDetailNum: res.data.data.count,
+            all_price: res.data.data.all_price,
+            remainDecMoney: res.data.data.remainDecMoney.remain,
+            remainDecMoneyReduce: res.data.data.remainDecMoney.dec,
+            remainDecMoneyHas: res.data.data.remainDecMoney.has
+          })
+          if (res.data.data.count > 0) {
+            that.setData({
+              menuBotDisplay: "block",
+            })
+          } else {
+            that.setData({
+              menuBotDisplay: "none",
+            })
+          }
+          if (res.data.data.first_check_tying == true){
+             wx.showModal({
+               title: '',
+               content: res.data.data.first_check_tying_name+"将被恢复原价",
+             })
+          }
+        }
+      }
+    })
+    wx.hideLoading();
+  },
+  start_order: function (e) {
+    // wx.requestSubscribeMessage({
+    //   tmplIds: ['JpCFOwqltafef9abxKme6LFXHA-i9lKH2Z7IbngLKu0'],
+    //   success(res) {
+    //     console.log(res);
+    //     console.log("111");
+    //   },
+    //   complete(ress) {
+    //     console.log(ress)
+    //     console.log("222");
+    //   }
+    // })
+    var order_no = wx.getStorageSync('order_no');
+if(this.data.haveChooseOrderDetails.length>0){
+  wx.navigateTo({
+    url: '/pages/order/order'
+  })
+}else{
+  wx.showModal({
+    content: '请选择产品',
+  })
+}
+    // if (order_no) {
+    // }
+  },
+  order: function () {
+    wx.navigateTo({
+      url: '../records/records'
+    })
+  },
+
+  clearAll: function () {
+    var order_no = wx.getStorageSync('order_no');
+    var that = this;
+    wx.showModal({
+      title: '提示',
+      content: "确定清除吗",
+      success: function (res) {
+        if (res.confirm) {
+          wx.showLoading({
+            title: 'loading',
+            mask: true
+          })
+          wx.request({
+            url: app.globalData.base_url + '/smdd/index/clearAll',//上线的话必须是https,没有appId的本地请求貌似不受影响
+            data: {
+              bloc_code: app.globalData.bloc_code,
+              order_no: order_no
+            },
+            method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
+            header: app.globalData.header, // 设置请求的 header
+            success: function (res) {
+              if (res.data.code == '200') {
+                wx.setStorageSync('order_no', '');
+                that.setData({
+                  haveChooseOrderDetail: [],
+                  haveChooseOrderDetails: [],
+                  haveChooseNoCar:[],
+                  haveChooseOrderDetailNum: 0,
+                  all_price: 0
+                })
+              }
+              wx.hideLoading()
+            }
+          })
+        }
+      }
+    })
+  },
+  noStartOrder: function () {
+    wx.showModal({
+      title: '提示',
+      content: "请选择产品",
+      showCancel: false,
+      success: function (res) {
+        if (res.confirm) {
+          console.log('用户点击确定')
+        }
+      }
+    })
+  },
+  clickTuiImg:function(e){
+    console.log(e);
+  },
+    clickImg: function (e) {
+     var no = e.target.dataset.url;
+      if(no){
+        this.setData({
+          toView: "series" + no,
+          toViews: no,
+        })
+      }
+    console.log(e);
+  },
+
+  getPhoneNumber:function(e){
+    var store_id = this.data.store_id;
+    this.checkLogin(e,store_id);
+   // console.log(e.detail.encryptedData);
+  },
+  checkLogin:function(e,store_id){
+    var that=this;
+    wx.login({
+      success: function (res) {
+        var code = res.code;
+        console.log(res);
+        //console.log(111);
+        if(code){
+          wx.request({
+            url: app.globalData.base_url + '/smdd/index/getOpenid',//上线的话必须是https,没有appId的本地请求貌似不受影响
+            data: {
+              code: res.code,
+              encryptedData: e.detail.encryptedData,
+              iv: e.detail.iv,
+              types: "smdd",
+              "bloc_code": app.globalData.bloc_code,
+              api_code: app.globalData.bloc_code,
+            },
+            method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
+            header: app.globalData.header, // 设置请求的 header
+            success: function (res) {
+              console.log(res);
+              if (res.data.code == 400) {
+                wx.showModal({
+                  title: '提示',
+                  content: res.data.msg,
+                  success: function (res) {
+                    if (res.confirm) {
+                      console.log('用户点击确定')
+                    }
+                  }
+                })
+              } else {
+                wx.setStorageSync("mobile", res.data.data.mobile);
+                wx.setStorageSync("openid", res.data.data.openid);
+                that.setData({
+                  check_mobile: true
+                })
+
+                //console.log(res.data.data.openid);
+                // if (!store_id) {
+                  /*
+                wx.redirectTo({
+                  url: '../getIntoUser/getIntoUser',
+                })
+                */
+
+                // } else {
+                //   wx.redirectTo({
+                //     url: '../index/index',
+                //   })
+                // }
+              }
+            },
+            fail: function () {
+              // fail
+            },
+            complete: function () {
+              // complete
+            }
+          })
+        }else{
+          var check_num = that.check_num * 1+1*1;
+          if(check_num>2){
+            wx.showModal({
+              title: '',
+              content: '授权失败,请退出重试',
+            })
+          }else{
+            that.setData({
+              check_num: check_num,
+            });
+            that.getPhoneNumber(e);
+          }
+        }
+
+      }
+    })
+  },
+
+  getMobile: function () {
+    var mobile = wx.getStorageSync('mobile');
+          wx.setStorageSync('check_go_where', 'index');
+          if (!mobile) {
+            wx.navigateTo({
+              url: '../getInto/getInto',
+            })
+          } else {
+            wx.navigateTo({
+              url: '../getIntoUser/getIntoUser',
+            })
+          }
+  },
+  getMobileX: function () {
+    var mobile = wx.getStorageSync('mobile');
+          //点击取消,默认隐藏弹框
+          wx.setStorageSync('check_go_where', 'index');
+          if (!mobile) {
+            wx.navigateTo({
+              url: '../getInto/getInto',
+            })
+          } else {
+            wx.navigateTo({
+              url: '../getIntoUser/getIntoUser',
+            })
+          }
+  },
+
+  handleTabClick: function (e) {
+    let index = e.currentTarget.dataset.index;
+    this.activeTab(index);
+    this.setData({ activeTab: index });
+  },
+  handleSwiperChange: function (e) {
+    var index = e.detail.current;
+    this.activeTab(index);
+    this.setData({ activeTab: index });
+  },
+  activeTab: function (_activeTab) {
+    var len = this.data.series.length;
+    if (len === 0) return;
+    var currentView = _activeTab - 1;
+    if (currentView < 0) currentView = 0;
+    if (currentView > len - 1) currentView = len - 1;
+    this.setData({ currentView: currentView });
+  },
+
+  initProduct: function(){
+    let series = this.data.series;
+    let productList = this.data.productList;
+    let currentProductList = [];
+    series.forEach((item,index) => {
+      currentProductList[index] = [];
+      let i = 0;
+      productList.forEach((element,pindex) => {
+        
+        if (element.productTypeId == item.id){
+          currentProductList[index][i] = element;
+          i++;
+        }
+      });
+    });
+    this.setData({
+      currentProductList:currentProductList
+    })
+  },
+  openCartDialog: function(e){
+    let type = e.currentTarget.dataset.type;
+    if (type === 'open'){
+      this.setData({showCart:true})
+    }else{
+      this.setData({showCart:false})
+    }
+  }
+})

+ 4 - 0
pages/food/food.json

@@ -0,0 +1,4 @@
+{
+  "usingComponents": {},
+  "navigationBarTitleText": "点餐"
+}

+ 119 - 0
pages/food/food.wxml

@@ -0,0 +1,119 @@
+
+ <view class="bx-tabs" wx:if="{{series.length > 0}}">
+     <view class="menu">
+         <scroll-view class="menu_content" scroll-x scroll-into-view="item_{{currentView}}" >
+            <block wx:for="{{series}}" wx:key="title" wx:for-index="index">
+               <view id="item_{{index}}" class="menu_item" bindtap="handleTabClick" data-index="{{index}}" data-seriesNo="{{item.id}}">
+                     <view class="">
+                        <text class="menu_title {{activeTab == index ? 'activeClass' : ''}}">{{item.title}}</text>
+                     </view>
+               </view>
+            </block>
+         </scroll-view>
+         <view class="icon">
+            <icon class="icon-small" type="search" size="18" color="black"></icon>
+         </view>
+     </view>
+     <swiper class="product_list" current="{{activeTab}}" duration="600" bindchange="handleSwiperChange" circular="true" >
+         <swiper-item wx:for="{{series}}" skip-hidden-item-layout="true" >
+             <view class="product_bg">
+                <view class="product_content_list" style="{{currentProductList[index].length > 4 ?'height:100%':''}}">
+                <block wx:for="{{currentProductList[index]}}" wx:key="product_id" wx:for-index="idx">
+                <view class="product-info">
+                  <block wx:if="{{item.productName}}">
+                   <view class="product_img_dir">
+                      <image  class="product_img" wx:if="{{!item.productImg}}" src="{{idx > 1 ? '../../images/good.png': '../../images/good2.png'}}" ></image>
+                      
+                     <image class="product_img" wx:if="{{item.productImg}}" src="{{item.productImg}}"></image>
+                     </view>
+                   <view class="good_name">
+                     {{item.productName}}
+                   </view>
+                   <view class="good_price">¥{{item.currentPrice}}
+                   </view>
+                   <view class="add-cart">
+                     <image bindtap="packages"  data-id="{{item.is_package}}" data-price="{{item.currentPrice}}" data-no="{{item.id}}" class="add-cart-size" src='../../images/jias.png'></image>
+                  
+                   </view>
+                  </block>
+                </view>
+                </block>
+                </view>
+             </view>
+         </swiper-item>
+     </swiper>
+     <view class="cart">
+         <view class="cart-icon cart-mar" bindtap="openCartDialog" data-type="open">
+            <image class="cart-icon-size" src="../../images/cart.png"></image>
+         </view>
+         <view class="cart-num cart-mar" bindtap="openCartDialog" data-type="open">
+            <text class="cart-num-txt" wx:if="{{haveChooseOrderDetails.length == 0}}">购物车空空如也~~~</text>
+            <text class="cart-num-txt" wx:if="{{haveChooseOrderDetails.length > 0}}">已点{{haveChooseOrderDetailNum}}个产品,点击查看详情</text>
+         </view>
+         <view class="buy-cart cart-mar" bindtap="start_order" wx:if="{{check_mobile}}">
+            <text class="buy-cart-txt">点好了</text>
+         </view>
+         
+         <view class="buy-cart cart-mar" wx:if="{{!check_mobile}}">
+            <button class="buy-cart-txt" style="background:none" open-type='getPhoneNumber' bindgetphonenumber="getPhoneNumber">点好了</button> 
+         </view>
+     </view>
+ </view>
+
+
+
+
+<view class="{{showCart ? 'weui-show' :'weui-hidden'}}"> 
+  <view class="weui-mask init" wx:if="{{mask}}" bindtap="openCartDialog" data-type="close"></view>
+  <view class="weui-half-screen-dialog cart-dialog">
+    <view class="weui-half-screen-dialog__hd cart-hd" >
+       <view class="discount-txt" wx:if="{{remainDecMoneyHas>0}}">已为您减免{{remainDecMoneyHas}}元</view>
+       <view class="discount-txt" wx:if="{{!remainDecMoneyHas>0 && !remainDecMoney>0}}"></view>
+       <view class="discount-txt" wx:if="{{remainDecMoney>0}}">再点{{remainDecMoney}}元,可减免{{remainDecMoneyReduce}}元</view>
+ 
+      <!-- <view class="weui-half-screen-dialog__hd__side" bindtap="close" data-type="close"> -->
+      <view bindtap="openCartDialog" data-type="close">
+        <view class=" weui-icon-btn_close">关闭</view>
+        </view>
+      <!-- </view> -->
+    </view>
+    <view class="weui-half-screen-dialog__bd" style="margin-top: 81rpx;max-height: 633rpx;">
+      <block>     
+         <view wx:for="{{haveChooseOrderDetails}}" class="weui-half-screen-dialog__desc cart-bd">
+           <image class="cart-good-img" wx:if="{{item.img}}" src="{{base_img_url}}{{item.img}}"></image>
+           <image class="cart-good-img" wx:if="{{!item.img}}" src="../../images/good.png"></image>
+           <view class="cart-info">
+              <view class="cart-good-name">
+                 {{item.product_name}}
+              </view>
+              <view wx:if="{{item.add}}">
+                <text wx:for="{{item.add}}" wx:for-item="add_item" style="margin-left:30rpx;font-weight:normal;font-size:30rpx">{{add_item.add_name}}</text>
+              </view>
+
+              <view class="cart-good-row">
+                 <view class="cart-good-price">{{item.product_price}}</view>
+                 <view class="cart-good-jia">
+                   <image class="add-cart-size" bindtap="{{canChooseProduct?'packages':''}}" wx:if="{{item.check_add == false}}" data-id="{{item.is_package}}" data-no="{{item.product_no}}" src='../../images/jias.png' ></image>
+                   <image class="add-cart-size" bindtap="{{canChooseProduct?'packages':''}}" wx:if="{{item.check_add == true}}" data-id="{{item.is_package}}" data-no="{{item.product_no}}" src='../../images/jias.png' ></image>
+                    <text class="cart-good-num">{{item.choose_num}}</text>
+                    <image class="add-cart-size" bindtap="deleteProduct" data-id="{{item.order_detail_id}}" data-no="{{item.product_no}}" src='../../images/cart-jian.png' ></image>
+
+
+
+                 </view>
+              </view>
+           </view>
+         </view>
+      </block>
+    </view>
+    <view class="weui-half-screen-dialog__ft" style="height: 50rpx;" wx:if="{{check_mobile}}" bindtap="start_order">
+      <button type="warn">去支付 </button>
+    </view>
+
+         <view class="weui-half-screen-dialog__ft" wx:if="{{!check_mobile}}">
+            <button style="color: #fff;background-color: #e64340;" open-type='getPhoneNumber' bindgetphonenumber="getPhoneNumber">去支付</button> 
+         </view>
+
+  </view>
+</view>
+

File diff suppressed because it is too large
+ 1153 - 0
pages/food/food.wxss


+ 38 - 3
pages/index/index.js

@@ -33,8 +33,8 @@ Page({
     pageNo: [1, 1, 1],
     pageSum: [],
     activeIndex: 0,
-    productHeight: 0
-
+    productHeight: 0,
+    isShowFood:true,
   },
 
 
@@ -359,5 +359,40 @@ Page({
     wx.navigateTo({
       url: '../appointment/appointment?' + 'shopId=' + shopId + '&productId=' + productId + '&address=' + address + "&shopName=" + shopName,
     })
-  }
+  },
+  goSmdd: function () {
+    console.log("11");
+        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: '二维码解析错误,重新扫描桌台码,谢谢!',
+                })
+              }
+            }
+          })
+         }
+      }
+)}
+
 })

+ 3 - 1
pages/index/index.wxml

@@ -50,5 +50,7 @@
     <!-- </view>
     </block> -->
   </view>
-
+  <view  class="orderFood" bindtap="goSmdd" wx:if="isShowFood">
+    <image src='/images/canju.png'></image>
+  </view>
 </view>

+ 20 - 0
pages/index/index.wxss

@@ -217,3 +217,23 @@ Page {
     top: -58rpx;
     color: #787878;
 }
+.orderFood{
+  position: fixed;
+  bottom:350rpx;
+  right:5rpx;
+  height: 80rpx;
+  width: 80rpx;
+  font-size:28rpx;
+  /* line-height: 30rpx; */
+  background: rgb(250,165,46);
+  border-radius: 40rpx;
+  text-align: center;
+  color: #fff;
+}
+
+.orderFood>image {
+  width: 50rpx;
+  height: 50rpx;
+  position: relative;
+  top: 15rpx;
+}

+ 1 - 1
project.config.json

@@ -45,7 +45,7 @@
     "minifyWXSS": true
   },
   "compileType": "miniprogram",
-  "libVersion": "2.10.4",
+  "libVersion": "2.16.0",
   "appid": "wx70aacbcde632b624",
   "projectname": "zy",
   "debugOptions": {

+ 7 - 0
project.private.config.json

@@ -1,4 +1,5 @@
 {
+  "setting": {},
   "condition": {
     "plugin": {
       "list": []
@@ -40,6 +41,12 @@
           "pathName": "pages/appointment/appointment",
           "query": "shopId=1&productId=1&address=上海普陀&shopName=测试门店",
           "scene": null
+        },
+        {
+          "name": "购买食物",
+          "pathName": "pages/food/food",
+          "query": "store_id=128&table_id=27994",
+          "scene": 1011
         }
       ]
     }

+ 9 - 1
utils/util.js

@@ -13,7 +13,15 @@ const formatNumber = n => {
   n = n.toString()
   return n[1] ? n : '0' + n
 }
+const getQueryString = (name, url)=> {
+  var subIndex = url.substr(url.indexOf('?'));
+  var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
+  var r = subIndex.substr(1).match(reg);
+  if (r != null) return unescape(r[2]);
+  return null;
+} 
 
 module.exports = {
-  formatTime: formatTime
+  formatTime: formatTime,
+  getQueryString: getQueryString
 }

File diff suppressed because it is too large
+ 4365 - 0
weui-wxss/weui.wxss