Browse Source

登录存在多个客户情况弹出客户选择

taidong
mk 11 months ago
parent
commit
5bb3e34e9e
  1. 2
      pages/index/index.js
  2. 129
      pages/login/login.js
  3. 5
      pages/login/login.json
  4. 12
      pages/login/login.wxml
  5. 40
      pages/login/login.wxss
  6. 7
      utils/api.js

2
pages/index/index.js

@ -25,7 +25,7 @@ Page({
}, },
// 事件处理函数 // 事件处理函数
onLoad: async function () { onLoad: async function () {
await this.getToken() // await this.getToken()
this.getIntelligentMessage() this.getIntelligentMessage()
// await this.getIntelligentMessage() // await this.getIntelligentMessage()
await this.getStaffbasicinfo() await this.getStaffbasicinfo()

129
pages/login/login.js

@ -1,6 +1,7 @@
// pages/register/register.js // pages/register/register.js
// 到入一个 // 到入一个
import {userLoginlog} from "../../utils/api" import api from "../../utils/api"
import {encryptedData} from "../../utils/index"
Page({ Page({
/** /**
@ -8,17 +9,18 @@ Page({
*/ */
data: { data: {
formData:{ formData:{
mobile:'', mobile:'18500000001',
password:'', password:'Elink8888',
appId:'wxaf87b420b87e2d79' appId:'wxaf87b420b87e2d79'
} },
show:false
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { onLoad(options) {
this.getPubKey()
}, },
/** /**
@ -62,6 +64,77 @@ Page({
onReachBottom() { 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){ handelBlurMobile(e){
this.setData({ this.setData({
// 获取绑定过的值,付给fromData.mobile // 获取绑定过的值,付给fromData.mobile
@ -77,6 +150,7 @@ Page({
console.log(this.data.formData) console.log(this.data.formData)
}, },
handelClickSubmit(){ handelClickSubmit(){
let that = this
if(!this.data.formData.mobile){ if(!this.data.formData.mobile){
// 微信的轻量级api // 微信的轻量级api
wx.showToast({ wx.showToast({
@ -96,16 +170,11 @@ Page({
}) })
return return
} }
const parm = {
// wxCode对象的初始化 // // 轻量级api,在加载时进行显示
wxCode :'', // wx.showLoading({
// ...将this.data.formData所有属性,赋值到表单中 // title: '登录中',
...this.data.formData // })
}
// 轻量级api,在加载时进行显示
wx.showLoading({
title: '登录中',
})
//微信的api,获取登录凭证,用户获取凭证 //微信的api,获取登录凭证,用户获取凭证
wx.getUserProfile({ wx.getUserProfile({
desc: '用于获取用户个人信息', desc: '用于获取用户个人信息',
@ -114,34 +183,8 @@ Page({
var avatarUrl = userInfo.avatarUrl; var avatarUrl = userInfo.avatarUrl;
wx.setStorageSync('avatarUrl', avatarUrl) wx.setStorageSync('avatarUrl', avatarUrl)
console.log("User's Avatar URL:", avatarUrl); console.log("User's Avatar URL:", avatarUrl);
wx.login({ that.getCustomerlist()
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()
},
})
} }
}) })

5
pages/login/login.json

@ -1,6 +1,9 @@
{ {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"usingComponents": {}, "usingComponents": {
"van-overlay": "@vant/weapp/overlay/index",
"van-icon": "@vant/weapp/icon/index"
},
"navigationStyle": "custom", "navigationStyle": "custom",
"navigationBarBackgroundColor": "#1673ee", "navigationBarBackgroundColor": "#1673ee",
"disableSwipeBack": true "disableSwipeBack": true

12
pages/login/login.wxml

@ -21,5 +21,17 @@
<!-- tap事件绑定到handelClickSubmit。tab事件,当触摸屏时 --> <!-- tap事件绑定到handelClickSubmit。tab事件,当触摸屏时 -->
<button bind:tap="handelClickSubmit" style="font-weight: 600;">登录</button> <button bind:tap="handelClickSubmit" style="font-weight: 600;">登录</button>
</view> </view>
<van-overlay show="{{ show }}" bind:click="onClickHide">
<image src="https://elink-esua-epdc.oss-cn-qingdao.aliyuncs.com/epmet-saas/prod/internal/20241011/395a740b4b474dfa88f718edea18dce9.png" mode="" class="center"/>
<view class="center customer">
<view class="title">请选择社区</view>
<view class="list">
<view class="item" wx:for="{{customerlist}}" wx:key="index" bind:tap="handelClickCustomer" data-id="{{item.customerId}}">
<view class="flex-1">{{item.customerName}}</view>
<van-icon name="arrow" color="#c1c1c1"/>
</view>
</view>
</view>
</van-overlay>

40
pages/login/login.wxss

@ -7,6 +7,15 @@ page {
/* 垂直方向.元素溢出时,显示滚动条 */ /* 垂直方向.元素溢出时,显示滚动条 */
overflow-y: auto; overflow-y: auto;
} }
.center{
position: absolute;
top: 50%;
left: 50%;
width:640rpx;
height: 550rpx;
transform: translate(-320rpx,-275rpx);
z-index: 100;
}
.header { .header {
height: 500rpx; height: 500rpx;
width: 100%; width: 100%;
@ -45,6 +54,7 @@ page {
background-color: #fff; background-color: #fff;
box-sizing: border-box; box-sizing: border-box;
padding:80rpx 60rpx 0; padding:80rpx 60rpx 0;
z-index: 0;
} }
.login .input_box { .login .input_box {
display: flex; display: flex;
@ -89,4 +99,34 @@ page {
height: 86rpx; height: 86rpx;
line-height: 86rpx; line-height: 86rpx;
padding: 0 !important; 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;
} }

7
utils/api.js

@ -88,7 +88,8 @@ module.exports = {
isUpdater, isUpdater,
Enterpriseambiguity, Enterpriseambiguity,
hotResidentSearch, hotResidentSearch,
hotHouseSearch hotHouseSearch,
customerlist
} }
// 获取公钥 // 获取公钥
@ -462,4 +463,8 @@ function hotResidentSearch(){
function hotHouseSearch(){ function hotHouseSearch(){
return fly.post(`actual/base/communityHouse/hotHouseSearch`) return fly.post(`actual/base/communityHouse/hotHouseSearch`)
} }
//获取客户
function customerlist(parm){
return fly.post(`epmetuser/customerstaff/customerlist`,parm)
}

Loading…
Cancel
Save