guhongwei vor 3 Jahren
Ursprung
Commit
af98aad2e4
5 geänderte Dateien mit 53 neuen und 4 gelöschten Zeilen
  1. 2 1
      app.js
  2. 2 2
      app.json
  3. 29 0
      pages/food/index.js
  4. 19 0
      pages/home/index.js
  5. 1 1
      project.config.json

+ 2 - 1
app.js

@@ -22,7 +22,8 @@ App({
   globalData: {
     userInfo: null,
     height: 0,
-    windowHeight: 0
+    windowHeight: 0,
+    publicUrl: 'http://192.168.1.19:9901'
   }
 })
 

+ 2 - 2
app.json

@@ -1,9 +1,9 @@
 {
   "pages": [
-    "pages/login/index",
+    "pages/food/index",
     "pages/home/index",
+    "pages/login/index",
     "pages/calorie/index",
-    "pages/food/index",
     "pages/reserve/index",
     "pages/news/index",
     "pages/news/detail",

+ 29 - 0
pages/food/index.js

@@ -1,4 +1,11 @@
 // pages/home/index.js
+import moment, { parseTwoDigitYear } from '../../utils/moment.min';
+moment.locale('en', {
+  longDateFormat: {
+    l: "YYYY-MM-DD",
+    L: "YYYY-MM-DD HH:mm:ss",
+  },
+})
 const app = getApp()
 Page({
 
@@ -23,6 +30,28 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: 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': 'test'
+      },
+      data: {},
+      success: res => {
+        console.log(res.data);
+      },
+      error: err => {
+        wx.showToast({
+          title: err.msg,
+          icon: 'error'
+        })
+      }
+    })
   },
 
   /**

+ 19 - 0
pages/home/index.js

@@ -46,7 +46,26 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
+    // const test = `${app.globalData.publicUrl}/api/st/dining/arrange`;
+    // console.log(test);
+    wx.request({
+      url: `${app.globalData.publicUrl}/api/st/dining/arrange`,
+      method: "get",
+      header: {
+        'x-tenant': 'test'
+      },
+      data: {},
 
+      success: res => {
+        console.log(res);
+      },
+      error: err => {
+        wx.showToast({
+          title: err.msg,
+          icon: 'error'
+        })
+      }
+    })
   },
 
   /**

+ 1 - 1
project.config.json

@@ -4,7 +4,7 @@
     "ignore": []
   },
   "setting": {
-    "urlCheck": true,
+    "urlCheck": false,
     "es6": true,
     "enhance": false,
     "postcss": true,