guhongwei před 3 roky
rodič
revize
554508bb13
1 změnil soubory, kde provedl 9 přidání a 6 odebrání
  1. 9 6
      pages/home/index.js

+ 9 - 6
pages/home/index.js

@@ -14,6 +14,7 @@ Page({
     background: '',
     tenant: '',
     heat: 80,
+    step: 0,
     heatColor: {
       '0%': '#E1FFFF',
       '25%': '#00FF7F',
@@ -70,6 +71,9 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
+    app.toLogin().then(res => {
+      this.getMealCard();
+    });
     wx.request({
       url: `${app.globalData.publicUrl}/api/st/system/tenant/getTenant/${app.globalData.tenant}`,
       method: "get",
@@ -88,9 +92,9 @@ Page({
       }
     })
     wx.getWeRunData({
-      success(res) {
+      success: (res) => {
         const { encryptedData, iv } = res
-        const session_key = app.globalData.wxInfo.session_key
+        const session_key = app.globalData.wxInfo.session_key;
         const data = { encryptedData, iv, session_key }
         // // 拿 encryptedData 到开发者后台解密开放数据
         wx.request({
@@ -101,14 +105,13 @@ Page({
             'x-tenant': app.globalData.tenant
           },
           success: (res) => {
-            console.log(res);
+            const { stepInfo } = res.data.data;
+            if (stepInfo) this.setData({ step: stepInfo.step })
           },
         })
       }
     })
-    app.toLogin().then(res => {
-      this.getMealCard();
-    });
+
   },
 
   /**