Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
store-assistant-assemble
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 6f2e41a3
authored
Apr 25, 2023
by
前端
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fixed
1 parent
089669a9
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
237 additions
and
225 deletions
api/merchants.js
api/usersApi/UsersApi.js
login/lib/index.js
pages/tab/logout/logout.js
pages/tab/output/components/client/client.js
pages/tab/output/output.js
project.private.config.json
utils/cache/storageApi.js
utils/constantData.js
utils/request/environment.js
utils/request/request.js
api/merchants.js
0 → 100644
View file @
6f2e41a
import
api
from
'~/utils/request/request'
module
.
exports
=
{
/**根据商户查询商户下级列表 */
findSubordinateListByPage
(
data
)
{
return
api
.
post
({
method
:
`merchants.api.open.findSubordinateListByPage`
,
...
data
})
}
}
\ No newline at end of file
api/usersApi/UsersApi.js
View file @
6f2e41a
import
api
from
'~/utils/request/request'
const
{
appId
appId
}
=
wx
.
getAccountInfoSync
().
miniProgram
const
CODE
=
{
platformEntrance
:
'STORE_ASSISTANT_TOTAL'
,
productCode
:
'PC00c5'
platformEntrance
:
'STORE_ASSISTANT_TOTAL'
,
productCode
:
'PC00c5'
}
class
UsersApi
{
/**调用后台接口获取用户信息js_code换取sessionId */
async
wxCodeLogin
()
{
const
appEnter
=
wx
.
getEnterOptionsSync
()
try
{
if
(
appEnter
.
scene
===
1154
&&
appEnter
.
mode
===
'singlePage'
)
throw
'login:fail rejected due to no permission currently'
const
{
code
}
=
await
this
.
getWxCode
()
return
await
api
.
post
({
method
:
'scrm.api.sso.wechat.applets.jscode.login'
,
appId
,
code
/**调用后台接口获取用户信息js_code换取sessionId */
async
wxCodeLogin
()
{
const
appEnter
=
wx
.
getEnterOptionsSync
()
try
{
if
(
appEnter
.
scene
===
1154
&&
appEnter
.
mode
===
'singlePage'
)
throw
'login:fail rejected due to no permission currently'
const
{
code
}
=
await
this
.
getWxCode
()
return
await
api
.
post
({
method
:
'scrm.api.sso.wechat.applets.jscode.login'
,
appId
,
code
},
true
)
}
catch
(
error
)
{
console
.
log
(
error
)
return
Promise
.
reject
()
}
}
/**退出登录 */
logout
()
{
return
api
.
post
({
method
:
'scrm.api.sso.wechat.applets.logout'
},
true
)
}
/**调用接口获取登录凭证(code)。通过凭证进而换取用户登录态信息,包括用户在当前小程序的唯一标识(openid)、微信开放平台帐号下的唯一标识(unionid,若当前小程序已绑定到微信开放平台帐号)及本次登录的会话密钥(session_key)等。用户数据的加解密通讯需要依赖会话密钥完成。 */
getWxCode
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
wx
.
login
({
success
:
res
=>
resolve
(
res
),
fail
:
err
=>
reject
(
err
)
})
})
}
/**授权手机号登录 */
async
authUserPhone
(
detail
,
loginToken
)
{
if
(
!
loginToken
)
{
wx
.
$api
.
showToast
(
'缺少loginToken'
)
Promise
.
reject
()
return
}
if
(
detail
.
errMsg
&&
detail
.
errMsg
==
'getPhoneNumber:fail user deny'
)
Promise
.
reject
()
delete
detail
.
errMsg
if
(
detail
.
iv
&&
detail
.
encryptedData
)
{
detail
.
loginToken
=
loginToken
return
api
.
post
({
method
:
'scrm.api.sso.wechat.applets.auth.phone'
,
...
detail
,
platformEntrance
:
'STORE_ASSISTANT_TOTAL'
// 平台标识:生意助手-STORE_ASSISTANT_TOTAL,门店助手-STORE_ASSISTANT,门店助手-店总版-STORE_ASSISTANT_TOTAL
},
true
)
}
else
Promise
.
reject
()
}
/**账号密码登录 */
async
accountLogin
(
data
=
{})
{
return
api
.
post
({
method
:
'scrm.api.sso.wechat.applets.password.login'
,
...
data
,
...
CODE
},
true
)
}
catch
(
error
)
{
console
.
log
(
error
)
return
Promise
.
reject
()
}
}
/**退出登录 */
logout
()
{
return
api
.
post
({
method
:
'scrm.api.sso.wechat.applets.logout'
},
true
)
}
/**调用接口获取登录凭证(code)。通过凭证进而换取用户登录态信息,包括用户在当前小程序的唯一标识(openid)、微信开放平台帐号下的唯一标识(unionid,若当前小程序已绑定到微信开放平台帐号)及本次登录的会话密钥(session_key)等。用户数据的加解密通讯需要依赖会话密钥完成。 */
getWxCode
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
wx
.
login
({
success
:
res
=>
resolve
(
res
),
fail
:
err
=>
reject
(
err
)
})
})
}
/**授权手机号登录 */
async
authUserPhone
(
detail
,
loginToken
)
{
if
(
!
loginToken
)
{
wx
.
$api
.
showToast
(
'缺少loginToken'
)
Promise
.
reject
()
return
}
if
(
detail
.
errMsg
&&
detail
.
errMsg
==
'getPhoneNumber:fail user deny'
)
Promise
.
reject
()
delete
detail
.
errMsg
if
(
detail
.
iv
&&
detail
.
encryptedData
)
{
detail
.
loginToken
=
loginToken
return
api
.
post
({
method
:
'scrm.api.sso.wechat.applets.auth.phone'
,
...
detail
,
platformEntrance
:
'STORE_ASSISTANT_TOTAL'
// 平台标识:生意助手-STORE_ASSISTANT_TOTAL,门店助手-STORE_ASSISTANT,门店助手-店总版-STORE_ASSISTANT_TOTAL
true
)
}
/** 手机号获取短信验证码 */
getSmsCode
(
mobile
)
{
return
api
.
post
({
method
:
'scrm.api.sso.wechat.applets.sms.get.code'
,
mobile
},
true
)
}
else
Promise
.
reject
()
}
/**账号密码登录 */
async
accountLogin
(
data
=
{})
{
return
api
.
post
({
method
:
'scrm.api.sso.wechat.applets.password.login'
,
...
data
,
...
CODE
},
true
)
}
/** 手机号获取短信验证码 */
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
:
'STORE_ASSISTANT_TOTAL'
},
true
)
}
/** 获取登录账号列表 */
getAccountList
(
sessionId
)
{
return
api
.
post
({
method
:
'scrm.api.sso.wechat.applets.listSelectAccount'
,
...
CODE
,
sessionId
},
true
)
}
/**
* 选择账号登录(手机绑定多个账号时) */
selectAccountLogin
(
data
)
{
return
api
.
post
({
method
:
'scrm.api.sso.wechat.applets.selectAccountLogin'
,
...
CODE
,
...
data
},
true
)
}
/**检查sessionId 是否过期 */
checkSession
()
{
return
api
.
post
({
method
:
'scrm.api.sso.login.status.check'
},
true
)
}
/** 超级管理员切换账号 */
adminSelectLogin
(
data
)
{
return
api
.
post
({
method
:
'scrm.api.sso.super.administrator.select.login'
,
...
CODE
,
...
data
}
// true
)
}
/** 超管切换子账号 */
switchSubLoginInfo
(
data
)
{
return
api
.
post
({
method
:
'scrm.api.sso.wechat.applets.switch.subLoginInfo'
,
...
CODE
,
...
data
})
}
/**获取微信用户信息 */
async
getWXUserInfo
()
{
let
wx_user_info
=
wx
.
$storage
.
get
(
'wx_user_info'
)
if
(
!
wx_user_info
)
{
const
data
=
await
this
.
getUserProfile
()
wx
.
$storage
.
set
(
'wx_user_info'
,
data
)
return
data
}
else
return
wx_user_info
}
/** 手机号授权解析(单纯解析内容返回前端)
* 只传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
:
'STORE_ASSISTANT_TOTAL'
})
}
// 登录自动创建服务中心
initServiceCenter
(
data
)
{
return
api
.
post
(
{
method
:
'scrm.api.busassistant.serviceCenter.init'
,
...
data
}
)
}
true
)
}
/** 手机号短信验证码登录 */
phoneSmsLogin
(
data
=
{})
{
return
api
.
post
({
method
:
'scrm.api.sso.wechat.applets.sms.login'
,
...
data
,
source
:
'MINIAPP'
,
platformEntrance
:
'STORE_ASSISTANT_TOTAL'
},
true
)
}
/** 获取登录账号列表 */
getAccountList
(
sessionId
)
{
return
api
.
post
({
method
:
'scrm.api.sso.wechat.applets.listSelectAccount'
,
...
CODE
,
sessionId
},
true
)
}
/**
* 选择账号登录(手机绑定多个账号时) */
selectAccountLogin
(
data
)
{
return
api
.
post
({
method
:
'scrm.api.sso.wechat.applets.selectAccountLogin'
,
...
CODE
,
...
data
},
true
)
}
/**检查sessionId 是否过期 */
checkSession
()
{
return
api
.
post
({
method
:
'scrm.api.sso.login.status.check'
},
true
)
}
/** 超级管理员切换账号 */
adminSelectLogin
(
data
)
{
return
api
.
post
({
method
:
'scrm.api.sso.super.administrator.select.login'
,
...
CODE
,
...
data
}
// true
)
}
/** 超管切换子账号 */
switchSubLoginInfo
(
data
)
{
return
api
.
post
({
method
:
'scrm.api.sso.wechat.applets.switch.subLoginInfo'
,
...
CODE
,
...
data
})
}
/**获取微信用户信息 */
async
getWXUserInfo
()
{
let
wx_user_info
=
wx
.
$storage
.
get
(
'wx_user_info'
)
if
(
!
wx_user_info
)
{
const
data
=
await
this
.
getUserProfile
()
wx
.
$storage
.
set
(
'wx_user_info'
,
data
)
return
data
}
else
return
wx_user_info
}
/** 手机号授权解析(单纯解析内容返回前端)
* 只传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
:
'STORE_ASSISTANT_TOTAL'
})
}
// 登录自动创建服务中心
initServiceCenter
(
data
)
{
return
api
.
post
(
{
method
:
'scrm.api.busassistant.serviceCenter.init'
,
...
data
}
)
}
/**根据商户查询商户下级列表 */
findSubordinateListByPage
(
data
)
{
return
api
.
post
({
method
:
`merchants.api.open.findSubordinateListByPage`
,
...
data
,
},
false
,
'merchant'
)
}
}
export
default
UsersApi
\ No newline at end of file
login/lib/index.js
View file @
6f2e41a
import
{
setSessionId
,
setUserInfo
setUserInfo
,
setSubMerchant
}
from
'~/utils/cache/storageApi'
import
USERAPI
from
'~/api/usersApi/index'
const
setRouteData
=
targetPath
=>
{
...
...
@@ -32,21 +33,34 @@ const selectAccountLogin = ({
message
})
=>
{
if
(
code
==
'0'
)
{
console
.
log
(
data
)
setLoginInfo
(
data
.
loginUserInfoList
[
0
],
data
.
sessionId
)
}
else
wx
.
$api
.
showToast
(
message
||
'系统异常'
)
})
}
/**获取门店号下的全部门店 */
const
findSubordinateListByPage
=
(
userInfo
)
=>
{
return
new
Promise
(
resolve
=>
{
USERAPI
.
findSubordinateListByPage
({
pageSize
:
10000
,
pageNum
:
1
,
merchantId
:
userInfo
.
merchantId
,
apiProjectName
:
'rop-merchants'
}).
then
(
res
=>
{
const
list
=
res
.
data
||
[]
const
merchant
=
list
.
map
(
i
=>
i
.
merchantNo
)
setSubMerchant
(
merchant
)
resolve
()
})
})
}
/**设置登录信息 */
const
setLoginInfo
=
(
userInfo
,
sessionId
)
=>
{
const
setLoginInfo
=
async
(
userInfo
,
sessionId
)
=>
{
if
(
!
userInfo
)
{
wx
.
$api
.
showToast
(
'
仅支持服务商类型账户登录
'
)
wx
.
$api
.
showToast
(
'
账户错误
'
)
return
}
// 自动创建服务中心
// initServiceCenter()
setUserInfo
(
userInfo
)
setSessionId
(
sessionId
)
try
{
await
findSubordinateListByPage
(
userInfo
)
}
catch
(
error
)
{
}
loginSuccess
()
}
const
initServiceCenter
=
()
=>
{
...
...
pages/tab/logout/logout.js
View file @
6f2e41a
...
...
@@ -37,6 +37,7 @@ Page({
// wx.$storage.rm('fileList')
wx
.
$storage
.
rm
(
'sessionId'
)
wx
.
$storage
.
rm
(
'userInfo'
)
wx
.
$storage
.
rm
(
'subMerchant'
)
wx
.
$storage
.
rm
(
'auto_login_object'
)
wx
.
$storage
.
rm
(
'posterId'
)
wx
.
$storage
.
rm
(
"mock_data"
)
...
...
pages/tab/output/components/client/client.js
View file @
6f2e41a
...
...
@@ -83,53 +83,16 @@ Component({
crowdOrderObj
:
{}
})
},
// 众筹数据处理
dealCrowdObj
(
data
)
{
let
_obj
=
{
totalNum
:
data
.
activityTotal
,
totalOrderCount
:
data
.
orderTotal
,
totalAmount
:
data
.
totalAmount
,
activityList
:
data
.
activityList
||
[]
}
_obj
.
activityList
.
forEach
(
k
=>
{
// 时间
k
.
time
=
k
.
startTime
.
slice
(
0
,
16
).
replace
(
/-/g
,
'.'
)
+
' - '
+
k
.
endTime
.
slice
(
0
,
16
).
replace
(
/-/g
,
'.'
)
let
startTimeFormat
=
k
.
startTime
.
slice
(
0
,
10
).
replace
(
/-/g
,
'/'
)
+
' 00:00:00'
let
nowDateFormat
=
new
Date
().
toLocaleDateString
().
replace
(
/-/g
,
'/'
)
+
' 23:59:59'
// activityStatus 1:未开始 2:进行中 3:已结束
switch
(
k
.
activityStatus
)
{
case
1
:
k
.
interDays
=
parseInt
((
new
Date
(
startTimeFormat
).
getTime
()
-
new
Date
().
getTime
())
/
(
1000
*
60
*
60
*
24
))
+
1
k
.
realTime
=
'-'
break
case
2
:
let
endTimeFormat
=
k
.
endTime
.
slice
(
0
,
10
).
replace
(
/-/g
,
'/'
)
+
' 23:59:59'
k
.
interDays
=
parseInt
((
new
Date
().
getTime
()
-
new
Date
(
startTimeFormat
).
getTime
())
/
(
1000
*
60
*
60
*
24
))
+
1
k
.
toEndDays
=
parseInt
((
new
Date
(
endTimeFormat
).
getTime
()
-
new
Date
(
nowDateFormat
).
getTime
())
/
(
1000
*
60
*
60
*
24
))
+
1
k
.
realTime
=
k
.
realStartTime
?.
slice
(
0
,
16
).
replace
(
/-/g
,
'.'
)
+
' - '
+
'已开始'
+
k
.
interDays
+
'天'
break
case
3
:
k
.
interDays
=
parseInt
((
new
Date
(
nowDateFormat
).
getTime
()
-
new
Date
(
k
.
endTime
.
replace
(
/-/g
,
'/'
)).
getTime
())
/
(
1000
*
60
*
60
*
24
))
+
1
k
.
realTime
=
(
k
.
realStartTime
?.
slice
(
0
,
16
).
replace
(
/-/g
,
'.'
)
||
''
)
+
' - '
+
(
k
.
realEndTime
?.
slice
(
0
,
16
).
replace
(
/-/g
,
'.'
)
||
''
)
break
}
})
this
.
setData
({
crowdOrderObj
:
_obj
})
},
getBusiStatistics
(
isReset
=
false
,
isBusiTab
=
false
)
{
let
sortTabModule
=
this
.
selectComponent
(
'#sortTab'
)
if
(
sortTabModule
&&
isBusiTab
)
{
sortTabModule
.
resetAllAsc
()
}
let
sortSearchData
=
sortTabModule
?
sortTabModule
.
dealParams
()
:
{}
let
{
userInfo
}
=
wx
.
$storage
.
get
()
let
{
subMerchant
}
=
wx
.
$storage
.
get
()
let
params
=
{
...
sortSearchData
,
merchantIds
:
userInfo
.
subLoginUser
.
permissionMerchantIds
,
merchantIds
:
subMerchant
,
}
outputApi
.
getBusiStatistics
(
params
).
then
(
res
=>
{
this
.
resetBusiData
()
...
...
pages/tab/output/output.js
View file @
6f2e41a
...
...
@@ -55,7 +55,7 @@ Page({
init
()
{
this
.
setUserInfo
()
this
.
getMerchantRange
()
this
.
getMockInfo
()
//
this.getMockInfo()
},
setUserInfo
()
{
let
{
userInfo
}
=
wx
.
$storage
.
get
()
...
...
project.private.config.json
View file @
6f2e41a
...
...
@@ -119,6 +119,8 @@
]
}
},
"setting"
:
{},
"setting"
:
{
"urlCheck"
:
false
},
"projectname"
:
"store-assistant-assemble"
}
\ No newline at end of file
utils/cache/storageApi.js
View file @
6f2e41a
...
...
@@ -12,6 +12,12 @@ export function setSessionId(sessionId) {
export
function
getUserInfo
()
{
return
$Storage
.
get
(
'userInfo'
)
}
export
function
getSubMerchant
()
{
return
$Storage
.
get
(
'subMerchant'
)
}
export
function
setSubMerchant
(
data
)
{
$Storage
.
set
(
'subMerchant'
,
data
)
}
export
function
setUserInfo
(
data
)
{
console
.
log
(
data
)
$Storage
.
set
(
'userInfo'
,
data
)
...
...
utils/constantData.js
View file @
6f2e41a
export
const
IMG_URL
=
'https://img02.glsx.com.cn/weapp/resource/saas/business-assistant/'
export
const
IMG_URL_STORE
=
'https://img02.glsx.com.cn/weapp/resource/miniprogram/'
// 缓存get方法为空的默认指定值
export
const
DEFAULT_GET_STORAGEKEY
=
[
'sessionId'
,
'merchantId'
,
'userInfo'
]
export
const
DEFAULT_GET_STORAGEKEY
=
[
'sessionId'
,
'merchantId'
,
'userInfo'
,
'subMerchant'
]
// 缓存get方法key的对应才映射值
export
const
STORAGE_OBJECTkEY
=
{
...
...
@@ -18,7 +18,8 @@ export const STORAGE_OBJECTkEY = {
disLikeRecordFlag
:
'disLikeRecordFlag'
,
fileList
:
'fileList'
,
posterId
:
'posterId'
,
mock_data
:
'mock_data'
mock_data
:
'mock_data'
,
subMerchant
:
'subMerchant'
}
export
const
IMG_VERSION
=
()
=>
{
...
...
utils/request/environment.js
View file @
6f2e41a
...
...
@@ -111,19 +111,23 @@ const domain = {
},
dev
:
{
dj
:
'https://dj.dev.glsx.com.cn'
,
scrm
:
'https://scrm.dev.glsx.com.cn'
scrm
:
'https://scrm.dev.glsx.com.cn'
,
merchant
:
"http://rop-merchant.dev.glsx.com.cn"
,
},
uat
:
{
dj
:
'https://dj.test.glsx.com.cn'
,
scrm
:
'https://scrm.test.glsx.com.cn'
scrm
:
'https://scrm.test.glsx.com.cn'
,
merchant
:
"https://rop-merchant.test.glsx.com.cn"
},
prod
:
{
dj
:
'https://dj.glsx.com.cn'
,
scrm
:
'https://scrm.glsx.com.cn'
scrm
:
'https://scrm.glsx.com.cn'
,
merchant
:
"https://commodity.glsx.com.cn"
},
preRelease
:
{
dj
:
'https://dj.beta.glsx.com.cn'
,
scrm
:
'https://scrm.beta.glsx.com.cn'
scrm
:
'https://scrm.beta.glsx.com.cn'
,
merchant
:
"https://rop-merchant.beta.glsx.com.cn"
}
}[
target
[
index
]]
...
...
@@ -145,7 +149,8 @@ const pathEnum = {
business
:
'/rop-scrm-entmicro/'
,
stoassistant
:
'/rop-scrm-stoassistant/'
,
assistant
:
'/rop-scrm-stoassistant/'
,
busassistant
:
'/rop-scrm-busassistant/'
busassistant
:
'/rop-scrm-busassistant/'
,
'rop-merchants'
:
'/rop-merchants/'
}
const
defaultMerchantId
=
{
ip
:
'44184606'
,
...
...
utils/request/request.js
View file @
6f2e41a
...
...
@@ -45,6 +45,7 @@ class Request {
if
(
code
==
20
||
code
==
21
)
{
wx
.
$storage
.
rm
(
'sessionId'
)
wx
.
$storage
.
rm
(
'userInfo'
)
wx
.
$storage
.
rm
(
'subMerchant'
)
const
thisPage
=
wx
.
$router
.
getPageInstance
(),
autoLoginObject
=
wx
.
$storage
.
get
(
'auto_login_object'
)
if
(
thisPage
.
route
==
'login/loading/loading'
)
{
...
...
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