Commit b2c36a0e by 胡悦

添加授权

1 parent 7210b752
import api from './request'
import ssoApi from './ssoApi'
import wechantApi from './wechantApi'
const common = 'scrm.api.carlife.common.'
module.exports = {
ssoApi,
wechantApi,
commonApi: {
/**上传图片
*/
......
......@@ -43,7 +43,8 @@ const domain = {
const pathEnum = {
sso: '/rop-scrm-sso/',
wechant: 'rop-scrm-wechant'
wechat: '/rop-scrm-sso/',
business: '/rop-scrm-entmicro/'
}
module.exports = {
index,
......
......@@ -23,9 +23,9 @@ class Request {
wx.showNavigationBarLoading()
let header = RequestMethods === 'POST' ? {
'content-type': 'application/x-www-form-urlencoded'
} : {}
const merchantId = wx.$util.getStorageSync('srcm_shopmall_merchant_id')
if (merchantId) header.merchantId = merchantId
} : {'Cache-Control': 'no-cache'}
// const merchantId = wx.$util.getStorageSync('srcm_shopmall_merchant_id')
// if (merchantId) header.merchantId = merchantId
let projectName = this.getRopProject(params.method)
if (!projectName) projectName = this.getRopProject(params.method)
const path = pathEnum[projectName]
......
......@@ -4,7 +4,7 @@ module.exports = {
/**wx.login登录 */
jsCodeLogin(data) {
return api.post({
method: `${path}jscode.login`,
method: `${path}jscode.getOpenId`,
...data
}, true)
},
......
......@@ -4,7 +4,7 @@ module.exports = {
/**根据openId获取用户信息 */
getUserInfo(data) {
return api.post({
method: `${path}auth.userProfile.getUserInfo`,
method: `${path}weapp.userProfile.getUserInfo`,
...data
}, true)
},
......
......@@ -7,7 +7,7 @@ import {
wechantApi
} from './api/api'
App({
onLaunch: function () {
onLaunch: function (options) {
/**挂载到wx对象 */
wx.$util = util
wx.$router = router
......@@ -20,6 +20,7 @@ App({
util.setStorageSync('srcm_shopmall_system_info', res)
}
})
console.log(options)
this.login()
},
login(returnResponse) {
......@@ -33,28 +34,31 @@ App({
code,
appId: _this.globalData.appId
}).then(res => {
console.log(res)
wx.$authStatus = res.code != 0
util.setSessionId(res.data.sessionId)
const openId = res.data.openId
wechantApi.getUserInfo({
openId
}).then(result => {
console.log(result)
if (returnResponse) {
console.log(res,' ====')
resolve(res)
console.log(result,' ====')
resolve(result)
} else {
if (res.code != -1) {
if (res.code == 0) {
util.setUserInfo(res.data)
// util.setSessionId(res.data.sessionId)
if (result.code != -1) {
if (result.code == 0) {
util.setUserInfo(result.data)
if (result.data.nickName) {
wx.$nickName = result.data.nickName
}
} else {
util.showToast(res.message || '网络异常')
util.showToast(result.message || '网络异常')
}
}
resolve(res)
resolve(result)
}
})
}).catch(() => {
wx.$authStatus = true
reject()
......
......@@ -9,6 +9,7 @@
import { menuMixin } from "../../../mixins/index";
import Draw from '../../../utils/Draw';
import { ssoApi } from '../../../api/api';
import {trackData} from '../../../utils/data'
Page({
behaviors: [menuMixin],
/**
......@@ -38,11 +39,12 @@ Page({
// icon1: "icon-cooperation",
// },
],
curTabIndex: 1,
curTabIndex: 0,
// 0-员工,1-代理商
customerType: 0,
// 是否授权昵称
hasUserInfo: false
hasUserInfo: false,
curTab: [trackData.COMPANY, trackData.CUBE]
},
introduce(e) {
const curTabIndex = e.currentTarget.dataset.index;
......@@ -50,16 +52,15 @@ Page({
// 0-公司介绍 1-方案介绍 2-视频直播 3-合作申请
console.log(this.data.curTabIndex);
switch (curTabIndex) {
case 3:
wx.$router.go("applicationPartener");
break;
case 2:
console.log("跳转直播");
wx.$Track.sendTrack(trackData.VIDEO)
break;
default:
this.setData({
curTabIndex: curTabIndex,
});
wx.$Track.sendTrack(this.data.curTab[this.data.curTabIndex])
}
},
......@@ -71,19 +72,29 @@ Page({
* 生命周期函数--监听页面加载
*/
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() {
this.setShareInfo();
console.log(wx.$util.getUserInfo())
wx.$Track.sendTrack(this.data.curTab[this.data.curTabIndex])
},
/**
......@@ -238,6 +249,9 @@ Page({
// 获取用户昵称
getUserProfile(e) {
console.log(e)
this.setData({
hasUserInfo: true
})
// 推荐使用 wx.getUserProfile 获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认
// 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
wx.getUserProfile({
......@@ -245,9 +259,6 @@ Page({
success: (res) => {
console.log(res)
console.log(this.data.hasUserInfo)
this.setData({
hasUserInfo: true
})
ssoApi.authUserInfo({
...res
}).then(({
......@@ -267,5 +278,4 @@ Page({
}
})
},
});
......@@ -39,6 +39,13 @@
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "pages/tab/index/index",
"query": "scene=sceneId%3D563",
"launchMode": "default",
"scene": null
}
]
}
......
......@@ -16,6 +16,7 @@
* }
*/
import api from '../api/request'
import {trackData} from '../utils/data'
let TRACK_TIME = null,
ADDRESS_INFO = null
const track_interval_time = 60 * 1e3
......@@ -24,7 +25,7 @@ class TRACK {
constructor() {
console.log('---------------- 埋点初始化 ----------------')
this.initPageProxy()
this.sendTrack()
// this.sendTrack()
// this.getAddressInfo().then(res => ADDRESS_INFO = res)
this.appHide()
}
......@@ -122,24 +123,47 @@ class TRACK {
return guest_no
}
/**定时发送埋点数据 */
sendTrack() {
TRACK_TIME = setInterval(() => {
let prepare_data = wx.getStorageSync('prepare_data')
let data = {
method: 'entmicro.api.customercollect.reportCustomerList',
jsonList: prepare_data
}
if (prepare_data && prepare_data.length) api.reportTrack(data).then(({
code,
sendTrack(p) {
let params = {
method: 'entmicro.api.business.card.cardRecord'
}
const userInfo = {
nickName: '萌萌哒西瓜',
type: 1,
openId: '123445',
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,
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)
message)
})
// TRACK_TIME = setInterval(() => {
// let prepare_data = wx.getStorageSync('prepare_data')
// let data = {
// method: 'entmicro.api.business.card.cardRecord',
// // jsonList: prepare_data
// }
// 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) => {
......
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
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!