Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas
/
mini-program
/
ai-card
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 b2c36a0e
authored
Sep 08, 2022
by
胡悦
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
添加授权
1 parent
7210b752
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
118 additions
and
45 deletions
api/api.js
api/environment.js
api/request.js
api/ssoApi.js
api/wechantApi.js
app.js
pages/tab/index/index.js
project.private.config.json
utils/Track.js
utils/data.js
api/api.js
View file @
b2c36a0
import
api
from
'./request'
import
api
from
'./request'
import
ssoApi
from
'./ssoApi'
import
ssoApi
from
'./ssoApi'
import
wechantApi
from
'./wechantApi'
const
common
=
'scrm.api.carlife.common.'
const
common
=
'scrm.api.carlife.common.'
module
.
exports
=
{
module
.
exports
=
{
ssoApi
,
ssoApi
,
wechantApi
,
commonApi
:
{
commonApi
:
{
/**上传图片
/**上传图片
*/
*/
...
...
api/environment.js
View file @
b2c36a0
...
@@ -43,7 +43,8 @@ const domain = {
...
@@ -43,7 +43,8 @@ const domain = {
const
pathEnum
=
{
const
pathEnum
=
{
sso
:
'/rop-scrm-sso/'
,
sso
:
'/rop-scrm-sso/'
,
wechant
:
'rop-scrm-wechant'
wechat
:
'/rop-scrm-sso/'
,
business
:
'/rop-scrm-entmicro/'
}
}
module
.
exports
=
{
module
.
exports
=
{
index
,
index
,
...
...
api/request.js
View file @
b2c36a0
...
@@ -23,9 +23,9 @@ class Request {
...
@@ -23,9 +23,9 @@ class Request {
wx
.
showNavigationBarLoading
()
wx
.
showNavigationBarLoading
()
let
header
=
RequestMethods
===
'POST'
?
{
let
header
=
RequestMethods
===
'POST'
?
{
'content-type'
:
'application/x-www-form-urlencoded'
'content-type'
:
'application/x-www-form-urlencoded'
}
:
{}
}
:
{
'Cache-Control'
:
'no-cache'
}
const
merchantId
=
wx
.
$util
.
getStorageSync
(
'srcm_shopmall_merchant_id'
)
//
const merchantId = wx.$util.getStorageSync('srcm_shopmall_merchant_id')
if
(
merchantId
)
header
.
merchantId
=
merchantId
//
if (merchantId) header.merchantId = merchantId
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
]
const
path
=
pathEnum
[
projectName
]
...
...
api/ssoApi.js
View file @
b2c36a0
...
@@ -4,7 +4,7 @@ module.exports = {
...
@@ -4,7 +4,7 @@ module.exports = {
/**wx.login登录 */
/**wx.login登录 */
jsCodeLogin
(
data
)
{
jsCodeLogin
(
data
)
{
return
api
.
post
({
return
api
.
post
({
method
:
`
${
path
}
jscode.
login
`
,
method
:
`
${
path
}
jscode.
getOpenId
`
,
...
data
...
data
},
true
)
},
true
)
},
},
...
...
api/wechantApi.js
View file @
b2c36a0
...
@@ -4,7 +4,7 @@ module.exports = {
...
@@ -4,7 +4,7 @@ module.exports = {
/**根据openId获取用户信息 */
/**根据openId获取用户信息 */
getUserInfo
(
data
)
{
getUserInfo
(
data
)
{
return
api
.
post
({
return
api
.
post
({
method
:
`
${
path
}
auth
.userProfile.getUserInfo`
,
method
:
`
${
path
}
weapp
.userProfile.getUserInfo`
,
...
data
...
data
},
true
)
},
true
)
},
},
...
...
app.js
View file @
b2c36a0
...
@@ -7,7 +7,7 @@ import {
...
@@ -7,7 +7,7 @@ import {
wechantApi
wechantApi
}
from
'./api/api'
}
from
'./api/api'
App
({
App
({
onLaunch
:
function
()
{
onLaunch
:
function
(
options
)
{
/**挂载到wx对象 */
/**挂载到wx对象 */
wx
.
$util
=
util
wx
.
$util
=
util
wx
.
$router
=
router
wx
.
$router
=
router
...
@@ -20,6 +20,7 @@ App({
...
@@ -20,6 +20,7 @@ App({
util
.
setStorageSync
(
'srcm_shopmall_system_info'
,
res
)
util
.
setStorageSync
(
'srcm_shopmall_system_info'
,
res
)
}
}
})
})
console
.
log
(
options
)
this
.
login
()
this
.
login
()
},
},
login
(
returnResponse
)
{
login
(
returnResponse
)
{
...
@@ -33,28 +34,31 @@ App({
...
@@ -33,28 +34,31 @@ App({
code
,
code
,
appId
:
_this
.
globalData
.
appId
appId
:
_this
.
globalData
.
appId
}).
then
(
res
=>
{
}).
then
(
res
=>
{
console
.
log
(
res
)
wx
.
$authStatus
=
res
.
code
!=
0
wx
.
$authStatus
=
res
.
code
!=
0
util
.
setSessionId
(
res
.
data
.
sessionId
)
util
.
setSessionId
(
res
.
data
.
sessionId
)
const
openId
=
res
.
data
.
openId
const
openId
=
res
.
data
.
openId
wechantApi
.
getUserInfo
({
wechantApi
.
getUserInfo
({
openId
openId
}).
then
(
result
=>
{
}).
then
(
result
=>
{
console
.
log
(
result
)
if
(
returnResponse
)
{
if
(
returnResponse
)
{
console
.
log
(
res
,
' ===='
)
console
.
log
(
res
ult
,
' ===='
)
resolve
(
res
)
resolve
(
res
ult
)
}
else
{
}
else
{
if
(
res
.
code
!=
-
1
)
{
if
(
result
.
code
!=
-
1
)
{
if
(
res
.
code
==
0
)
{
if
(
result
.
code
==
0
)
{
util
.
setUserInfo
(
res
.
data
)
util
.
setUserInfo
(
result
.
data
)
// util.setSessionId(res.data.sessionId)
if
(
result
.
data
.
nickName
)
{
wx
.
$nickName
=
result
.
data
.
nickName
}
}
else
{
}
else
{
util
.
showToast
(
res
.
message
||
'网络异常'
)
util
.
showToast
(
res
ult
.
message
||
'网络异常'
)
}
}
}
}
resolve
(
res
)
resolve
(
res
ult
)
}
}
})
})
}).
catch
(()
=>
{
}).
catch
(()
=>
{
wx
.
$authStatus
=
true
wx
.
$authStatus
=
true
reject
()
reject
()
...
...
pages/tab/index/index.js
View file @
b2c36a0
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
import
{
menuMixin
}
from
"../../../mixins/index"
;
import
{
menuMixin
}
from
"../../../mixins/index"
;
import
Draw
from
'../../../utils/Draw'
;
import
Draw
from
'../../../utils/Draw'
;
import
{
ssoApi
}
from
'../../../api/api'
;
import
{
ssoApi
}
from
'../../../api/api'
;
import
{
trackData
}
from
'../../../utils/data'
Page
({
Page
({
behaviors
:
[
menuMixin
],
behaviors
:
[
menuMixin
],
/**
/**
...
@@ -38,11 +39,12 @@ Page({
...
@@ -38,11 +39,12 @@ Page({
// icon1: "icon-cooperation",
// icon1: "icon-cooperation",
// },
// },
],
],
curTabIndex
:
1
,
curTabIndex
:
0
,
// 0-员工,1-代理商
// 0-员工,1-代理商
customerType
:
0
,
customerType
:
0
,
// 是否授权昵称
// 是否授权昵称
hasUserInfo
:
false
hasUserInfo
:
false
,
curTab
:
[
trackData
.
COMPANY
,
trackData
.
CUBE
]
},
},
introduce
(
e
)
{
introduce
(
e
)
{
const
curTabIndex
=
e
.
currentTarget
.
dataset
.
index
;
const
curTabIndex
=
e
.
currentTarget
.
dataset
.
index
;
...
@@ -50,16 +52,15 @@ Page({
...
@@ -50,16 +52,15 @@ Page({
// 0-公司介绍 1-方案介绍 2-视频直播 3-合作申请
// 0-公司介绍 1-方案介绍 2-视频直播 3-合作申请
console
.
log
(
this
.
data
.
curTabIndex
);
console
.
log
(
this
.
data
.
curTabIndex
);
switch
(
curTabIndex
)
{
switch
(
curTabIndex
)
{
case
3
:
wx
.
$router
.
go
(
"applicationPartener"
);
break
;
case
2
:
case
2
:
console
.
log
(
"跳转直播"
);
console
.
log
(
"跳转直播"
);
wx
.
$Track
.
sendTrack
(
trackData
.
VIDEO
)
break
;
break
;
default
:
default
:
this
.
setData
({
this
.
setData
({
curTabIndex
:
curTabIndex
,
curTabIndex
:
curTabIndex
,
});
});
wx
.
$Track
.
sendTrack
(
this
.
data
.
curTab
[
this
.
data
.
curTabIndex
])
}
}
},
},
...
@@ -71,19 +72,29 @@ Page({
...
@@ -71,19 +72,29 @@ Page({
* 生命周期函数--监听页面加载
* 生命周期函数--监听页面加载
*/
*/
onLoad
(
options
)
{
onLoad
(
options
)
{
console
.
log
(
this
.
data
.
hasUserInfo
);
// getApp().login().then(res => {
// console.log(res)
// if(res.data && res.data.nickName) {
// this.setData({
// hasUserInfo: true
// })
// }
// })
},
},
/**
/**
* 生命周期函数--监听页面初次渲染完成
* 生命周期函数--监听页面初次渲染完成
*/
*/
onReady
()
{},
onReady
()
{
},
/**
/**
* 生命周期函数--监听页面显示
* 生命周期函数--监听页面显示
*/
*/
onShow
()
{
onShow
()
{
this
.
setShareInfo
();
this
.
setShareInfo
();
console
.
log
(
wx
.
$util
.
getUserInfo
())
wx
.
$Track
.
sendTrack
(
this
.
data
.
curTab
[
this
.
data
.
curTabIndex
])
},
},
/**
/**
...
@@ -238,6 +249,9 @@ Page({
...
@@ -238,6 +249,9 @@ Page({
// 获取用户昵称
// 获取用户昵称
getUserProfile
(
e
)
{
getUserProfile
(
e
)
{
console
.
log
(
e
)
console
.
log
(
e
)
this
.
setData
({
hasUserInfo
:
true
})
// 推荐使用 wx.getUserProfile 获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认
// 推荐使用 wx.getUserProfile 获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认
// 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
// 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
wx
.
getUserProfile
({
wx
.
getUserProfile
({
...
@@ -245,9 +259,6 @@ Page({
...
@@ -245,9 +259,6 @@ Page({
success
:
(
res
)
=>
{
success
:
(
res
)
=>
{
console
.
log
(
res
)
console
.
log
(
res
)
console
.
log
(
this
.
data
.
hasUserInfo
)
console
.
log
(
this
.
data
.
hasUserInfo
)
this
.
setData
({
hasUserInfo
:
true
})
ssoApi
.
authUserInfo
({
ssoApi
.
authUserInfo
({
...
res
...
res
}).
then
(({
}).
then
(({
...
@@ -267,5 +278,4 @@ Page({
...
@@ -267,5 +278,4 @@ Page({
}
}
})
})
},
},
});
});
project.private.config.json
View file @
b2c36a0
...
@@ -39,6 +39,13 @@
...
@@ -39,6 +39,13 @@
"query"
:
""
,
"query"
:
""
,
"launchMode"
:
"default"
,
"launchMode"
:
"default"
,
"scene"
:
null
"scene"
:
null
},
{
"name"
:
""
,
"pathName"
:
"pages/tab/index/index"
,
"query"
:
"scene=sceneId%3D563"
,
"launchMode"
:
"default"
,
"scene"
:
null
}
}
]
]
}
}
...
...
utils/Track.js
View file @
b2c36a0
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
* }
* }
*/
*/
import
api
from
'../api/request'
import
api
from
'../api/request'
import
{
trackData
}
from
'../utils/data'
let
TRACK_TIME
=
null
,
let
TRACK_TIME
=
null
,
ADDRESS_INFO
=
null
ADDRESS_INFO
=
null
const
track_interval_time
=
60
*
1
e3
const
track_interval_time
=
60
*
1
e3
...
@@ -24,7 +25,7 @@ class TRACK {
...
@@ -24,7 +25,7 @@ class TRACK {
constructor
()
{
constructor
()
{
console
.
log
(
'---------------- 埋点初始化 ----------------'
)
console
.
log
(
'---------------- 埋点初始化 ----------------'
)
this
.
initPageProxy
()
this
.
initPageProxy
()
this
.
sendTrack
()
//
this.sendTrack()
// this.getAddressInfo().then(res => ADDRESS_INFO = res)
// this.getAddressInfo().then(res => ADDRESS_INFO = res)
this
.
appHide
()
this
.
appHide
()
}
}
...
@@ -122,24 +123,47 @@ class TRACK {
...
@@ -122,24 +123,47 @@ class TRACK {
return
guest_no
return
guest_no
}
}
/**定时发送埋点数据 */
/**定时发送埋点数据 */
sendTrack
()
{
sendTrack
(
p
)
{
TRACK_TIME
=
setInterval
(()
=>
{
let
params
=
{
let
prepare_data
=
wx
.
getStorageSync
(
'prepare_data'
)
method
:
'entmicro.api.business.card.cardRecord'
let
data
=
{
}
method
:
'entmicro.api.customercollect.reportCustomerList'
,
const
userInfo
=
{
jsonList
:
prepare_data
nickName
:
'萌萌哒西瓜'
,
}
type
:
1
,
if
(
prepare_data
&&
prepare_data
.
length
)
api
.
reportTrack
(
data
).
then
(({
openId
:
'123445'
,
code
,
unionId
:
''
,
phone
:
'18873336682'
,
merchant
:
'12121'
,
cardId
:
'1'
}
params
=
Object
.
assign
(
params
,
userInfo
,
p
)
console
.
log
(
params
)
api
.
reportTrack
(
params
).
then
(({
code
,
data
,
message
})
=>
{
console
.
log
(
code
,
data
,
data
,
message
message
)
})
=>
{
})
if
(
code
==
0
&&
data
)
{
// TRACK_TIME = setInterval(() => {
wx
.
setStorageSync
(
'prepare_data'
,
[])
// let prepare_data = wx.getStorageSync('prepare_data')
console
.
log
(
'---------------- 埋点定时推送成功 ----------------'
,
new
Date
().
format
(
'yyyy-MM-dd hh:mm:ss'
),
':'
,
prepare_data
)
// let data = {
}
else
console
.
log
(
'---------------- 埋点定时推送失败 ----------------'
,
new
Date
().
format
(
'yyyy-MM-dd hh:mm:ss'
),
':'
,
message
)
// method: 'entmicro.api.business.card.cardRecord',
})
// // jsonList: prepare_data
},
track_interval_time
)
// }
// if (prepare_data && prepare_data.length) api.reportTrack(data).then(({
// code,
// data,
// message
// }) => {
// if (code == 0 && data) {
// wx.setStorageSync('prepare_data', [])
// console.log('---------------- 埋点定时推送成功 ----------------', new Date().format('yyyy-MM-dd hh:mm:ss'), ':', prepare_data)
// } else console.log('---------------- 埋点定时推送失败 ----------------', new Date().format('yyyy-MM-dd hh:mm:ss'), ':', message)
// })
// }, track_interval_time)
}
}
/**获取页面对象实例 */
/**获取页面对象实例 */
getPageInstance
=
(
size
=
1
)
=>
{
getPageInstance
=
(
size
=
1
)
=>
{
...
...
utils/data.js
0 → 100644
View file @
b2c36a0
const
trackData
=
{
COMPANY
:
{
pageKey
:
0
,
pageName
:
'公司介绍'
},
VIDEO
:
{
pageKey
:
1
,
pageName
:
'视频直播'
},
CUBE
:
{
pageKey
:
2
,
pageName
:
'企微魔方'
},
EQUITY
:
{
pageKey
:
3
,
pageName
:
'数字化权益'
},
CLUE
:
{
pageKey
:
4
,
pageName
:
'智能线索'
}
}
export
{
trackData
}
\ 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