diff --git a/pages/index/index.js b/pages/index/index.js index d5feff7..74d98dd 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -25,7 +25,7 @@ Page({ }, // 事件处理函数 onLoad: async function () { - await this.getToken() + // await this.getToken() this.getIntelligentMessage() // await this.getIntelligentMessage() await this.getStaffbasicinfo() diff --git a/pages/login/login.js b/pages/login/login.js index c39acd5..ee49900 100644 --- a/pages/login/login.js +++ b/pages/login/login.js @@ -1,6 +1,7 @@ // pages/register/register.js // 到入一个 -import {userLoginlog} from "../../utils/api" +import api from "../../utils/api" +import {encryptedData} from "../../utils/index" Page({ /** @@ -8,17 +9,18 @@ Page({ */ data: { formData:{ - mobile:'', - password:'', + mobile:'18500000001', + password:'Elink8888', appId:'wxaf87b420b87e2d79' - } + }, + show:false }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { - + this.getPubKey() }, /** @@ -62,6 +64,77 @@ Page({ onReachBottom() { }, + onClickHide() { + this.setData({ show: false }); + }, + getPubKey(){ + api.getPubKey().then(res=>{ + this.setData({ + pubKey:res.data + }) + }).catch(err=>{ + + }) + }, + submitLogin(){ + const parm = { + wxCode :'', + ...this.data.formData, + customerId:this.data.customerId + } + wx.login({ + success: (res) => { + parm.wxCode = res.code; + console.log(parm,'seee'); + api.userLoginlog(parm).then((res)=>{ + console.log(res); + if(res.code == 0){ + wx.switchTab({ + url: '/pages/index/index', + }) + wx.setStorageSync('token', res.data.token) + + } + }).catch(err=>{ + wx.showToast({ + title: res.msg, + icon:'none', + duration:3000 + }) + console.log(err); + }) + }, + }) + }, + getCustomerlist(){ + let parm = { + phone:encryptedData(this.data.pubKey, this.data.formData.mobile) + } + api.customerlist(parm).then(res=>{ + if(res.code === 0 ){ + if(res.data.length>1){ + this.setData({ + show:true, + customerlist:res.data + }) + }else{ + this.setData({ + customerId:res.data[0].customerId + }) + this.submitLogin() + } + } + }).catch(err=>{ + + }) + }, + handelClickCustomer(e){ + this.setData({ + customerId:e.currentTarget.dataset.id, + show:false + }) + this.submitLogin() + }, handelBlurMobile(e){ this.setData({ // 获取绑定过的值,付给fromData.mobile @@ -77,6 +150,7 @@ Page({ console.log(this.data.formData) }, handelClickSubmit(){ + let that = this if(!this.data.formData.mobile){ // 微信的轻量级api wx.showToast({ @@ -96,16 +170,11 @@ Page({ }) return } - const parm = { - // wxCode对象的初始化 - wxCode :'', - // ...将this.data.formData所有属性,赋值到表单中 - ...this.data.formData - } - // 轻量级api,在加载时进行显示 - wx.showLoading({ - title: '登录中', - }) + + // // 轻量级api,在加载时进行显示 + // wx.showLoading({ + // title: '登录中', + // }) //微信的api,获取登录凭证,用户获取凭证 wx.getUserProfile({ desc: '用于获取用户个人信息', @@ -114,34 +183,8 @@ Page({ var avatarUrl = userInfo.avatarUrl; wx.setStorageSync('avatarUrl', avatarUrl) console.log("User's Avatar URL:", avatarUrl); - wx.login({ - success: (res) => { - parm.wxCode = res.code - console.log(parm.wxCode); - // 调用登录的接口 - userLoginlog(parm).then((res)=>{ - console.log(res); - // 判断登录是否成功 - if(res.code == 0){ - // 用于跳转的api,跳转到某某某 - wx.switchTab({ - url: '/pages/index/index', - }) - //加入本地内存的api - wx.setStorageSync('token', res.data.token) - - } - }).catch(err=>{ - wx.showToast({ - title: res.msg, - icon:'none', - duration:3000 - }) - console.log(err); - }) - wx.hideLoading() - }, - }) + that.getCustomerlist() + } }) diff --git a/pages/login/login.json b/pages/login/login.json index 5c009c3..b5f59ab 100644 --- a/pages/login/login.json +++ b/pages/login/login.json @@ -1,6 +1,9 @@ { "navigationBarTitleText": "", - "usingComponents": {}, + "usingComponents": { + "van-overlay": "@vant/weapp/overlay/index", + "van-icon": "@vant/weapp/icon/index" + }, "navigationStyle": "custom", "navigationBarBackgroundColor": "#1673ee", "disableSwipeBack": true diff --git a/pages/login/login.wxml b/pages/login/login.wxml index 942cf53..2fe3497 100644 --- a/pages/login/login.wxml +++ b/pages/login/login.wxml @@ -21,5 +21,17 @@ + + + + 请选择社区 + + + {{item.customerName}} + + + + + diff --git a/pages/login/login.wxss b/pages/login/login.wxss index 0f813f3..a7c87e5 100644 --- a/pages/login/login.wxss +++ b/pages/login/login.wxss @@ -7,6 +7,15 @@ page { /* 垂直方向.元素溢出时,显示滚动条 */ overflow-y: auto; } + .center{ + position: absolute; + top: 50%; + left: 50%; + width:640rpx; + height: 550rpx; + transform: translate(-320rpx,-275rpx); + z-index: 100; + } .header { height: 500rpx; width: 100%; @@ -45,6 +54,7 @@ page { background-color: #fff; box-sizing: border-box; padding:80rpx 60rpx 0; + z-index: 0; } .login .input_box { display: flex; @@ -89,4 +99,34 @@ page { height: 86rpx; line-height: 86rpx; padding: 0 !important; + } + .customer{ + z-index: 102; + padding: 100rpx 20rpx 20rpx ; + box-sizing: border-box; + } + .customer .title{ + color: #153166; + font-size: 40rpx; + } + .customer .list{ + background: #ffffff; + border-radius: 10rpx; + display: flex; + flex-direction: column; + height: calc(100% - 70rpx); + overflow-y: scroll; + padding: 0 20rpx; + box-sizing: border-box; + margin-top: 20rpx; + } + .customer .list .item{ + display: flex; + justify-content: space-between; + height: 100rpx; + line-height: 100rpx; + border-bottom: 1rpx solid #f2f2f2; + } + .customer .list .item .flex-1{ + flex: 1; } \ No newline at end of file diff --git a/utils/api.js b/utils/api.js index ce34953..a62b217 100644 --- a/utils/api.js +++ b/utils/api.js @@ -88,7 +88,8 @@ module.exports = { isUpdater, Enterpriseambiguity, hotResidentSearch, - hotHouseSearch + hotHouseSearch, + customerlist } // 获取公钥 @@ -462,4 +463,8 @@ function hotResidentSearch(){ function hotHouseSearch(){ return fly.post(`actual/base/communityHouse/hotHouseSearch`) } +//获取客户 +function customerlist(parm){ + return fly.post(`epmetuser/customerstaff/customerlist`,parm) +}