Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
business-assistant
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit b779454c
authored
Oct 11, 2022
by
李伟康
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修改登录
1 parent
4a82636a
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
115 additions
and
62 deletions
api/usersApi/UsersApi.js
login/index/components/Box/Box.js
login/index/components/Box/Box.wxml
login/index/index.js
login/index/index.json
login/index/index.wxml
login/loading/loading.js
login/loading/loading.wxml
utils/request/environment.js
utils/request/request.js
api/usersApi/UsersApi.js
View file @
b779454
import
api
from
'~/utils/request/request'
import
api
from
'~/utils/request/request'
const
{
appId
}
=
wx
.
getAccountInfoSync
().
miniProgram
const
{
appId
}
=
wx
.
getAccountInfoSync
().
miniProgram
class
UsersApi
{
class
UsersApi
{
/**调用后台接口获取用户信息 */
/**调用后台接口获取用户信息js_code换取sessionId */
async
login
()
{
async
wxCodeLogin
()
{
return
this
.
getWxCode
().
then
(({
code
})
=>
{
const
{
return
api
.
post
(
code
{
}
=
await
this
.
getWxCode
()
method
:
'scrm.api.sso.weapp.jscode.login'
,
return
await
api
.
post
({
method
:
'scrm.api.sso.wechat.applets.jscode.login'
,
appId
,
appId
,
code
code
},
},
true
true
)
)
})
}
async
login
()
{
}
}
/**调用接口获取登录凭证(code)。通过凭证进而换取用户登录态信息,包括用户在当前小程序的唯一标识(openid)、微信开放平台帐号下的唯一标识(unionid,若当前小程序已绑定到微信开放平台帐号)及本次登录的会话密钥(session_key)等。用户数据的加解密通讯需要依赖会话密钥完成。 */
/**调用接口获取登录凭证(code)。通过凭证进而换取用户登录态信息,包括用户在当前小程序的唯一标识(openid)、微信开放平台帐号下的唯一标识(unionid,若当前小程序已绑定到微信开放平台帐号)及本次登录的会话密钥(session_key)等。用户数据的加解密通讯需要依赖会话密钥完成。 */
getWxCode
()
{
getWxCode
()
{
...
@@ -23,39 +28,55 @@ class UsersApi {
...
@@ -23,39 +28,55 @@ class UsersApi {
})
})
})
})
}
}
/**授权手机号 */
/**授权手机号
登录
*/
async
authUserPhone
(
detail
,
sessionId
)
{
async
authUserPhone
(
detail
,
loginToken
)
{
if
(
!
sessionId
)
{
if
(
!
loginToken
)
{
wx
.
$api
.
showToast
(
'缺少
sessionId
'
)
wx
.
$api
.
showToast
(
'缺少
loginToken
'
)
Promise
.
reject
()
Promise
.
reject
()
return
}
}
if
(
detail
.
errMsg
&&
detail
.
errMsg
==
'getPhoneNumber:fail user deny'
)
Promise
.
reject
()
if
(
detail
.
errMsg
&&
detail
.
errMsg
==
'getPhoneNumber:fail user deny'
)
Promise
.
reject
()
delete
detail
.
errMsg
delete
detail
.
errMsg
if
(
detail
.
iv
&&
detail
.
encryptedData
)
{
if
(
detail
.
iv
&&
detail
.
encryptedData
)
{
wx
.
$api
.
showLoading
()
detail
.
loginToken
=
loginToken
detail
.
sessionId
=
sessionId
return
api
.
post
({
return
api
.
post
(
method
:
'scrm.api.sso.wechat.applets.auth.phone'
,
{
...
detail
,
method
:
'scrm.api.sso.weapp.auth.phone'
,
platformEntrance
:
'BUSINESS_ASSISTANT'
,
// 平台标识:生意助手-BUSINESS_ASSISTANT,门店助手-STORE_ASSISTANT
...
detail
},
},
true
true
)
)
}
else
Promise
.
reject
()
}
else
Promise
.
reject
()
}
}
/**更新客户手机号 */
/**账号密码登录 */
updataCustomerPhone
()
{
accountLogin
(
data
=
{})
{
let
customerId
=
wx
.
$storage
.
get
(
'srcm_shopmall_customer_id'
),
return
api
.
post
({
merchantId
=
wx
.
$storage
.
get
(
'srcm_shopmall_merchant_id'
)
method
:
'scrm.api.sso.wechat.applets.password.login'
,
api
...
data
,
.
post
({
platformEntrance
:
'BUSINESS_ASSISTANT'
,
method
:
'scrm.api.sso.weapp.mark.phone'
,
},
customerId
,
true
merchantId
)
})
}
.
then
(()
=>
{
/** 手机号获取短信验证码 */
wx
.
removeStorageSync
(
'srcm_shopmall_customer_id'
)
getSmsCode
(
mobile
)
{
})
return
api
.
post
({
method
:
'scrm.api.sso.wechat.applets.sms.get.code'
,
mobile
},
true
)
}
/** 手机号短信验证码登录 */
phoneSmsLogin
(
data
=
{})
{
return
api
.
post
({
method
:
'scrm.api.sso.wechat.applets.sms.login'
,
...
data
,
source
:
'MINIAPP'
,
platformEntrance
:
'BUSINESS_ASSISTANT'
},
true
)
}
}
}
}
export
default
UsersApi
export
default
UsersApi
\ No newline at end of file
\ No newline at end of file
login/index/components/Box/Box.js
View file @
b779454
...
@@ -19,10 +19,10 @@ Component({
...
@@ -19,10 +19,10 @@ Component({
*/
*/
data
:
{
data
:
{
formData
:
{
formData
:
{
phone
:
''
,
phone
:
'
13714966184
'
,
code
:
''
,
code
:
'
8888
'
,
account
:
''
,
account
:
'
admin
'
,
password
:
''
password
:
'
123456789
'
},
},
phoneReady
:
false
,
phoneReady
:
false
,
countDown
:
null
countDown
:
null
...
@@ -55,16 +55,28 @@ Component({
...
@@ -55,16 +55,28 @@ Component({
})
})
this
.
checkFormData
()
this
.
checkFormData
()
},
},
getSms
()
{
getSms
Code
()
{
const
{
const
{
phoneReady
,
phoneReady
,
formData
,
count
count
}
=
this
.
data
}
=
this
.
data
if
(
!
phoneReady
||
count
)
return
if
(
!
phoneReady
||
count
)
return
USERAPI
.
getSmsCode
(
formData
.
phone
).
then
(({
code
,
message
})
=>
{
if
(
code
==
'0'
)
{
this
.
setData
({
this
.
setData
({
count
:
countDown
count
:
countDown
})
})
this
.
countDown
()
this
.
countDown
()
}
else
{
wx
.
$api
.
showToast
(
message
||
'发送验证码失败'
)
}
}).
catch
(
err
=>
{
wx
.
$api
.
showToast
(
err
||
'发送验证码失败'
)
})
},
},
countDown
()
{
countDown
()
{
setTimeout
(()
=>
{
setTimeout
(()
=>
{
...
@@ -101,17 +113,40 @@ Component({
...
@@ -101,17 +113,40 @@ Component({
})
})
},
},
login
()
{
login
()
{
const
{
formData
,
loginType
}
=
this
.
data
,
target
=
{
1
:
'phoneSmsLogin'
,
2
:
'accountLogin'
}
[
loginType
],
obj
=
loginType
==
1
?
{
mobile
:
formData
.
phone
,
code
:
formData
.
code
}
:
{
userName
:
formData
.
account
,
password
:
formData
.
password
}
this
.
setBtnLoading
()
this
.
setBtnLoading
()
setTimeout
(()
=>
{
USERAPI
[
target
](
obj
).
then
(
res
=>
{
console
.
log
(
res
)
this
.
setBtnLoading
(
false
)
}).
catch
(
err
=>
{
this
.
setBtnLoading
(
false
)
this
.
setBtnLoading
(
false
)
}
,
5
e3
)
})
},
},
wxLogin
({
detail
})
{
wxLogin
({
if
(
!
detail
.
code
)
return
detail
})
{
if
(
!
detail
.
code
)
return
this
.
setBtnLoading
()
this
.
setBtnLoading
()
setTimeout
(()
=>
{
USERAPI
.
authUserPhone
(
detail
,
this
.
loginToken
).
then
(
res
=>
{
console
.
log
(
res
)
this
.
setBtnLoading
(
false
)
this
.
setBtnLoading
(
false
)
},
5
e3
)
}).
catch
(
err
=>
{
this
.
setBtnLoading
(
false
)
})
},
},
setBtnLoading
(
loading
=
true
)
{
setBtnLoading
(
loading
=
true
)
{
thisPage
.
setData
({
thisPage
.
setData
({
...
@@ -125,8 +160,10 @@ Component({
...
@@ -125,8 +160,10 @@ Component({
lifetimes
:
{
lifetimes
:
{
attached
:
function
()
{
attached
:
function
()
{
// 在组件实例进入页面节点树时执行
// 在组件实例进入页面节点树时执行
USERAPI
.
login
().
then
(
res
=>
{
USERAPI
.
wxCodeLogin
().
then
(({
console
.
log
(
res
)
data
})
=>
{
this
.
loginToken
=
data
})
})
thisPage
=
wx
.
$router
.
getPageInstance
()
thisPage
=
wx
.
$router
.
getPageInstance
()
},
},
...
...
login/index/components/Box/Box.wxml
View file @
b779454
...
@@ -11,9 +11,9 @@
...
@@ -11,9 +11,9 @@
<input-icon show="{{formData.phone}}" bindtap="clear" data-name="phone" />
<input-icon show="{{formData.phone}}" bindtap="clear" data-name="phone" />
</view>
</view>
<view class="input">
<view class="input">
<input type="number" placeholder="填写验证码" placeholder-class="placeholder" bindinput="input" data-name="code" value="{{formData.code}}" maxlength="
6
" />
<input type="number" placeholder="填写验证码" placeholder-class="placeholder" bindinput="input" data-name="code" value="{{formData.code}}" maxlength="
4
" />
<input-icon show="{{formData.code}}" bindtap="clear" data-name="code" />
<input-icon show="{{formData.code}}" bindtap="clear" data-name="code" />
<view class="sms text-center {{count?'sms-disabled':''}} {{phoneReady?'':'sms-disabled'}} " bindtap="getSms">{{
<view class="sms text-center {{count?'sms-disabled':''}} {{phoneReady?'':'sms-disabled'}} " bindtap="getSms
Code
">{{
count? count + 's':'获取验证码'
count? count + 's':'获取验证码'
}}</view>
}}</view>
<block wx:if="{{smsError}}">
<block wx:if="{{smsError}}">
...
...
login/index/index.js
View file @
b779454
...
@@ -5,8 +5,7 @@ Page({
...
@@ -5,8 +5,7 @@ Page({
* 页面的初始数据
* 页面的初始数据
*/
*/
data
:
{
data
:
{
loginType
:
0
,
loginType
:
0
agree
:
true
},
},
/**
/**
...
@@ -31,7 +30,6 @@ Page({
...
@@ -31,7 +30,6 @@ Page({
wx
.
hideLoading
()
wx
.
hideLoading
()
}
}
})
})
this
.
checkLoginBtn
()
},
},
/**
/**
...
@@ -60,23 +58,22 @@ Page({
...
@@ -60,23 +58,22 @@ Page({
// onShareAppMessage() {
// onShareAppMessage() {
// },
// },
checkLoginBtn
(
flag
=
false
)
{
checkLoginBtn
(
disabled
=
false
)
{
const
{
const
{
agree
,
loginType
loginType
}
=
this
.
data
}
=
this
.
data
if
(
loginType
==
0
)
flag
=
true
if
(
loginType
==
0
)
disabled
=
true
else
{
else
{
const
{
const
{
formData
,
formData
,
phoneReady
phoneReady
}
=
this
.
selectComponent
(
'#box'
).
data
}
=
this
.
selectComponent
(
'#box'
).
data
flag
=
loginType
==
1
?
disabled
=
loginType
==
1
?
phoneReady
&&
formData
.
code
:
phoneReady
&&
formData
.
code
:
formData
.
account
&&
formData
.
password
formData
.
account
&&
formData
.
password
}
}
this
.
setData
({
this
.
setData
({
disabled
:
!
agree
||
!
flag
disabled
:
!
disabled
})
})
},
},
})
})
\ No newline at end of file
\ No newline at end of file
login/index/index.json
View file @
b779454
...
@@ -3,8 +3,7 @@
...
@@ -3,8 +3,7 @@
"navigation-bar"
:
"/components/NavigationBar/NavigationBar"
,
"navigation-bar"
:
"/components/NavigationBar/NavigationBar"
,
"mask"
:
"./components/Mask/Mask"
,
"mask"
:
"./components/Mask/Mask"
,
"box"
:
"./components/Box/Box"
,
"box"
:
"./components/Box/Box"
,
"type-list"
:
"./components/TypeList/TypeList"
,
"type-list"
:
"./components/TypeList/TypeList"
"protocol"
:
"./components/Protocol/Protocol"
},
},
"navigationStyle"
:
"custom"
"navigationStyle"
:
"custom"
}
}
\ No newline at end of file
\ No newline at end of file
login/index/index.wxml
View file @
b779454
...
@@ -3,5 +3,5 @@
...
@@ -3,5 +3,5 @@
<navigation-bar navStyle="background-color: rgba(0,0,0,0)">生意助手</navigation-bar>
<navigation-bar navStyle="background-color: rgba(0,0,0,0)">生意助手</navigation-bar>
<box loginType="{{loginType}}" disabled="{{disabled}}" id="box" />
<box loginType="{{loginType}}" disabled="{{disabled}}" id="box" />
<type-list loginType="{{loginType}}" />
<type-list loginType="{{loginType}}" />
<
protocol agree="{{agree}}" /
>
<
!-- <protocol agree="{{agree}}" /> --
>
</view>
</view>
\ No newline at end of file
\ No newline at end of file
login/loading/loading.js
View file @
b779454
...
@@ -25,6 +25,7 @@ Page({
...
@@ -25,6 +25,7 @@ Page({
* 生命周期函数--监听页面显示
* 生命周期函数--监听页面显示
*/
*/
onShow
()
{
onShow
()
{
wx
.
$api
.
showLoading
()
const
{
const
{
sessionId
,
sessionId
,
}
=
wx
.
$storage
.
get
(),
{
}
=
wx
.
$storage
.
get
(),
{
...
...
login/loading/loading.wxml
View file @
b779454
<view class="layout">
<view class="layout">
<
image class="icon" src="https://img02.glsx.com.cn/weapp/resource/scrm-mobile/crowdfunding/COVER_LIVE.gif"></image
>
<
!-- <image class="icon" src="https://img02.glsx.com.cn/weapp/resource/scrm-mobile/crowdfunding/COVER_LIVE.gif"></image> --
>
</view>
</view>
\ No newline at end of file
\ No newline at end of file
utils/request/environment.js
View file @
b779454
...
@@ -6,7 +6,7 @@ const target = ['ip', 'dev', 'uat', 'prod']
...
@@ -6,7 +6,7 @@ const target = ['ip', 'dev', 'uat', 'prod']
2测试
2测试
3生产
3生产
*/
*/
const
index
=
3
const
index
=
0
const
secretKey
=
{
const
secretKey
=
{
ip
:
{},
ip
:
{},
dev
:
{
dev
:
{
...
@@ -32,7 +32,7 @@ const secretKey = {
...
@@ -32,7 +32,7 @@ const secretKey = {
const
domain
=
{
const
domain
=
{
// ip: 'http://192.168.2.94:8558',
// ip: 'http://192.168.2.94:8558',
// ip: 'http://192.168.2.3:8315',
// ip: 'http://192.168.2.3:8315',
ip
:
'http://192.168.
3.181:8394
'
,
ip
:
'http://192.168.
1.170:8315
'
,
/**登录: 192.168.2.3:8315
/**登录: 192.168.2.3:8315
商城: 192.168.2.3:8558 */
商城: 192.168.2.3:8558 */
dev
:
'https://scrm.dev.glsx.com.cn'
,
dev
:
'https://scrm.dev.glsx.com.cn'
,
...
...
utils/request/request.js
View file @
b779454
...
@@ -2,14 +2,12 @@ import {
...
@@ -2,14 +2,12 @@ import {
secretKey
,
secretKey
,
pathEnum
,
pathEnum
,
domain
,
domain
,
index
,
sign
sign
}
from
'./http.js'
}
from
'./http.js'
// import util from '../util'
// import util from '../util'
import
{
import
{
getSessionId
getSessionId
}
from
'~/utils/cache/storageApi'
}
from
'~/utils/cache/storageApi'
let
INTERRUPT
=
false
/**接口 */
/**接口 */
class
Request
{
class
Request
{
get
(
params
,
returnAll
=
false
)
{
get
(
params
,
returnAll
=
false
)
{
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment