guhongwei 4 years ago
parent
commit
1c5e7d1def
5 changed files with 38 additions and 45 deletions
  1. 1 1
      app.js
  2. 6 33
      pages/home/home.js
  3. 5 5
      pages/home/home.wxml
  4. 25 5
      pages/login/login.js
  5. 1 1
      pages/login/login.wxml

+ 1 - 1
app.js

@@ -35,7 +35,7 @@ App({
   },
   globalData: {
     userInfo: null,
-    publicUrl: 'http://broadcast.waityou24.cn'
+    publicUrl: 'http://192.168.1.119:11000'
   },
   id: 'wx74f916cbbb2173fa'
 })

+ 6 - 33
pages/home/home.js

@@ -5,9 +5,8 @@ const app = getApp()
 Page({
   data: {
     // 个人信息
-    userInfo: {
-
-    }
+    videoUrl: 'https://vd3.bdstatic.com/mda-kar9n2ip1u508ewq/hd/mda-kar9n2ip1u508ewq.mp4?pd=20',
+    userInfo: {}
   },
   //事件处理函数
   // 统计信息
@@ -97,16 +96,13 @@ Page({
       url: '../user/user'
     })
   },
-
   onLoad: function () {
+    let data = app.globalData.userInfo;
+    this.setData({ userInfo: data })
     wx.getUserInfo({
       success: res => {
         var data = res.userInfo;
-        data.phone = '17319450324',
-          data.grade = '业务员',
-          this.setData({
-            userInfo: data,
-          })
+        this.setData({ "userInfo.avatarUrl": data.avatarUrl })
       },
       fail: err => {
         wx.showToast({
@@ -114,30 +110,7 @@ Page({
           icon: 'error',
           duration: 2000
         })
-        wx.redirectTo({
-          url: '/pages/index/index',
-        })
       }
-    }),
-      wx.request({
-        url: app.globalData.publicUrl + '/api/market/product/newquery',
-        method: "get",
-        data: { skip: 0, limit: 10 },
-        success: (res) => {
-          if (res.data.errcode == '0') {
-            wx.showToast({
-              title: '搜索成功',
-              icon: 'success',
-              duration: 2000
-            })
-          } else {
-            wx.showToast({
-              title: '查询失败',
-              icon: 'error',
-              duration: 2000
-            })
-          }
-        }
-      })
+    })
   },
 })

+ 5 - 5
pages/home/home.wxml

@@ -2,15 +2,15 @@
 <view class="main">
   <van-row>
     <van-col span="24" class="one">
-      <video src="https://vd3.bdstatic.com/mda-kar9n2ip1u508ewq/hd/mda-kar9n2ip1u508ewq.mp4?pd=20" autoplay loop
-        show-mute-btn></video>
+      <!-- <video src="{{videoUrl}}" autoplay loop show-mute-btn></video> -->
+      视频
     </van-col>
     <van-col span="24" class="personal">
       <image src="{{userInfo.avatarUrl}}"></image>
       <view class="userInfo">
-        <text>{{userInfo.nickName}}</text>
-        <text>电话:{{userInfo.phone}}</text>
-        <text>星级:{{userInfo.grade}}</text>
+        <text>{{userInfo.name}}</text>
+        <text>电话:{{userInfo.mobile}}</text>
+        <text>星级:{{userInfo.level=='1'?'业务员':userInfo.level=='2'?'经理':userInfo.level=='3'?'一星经理':userInfo.level=='4'?'二星经理':userInfo.level=='5'?'三星经理':"四星经理"}}</text>
       </view>
     </van-col>
     <van-col span="24" class="two">

+ 25 - 5
pages/login/login.js

@@ -9,7 +9,7 @@ Page({
   },
   initValidate() {
     const rules = {
-      phone: {
+      mobile: {
         required: true,
         tel: true
       },
@@ -17,7 +17,7 @@ Page({
     }
     // 验证字段的提示信息,若不传则调用默认的信息
     const messages = {
-      phone: { required: '请输入手机号', },
+      mobile: { required: '请输入手机号', },
       password: { required: '请输入密码', },
     };
     this.WxValidate = new WxValidate(rules, messages)
@@ -33,9 +33,29 @@ Page({
       })
       return false
     } else {
-      console.log(params);
-      wx.navigateTo({
-        url: '/pages/home/home'
+      wx.request({
+        url: app.globalData.publicUrl + '/api/htyd/login',
+        method: "post",
+        data: params,
+        success: (res) => {
+          if (res.data.errcode == '0') {
+            app.globalData.userInfo = res.data.data
+            wx.showToast({
+              title: '登录成功',
+              icon: 'success',
+              duration: 2000
+            })
+            wx.navigateTo({
+              url: '/pages/home/home'
+            })
+          } else {
+            wx.showToast({
+              title: '登录失败',
+              icon: 'error',
+              duration: 2000
+            })
+          }
+        }
       })
     }
   },

+ 1 - 1
pages/login/login.wxml

@@ -8,7 +8,7 @@
     <form bindsubmit="formSubmit" bindreset="formReset">
       <view class='content'>
         <view class='input'>
-          <input type='number' name="phone" value="{{form.phone}}" maxlength="11" placeholder='请输入您本人的手机号码'></input>
+          <input type='number' name="mobile" value="{{form.mobile}}" maxlength="11" placeholder='请输入您本人的手机号码'></input>
         </view>
         <view class='input'>
           <input type='text' name="password" value="{{form.password}}" placeholder='请输入密码' password></input>