Commit 542b5bdf by 张立顺

Merge branch 'develop' of 192.168.3.233:saas_plus/business-assistant into develop

2 parents 8c92d3d8 f9dfabb8
...@@ -84,10 +84,11 @@ class UsersApi { ...@@ -84,10 +84,11 @@ class UsersApi {
) )
} }
/** 获取登录账号列表 */ /** 获取登录账号列表 */
getAccountList() { getAccountList(sessionId) {
return api.post({ return api.post({
method: 'scrm.api.sso.wechat.applets.listSelectAccount', method: 'scrm.api.sso.wechat.applets.listSelectAccount',
platformEntrance: 'BUSINESS_ASSISTANT' platformEntrance: 'BUSINESS_ASSISTANT',
sessionId
}, },
true true
) )
......
...@@ -46,7 +46,9 @@ Component({ ...@@ -46,7 +46,9 @@ Component({
right, right,
width, width,
top top
} = wx.getMenuButtonBoundingClientRect() } = wx.getMenuButtonBoundingClientRect(),
currentPages = getCurrentPages()
let navigationBarHeight = height + ((top - statusBarHeight) * 2) + 4 // 4 let navigationBarHeight = height + ((top - statusBarHeight) * 2) + 4 // 4
let navigationBarPadding = screenWidth - right let navigationBarPadding = screenWidth - right
let navigationBarWidth = screenWidth - (navigationBarPadding * 2 + width) - width let navigationBarWidth = screenWidth - (navigationBarPadding * 2 + width) - width
...@@ -68,7 +70,6 @@ Component({ ...@@ -68,7 +70,6 @@ Component({
}) { }) {
let navHeight = navigationBarHeight + statusBarHeight let navHeight = navigationBarHeight + statusBarHeight
const thisPage = wx.$router.getPageInstance() const thisPage = wx.$router.getPageInstance()
const currentPages = getCurrentPages()
this.triggerEvent('navbarReady', { this.triggerEvent('navbarReady', {
height: navHeight, height: navHeight,
statusBarHeight statusBarHeight
...@@ -80,9 +81,6 @@ Component({ ...@@ -80,9 +81,6 @@ Component({
navHeight, navHeight,
statusBarHeight statusBarHeight
}) })
if (currentPages.length == 1 && !thisPage.rootName) thisPage.setData({
showHomeBtn: true
})
} }
}, },
lifetimes: { lifetimes: {
......
// pages/accountItems/accountItems.js // pages/accountItems/accountItems.js
import USERAPI from '~/api/usersApi/index' import USERAPI from '~/api/usersApi/index'
import {
selectAccountLogin
} from '~/login/lib/index'
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {},
/**accountLevel 1工厂。2省 ,3市。4门店 */ onRoute({
sessionId
}) {
this.getListSelectAccount(sessionId)
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
this.getListSelectAccount()
}, },
getListSelectAccount() { getListSelectAccount(sessionId) {
wx.$util.showLoading('加载中...') wx.$api.showLoading('加载中...')
api.getListSelectAccount().then(res => { USERAPI.getAccountList(sessionId).then(({
code,
data,
message
}) => {
wx.hideLoading() wx.hideLoading()
console.log(res)
let {
code,
data,
message
} = res
if (code == 0) { if (code == 0) {
let { let {
loginUserInfoList, loginUserInfoList,
sessionId sessionId
} = data } = data
wx.$util.setSessionId(sessionId)
this.setData({ this.setData({
loginUserInfoList loginUserInfoList
}) })
} else { this.sessionId = sessionId
wx.$util.showToast(message) } else wx.$api.showToast(message)
}
this.setData({ this.setData({
flag: true flag: true
}) })
...@@ -59,48 +59,23 @@ Page({ ...@@ -59,48 +59,23 @@ Page({
choiceAccountLogin() { choiceAccountLogin() {
let { let {
loginUserInfoList loginUserInfoList
} = this.data } = this.data,
let id = null id = null, {
sessionId
} = this
loginUserInfoList.map(e => { loginUserInfoList.map(e => {
if (e.active) id = e.uuid if (e.active) id = e.uuid
}) })
if (!id) { if (!id) {
wx.$util.showToast('请选择账号') wx.$api.showToast('请选择账号')
return return
} }
wx.$util.showLoading() console.log(sessionId)
api.selectAccountLogin({ wx.$api.showLoading()
id selectAccountLogin({
}).then(res => { id,
let { sessionId
data, })
message
} = res
if (data) {
wx.$util.setUserInfo(data.loginUserInfoList[0])
const SCENE = wx.$SCENE
if (SCENE) {
let {
path,
query: {
scene
}
} = SCENE
let {
target,
name
} = wx.$util.getSceneId(path)
wx.$router.reLaunch(`${target}.${name}`, {
scene
})
wx.$SCENE = null
} else {
wx.$router.reLaunch('tabIndex.index')
}
} else {
wx.$util.showToast(message)
}
})
}, },
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
...@@ -110,9 +85,7 @@ Page({ ...@@ -110,9 +85,7 @@ Page({
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function () { onShow: function () {},
wx.hideHomeButton()
},
/** /**
* 生命周期函数--监听页面隐藏 * 生命周期函数--监听页面隐藏
......
{ {
"navigationBarTitleText": "选择账号" "usingComponents": {
"navigation-bar": "/components/NavigationBar/NavigationBar"
},
"navigationStyle": "custom"
} }
\ No newline at end of file \ No newline at end of file
/* login/accountItems/accountItems.wxss */ /* login/accountItems/accountItems.wxss */
@import '../index/index.scss';
page {
background-color: #fff;
}
.layout { .layout {
margin: 40rpx 40rpx 0;
font-size: 28rpx; font-size: 28rpx;
color: #333; color: #323436;
letter-spacing: 0; letter-spacing: 0;
padding: 196rpx 32rpx 224rpx;
position: relative;
&::after {
content: '';
width: 100%;
height: 486rpx;
background: url('https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/login/bg.png') no-repeat;
background-size: 100% 486rpx;
position: absolute;
left: 0;
top: 0;
z-index: -1;
}
} }
.title { .title {
margin-bottom: 32rpx; font-weight: 500;
font-size: 36rpx;
color: #323436;
margin-bottom: 20rpx;
} }
.items { .items {
width: 100%; width: 100%;
min-height: 104rpx; min-height: 108rpx;
box-shadow: 0 0 8rpx 0 rgba(0, 0, 0, 0.15); box-shadow: 0 4rpx 16rpx 0 rgba(180, 186, 204, 0.32);
padding: 32rpx; padding: 32rpx;
margin-bottom: 40rpx; margin-bottom: 32rpx;
background-color: #fff; background-color: #fff;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
box-sizing: border-box; box-sizing: border-box;
} }
.items .name{
.items .name {
width: calc(100% - 70rpx); width: calc(100% - 70rpx);
} }
.items:last-of-type { .items:last-of-type {
margin-bottom: 0; margin-bottom: 0;
} }
.radio { .radio {
width: 32rpx; width: 28rpx;
height: 32rpx; height: 28rpx;
border: 2rpx solid #cccccc; border: 2rpx solid #DDE3F0;
border-radius: 100%; border-radius: 100%;
transition: all .2s; transition: all .2s;
box-sizing: border-box;
} }
.icon { .icon {
width: 36rpx; width: 28rpx;
height: 36rpx; height: 28rpx;
transition: all .2s; transition: all .2s;
display: none; display: none;
} }
...@@ -48,9 +73,11 @@ ...@@ -48,9 +73,11 @@
.active .icon { .active .icon {
display: block; display: block;
} }
.active .radio{
.active .radio {
display: none; display: none;
} }
.btn-box { .btn-box {
position: fixed; position: fixed;
left: 0; left: 0;
...@@ -62,24 +89,12 @@ ...@@ -62,24 +89,12 @@
align-items: center; align-items: center;
z-index: 20; z-index: 20;
background-color: #fff; background-color: #fff;
border-radius: 40rpx;
font-size: 32rpx;
color: #fff; color: #fff;
letter-spacing: 13rpx; padding: 0 32rpx;
} box-sizing: border-box;
.isFullSucreen-btn {
padding-bottom: 34px !important;
} }
.btn { .list-not {
width: calc(100% - 80rpx); height: calc(100vh - 159px);
height: 80rpx;
line-height: 80rpx;
text-align: center;
background-color: #3582EE;
border-radius: 16rpx;
}
.list-not{
font-size: 40rpx; font-size: 40rpx;
} }
\ No newline at end of file \ No newline at end of file
<view class="layout" style="padding-bottom:{{isFullSucreen?'224rpx':'160rpx'}}"> <view class="layout">
<view class="title">请选择登录的账号</view> <navigation-bar navStyle="background-color: rgba(0,0,0,0)">选择账号</navigation-bar>
<view class="list"> <view class="title">请选择登录的账号</view>
<block wx:if="{{flag}}"> <view class="list">
<block wx:if="{{loginUserInfoList}}"> <block wx:if="{{flag}}">
<block wx:for="{{loginUserInfoList}}" wx:key="index"> <block wx:if="{{loginUserInfoList.length}}">
<view class="items {{item.active?'active':''}}" bindtap="chooseAccount" data-index="{{index}}"> <block wx:for="{{loginUserInfoList}}" wx:key="index">
<view class="name"> <view class="items {{item.active?'active':''}}" bindtap="chooseAccount" data-index="{{index}}">
{{item.merchantName}}{{item.isSuper==true?'(超管)':item.userType==1?'(商户号)':'(员工号)'}} <view class="name">
</view> {{item.merchantName}}{{item.isSuper?'(超管)':item.userType==1?'(商户号)':'(员工号)'}}
<view class="icon"> </view>
<image src="/images/active-arc.png" /> <view class="icon">
</view> <image src="https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/login/radio.png" />
<view class='radio' /> </view>
</view> <view class='radio' />
</block> </view>
</block> </block>
<block wx:else> </block>
<view class="list-not" style="height: calc(100vh - {{isFullSucreen ? '159' :'125'}}px)" bindtap="getListSelectAccount"> <block wx:else>
点击刷新 <view class="list-not" bindtap="getListSelectAccount">
</view> 点击刷新
</block> </view>
</block> </block>
</view> </block>
<view class="btn-box {{isFullSucreen?'isFullSucreen-btn':''}}"> </view>
<view class='btn' bindtap="choiceAccountLogin">确定</view> <view class="btn-box isFullSucreen">
</view> <button class="button" bindtap="choiceAccountLogin">确定</button>
</view> </view>
</view>
\ No newline at end of file \ No newline at end of file
// login/index/components/LoginBox.js // login/index/components/LoginBox.js
import USERAPI from '~/api/usersApi/index' import USERAPI from '~/api/usersApi/index'
import { import {
setSessionId, selectAccountLogin,
setUserInfo setLoginInfo
} from '~/utils/cache/storageApi'
import {
setRouteData
} from '~/login/lib/index' } from '~/login/lib/index'
let thisPage let thisPage
Component({ Component({
...@@ -38,11 +35,13 @@ Component({ ...@@ -38,11 +35,13 @@ Component({
* 组件的方法列表 * 组件的方法列表
*/ */
methods: { methods: {
/**隐藏验证码错误 */
hideError(name) { hideError(name) {
if (name == 'code') this.setData({ if (name == 'code') this.setData({
smsError: false smsError: false
}) })
}, },
/**输入回调 */
input(e) { input(e) {
const { const {
value value
...@@ -58,6 +57,7 @@ Component({ ...@@ -58,6 +57,7 @@ Component({
this.hideError(name) this.hideError(name)
this.checkFormData() this.checkFormData()
}, },
/**清除input value */
clear(e) { clear(e) {
const { const {
name name
...@@ -68,6 +68,7 @@ Component({ ...@@ -68,6 +68,7 @@ Component({
this.hideError(name) this.hideError(name)
this.checkFormData() this.checkFormData()
}, },
/**获取验证码 */
getSmsCode() { getSmsCode() {
const { const {
phoneReady, phoneReady,
...@@ -95,6 +96,7 @@ Component({ ...@@ -95,6 +96,7 @@ Component({
wx.$api.showToast(err || '发送验证码失败') wx.$api.showToast(err || '发送验证码失败')
}) })
}, },
/**验证码倒计时 */
countDown(countDown) { countDown(countDown) {
if (countDown) this.setData({ if (countDown) this.setData({
count: countDown count: countDown
...@@ -112,6 +114,7 @@ Component({ ...@@ -112,6 +114,7 @@ Component({
}) })
}, 1e3) }, 1e3)
}, },
/**检查输入框内容 */
checkFormData() { checkFormData() {
const { const {
loginType, loginType,
...@@ -127,11 +130,13 @@ Component({ ...@@ -127,11 +130,13 @@ Component({
} else thisPage.checkLoginBtn() } else thisPage.checkLoginBtn()
} }
}, },
/**显示隐藏密码 */
pwdSwitch() { pwdSwitch() {
this.setData({ this.setData({
showPwd: !this.data.showPwd showPwd: !this.data.showPwd
}) })
}, },
/**手机号&帐号密码登录 */
login() { login() {
const { const {
formData, formData,
...@@ -157,12 +162,12 @@ Component({ ...@@ -157,12 +162,12 @@ Component({
}) => { }) => {
this.setBtnLoading(false) this.setBtnLoading(false)
if (code == '0') { if (code == '0') {
if (loginType == 1) this.selectAccountLogin({ if (loginType == 1) this.checkLoginUserInfo(data)
id: data.loginUserInfoList[0].uuid,
sessionId: data.sessionId
})
else { else {
console.log(data) const {
sessionId
} = data
setLoginInfo(data, sessionId)
} }
} else { } else {
if (loginType == 1) this.setData({ if (loginType == 1) this.setData({
...@@ -175,6 +180,7 @@ Component({ ...@@ -175,6 +180,7 @@ Component({
this.setBtnLoading(false) this.setBtnLoading(false)
}) })
}, },
/**微信登录 */
wxLogin({ wxLogin({
detail detail
}) { }) {
...@@ -185,18 +191,8 @@ Component({ ...@@ -185,18 +191,8 @@ Component({
data, data,
message message
}) => { }) => {
if (code == '0') { if (code == '0') this.checkLoginUserInfo(data)
const { else wx.$api.showToast(message || '系统异常')
loginUserInfoList,
sessionId
} = data
if (loginUserInfoList.length > 1) {
wx.$router.go('login.accountItems')
} else this.selectAccountLogin({
id: loginUserInfoList[0].uuid,
sessionId
})
} else wx.$api.showToast(message || '系统异常')
this.setBtnLoading(false) this.setBtnLoading(false)
}).catch(({ }).catch(({
errMsg errMsg
...@@ -205,6 +201,23 @@ Component({ ...@@ -205,6 +201,23 @@ Component({
this.setBtnLoading(false) this.setBtnLoading(false)
}) })
}, },
/**手机号&微信登录:是否跳转登录列表页 */
checkLoginUserInfo({
loginUserInfoList,
sessionId
}) {
/**多个账号 */
if (loginUserInfoList.length > 1) wx.$router.go('login.accountItems', {
sessionId,
...thisPage.options
})
/**只有一个账号 */
else selectAccountLogin({
id: loginUserInfoList[0].uuid,
sessionId
})
},
/**设置登录按钮loading状态 */
setBtnLoading(loading = true) { setBtnLoading(loading = true) {
thisPage.setData({ thisPage.setData({
loading loading
...@@ -213,6 +226,7 @@ Component({ ...@@ -213,6 +226,7 @@ Component({
loading loading
}) })
}, },
/**页面初始化 */
async init() { async init() {
thisPage = wx.$router.getPageInstance() thisPage = wx.$router.getPageInstance()
wx.$api.showLoading() wx.$api.showLoading()
...@@ -236,6 +250,7 @@ Component({ ...@@ -236,6 +250,7 @@ Component({
this.reLogin() this.reLogin()
} }
}, },
/**获取loginToken */
reLogin(message) { reLogin(message) {
wx.showModal({ wx.showModal({
content: message || '获取loginToken失败', content: message || '获取loginToken失败',
...@@ -246,40 +261,6 @@ Component({ ...@@ -246,40 +261,6 @@ Component({
}) => { }) => {
if (confirm) this.init() if (confirm) this.init()
}) })
},
selectAccountLogin({
id,
sessionId
}) {
const {
options: {
targetPath
}
} = thisPage
USERAPI.selectAccountLogin({
id,
sessionId
}).then(({
code,
data,
message
}) => {
if (code == '0') {
setUserInfo(data.loginUserInfoList[0])
setSessionId(data.sessionId)
if (targetPath) {
const {
url,
obj
} = setRouteData(targetPath)
wx.$router.reLaunch(url, obj)
} else wx.$router.go('pages.index')
} else wx.$api.showToast(message || '系统异常')
}).catch(({
errMsg
}) => {
wx.$api.showToast(errMsg || '系统异常')
})
} }
}, },
lifetimes: { lifetimes: {
......
...@@ -68,22 +68,3 @@ ...@@ -68,22 +68,3 @@
} }
} }
} }
.button {
width: 100% !important;
height: 88rpx;
background: #3666FE;
border-radius: 8rpx;
font-weight: 500;
font-size: 28rpx;
color: #FFFFFF;
line-height: 88rpx;
padding: 0;
&[disabled]:not([type]){
background: #CCCED1 !important;
color: #fff !important;
}
}
.btn-hover {
opacity: .75;
}
\ No newline at end of file \ No newline at end of file
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
</block> </block>
<block wx:else> <block wx:else>
<view class="input"> <view class="input">
<input type="text" placeholder="填写账号" placeholder-class="placeholder" bindinput="input" data-name="account" value="{{formData.account}}" maxlength="20" /> <input type="text" placeholder="填写账号" placeholder-class="placeholder" bindinput="input" data-name="account" value="{{formData.account}}" maxlength="15" />
<input-icon show="{{formData.account}}" bindtap="clear" data-name="account" /> <input-icon show="{{formData.account}}" bindtap="clear" data-name="account" />
</view> </view>
<view class="input"> <view class="input">
......
...@@ -8,8 +8,7 @@ Page({ ...@@ -8,8 +8,7 @@ Page({
loginType: 0, loginType: 0,
disabled: true disabled: true
}, },
onRoute(options){ onRoute(options) {},
},
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
...@@ -65,15 +64,14 @@ Page({ ...@@ -65,15 +64,14 @@ Page({
loginType loginType
} = this.data, { } = this.data, {
data: { data: {
formData, formData
phoneReady
}, },
loginToken loginToken
} = this.selectComponent('#box') } = this.selectComponent('#box')
if (loginType == 0) { if (loginType == 0) {
disabled = loginToken disabled = loginToken
} else disabled = loginType == 1 ? } else disabled = loginType == 1 ?
phoneReady && formData.code : formData.phone && this.validate.methods.tel(formData.phone) && formData.code :
formData.account && formData.password formData.account && formData.password
this.setData({ this.setData({
disabled: !disabled disabled: !disabled
......
...@@ -26,4 +26,22 @@ ...@@ -26,4 +26,22 @@
opacity: 1; opacity: 1;
transform: scale(1); transform: scale(1);
} }
}
.button {
width: 100% !important;
height: 88rpx;
background: var(--btnColor);
border-radius: 8rpx;
font-weight: 500;
font-size: 28rpx;
color: #FFFFFF;
line-height: 88rpx;
padding: 0;
&[disabled]:not([type]){
background: #CCCED1 !important;
color: #fff !important;
}
}
.btn-hover {
opacity: .75;
} }
\ No newline at end of file \ No newline at end of file
export const setRouteData = targetPath => { import {
setSessionId,
setUserInfo
} from '~/utils/cache/storageApi'
import USERAPI from '~/api/usersApi/index'
const setRouteData = targetPath => {
let [url, query] = targetPath.split('?'), let [url, query] = targetPath.split('?'),
obj = {} obj = {}
if (query) { if (query) {
...@@ -11,4 +16,49 @@ export const setRouteData = targetPath => { ...@@ -11,4 +16,49 @@ export const setRouteData = targetPath => {
url, url,
obj obj
} }
}
/**选择账号登录 */
const selectAccountLogin = ({
id,
sessionId
}) => {
USERAPI.selectAccountLogin({
id,
sessionId
}).then(({
code,
data,
message
}) => {
if (code == '0') {
setLoginInfo(data.loginUserInfoList[0], data.sessionId)
} else wx.$api.showToast(message || '系统异常')
})
}
/**设置登录信息 */
const setLoginInfo = (userInfo, sessionId) => {
setUserInfo(userInfo)
setSessionId(sessionId)
loginSuccess()
}
/**成功跳转 */
const loginSuccess = () => {
const {
options: {
targetPath
}
} = wx.$router.getPageInstance()
if (targetPath) {
const {
url,
obj
} = setRouteData(targetPath)
wx.$router.reLaunch(url, obj)
} else wx.$router.go('pages.index')
}
module.exports = {
selectAccountLogin,
loginSuccess,
setRouteData,
setLoginInfo
} }
\ No newline at end of file \ No newline at end of file
...@@ -17,7 +17,14 @@ ...@@ -17,7 +17,14 @@
{ {
"name": "携带目标页面", "name": "携带目标页面",
"pathName": "login/loading/loading", "pathName": "login/loading/loading",
"query": "url=%2Fpages%2Ftab%2Foutput%2Foutput%3Fid%3D123", "query": "url=%2Fpages%2Ftab%2Fmine%2Fmine%3Fid%3D123",
"launchMode": "default",
"scene": null
},
{
"name": "选择账号",
"pathName": "login/accountItems/accountItems",
"query": "",
"launchMode": "default", "launchMode": "default",
"scene": null "scene": null
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!