Commit 2022ba44 by 匡雅琴

Merge branch 'kuangyq_v2.10.0' of http://192.168.3.233:8090/saas/mini-program/ai…

…-card into kuangyq_v2.10.0
2 parents 11718ce2 8d35ac73
import api from './request'
import ssoApi from './ssoApi'
import wechantApi from './wechantApi'
import entmicroApi from './entmicroApi'
const common = 'scrm.api.carlife.common.'
module.exports = {
ssoApi,
entmicroApi,
wechantApi,
commonApi: {
/**上传图片
*/
......
......@@ -37,10 +37,10 @@ const domain = {
}[target[index]];
const pathEnum = {
sso: "/rop-scrm-sso/",
wechant: "rop-scrm-wechant",
business: "/rop-scrm-entmicro/",
};
sso: '/rop-scrm-sso/',
wechat: '/rop-scrm-sso/',
business: '/rop-scrm-entmicro/'
}
module.exports = {
index,
domain,
......
......@@ -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()
......
......@@ -10,6 +10,7 @@ import { menuMixin } from "../../../mixins/index";
import Draw from "../../../utils/Draw";
import { ssoApi, entmicroApi } from "../../../api/api";
import util from "../../../utils/util";
import {trackData} from '../../../utils/data'
Page({
behaviors: [menuMixin],
/**
......@@ -39,13 +40,17 @@ Page({
// icon1: "icon-cooperation",
// },
],
curTabIndex: 1,
curTabIndex: 0,
// 0-员工,1-代理商
customerType: 0,
// 是否授权昵称
hasUserInfo: false,
<<<<<<< HEAD
// 是否授权手机号
hasPhoneNumber: false
=======
curTab: [trackData.COMPANY, trackData.CUBE]
>>>>>>> 8d35ac732b4e690c36b92f97d7f3262c98e54c4a
},
introduce(e) {
const curTabIndex = e.currentTarget.dataset.index;
......@@ -53,16 +58,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])
}
},
......@@ -97,13 +101,16 @@ Page({
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {},
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
this.setShareInfo();
console.log(wx.$util.getUserInfo())
wx.$Track.sendTrack(this.data.curTab[this.data.curTabIndex])
},
/**
......@@ -257,34 +264,33 @@ Page({
},
// 获取用户昵称
getUserProfile(e) {
console.log(e);
console.log(e)
this.setData({
hasUserInfo: true
})
// 推荐使用 wx.getUserProfile 获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认
// 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
wx.getUserProfile({
desc: "用于完善资料", // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: (res) => {
console.log(res);
console.log(this.data.hasUserInfo);
this.setData({
hasUserInfo: true,
});
ssoApi
.authUserInfo({
...res,
})
.then(({ code }) => {
if (code == "0") {
getApp()
.login()
.then(({ data }) => {
this.setData({
userInfo: data,
// hasUserInfo: true
});
});
}
});
},
});
},
});
console.log(this.data.hasUserInfo)
ssoApi.authUserInfo({
...res
}).then(({
code
}) => {
if (code == '0') {
getApp().login().then(({
data
}) => {
this.setData({
userInfo: data,
// hasUserInfo: true
})
})
}
})
}
})
}
})
......@@ -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!