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 1286910d
authored
Oct 18, 2022
by
李伟康
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
提交代码
1 parent
ba354600
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
115 additions
and
111 deletions
api/api.js
api/index.js
api/ssoApi.js
api/usersApi/UsersApi.js
app.js
login/index/components/Box/Box.js
login/loading/loading.js
pages/tab/index/index.js
pages/webView/webView.js
utils/constantData.js
utils/request/request.js
utils/share.js
api/api.js
View file @
1286910
import
api
from
'~/utils/request/request'
import
api
from
'~/utils/request/request'
import
ssoApi
from
'./ssoApi'
const
common
=
'scrm.api.carlife.common.'
const
common
=
'scrm.api.carlife.common.'
module
.
exports
=
{
module
.
exports
=
{
ssoApi
,
commonApi
:
{
commonApi
:
{
/**上传图片
/**上传图片
*/
*/
...
...
api/index.js
View file @
1286910
/**
/**
* 拓客户,看线索接口
* 拓客户,看线索接口
*/
*/
import
api
from
'~/utils/request/request'
import
api
from
'~/utils/request/request'
const
common
=
'scrm.api.carlife.common.'
const
common
=
'scrm.api.carlife.common.'
// 拓客户
// 拓客户
// 看线索
// 看线索
module
.
exports
=
{
/** 线索埋点数据上报
* operationType 操作类型(0:分享 1:浏览 2:申请活动)
*/
reportData
(
data
=
{},
operationType
=
0
)
{
return
api
.
post
({
method
:
'scrm.api.busassistant.clue.report'
,
...
data
,
operationType
,
operationDate
:
new
Date
().
format
(
'yyyy-MM-dd hh:mm:ss'
),
})
}
}
\ No newline at end of file
\ No newline at end of file
api/ssoApi.js
deleted
100644 → 0
View file @
ba35460
import
api
from
'~/utils/request/request'
const
path
=
'scrm.api.sso.weapp.'
module
.
exports
=
{
/**wx.login登录 */
jsCodeLogin
(
data
)
{
return
api
.
post
(
{
method
:
`
${
path
}
jscode.login`
,
...
data
},
true
)
},
/**授权用户信息 */
authUserInfo
(
data
)
{
return
api
.
post
(
{
method
:
'scrm.api.sso.weapp.auth.userinfo'
,
...
data
},
true
)
},
/**授权手机号 */
authUserPhone
(
data
)
{
return
api
.
post
(
{
method
:
`
${
path
}
auth.phone`
,
...
data
},
true
)
},
/**退出 */
logout
()
{
return
api
.
post
(
{
method
:
`scrm.api.sso.user.logout`
},
true
)
},
//保存用户授权信息
saveuserProfile
(
data
)
{
return
api
.
post
(
{
method
:
`scrm.api.wechat.auth.userProfile.save`
,
...
data
},
true
)
},
/**更新客户手机号 */
updataCustomerPhone
(
data
)
{
return
api
.
post
({
method
:
`scrm.api.sso.weapp.mark.phone`
,
...
data
})
}
}
api/usersApi/UsersApi.js
View file @
1286910
import
api
from
'~/utils/request/request'
import
api
from
'~/utils/request/request'
const
{
appId
}
=
wx
.
getAccountInfoSync
().
miniProgram
const
{
appId
}
=
wx
.
getAccountInfoSync
().
miniProgram
const
CODE
=
{
const
CODE
=
{
platformEntrance
:
'BUSINESS_ASSISTANT'
,
platformEntrance
:
'BUSINESS_ASSISTANT'
,
productCode
:
'PC00c3'
productCode
:
'PC00c3'
...
@@ -7,9 +9,10 @@ const CODE = {
...
@@ -7,9 +9,10 @@ const CODE = {
class
UsersApi
{
class
UsersApi
{
/**调用后台接口获取用户信息js_code换取sessionId */
/**调用后台接口获取用户信息js_code换取sessionId */
async
wxCodeLogin
()
{
async
wxCodeLogin
()
{
const
{
code
}
=
await
this
.
getWxCode
()
const
{
return
await
api
.
post
(
code
{
}
=
await
this
.
getWxCode
()
return
await
api
.
post
({
method
:
'scrm.api.sso.wechat.applets.jscode.login'
,
method
:
'scrm.api.sso.wechat.applets.jscode.login'
,
appId
,
appId
,
code
code
...
@@ -19,8 +22,7 @@ class UsersApi {
...
@@ -19,8 +22,7 @@ class UsersApi {
}
}
/**退出登录 */
/**退出登录 */
logout
()
{
logout
()
{
return
api
.
post
(
return
api
.
post
({
{
method
:
'scrm.api.sso.wechat.applets.logout'
method
:
'scrm.api.sso.wechat.applets.logout'
},
},
true
true
...
@@ -46,8 +48,7 @@ class UsersApi {
...
@@ -46,8 +48,7 @@ class UsersApi {
delete
detail
.
errMsg
delete
detail
.
errMsg
if
(
detail
.
iv
&&
detail
.
encryptedData
)
{
if
(
detail
.
iv
&&
detail
.
encryptedData
)
{
detail
.
loginToken
=
loginToken
detail
.
loginToken
=
loginToken
return
api
.
post
(
return
api
.
post
({
{
method
:
'scrm.api.sso.wechat.applets.auth.phone'
,
method
:
'scrm.api.sso.wechat.applets.auth.phone'
,
...
detail
,
...
detail
,
platformEntrance
:
'BUSINESS_ASSISTANT'
// 平台标识:生意助手-BUSINESS_ASSISTANT,门店助手-STORE_ASSISTANT
platformEntrance
:
'BUSINESS_ASSISTANT'
// 平台标识:生意助手-BUSINESS_ASSISTANT,门店助手-STORE_ASSISTANT
...
@@ -58,8 +59,7 @@ class UsersApi {
...
@@ -58,8 +59,7 @@ class UsersApi {
}
}
/**账号密码登录 */
/**账号密码登录 */
async
accountLogin
(
data
=
{})
{
async
accountLogin
(
data
=
{})
{
return
api
.
post
(
return
api
.
post
({
{
method
:
'scrm.api.sso.wechat.applets.password.login'
,
method
:
'scrm.api.sso.wechat.applets.password.login'
,
...
data
,
...
data
,
...
CODE
...
CODE
...
@@ -69,8 +69,7 @@ class UsersApi {
...
@@ -69,8 +69,7 @@ class UsersApi {
}
}
/** 手机号获取短信验证码 */
/** 手机号获取短信验证码 */
getSmsCode
(
mobile
)
{
getSmsCode
(
mobile
)
{
return
api
.
post
(
return
api
.
post
({
{
method
:
'scrm.api.sso.wechat.applets.sms.get.code'
,
method
:
'scrm.api.sso.wechat.applets.sms.get.code'
,
mobile
mobile
},
},
...
@@ -79,8 +78,7 @@ class UsersApi {
...
@@ -79,8 +78,7 @@ class UsersApi {
}
}
/** 手机号短信验证码登录 */
/** 手机号短信验证码登录 */
phoneSmsLogin
(
data
=
{})
{
phoneSmsLogin
(
data
=
{})
{
return
api
.
post
(
return
api
.
post
({
{
method
:
'scrm.api.sso.wechat.applets.sms.login'
,
method
:
'scrm.api.sso.wechat.applets.sms.login'
,
...
data
,
...
data
,
source
:
'MINIAPP'
,
source
:
'MINIAPP'
,
...
@@ -91,8 +89,7 @@ class UsersApi {
...
@@ -91,8 +89,7 @@ class UsersApi {
}
}
/** 获取登录账号列表 */
/** 获取登录账号列表 */
getAccountList
(
sessionId
)
{
getAccountList
(
sessionId
)
{
return
api
.
post
(
return
api
.
post
({
{
method
:
'scrm.api.sso.wechat.applets.listSelectAccount'
,
method
:
'scrm.api.sso.wechat.applets.listSelectAccount'
,
...
CODE
,
...
CODE
,
sessionId
sessionId
...
@@ -103,8 +100,7 @@ class UsersApi {
...
@@ -103,8 +100,7 @@ class UsersApi {
/**
/**
* 选择账号登录(手机绑定多个账号时) */
* 选择账号登录(手机绑定多个账号时) */
selectAccountLogin
(
data
)
{
selectAccountLogin
(
data
)
{
return
api
.
post
(
return
api
.
post
({
{
method
:
'scrm.api.sso.wechat.applets.selectAccountLogin'
,
method
:
'scrm.api.sso.wechat.applets.selectAccountLogin'
,
...
CODE
,
...
CODE
,
...
data
...
data
...
@@ -114,8 +110,7 @@ class UsersApi {
...
@@ -114,8 +110,7 @@ class UsersApi {
}
}
/**检查sessionId 是否过期 */
/**检查sessionId 是否过期 */
checkSession
()
{
checkSession
()
{
return
api
.
post
(
return
api
.
post
({
{
method
:
'scrm.api.sso.login.status.check'
method
:
'scrm.api.sso.login.status.check'
},
},
true
true
...
@@ -123,8 +118,7 @@ class UsersApi {
...
@@ -123,8 +118,7 @@ class UsersApi {
}
}
/** 超级管理员切换账号 */
/** 超级管理员切换账号 */
adminSelectLogin
(
data
)
{
adminSelectLogin
(
data
)
{
return
api
.
post
(
return
api
.
post
({
{
method
:
'scrm.api.sso.super.administrator.select.login'
,
method
:
'scrm.api.sso.super.administrator.select.login'
,
...
CODE
,
...
CODE
,
...
data
...
data
...
@@ -140,5 +134,24 @@ class UsersApi {
...
@@ -140,5 +134,24 @@ class UsersApi {
...
data
...
data
})
})
}
}
/** 手机号授权解析(单纯解析内容返回前端)
* 只传loginToken就返回unionId和openid
* 传加密信息就解析手机号
*/
async
getUserProfile
(
loginToken
,
detail
=
{})
{
if
(
detail
.
errMsg
&&
detail
.
errMsg
==
'getPhoneNumber:fail user deny'
)
Promise
.
reject
()
delete
detail
.
errMsg
if
(
!
loginToken
)
{
let
res
=
await
this
.
wxCodeLogin
()
loginToken
=
res
.
data
}
detail
.
loginToken
=
loginToken
return
api
.
post
({
method
:
'scrm.api.sso.wechat.applets.phone.grant.analysis'
,
...
detail
,
platformEntrance
:
'BUSINESS_ASSISTANT'
}
)
}
}
}
export
default
UsersApi
export
default
UsersApi
\ No newline at end of file
\ No newline at end of file
app.js
View file @
1286910
...
@@ -12,7 +12,7 @@ import { setSystem_info } from '~/utils/cache/storageApi'
...
@@ -12,7 +12,7 @@ import { setSystem_info } from '~/utils/cache/storageApi'
import
getUpdateManager
from
'./utils/lib/wxUpdateManager'
import
getUpdateManager
from
'./utils/lib/wxUpdateManager'
// 埋点
// 埋点
import
'./utils/track/Track'
//
import './utils/track/Track'
import
eventbus
from
'./utils/evenbus'
import
eventbus
from
'./utils/evenbus'
...
...
login/index/components/Box/Box.js
View file @
1286910
...
@@ -160,12 +160,10 @@ Component({
...
@@ -160,12 +160,10 @@ Component({
2
:
'accountLogin'
2
:
'accountLogin'
}
[
loginType
],
}
[
loginType
],
obj
=
obj
=
loginType
==
1
?
loginType
==
1
?
{
{
mobile
:
formData
.
phone
,
mobile
:
formData
.
phone
,
code
:
formData
.
code
code
:
formData
.
code
}
:
}
:
{
{
userName
:
formData
.
account
,
userName
:
formData
.
account
,
password
:
md5
(
formData
.
password
)
password
:
md5
(
formData
.
password
)
}
}
...
@@ -275,6 +273,9 @@ Component({
...
@@ -275,6 +273,9 @@ Component({
disabled
:
false
disabled
:
false
})
})
this
.
loginToken
=
data
this
.
loginToken
=
data
USERAPI
.
getUserProfile
(
data
).
then
(
data
=>
{
wx
.
$storage
.
set
(
'wx_user_info'
,
data
)
})
}
else
this
.
reLogin
(
message
)
}
else
this
.
reLogin
(
message
)
wx
.
hideLoading
()
wx
.
hideLoading
()
}
catch
({
}
catch
({
...
...
login/loading/loading.js
View file @
1286910
pages/tab/index/index.js
View file @
1286910
...
@@ -534,5 +534,5 @@ Page({
...
@@ -534,5 +534,5 @@ Page({
* 用户点击右上角分享
* 用户点击右上角分享
*/
*/
onShareAppMessage
:
function
()
{},
onShareAppMessage
:
function
()
{},
onShareTimeline
:
function
()
{}
,
onShareTimeline
:
function
()
{}
});
});
pages/webView/webView.js
View file @
1286910
...
@@ -29,7 +29,7 @@ Page({
...
@@ -29,7 +29,7 @@ Page({
let
param
=
this
.
getParams
(
decodeUrl
)
let
param
=
this
.
getParams
(
decodeUrl
)
if
(
param
.
urlParam
)
{
if
(
param
.
urlParam
)
{
let
query
=
JSON
.
parse
(
param
.
urlParam
)
let
query
=
JSON
.
parse
(
param
.
urlParam
)
this
.
data
.
refresh
=
query
.
refresh
this
.
refresh
=
query
.
refresh
}
}
this
.
setData
({
this
.
setData
({
url
:
decodeUrl
url
:
decodeUrl
...
@@ -46,7 +46,7 @@ Page({
...
@@ -46,7 +46,7 @@ Page({
* 生命周期函数--监听页面显示
* 生命周期函数--监听页面显示
*/
*/
onShow
:
function
()
{
onShow
:
function
()
{
if
(
this
.
data
.
refresh
)
{
if
(
this
.
refresh
)
{
this
.
setData
(
this
.
setData
(
{
{
flag
:
true
flag
:
true
...
@@ -64,7 +64,7 @@ Page({
...
@@ -64,7 +64,7 @@ Page({
* 生命周期函数--监听页面隐藏
* 生命周期函数--监听页面隐藏
*/
*/
onHide
:
function
()
{
onHide
:
function
()
{
if
(
this
.
data
.
refresh
)
{
if
(
this
.
refresh
)
{
this
.
setData
({
this
.
setData
({
flag
:
false
flag
:
false
})
})
...
@@ -75,7 +75,7 @@ Page({
...
@@ -75,7 +75,7 @@ Page({
* 生命周期函数--监听页面卸载
* 生命周期函数--监听页面卸载
*/
*/
onUnload
:
function
()
{
onUnload
:
function
()
{
if
(
this
.
data
.
refresh
)
{
if
(
this
.
refresh
)
{
this
.
setData
({
this
.
setData
({
flag
:
false
flag
:
false
})
})
...
...
utils/constantData.js
View file @
1286910
...
@@ -10,5 +10,6 @@ export const STORAGE_OBJECTkEY = {
...
@@ -10,5 +10,6 @@ export const STORAGE_OBJECTkEY = {
userInfo
:
'userInfo'
,
userInfo
:
'userInfo'
,
system_info
:
'systemInfo'
,
system_info
:
'systemInfo'
,
app_title
:
'appTitle'
,
app_title
:
'appTitle'
,
auto_login_object
:
'auto_login_object'
auto_login_object
:
'auto_login_object'
,
wx_user_info
:
'wx_user_info'
}
}
\ No newline at end of file
\ No newline at end of file
utils/request/request.js
View file @
1286910
import
{
secretKey
,
pathEnum
,
domain
,
sign
}
from
'./http.js'
import
{
import
{
getSessionId
}
from
'~/utils/cache/storageApi'
secretKey
,
pathEnum
,
domain
,
sign
}
from
'./http.js'
import
{
getSessionId
}
from
'~/utils/cache/storageApi'
import
network
from
'~/utils/network'
import
network
from
'~/utils/network'
/**接口 */
/**接口 */
class
Request
{
class
Request
{
...
@@ -15,14 +22,15 @@ class Request {
...
@@ -15,14 +22,15 @@ class Request {
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
wx
.
showNavigationBarLoading
()
wx
.
showNavigationBarLoading
()
let
header
=
let
header
=
RequestMethods
===
'POST'
RequestMethods
===
'POST'
?
?
{
{
'content-type'
:
'application/x-www-form-urlencoded'
'content-type'
:
'application/x-www-form-urlencoded'
}
}
:
:
{}
{}
let
projectName
=
this
.
getRopProject
(
params
.
method
)
let
projectName
=
this
.
getRopProject
(
params
.
method
)
if
(
!
projectName
)
projectName
=
this
.
getRopProject
(
params
.
method
)
if
(
!
projectName
)
projectName
=
this
.
getRopProject
(
params
.
method
)
const
path
=
pathEnum
[
projectName
]
let
path
=
pathEnum
[
projectName
]
if
(
!
path
)
path
=
`/rop-scrm-
${
projectName
}
/`
params
=
this
.
getData
(
params
)
params
=
this
.
getData
(
params
)
wx
.
request
({
wx
.
request
({
url
:
`
${
domain
}${
path
}
router?method=
${
params
.
method
}
`
,
url
:
`
${
domain
}${
path
}
router?method=
${
params
.
method
}
`
,
...
@@ -34,7 +42,10 @@ class Request {
...
@@ -34,7 +42,10 @@ class Request {
success
(
response
)
{
success
(
response
)
{
/**业务代码 */
/**业务代码 */
let
{
let
{
data
:
{
code
,
message
},
data
:
{
code
,
message
},
data
data
}
=
response
}
=
response
if
(
code
==
20
||
code
==
21
)
{
if
(
code
==
20
||
code
==
21
)
{
...
...
utils/share.js
View file @
1286910
...
@@ -5,8 +5,13 @@
...
@@ -5,8 +5,13 @@
* @param {*} shareQuery 分享页面参数
* @param {*} shareQuery 分享页面参数
* @param {*} noPageAuth 分享页面是否需要登录拦截
* @param {*} noPageAuth 分享页面是否需要登录拦截
* @param {*} shareFun 分享页面
* @param {*} shareFun 分享页面
* @param {*} isShareTrack 是否分享埋点
* @returns
* @returns
*/
*/
import
{
reportData
}
from
'~/api/index.js'
class
Share
{
class
Share
{
constructor
()
{
constructor
()
{
console
.
log
(
'---------------- 分享初始化 ----------------'
)
console
.
log
(
'---------------- 分享初始化 ----------------'
)
...
@@ -34,13 +39,15 @@ class Share {
...
@@ -34,13 +39,15 @@ class Share {
shareImage
,
shareImage
,
shareQuery
,
shareQuery
,
noPageAuth
,
noPageAuth
,
shareFun
shareFun
,
}
=
this
,
shareTrackData
path
=
`/
${
this
.
route
}
`
}
=
page
,
path
=
`/
${
page
.
route
}
`
if
(
sharePath
)
path
=
`/
${
sharePath
}
`
if
(
sharePath
)
path
=
`/
${
sharePath
}
`
if
(
shareQuery
)
path
+=
`?
${
shareQuery
}
`
if
(
shareQuery
)
path
+=
`?
${
shareQuery
}
`
if
(
!
noPageAuth
)
path
=
`/login/loading/loading?url=
${
encodeURIComponent
(
path
)}
`
if
(
!
noPageAuth
)
path
=
`/login/loading/loading?url=
${
encodeURIComponent
(
path
)}
`
if
(
shareFun
)
shareFun
()
if
(
shareFun
)
shareFun
()
if
(
shareTrackData
)
this
.
reportShareData
(
shareTrackData
)
return
{
return
{
path
,
path
,
title
:
shareTitle
,
title
:
shareTitle
,
...
@@ -54,9 +61,11 @@ class Share {
...
@@ -54,9 +61,11 @@ class Share {
shareTitle
,
shareTitle
,
shareImage
,
shareImage
,
shareQuery
,
shareQuery
,
shareFun
shareFun
,
}
=
this
shareTrackData
}
=
page
if
(
shareFun
)
shareFun
()
if
(
shareFun
)
shareFun
()
if
(
shareTrackData
)
this
.
reportShareData
(
shareTrackData
)
return
{
return
{
query
:
shareQuery
,
query
:
shareQuery
,
title
:
shareTitle
,
title
:
shareTitle
,
...
@@ -66,5 +75,23 @@ class Share {
...
@@ -66,5 +75,23 @@ class Share {
}
}
}
}
reportShareData
(
shareTrackData
)
{
const
WXUSERINFO
=
wx
.
$storage
.
get
(
'wx_user_info'
),
USERINFO
=
wx
.
$storage
.
get
(
'userInfo'
)
console
.
log
(
shareTrackData
,
'============'
)
reportData
({
openId
:
WXUSERINFO
.
openId
||
''
,
unionId
:
WXUSERINFO
.
unionId
||
''
,
nickName
:
WXUSERINFO
.
nickName
||
''
,
avatar
:
WXUSERINFO
.
avatarUrl
||
''
,
phone
:
USERINFO
.
phone
||
''
,
merchantId
:
USERINFO
.
merchantId
||
''
,
shareOpenId
:
WXUSERINFO
.
openId
||
''
,
sharePhone
:
USERINFO
.
phone
||
''
,
...
shareTrackData
}).
then
(
res
=>
{
console
.
log
(
res
)
})
}
}
}
new
Share
()
new
Share
()
\ No newline at end of file
\ No newline at end of file
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