zs 3 years ago
parent
commit
ec6a1b0116
2 changed files with 28 additions and 7 deletions
  1. 2 1
      app.json
  2. 26 6
      pages/login/index.js

+ 2 - 1
app.json

@@ -1,7 +1,8 @@
 {
   "pages": [
-    "pages/home/index",
     "pages/login/index",
+    "pages/home/index",
+   
     "pages/search/index",
     "pages/administration/index",
     "pages/administration/detail",

+ 26 - 6
pages/login/index.js

@@ -26,11 +26,31 @@ Page({
       wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
       return false
     } else {
-      params.name = '登录';
-      app.globalData.userInfo = params;
-      wx.setStorage({ key: "token", data: 'token' })
-      wx.showToast({ title: `账号登录成功`, icon: 'success', duration: 2000 })
-      wx.navigateTo({ url: '/pages/home/index' })
+      console.log("parmas",params);
+      var phone = params.phone;
+      var password = params.password;
+      wx.request({
+        url: 'http://broadcast.waityou24.cn/courtAdmin/api/user/login', //接口地址
+        dataType: 'json',
+        method: 'POST',
+        data: {
+          phone: phone,
+          password: password,
+        },
+        header: {
+          'content-type': 'application/json' // 默认值
+        },
+        success (res) {
+          console.log(res.data)
+          if (res.data.errmsg == "用户不存在") {
+            wx.showToast({
+              title: res.data.errmsg,
+              icon: 'none',
+              duration: 2000
+            })
+          } 
+        }
+      })
     }
   },
   // 微信登录
@@ -55,7 +75,7 @@ Page({
   searchHeight: function () {
     let frameStyle = this.data.frameStyle;
     let client = app.globalData.client;
-    let infoHeight=client.windowHeight;
+    let infoHeight = client.windowHeight;
     // 减去状态栏
     if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2)
     // 是否减去底部菜单