guhongwei 4 년 전
부모
커밋
8eb7597749
11개의 변경된 파일113개의 추가작업 그리고 80개의 파일을 삭제
  1. 1 1
      app.js
  2. 0 5
      pages/about/about.js
  3. 44 2
      pages/card/card.js
  4. 3 3
      pages/card/card.wxml
  5. 18 35
      pages/home/home.js
  6. 2 1
      pages/home/home.wxml
  7. 11 0
      pages/home/home.wxss
  8. 2 4
      pages/integral/integral.js
  9. 2 2
      pages/login/login.js
  10. 25 24
      pages/perssonal/perssonal.js
  11. 5 3
      pages/team/team.js

+ 1 - 1
app.js

@@ -5,7 +5,6 @@ App({
     var logs = wx.getStorageSync('logs') || []
     logs.unshift(Date.now())
     wx.setStorageSync('logs', logs)
-
     // 登录
     wx.login({
       success: res => {
@@ -36,6 +35,7 @@ App({
   globalData: {
     userInfo: null,
     publicUrl: 'http://192.168.1.119:11000'
+    // publicUrl: 'https://htyd.jlsci.cn'
   },
   id: 'wx74f916cbbb2173fa',
 })

+ 0 - 5
pages/about/about.js

@@ -7,11 +7,6 @@ Page({
     companyInfo: {}
   },
   //事件处理函数
-  bindViewTap: function () {
-    wx.navigateTo({
-      url: '../index/index'
-    })
-  },
   onLoad: function () {
     // 查询信息
     wx.request({

+ 44 - 2
pages/card/card.js

@@ -1,7 +1,7 @@
 //index.js
 //获取应用实例
 const app = getApp()
-
+import WxValidate from '../../utils/wxValidate';
 Page({
   data: {
     form: {},
@@ -12,9 +12,34 @@ Page({
     // 套餐列表
     setList: [],
   },
+  initValidate() {
+    const rules = {
+      mobile: { required: true, tel: true },
+      password: { required: true, },
+      province: { required: true, },
+      city: { required: false, },
+      set: { required: true, },
+      name: { required: true, },
+      id_card: { required: true, idcard: true },
+      wxaccount: { required: true, },
+    }
+    // 验证字段的提示信息,若不传则调用默认的信息
+    const messages = {
+      mobile: { required: '请输入新办理号码', },
+      password: { required: '请输入密码', },
+      province: { required: '请选择省份', },
+      city: { required: '请选择市区', },
+      set: { required: '请选择套餐', },
+      name: { required: '请输入姓名', },
+      id_card: { required: '请输入身份证号', },
+      wxaccount: { required: '请输入微信账号', },
+    };
+    this.WxValidate = new WxValidate(rules, messages)
+  },
   // 选择省份
   provinceChange: function (e) {
     this.setData({ "form.province": this.data.provinceList[e.detail.value].code })
+    this.setData({ "form.provinces": this.data.provinceList[e.detail.value].name })
     // 查询市
     wx.request({
       url: app.globalData.publicUrl + '/api/htyd/xzqh',
@@ -56,6 +81,7 @@ Page({
   // 选择市区
   cityChange: function (e) {
     this.setData({ "form.city": this.data.cityList[e.detail.value].code })
+    this.setData({ "form.citys": this.data.cityList[e.detail.value].name })
     // 套餐
     wx.request({
       url: app.globalData.publicUrl + '/api/htyd/set',
@@ -77,10 +103,22 @@ Page({
   // 选择套餐
   setChange: function (e) {
     this.setData({ "form.set": this.data.setList[e.detail.value].id })
+    this.setData({ "form.sets": this.data.setList[e.detail.value].title })
   },
   //事件处理函数
   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: 'none',
+        duration: 2000
+      })
+      return false
+    } else {
+      console.log(params);
+    }
     wx.request({
       url: app.globalData.publicUrl + '/api/htyd/card',
       method: "post",
@@ -92,6 +130,9 @@ Page({
             icon: 'success',
             duration: 2000
           })
+          wx.redirectTo({
+            url: 'pages/home/home',
+          })
         } else {
           wx.showToast({
             title: '办卡失败',
@@ -102,7 +143,8 @@ Page({
       }
     })
   },
-  onLoad: function () {
+  onLoad: function (options) {
+    this.initValidate()//验证规则函数
     // 获取推荐人信息
     let data = app.globalData.userInfo;
     if (data) {

+ 3 - 3
pages/card/card.wxml

@@ -17,7 +17,7 @@
         <text class="label">号码归属省</text>
         <picker class="createTime" bindchange="provinceChange" name="province" value="{{form.province}}"
           range="{{provinceList}}" range-key="{{'name'}}">
-          <view class="picker">{{form.province||'选择省份'}}
+          <view class="picker">{{form.provinces||'选择省份'}}
           </view>
         </picker>
       </view>
@@ -25,7 +25,7 @@
         <text class="label">号码归属市</text>
         <picker class="createTime" bindchange="cityChange" name="city" value="{{form.city}}" range="{{cityList}}"
           range-key="{{'name'}}">
-          <view class="picker">{{form.city||'选择市区'}}
+          <view class="picker">{{form.citys||'选择市区'}}
           </view>
         </picker>
       </view>
@@ -33,7 +33,7 @@
         <text class="label">套餐</text>
         <picker class="createTime" bindchange="setChange" name="set" value="{{form.set}}" range="{{setList}}"
           range-key="{{'title'}}">
-          <view class="picker">{{form.set||'选择套餐'}}
+          <view class="picker">{{form.sets||'选择套餐'}}
           </view>
         </picker>
       </view>

+ 18 - 35
pages/home/home.js

@@ -102,43 +102,20 @@ Page({
     })
   },
   onLoad: function () {
-    // let data = app.globalData.userInfo;
-    let data = {
-      avatarUrl: "https://thirdwx.qlogo.cn/mmopen/vi_32/ibzXIKnSribia9qZzSkEokEVfLuxOUEJ8xPAMibU29vB3KS8Pic5fUwUricWsXAEfL8zibZSGjUvPUm6PibxiadY8RAdv1w/132",
-      car_show: false,
-      city: "220100",
-      create_time: "2021-01-06 16:31:30",
-      id: "5ff575b0a3f2771eb4d03114",
-      id_card: "22010319950601161x",
-      level: 2,
-      mobile: "13089419810",
-      name: "刘睿峰",
-      points: 5500,
-      province: "220000",
-      set: "5ff6710f7fa08b4500e61e5f",
-      stockholder: false,
-      wxaccount: "lrf402788946",
-      _id: "5ff575b0a3f2771eb4d03114",
+    let data = app.globalData.userInfo;
+    if (data) {
+      this.setData({ userInfo: data })
+      wx.getUserInfo({
+        success: res => {
+          if (res.userInfo) {
+            this.setData({ 'userInfo.avatarUrl': res.userInfo.avatarUrl })
+          }
+        }
+      })
+      this.indexCount();
+      this.searchPicker();
     }
-    console.log(data);
-    this.setData({ userInfo: data })
-    wx.getUserInfo({
-      success: res => {
-        var data = res.userInfo;
-        this.setData({ "userInfo.avatarUrl": data.avatarUrl })
-      },
-      fail: err => {
-        wx.showToast({
-          title: '没有授权获取微信用户信息',
-          icon: 'error',
-          duration: 2000
-        })
-      }
-    })
-    this.indexCount();
-    this.searchPicker();
   },
-
   /**
    * 首页查询4块统计
    * @property mobile 当前用户手机号,查询条件
@@ -164,5 +141,11 @@ Page({
         // this.setData({ videoUrl: res.data.data[0].url })
       }
     })
+  },
+  // 获取用户头像
+  getUserInfo: function (e) {
+    if (e.detail.userInfo) {
+      this.setData({ 'userInfo.avatarUrl': e.detail.userInfo.avatarUrl })
+    }
   }
 })

+ 2 - 1
pages/home/home.wxml

@@ -5,7 +5,8 @@
       <video src="{{videoUrl}}" autoplay loop show-mute-btn></video>
     </van-col>
     <van-col span="24" class="personal">
-      <image src="{{userInfo.avatarUrl}}"></image>
+      <image src="{{userInfo.avatarUrl}}" wx:if="{{userInfo.avatarUrl}}"></image>
+      <button wx:else open-type="getUserInfo" bindgetuserinfo="getUserInfo" class="userAdv">获取头像</button>
       <view class="userInfo">
         <text>{{userInfo.name}}</text>
         <text>电话:{{userInfo.mobile}}</text>

+ 11 - 0
pages/home/home.wxss

@@ -35,6 +35,17 @@
   border-radius: 90rpx;
 }
 
+.personal .userAdv {
+  float: left;
+  font-size: 35rpx;
+  padding: 25rpx 35rpx;
+  width: 150rpx;
+  height: 143rpx;
+  line-height: 45rpx;
+  font-size: 35rpx;
+  border-radius: 360rpx;
+}
+
 .personal .userInfo {
   float: left;
   width: 77%;

+ 2 - 4
pages/integral/integral.js

@@ -52,7 +52,7 @@ Page({
       success: res => {
         let { data } = res.data
         if (data.length <= 0) wx.showToast({
-          title: '未查到相关数据',
+          title: '未查到相关直推积分数据',
           icon: "none"
         })
         data = data.map(i => {
@@ -79,7 +79,7 @@ Page({
       success: res => {
         let { data } = res.data
         if (data.length <= 0) wx.showToast({
-          title: '未查到相关数据',
+          title: '未查到相关卡单分红数据',
           icon: "none"
         })
         data = data.map(i => {
@@ -110,6 +110,4 @@ Page({
     else res = '业务员'
     return res;
   }
-
-
 })

+ 2 - 2
pages/login/login.js

@@ -5,7 +5,7 @@ const app = getApp()
 
 Page({
   data: {
-    form: {}
+    form: {},
   },
   initValidate() {
     const rules = {
@@ -39,7 +39,7 @@ Page({
         data: params,
         success: (res) => {
           if (res.data.errcode == '0') {
-            app.globalData.userInfo = res.data.data
+            app.globalData.userInfo = res.data.data;
             wx.showToast({
               title: '登录成功',
               icon: 'success',

+ 25 - 24
pages/perssonal/perssonal.js

@@ -15,30 +15,31 @@ Page({
         url: app.globalData.publicUrl + '/api/htyd/xzqh',
         method: "get",
         data: { code: data.province },
-        success: (res) => {
-          data.province = res.data.data[0].name;
-        }
-      })
-      // 查询市区
-      wx.request({
-        url: app.globalData.publicUrl + '/api/htyd/xzqh',
-        method: "get",
-        data: { pcode: data.province },
-        success: (res) => {
-          let city = res.data.data.find(i => i.code == data.city)
-          if (city) data.city = city.name;
-        }
-      })
-      // 查询套餐
-      wx.request({
-        url: app.globalData.publicUrl + '/api/htyd/set/' + data.set,
-        method: "get",
-        data: {},
-        success: (res) => {
-          if (res.data.errcode === 0) {
-            data.set = res.data.data.title
-            this.setData({ personalInfo: data })
-          }
+        success: (proRes) => {
+          data.province = proRes.data.data[0].name;
+          // 查询市区
+          wx.request({
+            url: app.globalData.publicUrl + '/api/htyd/xzqh',
+            method: "get",
+            data: { pcode: proRes.data.data[0].code },
+            success: (cityRes) => {
+              let city = cityRes.data.data.find(i => i.code == data.city)
+              console.log(city);
+              if (city) data.city = city.name;
+              // 查询套餐
+              wx.request({
+                url: app.globalData.publicUrl + '/api/htyd/set/' + data.set,
+                method: "get",
+                data: {},
+                success: (setRes) => {
+                  if (setRes.data.errcode === 0) {
+                    data.set = setRes.data.data.title;
+                    this.setData({ personalInfo: data })
+                  }
+                }
+              })
+            }
+          })
         }
       })
     } else { }

+ 5 - 3
pages/team/team.js

@@ -45,6 +45,8 @@ moment.locale('en', {
         data: { contact: this.data.provinceList[e.detail.value].code },
         success: (res) => {
           if (res.data.errcode == '0') {
+            let data = res.data.data;
+            data.unshift({ title: '全部' });
             this.setData({ setList: res.data.data })
           } else {
             wx.showToast({
@@ -59,8 +61,9 @@ moment.locale('en', {
     // 选择套餐
     mealChange: function (e) {
       let oneValue = this.data.setList[e.detail.value] ? this.data.setList[e.detail.value] : this.data.setList.find(i => i.title == e.detail.value)
+      if (oneValue.title == '全部') this.setData({ "searchForm.set": null });
+      else this.setData({ "searchForm.set": oneValue.id });
       if (oneValue) this.setData({ "form.set": oneValue.title });
-      this.setData({ "searchForm.set": oneValue.id });
       // 调用查询方法
       this.search(this.data.searchForm);
     },
@@ -107,7 +110,7 @@ moment.locale('en', {
       let data = e.detail.value;
       data = {
         province: this.data.searchForm.province,
-        set: this.data.searchForm.set,
+        set: this.data.searchForm.set || null,
         "create_time@start": data.start_time || null,
         "create_time@end": data.end_time || null,
       }
@@ -212,6 +215,5 @@ moment.locale('en', {
           }
         })
       }
-
     },
   })