Commit f1710e07 by 前端

缓存替换

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