Browse Source

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

taidong
mk 11 months ago
parent
commit
5bb3e34e9e
  1. 2
      pages/index/index.js
  2. 127
      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 () {
await this.getToken()
// await this.getToken()
this.getIntelligentMessage()
// await this.getIntelligentMessage()
await this.getStaffbasicinfo()

127
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()
},
/**
@ -61,6 +63,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({
@ -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,35 +183,9 @@ 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)
that.getCustomerlist()
}
}).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": "",
"usingComponents": {},
"usingComponents": {
"van-overlay": "@vant/weapp/overlay/index",
"van-icon": "@vant/weapp/icon/index"
},
"navigationStyle": "custom",
"navigationBarBackgroundColor": "#1673ee",
"disableSwipeBack": true

12
pages/login/login.wxml

@ -21,5 +21,17 @@
<!-- tap事件绑定到handelClickSubmit。tab事件,当触摸屏时 -->
<button bind:tap="handelClickSubmit" style="font-weight: 600;">登录</button>
</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;
}
.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;
@ -90,3 +100,33 @@ page {
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;
}

7
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)
}

Loading…
Cancel
Save