Commit f1710e07 by 前端

缓存替换

1 parent 325fceb4
......@@ -24,7 +24,7 @@ class Request {
let header = RequestMethods === 'POST' ? {
'content-type': 'application/x-www-form-urlencoded'
} : {'Cache-Control': 'no-cache'}
// const merchantId = wx.$util.getStorageSync('srcm_shopmall_merchant_id')
// const merchantId = wx.$storage.get('srcm_shopmall_merchant_id')
// if (merchantId) header.merchantId = merchantId
let projectName = this.getRopProject(params.method)
if (!projectName) projectName = this.getRopProject(params.method)
......@@ -103,7 +103,8 @@ class Request {
appKey = secretKey[projectName].appKey
secret = secretKey[projectName].secret
}
const sessionId = util.getSessionId()
// const sessionId = util.getSessionId()
const sessionId = wx.$storage.get("aicard_info").sessionId
let noSignAttr = []
if (!params.sessionId && sessionId) params.sessionId = sessionId
if (params.noSignAttr) {
......
......@@ -30,11 +30,11 @@ App({
wx.$router = router
wx.$imgUrl = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/ai-card/'
wx.$appId = wx.getAccountInfoSync().miniProgram.appId
const systemInfo = wx.getStorageSync('aicard_system_info')
const systemInfo = wx.$storage.get('aicard_system_info')
if (!systemInfo)
wx.getSystemInfo({
success(res) {
util.setStorageSync('aicard_system_info', res)
wx.$storage.set('aicard_system_info', res)
}
})
if (options.path != 'pages/tab/index/index') {
......@@ -57,11 +57,11 @@ App({
})
.then(res => {
wechatInfo = res.data
util.setStorageSync('aicard_info', wechatInfo)
wx.$storage.set('aicard_info', wechatInfo)
wx.$authStatus = res.code != 0
util.setSessionId(wechatInfo.sessionId)
// util.setSessionId(wechatInfo.sessionId)
openId = wechatInfo.openId
// util.setStorageSync('openId', openId)
// wx.$storage.set('openId', openId)
console.log(wx.$trackData)
wx.showMeasure = !!wx.$trackData.scene
if (wx.$trackData.scene) {
......@@ -70,8 +70,8 @@ App({
wx.$trackData.merchant = res.merchantId
wx.$trackData.cardId = res.cardId
console.log('wx.$trackData.cardId', wx.$trackData.cardId)
util.setStorageSync('scene', res)
const systemInfo = JSON.parse(wx.getStorageSync('aicard_system_info'))
wx.$storage.set('scene', res)
const systemInfo = JSON.parse(wx.$storage.get('aicard_system_info'))
wx.$trackData.type = systemInfo.environment ? 2 : 1
wx.$Track.sendTrack(trackData.COMPANY, wechatInfo)
})
......@@ -88,13 +88,13 @@ App({
}
}
} else if (wx.$trackData.isShare) {
util.setStorageSync('scene', wx.$trackData)
const systemInfo = JSON.parse(wx.getStorageSync('aicard_system_info'))
wx.$storage.set('scene', wx.$trackData)
const systemInfo = JSON.parse(wx.$storage.get('aicard_system_info'))
wx.$trackData.type = systemInfo.environment ? 2 : 1
} else if (!wx.$trackData.detailShare && wx.$trackData.cardId) {
// 名片分享在这里设置埋点
util.setStorageSync('scene', wx.$trackData)
const systemInfo = JSON.parse(wx.getStorageSync('aicard_system_info'))
wx.$storage.set('scene', wx.$trackData)
const systemInfo = JSON.parse(wx.$storage.get('aicard_system_info'))
wx.$trackData.type = systemInfo.environment ? 2 : 1
wx.$Track.sendTrack(trackData.COMPANY, wechatInfo)
}
......
......@@ -111,14 +111,14 @@ Component({
sessionId: ''
})
wx.$util.setUserInfo(data)
wx.$util.setSessionId(data.sessionId)
// wx.$util.setSessionId(data.sessionId)
thisPage.onLoad()
thisPage.onShow()
if (thisPage.init) thisPage.init()
if (thisPage.onRoute) thisPage.onRoute()
if (thisPage.loginCallBack) thisPage.loginCallBack(data)
let customerId = wx.$util.getStorageSync('srcm_shopmall_customer_id')
let merchantId = wx.$util.getStorageSync('srcm_shopmall_merchant_id')
let customerId = wx.$storage.get('srcm_shopmall_customer_id')
let merchantId = wx.$storage.get('srcm_shopmall_merchant_id')
if (customerId) {
ssoApi.updataCustomerPhone({
customerId,
......
......@@ -57,7 +57,7 @@ Component({
wx.hideLoading()
if (code==0) {
wx.$util.setUserInfo(data);
wx.$util.setSessionId(data.sessionId);
// wx.$util.setSessionId(data.sessionId);
// 其他操作
this.triggerEvent("updatePhoneNumber", data.phone);
} else {
......
......@@ -2,8 +2,8 @@ import util from '../utils/util'
module.exports = Behavior({
methods: {
shareTrack(name, type) {
let merchant = util.getStorageSync("scene").merchant || util.getStorageSync("scene").merchantId
let pathName = `pages/productDetail/${type}/${type}?cardId=`+util.getStorageSync('scene').cardId + "&merchant=" + merchant + '&detailShare=' + `trackData.${name}.pageName`
let merchant = wx.$storage.get("scene").merchant || wx.$storage.get("scene").merchantId
let pathName = `pages/productDetail/${type}/${type}?cardId=`+wx.$storage.get('scene').cardId + "&merchant=" + merchant + '&detailShare=' + `trackData.${name}.pageName`
return {
title: trackData[name].pageName,
path: pathName
......
......@@ -189,12 +189,12 @@ Page({
params.businessScenario = businessItem.title;
params.productItems = productItems.join(",");
}
params.cardId = wx.$util.getStorageSync("scene").cardId;
params.cardId = wx.$storage.get("scene").cardId;
params.merchant =
wx.$util.getStorageSync("scene").merchant ||
wx.$util.getStorageSync("scene").merchantId;
params.openId = wx.$util.getStorageSync("aicard_info").openId;
params.unionId = wx.$util.getStorageSync("aicard_info").unionId;
wx.$storage.get("scene").merchant ||
wx.$storage.get("scene").merchantId;
params.openId = wx.$storage.get("aicard_info").openId;
params.unionId = wx.$storage.get("aicard_info").unionId;
console.log(params);
entmicroApi.activityApply(params).then(({ data, code, message }) => {
if (code == 0) {
......@@ -288,17 +288,6 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
// const options = wx.getEnterOptionsSync();
// if (options.query.cardId) {
// wx.$trackData = options.query;
// }
// getApp()
// .login()
// .then(({ data }) => {
// if (!wx.$trackData.detailShare) {
// wx.$Track.sendTrack(trackData.ACTIVITYAPPLICATION);
// }
// });
},
/**
......
......@@ -588,8 +588,8 @@ Page({
onShareAppMessage() {
let {senceData,actNum,activeNavIdx,isShare} = this.data
let product = senceData[actNum]?.productList[activeNavIdx].proName
let merchant = utils.getStorageSync("scene").merchant || utils.getStorageSync("scene").merchantId
const cardId = utils.getStorageSync('scene').cardId
let merchant = wx.$storage.get("scene").merchant || wx.$storage.get("scene").merchantId
const cardId = wx.$storage.get('scene').cardId
console.log('product: ', product);
return {
// title: `给你分享一个活动${product},戳我参与~`,
......
......@@ -47,10 +47,10 @@ Page({
let applyType = validFlag[1]
// 区分代理商和门店
params.merchantName = applyType == 0 ? params.merchantName + '(新能源-门店)' : params.merchantName + '(新能源-代理商)'
params.cardId = wx.$util.getStorageSync("scene").cardId
params.merchant = wx.$util.getStorageSync("scene").merchant || wx.$util.getStorageSync("scene").merchantId
params.openId = wx.$util.getStorageSync('aicard_info').openId
params.unionId = wx.$util.getStorageSync('aicard_info').unionId
params.cardId = wx.$storage.get("scene").cardId
params.merchant = wx.$storage.get("scene").merchant || wx.$storage.get("scene").merchantId
params.openId = wx.$storage.get('aicard_info').openId
params.unionId = wx.$storage.get('aicard_info').unionId
console.log(params);
entmicroApi.activityApply(params).then(({
data,
......
......@@ -249,8 +249,8 @@ Page({
* 用户点击右上角分享
*/
onShareAppMessage() {
const cardId = util.getStorageSync("scene").cardId
const merchant = util.getStorageSync("scene").merchantId || util.getStorageSync("scene").merchant
const cardId = wx.$storage.get("scene").cardId
const merchant = wx.$storage.get("scene").merchantId || wx.$storage.get("scene").merchant
return {
title: `您好,我向你推荐了广联数科${this.data.cardInfo.staffName}的智能名片~`,
imageUrl: this.data.shareImg,
......@@ -439,8 +439,8 @@ Page({
this.setData({
'tabList[3].isShow': wx.showMeasure
})
console.log(util.getStorageSync('scene'), wx.$trackData.cardId)
const scene = util.getStorageSync('scene');
console.log(wx.$storage.get('scene'), wx.$trackData.cardId)
const scene = wx.$storage.get('scene');
let params = {
cardId: wx.$trackData.cardId || scene.cardId
};
......
......@@ -10,7 +10,7 @@ class Draw {
constructor(_this_, canvasObject) {
let {
pixelRatio
} = JSON.parse(wx.getStorageSync('aicard_system_info'))
} = JSON.parse(wx.$storage.get('aicard_system_info'))
this[_canvasObject_] = canvasObject
this[_pixelRatio_] = canvasObject.pixelRatio || pixelRatio || 2
const height = this.toRpx(canvasObject.height),
......
......@@ -112,7 +112,7 @@ class TRACK {
// wx.setStorageSync('prepare_data', prepare_data)
}
getGuestNo() {
let guest_no = wx.getStorageSync('guest_no')
let guest_no = wx.$storage.get('guest_no')
if (!guest_no) {
guest_no = this.setGuestNo()
wx.setStorageSync('guest_no', guest_no)
......@@ -126,7 +126,7 @@ class TRACK {
let params = {
method: 'entmicro.api.business.card.cardRecord',
cardId: wx.$trackData.cardId,
merchant: wx.$trackData.merchant || wx.$trackData.merchantId || wx.$util.getStorageSync("scene").merchant,
merchant: wx.$trackData.merchant || wx.$trackData.merchantId || wx.$storage.get("scene").merchant,
type: wx.$trackData.type
}
let userInfo = { }
......@@ -135,7 +135,7 @@ class TRACK {
const {nickName, openId, phone} = wx.$util.getUserInfo() || {}
userInfo = {
nickName,
unionId: wx.$util.getStorageSync('aicard_info').unionId,
unionId: wx.$storage.get('aicard_info').unionId,
openId,
phone,
}
......@@ -143,11 +143,11 @@ class TRACK {
// if (info.openId) {
// userInfo.openId = info.openId
// } else {
// // userInfo.openId = wx.$util.getStorageSync('openId')
// userInfo.openId = wx.$util.getStorageSync('aicard_info').openId
// // userInfo.openId = wx.$storage.get('openId')
// userInfo.openId = wx.$storage.get('aicard_info').openId
// }
userInfo.openId = info && info.openId ? info.openId : wx.$util.getStorageSync('aicard_info').openId
userInfo.unionId = info && info.unionId ? info.unionId : wx.$util.getStorageSync('aicard_info').unionId
userInfo.openId = info && info.openId ? info.openId : wx.$storage.get('aicard_info').openId
userInfo.unionId = info && info.unionId ? info.unionId : wx.$storage.get('aicard_info').unionId
}
params = Object.assign(params, userInfo, p)
......@@ -192,7 +192,7 @@ class TRACK {
model,
system,
version
} = JSON.parse(wx.getStorageSync('aicard_system_info'))
} = JSON.parse(wx.$storage.get('aicard_system_info'))
return {
SDK_version: SDKVersion,
brand,
......@@ -205,14 +205,14 @@ class TRACK {
getMerchantInfo() {
let {
merchantId
} = wx.getStorageSync('merchant_info')
} = wx.$storage.get('merchant_info')
return {
merchant_id: merchantId
}
}
/**获取用户位置信息 */
// getAddressInfo() {
// let addressInfo = wx.getStorageSync('address_info')
// let addressInfo = wx.$storage.get('address_info')
// return new Promise((resolve) => {
// if (addressInfo && Date.now() - addressInfo.createTime < 2 * 60 * 1e3) resolve(addressInfo)
// else wx.getLocation({
......
......@@ -14,7 +14,12 @@ export const STORAGE_OBJECTkEY = {
wx_user_info: 'wx_user_info',
userPhone: 'userPhone',
firstLogin:'firstLogin',
authphone:'authphone'
authphone:'authphone',
aicard_system_info: 'aicard_system_info',
aicard_info: 'aicard_info',
aicard_sessionId: 'aicard_sessionId',
scene: 'scene',
aicard_user_info: 'aicard_user_info'
}
export const IMG_VERSION = () =>{
......
......@@ -303,12 +303,12 @@ const phoneCall = phoneNumber => {
}
/**获取用户信息 */
const getUserInfo = () => {
let user = wx.getStorageSync('aicard_user_info') || null
let user = wx.$storage.get('aicard_user_info') || null
return JSON.parse(user)
}
/**设置用户信息 */
const setUserInfo = userInfo => {
wx.setStorageSync('aicard_user_info', JSON.stringify(userInfo))
wx.$storage.set('aicard_user_info', JSON.stringify(userInfo))
}
/**IOS时间兼容 */
const iosTimeFormat = time => {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!