lrf 1 rok temu
rodzic
commit
0d468adb6b

+ 3 - 8
app.js

@@ -15,11 +15,8 @@ App({
         const { code: js_code } = res
         // 发送 res.code 到后台换取 openId, sessionKey, unionId
         wx.request({
-          url: `${app.globalData.publicUrl}/api/st/system/weixin/appAuth?js_code=` + js_code,
+          url: `${app.globalData.publicUrl}/st/api/weixin/appAuth?js_code=` + js_code,
           method: "get",
-          header: {
-            'x-tenant': app.globalData.tenant
-          },
           success: res => {
             const { errcode, data } = res.data
             if (errcode === 0) {
@@ -53,12 +50,10 @@ App({
     // 手机页面高度
     windowHeight: 0,
     // 请求接口
-    // publicUrl: 'http://192.168.1.19:9901',
-    publicUrl: 'https://www.waityou24.cn',
+    publicUrl: 'http://192.168.1.197:9902',
+    // publicUrl: 'https://www.waityou24.cn',
     // 图片请求接口
     fileUrl: "http://broadcast.waityou24.cn",
-    // 站点标识
-    tenant: "test",
   },
   // 微信openid回调
   toLogin: login.toLogin,

+ 33 - 26
pages/food/index.js

@@ -36,37 +36,44 @@ Page({
   /**
    * 生命周期函数--监听页面加载
    */
-  onLoad: function (options) {
+  onLoad: async function (options) {
     // 获取当前周的周一
     let weekOfday = parseInt(moment().format('d'));
     let start = moment().subtract(weekOfday - 1, 'days').format('YYYY-MM-DD');
     let end = moment().add(7 - weekOfday, 'days').format('YYYY-MM-DD');
     const query = `date@start=${start}&date@end=${end}`
-    wx.request({
-      url: `${app.globalData.publicUrl}/api/st/dining/arrange?${query}`,
-      method: "get",
-      header: {
-        'x-tenant': app.globalData.tenant
-      },
-      data: {},
-      success: res => {
-        for (const val of res.data.data) {
-          let style = {}
-          style.one = val.arrange.breakfast.length > 0 ? 30 * val.arrange.breakfast.length : 30;
-          style.two = val.arrange.lunch.length > 0 ? 30 * val.arrange.lunch.length : 30;
-          style.thr = val.arrange.dinner.length > 0 ? 30 * val.arrange.dinner.length : 30;
-          style.total = style.one + style.two + style.thr;
-          val.style = style;
-        }
-        this.setData({ list: res.data.data });
-      },
-      error: err => {
-        wx.showToast({
-          title: err.errmsg,
-          icon: 'error'
-        })
-      }
-    })
+    const res = await app.$get(`/arrange?${query}`);
+    for (const val of res.data) {
+      let style = {};
+      style.one = val.arrange.breakfast.length > 0 ? 30 * val.arrange.breakfast.length : 30;
+      style.two = val.arrange.lunch.length > 0 ? 30 * val.arrange.lunch.length : 30;
+      style.thr = val.arrange.dinner.length > 0 ? 30 * val.arrange.dinner.length : 30;
+      style.total = style.one + style.two + style.thr;
+      val.style = style;
+    }
+    this.setData({ list: res.data });
+    // wx.request({
+    //   url: `${app.globalData.publicUrl}/api/st/dining/arrange?${query}`,
+    //   method: "get",
+    //   data: {},
+    //   success: res => {
+    //     for (const val of res.data.data) {
+    //       let style = {}
+    //       style.one = val.arrange.breakfast.length > 0 ? 30 * val.arrange.breakfast.length : 30;
+    //       style.two = val.arrange.lunch.length > 0 ? 30 * val.arrange.lunch.length : 30;
+    //       style.thr = val.arrange.dinner.length > 0 ? 30 * val.arrange.dinner.length : 30;
+    //       style.total = style.one + style.two + style.thr;
+    //       val.style = style;
+    //     }
+    //     this.setData({ list: res.data.data });
+    //   },
+    //   error: err => {
+    //     wx.showToast({
+    //       title: err.errmsg,
+    //       icon: 'error'
+    //     })
+    //   }
+    // })
   },
   // 计算高度
   searchStyle: function (data) {

+ 60 - 68
pages/history/detail.js

@@ -1,8 +1,7 @@
 // pages/history/detail.js
-const app = getApp()
-import QRCode from '../../utils/weapp-qrcode'
+const app = getApp();
+import QRCode from '../../utils/weapp-qrcode';
 Page({
-
   /**
    * 页面的初始数据
    */
@@ -10,7 +9,7 @@ Page({
     height: app.globalData.height * 2 + 25,
     windowHeight: app.globalData.windowHeight,
     navbarData: {
-      name: '点餐详情'
+      name: '点餐详情',
     },
     logo: '',
     tenant: '',
@@ -24,42 +23,46 @@ Page({
   clearQR() {
     this.setData({ show: false });
   },
-  noop() { },
+  noop() {},
   // 返回
   back: function () {
     wx.reLaunch({
-      url: `/pages/history/index?openid=${app.globalData.wxInfo.openid}`
-    })
+      url: `/pages/history/index?openid=${app.globalData.wxInfo.openid}`,
+    });
   },
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
     this.searchST();
-    const { id, label, date } = options
+    const { id, label, date } = options;
     // let id = '60d3ed0c55bc8a3b58245b73';
     // let label = '午餐';
     // let date = '2021-06-25';
-    this.setData({ info: { label, date } })
+    this.setData({ info: { label, date } });
     this.getMeal(id);
     this.initQrCode(id);
   },
 
-  getMeal(id) {
-    wx.request({
-      url: `${app.globalData.publicUrl}/api/st/dining/order/getMeal/${id}`,
-      method: "GET",
-      header: { 'x-tenant': app.globalData.tenant },
-      success: (res) => {
-        if (res.data.errcode !== 0) return;
-        let arr = res.data.data;
-        arr = this.dealImg(arr)
-        this.setData({ meal: arr })
-      },
-      error: (e) => {
-        console.error(e)
-      }
-    })
+  async getMeal(id) {
+    const res = await app.$get(`/order/getMeal/${id}`);
+    if (res.data.errcode !== 0) return;
+    let arr = res.data.data;
+    arr = this.dealImg(arr);
+    this.setData({ meal: arr });
+    // wx.request({
+    //   url: `${app.globalData.publicUrl}/api/st/dining/order/getMeal/${id}`,
+    //   method: 'GET',
+    //   success: (res) => {
+    //     if (res.data.errcode !== 0) return;
+    //     let arr = res.data.data;
+    //     arr = this.dealImg(arr);
+    //     this.setData({ meal: arr });
+    //   },
+    //   error: (e) => {
+    //     console.error(e);
+    //   },
+    // });
   },
   dealImg(list) {
     for (let i of list.list) {
@@ -68,86 +71,75 @@ Page({
     }
     return list;
   },
-  searchST: function () {
-    wx.request({
-      url: `${app.globalData.publicUrl}/api/st/system/tenant/getTenant/${app.globalData.tenant}`,
-      method: "get",
-      header: { 'x-tenant': app.globalData.tenant },
-      data: {},
-      success: res => {
-        const { data } = res.data;
-        this.setData({ tenant: data.name });
-        this.setData({ logo: `${app.globalData.fileUrl}` + data.img.logo })
-      },
-      error: err => {
-        wx.showToast({
-          title: err.msg,
-          icon: 'error'
-        })
-      }
-    })
+  searchST: async function () {
+    const res = await app.$get('/config');
+    const logo = `${res.data.logo[0].url || ''}`;
+    this.setData({ logo });
+
+    // wx.request({
+    //   url: `${app.globalData.publicUrl}/api/st/system/tenant/getTenant/${app.globalData.tenant}`,
+    //   method: 'get',
+    //   data: {},
+    //   success: (res) => {
+    //     const { data } = res.data;
+    //     this.setData({ tenant: data.name });
+    //     this.setData({ logo: `${app.globalData.fileUrl}` + data.img.logo });
+    //   },
+    //   error: (err) => {
+    //     wx.showToast({
+    //       title: err.msg,
+    //       icon: 'error',
+    //     });
+    //   },
+    // });
   },
   // 创建二维码
   initQrCode(id) {
-    const url = `${app.globalData.publicUrl}/api/st/dining/order/useMeal/${id}?_tenant=${this.data.tenant}`;
+    const url = `${app.globalData.publicUrl}/st/api/order/useMeal/${id}`;
+    // const url = `${app.globalData.publicUrl}/api/st/dining/order/useMeal/${id}`;
     var qrcode = new QRCode(`myQrcode`, {
       text: url,
       width: 130,
       height: 130,
       padding: 3,
-      colorDark: "#000000",
-      colorLight: "#ffffff",
+      colorDark: '#000000',
+      colorLight: '#ffffff',
       correctLevel: QRCode.CorrectLevel.L,
     });
   },
 
-
   /**
    * 生命周期函数--监听页面初次渲染完成
    */
-  onReady: function () {
-
-  },
+  onReady: function () {},
 
   /**
    * 生命周期函数--监听页面显示
    */
-  onShow: function () {
-
-  },
+  onShow: function () {},
 
   /**
    * 生命周期函数--监听页面隐藏
    */
-  onHide: function () {
-
-  },
+  onHide: function () {},
 
   /**
    * 生命周期函数--监听页面卸载
    */
-  onUnload: function () {
-
-  },
+  onUnload: function () {},
 
   /**
    * 页面相关事件处理函数--监听用户下拉动作
    */
-  onPullDownRefresh: function () {
-
-  },
+  onPullDownRefresh: function () {},
 
   /**
    * 页面上拉触底事件的处理函数
    */
-  onReachBottom: function () {
-
-  },
+  onReachBottom: function () {},
 
   /**
    * 用户点击右上角分享
    */
-  onShareAppMessage: function () {
-
-  }
-})
+  onShareAppMessage: function () {},
+});

+ 35 - 48
pages/history/index.js

@@ -1,7 +1,6 @@
 // pages/home/index.js
-const app = getApp()
+const app = getApp();
 Page({
-
   /**
    * 页面的初始数据
    */
@@ -9,15 +8,15 @@ Page({
     height: app.globalData.height * 2 + 25,
     windowHeight: app.globalData.windowHeight,
     navbarData: {
-      name: '历史记录'
+      name: '历史记录',
     },
     activeName: 0,
     list: [],
     mealList: [
       { label: '早餐', key: 'breakfast' },
-      { label: "午餐", key: 'lunch' },
-      { label: "晚餐", key: "dinner" }
-    ]
+      { label: '午餐', key: 'lunch' },
+      { label: '晚餐', key: 'dinner' },
+    ],
   },
   onChange(event) {
     this.setData({ activeName: Number(event.detail) });
@@ -29,48 +28,46 @@ Page({
       url = `/pages/history/detail?id=${id}&label=${label}&date=${date}`;
     } else {
       url = null;
-      wx.showToast({ title: '未订餐' })
+      wx.showToast({ title: '未订餐' });
     }
     if (!url) return;
-    wx.redirectTo({ url })
+    wx.redirectTo({ url });
   },
   // 返回
   back: function () {
     wx.switchTab({
       url: '/pages/my/index',
-    })
+    });
   },
   /**
    * 生命周期函数--监听页面加载
    */
-  onLoad: function (options) {
-    if (options.openid) {
-      wx.request({
-        url: `${app.globalData.publicUrl}/api/st/dining/order?openid=${options.openid}`,
-        method: "get",
-        header: { 'x-tenant': app.globalData.tenant },
-        data: {},
-        success: res => {
-          const { data } = res.data;
-          this.setData({ list: data })
-        },
-        error: err => {
-          wx.showToast({
-            title: err.msg,
-            icon: 'error'
-          })
-        }
-      })
-    }
-
+  onLoad: async function (options) {
+    const res = await app.$get(`/order?openid=${options.openid}`);
+    this.setData({ list: res.data });
+    // if (options.openid) {
+    //   wx.request({
+    //     url: `${app.globalData.publicUrl}/api/st/dining/order?openid=${options.openid}`,
+    //     method: "get",
+    //     data: {},
+    //     success: res => {
+    //       const { data } = res.data;
+    //       this.setData({ list: data })
+    //     },
+    //     error: err => {
+    //       wx.showToast({
+    //         title: err.msg,
+    //         icon: 'error'
+    //       })
+    //     }
+    //   })
+    // }
   },
 
   /**
    * 生命周期函数--监听页面初次渲染完成
    */
-  onReady: function () {
-
-  },
+  onReady: function () {},
 
   /**
    * 生命周期函数--监听页面显示
@@ -87,35 +84,25 @@ Page({
   /**
    * 生命周期函数--监听页面隐藏
    */
-  onHide: function () {
-
-  },
+  onHide: function () {},
 
   /**
    * 生命周期函数--监听页面卸载
    */
-  onUnload: function () {
-
-  },
+  onUnload: function () {},
 
   /**
    * 页面相关事件处理函数--监听用户下拉动作
    */
-  onPullDownRefresh: function () {
-
-  },
+  onPullDownRefresh: function () {},
 
   /**
    * 页面上拉触底事件的处理函数
    */
-  onReachBottom: function () {
-
-  },
+  onReachBottom: function () {},
 
   /**
    * 用户点击右上角分享
    */
-  onShareAppMessage: function () {
-
-  }
-})
+  onShareAppMessage: function () {},
+});

+ 103 - 102
pages/home/index.js

@@ -1,22 +1,21 @@
 // pages/home/index.js
-const app = getApp()
-import QRCode from '../../utils/weapp-qrcode'
+const app = getApp();
+import QRCode from '../../utils/weapp-qrcode';
 Page({
-
   /**
    * 页面的初始数据
    */
   data: {
     height: app.globalData.height * 2 + 25,
     navbarData: {
-      name: '节俭会'
+      name: '节俭会',
     },
     // 背景图片
     background: '',
 
     // 热量占比
     heat: 100,
-    heatColor: { '0%': '#E1FFFF', '25%': '#00FF7F', '50%': '#191970', '75%': '#ee0a24', '100%': '#ff0000', },
+    heatColor: { '0%': '#E1FFFF', '25%': '#00FF7F', '50%': '#191970', '75%': '#ee0a24', '100%': '#ff0000' },
     // 微信运动
     step: 0,
     // 用餐卡
@@ -26,174 +25,176 @@ Page({
     tenant: '',
     // 餐列表
     thrList: [],
-
   },
   // 查看本周菜谱
   reserveBtn: function () {
     wx.redirectTo({
       url: '/pages/food/index',
-    })
+    });
   },
   // 报餐:1,余菜打包:2,卡路里计算:3
   twoBtn: function (e) {
-    let type = e.currentTarget.dataset.smile
-    if (type == '1') {//报餐
+    let type = e.currentTarget.dataset.smile;
+    if (type == '1') {
+      //报餐
       wx.switchTab({
         url: '/pages/reserve/index',
-      })
-    } else if (type == '2') {//余菜打包
+      });
+    } else if (type == '2') {
+      //余菜打包
       wx.showToast({
         title: '暂未开通',
-      })
-    } else {//卡路里计算
+      });
+    } else {
+      //卡路里计算
       wx.showToast({
         title: '暂未开通',
-      })
+      });
     }
   },
   /**
    * 生命周期函数--监听页面加载
    */
-  onLoad: function (options) {
-    // 登录,获取用户openid,sessonkey
-    app.toLogin().then(res => {
-      this.getMealCard();
-    });
+  onLoad: async function (options) {
+    await this.getMealCard();
     // 获取背景图片,站点信息
-    wx.request({
-      url: `${app.globalData.publicUrl}/api/st/system/tenant/getTenant/${app.globalData.tenant}`,
-      method: "get",
-      header: { 'x-tenant': app.globalData.tenant },
-      data: {},
-      success: res => {
-        const { data } = res.data;
-        this.setData({ background: `${app.globalData.fileUrl}` + data.img.home })
-        this.setData({ tenant: data.name })
-      },
-      error: err => {
-        wx.showToast({
-          title: err.msg,
-          icon: 'error'
-        })
-      }
-    })
-    // 获取微信运动信息
+    const res = await app.$get('/config');
+    const logo = `${res.data.logo[0].url || ''}`;
+    this.setData({ background: logo });
+
+    // wx.request({
+    //   url: `${app.globalData.publicUrl}/api/st/system/tenant/getTenant/${app.globalData.tenant}`,
+    //   method: 'get',
+    //   data: {},
+    //   success: (res) => {
+    //     const { data } = res.data;
+    //     this.setData({ background: `${app.globalData.fileUrl}` + data.img.home });
+    //     this.setData({ tenant: data.name });
+    //   },
+    //   error: (err) => {
+    //     wx.showToast({
+    //       title: err.msg,
+    //       icon: 'error',
+    //     });
+    //   },
+    // });
+    // TODO:获取微信运动信息
     wx.getWeRunData({
       success: (res) => {
-        const app = getApp()
-        const { encryptedData, iv } = res
+        const app = getApp();
+        const { encryptedData, iv } = res;
         const session_key = app.globalData.wxInfo.session_key;
-        const data = { encryptedData, iv, session_key }
+        const data = { encryptedData, iv, session_key };
         wx.request({
-          url: `${app.globalData.publicUrl}/api/st/system/weixin/decrypt`,
-          method: "POST",
+          url: `${app.globalData.publicUrl}/st/api/weixin/decrypt`,
+          method: 'POST',
           data,
-          header: {
-            'x-tenant': app.globalData.tenant
-          },
           success: (res) => {
-            const { stepInfo } = res.data.data;
-            if (stepInfo) this.setData({ step: stepInfo.step })
+            console.log(res)
+            const setpInfo = res.data?.data;
+            if (stepInfo) this.setData({ step: stepInfo.step });
           },
-        })
-      }
-    })
+        });
+      },
+    });
   },
 
   /**
    * 生命周期函数--监听页面初次渲染完成
    */
-  onReady: function () {
-
-  },
+  onReady: function () {},
 
   /**
    * 生命周期函数--监听页面显示
    */
   onShow: function () {
-    if (typeof this.getTabBar === 'function' &&
-      this.getTabBar()) {
+    if (typeof this.getTabBar === 'function' && this.getTabBar()) {
       this.getTabBar().setData({
-        selected: 0
-      })
+        selected: 0,
+      });
     }
   },
 
   /**
    * 生命周期函数--监听页面隐藏
    */
-  onHide: function () {
-
-  },
+  onHide: function () {},
 
   /**
    * 生命周期函数--监听页面卸载
    */
-  onUnload: function () {
-  },
+  onUnload: function () {},
 
   /**
    * 页面相关事件处理函数--监听用户下拉动作
    */
-  onPullDownRefresh: function () {
-
-  },
+  onPullDownRefresh: function () {},
 
   /**
    * 页面上拉触底事件的处理函数
    */
-  onReachBottom: function () {
-
-  },
+  onReachBottom: function () {},
 
   /**
    * 用户点击右上角分享
    */
-  onShareAppMessage: function () {
-
-  },
+  onShareAppMessage: function () {},
   // 获取用餐卡
-  getMealCard() {
+  async getMealCard() {
+    if(!app.globalData.wxInfo.openid) await app.toLogin();
     const openid = app.globalData.wxInfo.openid;
     if (!openid) return;
-    wx.request({
-      url: `${app.globalData.publicUrl}/api/st/dining/order/mealCard/${openid}`,
-      method: "POST",
-      header: {
-        'x-tenant': app.globalData.tenant
-      },
-      success: (res) => {
-        if (res.data.errcode === 0) {
-          const { data } = res.data
-          if (!data) {
-            this.setData({
-              thrList: [],
-            })
-            return;
-          }
-          this.initQrCode(data.data._id)
-          this.setData({
-            thrList: data.data.list || [],
-            thrTitle: data.type
-          })
-        }
-      },
-      error: (err) => {
-        console.error(err.data.errmsg)
+    const res = await app.$post(`/order/mealCard/${openid}`);
+    if (res.data.errcode === 0) {
+      const { data } = res.data;
+      if (!data) {
+        this.setData({
+          thrList: [],
+        });
+        return;
       }
-    })
+      this.initQrCode(data.data._id);
+      this.setData({
+        thrList: data.data.list || [],
+        thrTitle: data.type,
+      });
+    }
+    // wx.request({
+    //   url: `${app.globalData.publicUrl}/api/st/dining/order/mealCard/${openid}`,
+    //   method: 'POST',
+    //   success: (res) => {
+    //     if (res.data.errcode === 0) {
+    //       const { data } = res.data;
+    //       if (!data) {
+    //         this.setData({
+    //           thrList: [],
+    //         });
+    //         return;
+    //       }
+    //       this.initQrCode(data.data._id);
+    //       this.setData({
+    //         thrList: data.data.list || [],
+    //         thrTitle: data.type,
+    //       });
+    //     }
+    //   },
+    //   error: (err) => {
+    //     console.error(err.data.errmsg);
+    //   },
+    // });
   },
   // 创建二维码
   initQrCode(id) {
-    const url = `${app.globalData.publicUrl}/api/st/dining/order/useMeal/${id}?_tenant=${app.globalData.tenant}`;
+    const url = `${app.globalData.publicUrl}/st/api/order/useMeal/${id}`;
+    // const url = `${app.globalData.publicUrl}/api/st/dining/order/useMeal/${id}`;
     var qrcode = new QRCode(`myQrcode`, {
       text: url,
       width: 100,
       height: 100,
       padding: 3,
-      colorDark: "#000000",
-      colorLight: "#ffffff",
+      colorDark: '#000000',
+      colorLight: '#ffffff',
       correctLevel: QRCode.CorrectLevel.L,
     });
-  }
-})
+  },
+});

+ 97 - 111
pages/login/index.js

@@ -1,114 +1,100 @@
 // pages/login/index.js
-import WxValidate from '../../utils/wxValidate'
-const app = getApp()
+import WxValidate from '../../utils/wxValidate';
+const app = getApp();
 Page({
-
-    /**
-     * 页面的初始数据
-     */
-    data: {
-        height: app.globalData.height * 2 + 25,
-        background: '',
-        form: {},
-
-    },
-    initValidate() {
-        const rules = {
-            phone: { required: false, tel: true },
-            password: { required: false, },
-        }
-        // 验证字段的提示信息,若不传则调用默认的信息
-        const messages = {
-            phone: { required: '请输入账号', },
-            password: { required: '请输入密码', },
-        };
-        this.WxValidate = new WxValidate(rules, messages)
-    },
-    formSubmit: function (e) {
-        const params = e.detail.value;
-        if (!this.WxValidate.checkForm(params)) {
-            const error = this.WxValidate.errorList[0];
-            wx.showToast({
-                title: error.msg,
-                icon: 'error',
-                duration: 2000
-            })
-            return false
-        } else {
-            wx.switchTab({
-                url: '/pages/home/index',
-            })
-        }
-    },
-    /**
-     * 生命周期函数--监听页面加载
-     */
-    onLoad: function (options) {
-        this.initValidate()//验证规则函数
-        wx.request({
-            url: `${app.globalData.publicUrl}/api/st/system/tenant/getTenant/${app.globalData.tenant}`,
-            method: "get",
-            header: { 'x-tenant': app.globalData.tenant },
-            data: {},
-            success: res => {
-                const { data } = res.data;
-                this.setData({ background: `${app.globalData.fileUrl}` + data.img.login })
-            },
-            error: err => {
-                wx.showToast({
-                    title: err.msg,
-                    icon: 'error'
-                })
-            }
-        })
-    },
-
-    /**
-     * 生命周期函数--监听页面初次渲染完成
-     */
-    onReady: function () {
-
-    },
-
-    /**
-     * 生命周期函数--监听页面显示
-     */
-    onShow: function () {
-
-    },
-
-    /**
-     * 生命周期函数--监听页面隐藏
-     */
-    onHide: function () {
-
-    },
-
-    /**
-     * 生命周期函数--监听页面卸载
-     */
-    onUnload: function () {
-
-    },
-
-    /**
-     * 页面相关事件处理函数--监听用户下拉动作
-     */
-    onPullDownRefresh: function () {
-
-    },
-
-    /**
-     * 页面上拉触底事件的处理函数
-     */
-    onReachBottom: function () {
-
-    },
-
-    /**
-     * 用户点击右上角分享
-     */
-    onShareAppMessage: function () {
-
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    height: app.globalData.height * 2 + 25,
+    background: '',
+    form: {},
+  },
+  initValidate() {
+    const rules = {
+      phone: { required: false, tel: true },
+      password: { required: false },
+    };
+    // 验证字段的提示信息,若不传则调用默认的信息
+    const messages = {
+      phone: { required: '请输入账号' },
+      password: { required: '请输入密码' },
+    };
+    this.WxValidate = new WxValidate(rules, messages);
+  },
+  formSubmit: function (e) {
+    const params = e.detail.value;
+    if (!this.WxValidate.checkForm(params)) {
+      const error = this.WxValidate.errorList[0];
+      wx.showToast({
+        title: error.msg,
+        icon: 'error',
+        duration: 2000,
+      });
+      return false;
+    } else {
+      wx.switchTab({
+        url: '/pages/home/index',
+      });
     }
-})
+  },
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: async function (options) {
+    this.initValidate(); //验证规则函数
+    const res = await app.$get('/config');
+    const logo = `${res.data.logo[0].url || ''}`;
+    this.setData({ background: logo });
+    // wx.request({
+    //   url: `${app.globalData.publicUrl}/api/st/system/tenant/getTenant/${app.globalData.tenant}`,
+    //   method: 'get',
+    //   data: {},
+    //   success: (res) => {
+    //     const { data } = res.data;
+    //     this.setData({ background: `${app.globalData.fileUrl}` + data.img.login });
+    //   },
+    //   error: (err) => {
+    //     wx.showToast({
+    //       title: err.msg,
+    //       icon: 'error',
+    //     });
+    //   },
+    // });
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {},
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {},
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {},
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {},
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {},
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {},
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {},
+});

+ 21 - 18
pages/news/detail.js

@@ -23,25 +23,28 @@ Page({
   /**
    * 生命周期函数--监听页面加载
    */
-  onLoad: function (options) {
+  onLoad: async function (options) {
     console.log(options.id);
-    wx.request({
-      url: `${app.globalData.publicUrl}/api/st/system/news/${options.id}`,
-      method: "get",
-      header: { 'x-tenant': app.globalData.tenant },
-      data: {},
-      success: res => {
-        var result = res.data.data;
-        result.content = formatRichText(result.content)
-        this.setData({ detailInfo: result })
-      },
-      error: err => {
-        wx.showToast({
-          title: err.msg,
-          icon: 'error'
-        })
-      }
-    })
+    const res = await app.$get(`/news/${options.id}`);
+    var result = res.data.data;
+    result.content = formatRichText(result.content);
+    this.setData({ detailInfo: result });
+    // wx.request({
+    //   url: `${app.globalData.publicUrl}/api/st/system/news/${options.id}`,
+    //   method: "get",
+    //   data: {},
+    //   success: res => {
+    //     var result = res.data.data;
+    //     result.content = formatRichText(result.content)
+    //     this.setData({ detailInfo: result })
+    //   },
+    //   error: err => {
+    //     wx.showToast({
+    //       title: err.msg,
+    //       icon: 'error'
+    //     })
+    //   }
+    // })
   },
 
   /**

+ 29 - 82
pages/news/index.js

@@ -1,7 +1,6 @@
 // pages/home/index.js
-const app = getApp()
+const app = getApp();
 Page({
-
   /**
    * 页面的初始数据
    */
@@ -9,17 +8,17 @@ Page({
     height: app.globalData.height * 2 + 25,
     windowHeight: app.globalData.windowHeight,
     navbarData: {
-      name: '新闻'
+      name: '新闻',
     },
     logo: '',
     currentTab: 0,
     // 國内新聞
     oneList: [],
-    twoList: []
+    twoList: [],
   },
   // 禁止左右滑动
   stopTab: function (e) {
-    return false
+    return false;
   },
   //点击切换
   clickTab: function (e) {
@@ -28,52 +27,26 @@ Page({
       return false;
     } else {
       that.setData({
-        currentTab: e.target.dataset.current
-      })
+        currentTab: e.target.dataset.current,
+      });
     }
   },
   detail: function (data) {
     wx.navigateTo({
-      url: `/pages/news/detail?id=${data.detail.id}`
-    })
+      url: `/pages/news/detail?id=${data.detail.id}`,
+    });
   },
   /**
    * 生命周期函数--监听页面加载
    */
-  onLoad: function (options) {
+  onLoad: async function (options) {
     this.searchST();
-    wx.request({
-      url: `${app.globalData.publicUrl}/api/st/system/news`,
-      method: "get",
-      header: { 'x-tenant': app.globalData.tenant },
-      data: { "type": '国内新闻' },
-      success: res => {
-        let data = this.dealImg(res.data.data)
-        this.setData({ oneList: data })
-      },
-      error: err => {
-        wx.showToast({
-          title: err.msg,
-          icon: 'error'
-        })
-      }
-    })
-    wx.request({
-      url: `${app.globalData.publicUrl}/api/st/system/news`,
-      method: "get",
-      header: { 'x-tenant': app.globalData.tenant },
-      data: { "type": '健康资讯' },
-      success: res => {
-        let data = this.dealImg(res.data.data)
-        this.setData({ twoList: data })
-      },
-      error: err => {
-        wx.showToast({
-          title: err.msg,
-          icon: 'error'
-        })
-      }
-    })
+    const res = await app.$get('/news', { type: '国内新闻' });
+    let data = this.dealImg(res.data.data);
+    this.setData({ oneList: data });
+    const res2 = await app.$get('/news', { type: '健康资讯' });
+    let data2 = this.dealImg(res2.data.data);
+    this.setData({ twoList: data2 });
   },
   dealImg(list) {
     for (let i of list) {
@@ -82,76 +55,50 @@ Page({
     }
     return list;
   },
-  searchST: function () {
-    wx.request({
-      url: `${app.globalData.publicUrl}/api/st/system/tenant/getTenant/${app.globalData.tenant}`,
-      method: "get",
-      header: { 'x-tenant': app.globalData.tenant },
-      data: {},
-      success: res => {
-        const { data } = res.data;
-        this.setData({ logo: `${app.globalData.fileUrl}` + data.img.logo })
-      },
-      error: err => {
-        wx.showToast({
-          title: err.msg,
-          icon: 'error'
-        })
-      }
-    })
+  searchST: async function () {
+    const res = await app.$get('/config');
+    const logo = `${res.data.logo[0].url || ''}`;
+    this.setData({ logo });
   },
 
   /**
    * 生命周期函数--监听页面初次渲染完成
    */
-  onReady: function () {
-
-  },
+  onReady: function () {},
 
   /**
    * 生命周期函数--监听页面显示
    */
   onShow: function () {
-    if (typeof this.getTabBar === 'function' &&
-      this.getTabBar()) {
+    if (typeof this.getTabBar === 'function' && this.getTabBar()) {
       this.getTabBar().setData({
-        selected: 2
-      })
+        selected: 2,
+      });
     }
   },
 
   /**
    * 生命周期函数--监听页面隐藏
    */
-  onHide: function () {
-
-  },
+  onHide: function () {},
 
   /**
    * 生命周期函数--监听页面卸载
    */
-  onUnload: function () {
-
-  },
+  onUnload: function () {},
 
   /**
    * 页面相关事件处理函数--监听用户下拉动作
    */
-  onPullDownRefresh: function () {
-
-  },
+  onPullDownRefresh: function () {},
 
   /**
    * 页面上拉触底事件的处理函数
    */
-  onReachBottom: function () {
-
-  },
+  onReachBottom: function () {},
 
   /**
    * 用户点击右上角分享
    */
-  onShareAppMessage: function () {
-
-  }
-})
+  onShareAppMessage: function () {},
+});

+ 149 - 143
pages/reserve/index.js

@@ -2,13 +2,12 @@
 import moment, { parseTwoDigitYear } from '../../utils/moment.min';
 moment.locale('en', {
   longDateFormat: {
-    l: "YYYY-MM-DD",
-    L: "YYYY-MM-DD HH:mm:ss",
+    l: 'YYYY-MM-DD',
+    L: 'YYYY-MM-DD HH:mm:ss',
   },
-})
-const app = getApp()
+});
+const app = getApp();
 Page({
-
   /**
    * 页面的初始数据
    */
@@ -16,7 +15,7 @@ Page({
     height: app.globalData.height * 2 + 25,
     windowHeight: app.globalData.windowHeight,
     navbarData: {
-      name: '报餐'
+      name: '报餐',
     },
     tenant: '',
     logo: '',
@@ -24,7 +23,7 @@ Page({
     // 点餐
     currentTab: 0,
     // 早餐,午餐,晚餐
-    infoTab: 0,
+    infoTab: '0',
     // 餐列表
     breakfastList: [],
     lunchList: [],
@@ -35,23 +34,23 @@ Page({
     thrStepper: 0,
     // 选餐表单
     form: {
-      breakfast: { reserve: 0, list: [], },
-      lunch: { reserve: 0, list: [], },
-      dinner: { reserve: 0, list: [], },
+      breakfast: { reserve: 0, list: [] },
+      lunch: { reserve: 0, list: [] },
+      dinner: { reserve: 0, list: [] },
     },
     // 时间选择范围
     picker: {},
   },
   // 选择日期
   bindDateChange: async function (e) {
-    console.log('picker发送选择改变,携带值为', e.detail.value)
-    this.setData({ today: e.detail.value })
+    console.log('picker发送选择改变,携带值为', e.detail.value);
+    this.setData({ today: e.detail.value });
     await this.searchDate();
     await this.searchOrder();
   },
   // 禁止左右滑动
   stopTab: function (e) {
-    return false
+    return false;
   },
   //点击切换
   clickTab: function (e) {
@@ -60,8 +59,8 @@ Page({
       return false;
     } else {
       that.setData({
-        currentTab: e.target.dataset.current
-      })
+        currentTab: e.target.dataset.current,
+      });
     }
   },
   // 点击选择餐食
@@ -70,57 +69,63 @@ Page({
     let data = e.target.dataset.current;
     if (this.data.infoTab === data) return false;
     else that.setData({ infoTab: data });
-
   },
   // 选择餐数量
   // 早餐,午餐,晚餐
   oneChange: function (e) {
     console.log(e);
-    const { data, type } = e.target.dataset
+    const { data, type } = e.target.dataset;
     const { detail } = e;
-    this.menuNumOpera(type, detail, data._id)
+    this.menuNumOpera(type, detail, data._id);
   },
   // 增加
   onePlus: function (e) {
     console.log('增加');
     let data = e.target.dataset.data;
     let type = this.data.infoTab;
+    console.log(typeof type);
+    let initMealData = { list: [], reserve: 0 };
     let meal;
     let mw;
-    if (type == 0) {//早餐
-      mw = 'breakfast';
-      meal = this.data.form.breakfast;
-      // 计算卡路里
-      let reserve = meal.reserve + data.reserve;
-      this.setData({ 'form.breakfast.reserve': reserve })
-    } else if (type == 1) {//午餐
-      mw = 'lunch';
-      meal = this.data.form.lunch;
-      // 计算卡路里
-      let reserve = meal.reserve + data.reserve;
-      this.setData({ 'form.lunch.reserve': reserve })
-    } else if (type == 2) {//晚餐
-      mw = 'dinner';
-      meal = this.data.form.dinner;
-      // 计算卡路里
-      let reserve = meal.reserve + data.reserve;
-      this.setData({ 'form.dinner.reserve': reserve })
+    switch (type) {
+      case '0':
+        mw = 'breakfast';
+        meal = this.data.form.breakfast;
+        break;
+      case '1':
+        mw = 'lunch';
+        meal = this.data.form.lunch;
+        break;
+      case '2':
+        mw = 'dinner';
+        meal = this.data.form.dinner;
+        break;
+
+      default:
+        break;
     }
+    if (!meal) meal = initMealData;
+    // 计算卡路里
+    meal.reserve = meal.reserve + data.reserve;
     // 查询下标
-    let res = meal.list.findIndex(i => i.id === data.id);
+    let res = meal.list.findIndex((i) => i._id === data._id);
     // 查询数据
-    let arr = meal.list.find(i => i.id === data.id);
+    let arr = meal.list.find((i) => i._id === data._id);
     let onum = 0;
-    if (arr) {//已有值
+    if (arr) {
+      //已有值
       onum = arr.num + 1;
-      let qwe = { ...arr, num: onum } //id: arr.id, title: arr.title
-      meal.list.splice(res, 1, qwe)
-    } else {//没有值
-      console.log(data)
+      let qwe = { ...arr, num: onum }; //id: arr.id, title: arr.title
+      meal.list.splice(res, 1, qwe);
+    } else {
+      //没有值
       let onum = 1;
-      let arr = { ...data, num: onum } //id: data.id, title: data.title
-      meal.list.push(arr)
+      let arr = { ...data, num: onum }; //id: data.id, title: data.title
+      meal.list.push(arr);
     }
+    const key = `form.${mw}`;
+    this.setData({ [key]: meal });
+    this.computedTotalReserve();
   },
   /**
    * 更新菜单的数量
@@ -130,16 +135,16 @@ Page({
    */
   menuNumOpera(type, num, id) {
     let list = this.data[`${type}List`];
-    console.log(list)
-    const li = list.findIndex(f => f._id === id)
-    const ld = list.find(f => f._id === id)
-    console.log(li, id)
+    console.log(list);
+    const li = list.findIndex((f) => f._id === id);
+    const ld = list.find((f) => f._id === id);
+    console.log(li, id);
     if (ld) {
       ld.num = num;
-      list.splice(li, 1, ld)
+      list.splice(li, 1, ld);
       this.setData({
-        [`${type}List`]: list
-      })
+        [`${type}List`]: list,
+      });
     }
   },
 
@@ -148,51 +153,62 @@ Page({
     console.log('减少');
     let data = e.target.dataset.data;
     let type = this.data.infoTab;
+    let initMealData = { list: [], reserve: 0 };
     let meal;
     let mw;
-    if (type == 0) {//早餐
-      mw = 'breakfast';
-      meal = this.data.form.breakfast;
-      // 计算减少卡路里
-      let reserve = meal.reserve - data.reserve;
-      this.setData({ 'form.breakfast.reserve': reserve })
-    } else if (type == 1) {//午餐
-      mw = 'lunch';
-      meal = this.data.form.lunch;
-      // 计算减少卡路里
-      let reserve = meal.reserve - data.reserve;
-      this.setData({ 'form.lunch.reserve': reserve })
-    } else if (type == 2) {//晚餐
-      mw = 'dinner';
-      meal = this.data.form.dinner;
-      // 计算减少卡路里
-      let reserve = meal.reserve - data.reserve;
-      this.setData({ 'form.dinner.reserve': reserve })
+    switch (type) {
+      case '0':
+        mw = 'breakfast';
+        meal = this.data.form.breakfast;
+        break;
+      case '1':
+        mw = 'lunch';
+        meal = this.data.form.lunch;
+        break;
+      case '2':
+        mw = 'dinner';
+        meal = this.data.form.dinner;
+        break;
+
+      default:
+        break;
     }
+    if (!meal) meal = initMealData;
+    // 计算卡路里
+    meal.reserve = meal.reserve - data.reserve;
     // 查询下标
-    let res = meal.list.findIndex(i => i.id === data.id);
+    let res = meal.list.findIndex((i) => i._id === data._id);
     // 查询数据
-    let arr = meal.list.find(i => i.id === data.id);
+    let arr = meal.list.find((i) => i._id === data._id);
     if (arr) {
-      if (arr.num - 1 <= 0) meal.list.splice(res, 1)
+      if (arr.num - 1 <= 0) meal.list.splice(res, 1);
       else {
-        let qwe = { ...arr, num: arr.num - 1 }
-        meal.list.splice(res, 1, qwe)
+        let qwe = { ...arr, num: arr.num - 1 };
+        meal.list.splice(res, 1, qwe);
       }
-
     }
-    // this.menuNumOpera(mw, onum, data._id)
+    const key = `form.${mw}`;
+    this.setData({ [key]: meal });
+    this.computedTotalReserve();
+  },
+  computedTotalReserve() {
+    const form = this.data.form;
+    const br = form.breakfast && form.breakfast.reserve ? form.breakfast.reserve : 0;
+    const lr = form.lunch && form.lunch.reserve ? form.lunch.reserve : 0;
+    const dr = form.dinner && form.dinner.reserve ? form.dinner.reserve : 0;
+    const total = br + lr + dr;
+    this.setData({ totalReserve: total });
   },
   // 提交
   onSubmit: async function () {
-    const data = JSON.parse(JSON.stringify(this.data.form))
+    const data = JSON.parse(JSON.stringify(this.data.form));
     if (app.globalData.wxInfo) data.openid = app.globalData.wxInfo.openid;
     if (this.data.today) data.date = this.data.today;
     let url;
-    if (data._id) url = `${app.globalData.publicUrl}/api/st/dining/order/update/${data._id}`
-    else url = `${app.globalData.publicUrl}/api/st/dining/order`;
+    if (data._id) url = `/order/update/${data._id}`;
+    else url = `/order`;
     const res = await app.$post(url, data);
-    if (res.errcode === 0) wx.showToast({ title: '点餐成功', icon: 'success' })
+    if (res.errcode === 0) wx.showToast({ title: '点餐成功', icon: 'success' });
   },
   /**
    * 生命周期函数--监听页面加载
@@ -201,66 +217,69 @@ Page({
     this.searchST();
     let today = moment().add(1, 'days').format('YYYY-MM-DD');
     let endday = moment().add(1, 'months').format('YYYY-MM-DD');
-    this.setData({ today: today, picker: { start: today, end: endday } })
+    this.setData({ today: today, picker: { start: today, end: endday } });
     await this.searchDate();
     await this.searchOrder();
   },
   // 查询时间
   searchDate: async function () {
     let today = this.data.today;
-    const res = await app.$get(`${app.globalData.publicUrl}/api/st/dining/arrange/getByDate?date=${today}`)
+    const res = await app.$get(`/arrange/getByDate?date=${today}`);
     const { arrange } = res.data;
     if (!arrange) return;
-    let { breakfast, lunch, dinner } = arrange
-    breakfast = this.dealImg(breakfast)
-    lunch = this.dealImg(lunch)
-    dinner = this.dealImg(dinner)
+    let { breakfast, lunch, dinner } = arrange;
+    breakfast = this.dealImg(breakfast);
+    lunch = this.dealImg(lunch);
+    dinner = this.dealImg(dinner);
     this.setData({
       breakfastList: breakfast,
       lunchList: lunch,
-      dinnerList: dinner
-    })
+      dinnerList: dinner,
+    });
   },
   dealImg(list) {
     for (let i of list) {
-      if (i.img && i.img.length > 0 && i.img[0]) i.url = `${app.globalData.fileUrl}${i.img[0].url}`;
+      if (i.img && i.img.length > 0 && i.img[0]) i.url = `${i.img[0].url}`;
       else i.url = this.data.logo;
     }
     return list;
   },
   searchST: async function () {
-    wx.request({
-      url: `${app.globalData.publicUrl}/api/st/system/tenant/getTenant/${app.globalData.tenant}`,
-      method: "get",
-      header: { 'x-tenant': app.globalData.tenant },
-      data: {},
-      success: res => {
-        const { data } = res.data;
-        this.setData({ tenant: data.name });
-        this.setData({ logo: `${app.globalData.fileUrl}` + data.img.logo })
-      },
-      error: err => {
-        wx.showToast({
-          title: err.msg,
-          icon: 'error'
-        })
-      }
-    })
+    const res = await app.$get('/config');
+    const logo = `${res.data.logo[0].url || ''}`;
+    this.setData({ logo });
+    // wx.request({
+    //   url: `${app.globalData.publicUrl}/api/st/system/tenant/getTenant/${app.globalData.tenant}`,
+    //   method: "get",
+    //   data: {},
+    //   success: res => {
+    //     const { data } = res.data;
+    //     this.setData({ tenant: data.name });
+    //     this.setData({ logo: `${app.globalData.fileUrl}` + data.img.logo })
+    //   },
+    //   error: err => {
+    //     wx.showToast({
+    //       title: err.msg,
+    //       icon: 'error'
+    //     })
+    //   }
+    // })
   },
   // 查订单
   async searchOrder() {
     let today = this.data.today;
     let openid = app.globalData.wxInfo.openid;
-    const res = await app.$get(`${app.globalData.publicUrl}/api/st/dining/order/getByOpenid?date=${today}&openid=${openid}`)
-    const { data } = res
-    if (!data) return
+    const res = await app.$get(`/order/getByOpenid?date=${today}&openid=${openid}`);
+    const { data } = res;
+    if (!data) return;
     this.setData({
       form: res.data,
-    })
-    const robj = res.data
-    if (robj.breakfast && robj.breakfast.list && robj.breakfast.list.length > 0) this.dealOrderToMenu('breakfast', robj.breakfast.list)
-    if (robj.lunch && robj.lunch.list && robj.lunch.list.length > 0) this.dealOrderToMenu('lunch', robj.lunch.list)
-    if (robj.dinner && robj.dinner.list && robj.dinner.list.length > 0) this.dealOrderToMenu('dinner', robj.dinner.list)
+    });
+    const robj = res.data;
+    if (robj.breakfast && robj.breakfast.list && robj.breakfast.list.length > 0) this.dealOrderToMenu('breakfast', robj.breakfast.list);
+    if (robj.lunch && robj.lunch.list && robj.lunch.list.length > 0) this.dealOrderToMenu('lunch', robj.lunch.list);
+    if (robj.dinner && robj.dinner.list && robj.dinner.list.length > 0) this.dealOrderToMenu('dinner', robj.dinner.list);
+    this.computedTotalReserve();
   },
   /**
    * 将点过的单还原,继续修改
@@ -268,70 +287,57 @@ Page({
    * @param {Array} list 某餐的内容
    */
   dealOrderToMenu(type, list) {
-    console.log(type, list)
+    console.log(type, list);
     if (list.length <= 0) return;
-    const menu = this.data[`${type}List`]
+    const menu = this.data[`${type}List`];
     if (!menu) {
-      console.log('没找到菜单')
+      console.log('没找到菜单');
       return;
     }
     for (const o of list) {
-      const { num, _id } = o
-      this.menuNumOpera(type, num, _id)
+      const { num, _id } = o;
+      this.menuNumOpera(type, num, _id);
     }
   },
 
   /**
    * 生命周期函数--监听页面初次渲染完成
    */
-  onReady: function () {
-
-  },
+  onReady: function () {},
 
   /**
    * 生命周期函数--监听页面显示
    */
   onShow: function () {
-    if (typeof this.getTabBar === 'function' &&
-      this.getTabBar()) {
+    if (typeof this.getTabBar === 'function' && this.getTabBar()) {
       this.getTabBar().setData({
-        selected: 1
-      })
+        selected: 1,
+      });
     }
   },
 
   /**
    * 生命周期函数--监听页面隐藏
    */
-  onHide: function () {
-
-  },
+  onHide: function () {},
 
   /**
    * 生命周期函数--监听页面卸载
    */
-  onUnload: function () {
-
-  },
+  onUnload: function () {},
 
   /**
    * 页面相关事件处理函数--监听用户下拉动作
    */
-  onPullDownRefresh: function () {
-
-  },
+  onPullDownRefresh: function () {},
 
   /**
    * 页面上拉触底事件的处理函数
    */
-  onReachBottom: function () {
-
-  },
+  onReachBottom: function () {},
 
   /**
    * 用户点击右上角分享
    */
-  onShareAppMessage: function () {
-
-  }
-})
+  onShareAppMessage: function () {},
+});

+ 5 - 5
pages/reserve/index.wxml

@@ -1,7 +1,7 @@
 <nav-bar navbar-data='{{navbarData}}' needBack="{{false}}"></nav-bar>
 <view class="main" style="padding-top:{{height}}px;height:{{windowHeight-height}}px">
   <view class="one">
-    <view class="one_1">您的绑定餐厅为:{{tenant}}</view>
+   <!-- <view class="one_1">您的绑定餐厅为:{{tenant}}</view> -->
     <view class="one_2">
       <view>请您在前一天21点前报餐</view>
       <view>
@@ -18,9 +18,9 @@
     </view>
     <swiper current="{{currentTab}}" style="height:{{windowHeight-height-138}}px">
       <swiper-item catchtouchmove="stopTab">
-        <view class="two_1" style="height:{{windowHeight-height-138}}px">
-          <view class="info" style="height:{{windowHeight-height-188}}px">
-            <view class="info_left" style="height:{{windowHeight-height-188}}px">
+        <view class="two_1" style="height:{{windowHeight-height-200}}px">
+          <view class="info" style="height:{{windowHeight-height-240}}px">
+            <view class="info_left" style="height:{{windowHeight-height-240}}px">
               <view class="infoTab {{infoTab==0?'infoActive':''}}" data-current="0" bindtap="infoClickTab">早餐</view>
               <view class="infoTab {{infoTab==1?'infoActive':''}}" data-current="1" bindtap="infoClickTab">午餐</view>
               <view class="infoTab {{infoTab==2?'infoActive':''}}" data-current="2" bindtap="infoClickTab">晚餐</view>
@@ -101,7 +101,7 @@
           </view>
           <view class="btn">
             <view class="btn_1">
-              卡路里:{{form.breakfast.reserve+form.lunch.reserve+form.dinner.reserve}}
+              卡路里:{{totalReserve}}
             </view>
             <view class="btn_2">
               <button type="primary" bindtap="onSubmit">完成</button>

+ 2 - 2
project.private.config.json

@@ -1,7 +1,7 @@
 {
     "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
-    "projectname": "%E9%A3%9F%E5%A0%82",
+    "projectname": "smart-canteen",
     "setting": {
-        "compileHotReLoad": false
+        "compileHotReLoad": true
     }
 }

+ 1 - 10
utils/httpUtil.js

@@ -1,41 +1,32 @@
-let baseUrl = "";
+let baseUrl = 'http://192.168.1.197:9902/st/api';
 const $get = (uri, data) => {
-    let app = getApp();
-    let tenant = app.tenant || "master";
     return new Promise((resolve, reject) => {
         wx.request({
             url: `${baseUrl}${uri}`,
             method: "get",
             data,
-            header: { "x-tenant": tenant },
             success: (res) => toResolve(resolve, res),
             error: (e) => toReject(reject, e),
         });
     });
 };
 const $post = (uri, data) => {
-    let app = getApp();
-    let tenant = app.tenant || "master";
     return new Promise((resolve, reject) => {
         wx.request({
             url: `${baseUrl}${uri}`,
             method: "post",
             data,
-            header: { "x-tenant": tenant },
             success: (res) => toResolve(resolve, res),
             error: (e) => toReject(reject, e),
         });
     });
 };
 const $delete = (uri, data) => {
-    let app = getApp();
-    let tenant = app.tenant || "master";
     return new Promise((resolve, reject) => {
         wx.request({
             url: `${baseUrl}${uri}`,
             method: "delete",
             data,
-            header: { "x-tenant": tenant },
             success: (res) => toResolve(resolve, res),
             error: (e) => toReject(reject, e),
         });

+ 1 - 4
utils/login.js

@@ -8,11 +8,8 @@ module.exports = {
           const { code: js_code } = res
           // 发送 res.code 到后台换取 openId, sessionKey, unionId
           wx.request({
-            url: `${app.globalData.publicUrl}/api/st/system/weixin/appAuth?js_code=` + js_code,
+            url: `${app.globalData.publicUrl}/st/api/weixin/appAuth?js_code=` + js_code,
             method: "get",
-            header: {
-              'x-tenant': app.globalData.tenant
-            },
             success: res => {
               const { errcode, data } = res.data
               if (errcode === 0) {