Commit 0bcc3a32 by 李嘉林

扫门店码进入优化

parent a9a01578
<script> <script>
// import "@/utils/posthog" // import "@/utils/posthog"
import shop from "@/api/shop"; import shop from "@/api/shop";
import indexApi from "@/api/index.js";
import spokesman from "@/api/spokesman"; import spokesman from "@/api/spokesman";
import { themeColor, checkShowConditionIds, getStoreInfo } from "@/utils/mayi"; import { themeColor, checkShowConditionIds, getStoreInfo, setStoreInfo } from "@/utils/mayi";
import { query_isEntry } from "@/utils/mayi_fenxiao"; import { query_isEntry } from "@/utils/mayi_fenxiao";
export default { export default {
...@@ -44,7 +45,7 @@ export default { ...@@ -44,7 +45,7 @@ export default {
console.log("1444444444", extConfig); console.log("1444444444", extConfig);
this.$store.commit("setExtConfig", extConfig.mixid); this.$store.commit("setExtConfig", extConfig.mixid);
this.$store.commit('setExtConfigInfo',extConfig) this.$store.commit('setExtConfigInfo', extConfig)
// 调用API从本地缓存中获取数据 // 调用API从本地缓存中获取数据
/* /*
* 平台 api 差异的处理方式: api 方法统一挂载到 mpvue 名称空间, 平台判断通过 mpvuePlatform 特征字符串 * 平台 api 差异的处理方式: api 方法统一挂载到 mpvue 名称空间, 平台判断通过 mpvuePlatform 特征字符串
...@@ -74,10 +75,6 @@ export default { ...@@ -74,10 +75,6 @@ export default {
// 页面配置信息 // 页面配置信息
this.getThemePage(extConfig); this.getThemePage(extConfig);
// 商城配置
await this.shopConfiguration()
let mpApp = getApp(); let mpApp = getApp();
console.log(mpApp, "this.mpApp"); console.log(mpApp, "this.mpApp");
mpApp.getShopInfo = this.getShopInfo mpApp.getShopInfo = this.getShopInfo
...@@ -86,6 +83,38 @@ export default { ...@@ -86,6 +83,38 @@ export default {
},300) },300)
}, },
async mounted() {
let { query = {}, path = "" } = {} = this.$mp.appOptions;
console.log('app-mounted-url', path, query);
// 通过扫码直接进入门店要先获取到url的门店code(这块暂时只能在mounted->this.$mp.appOptions中获取到)
// url存在门店信息存门店缓存
// 扫码进入url有scene参数
try {
if (JSON.stringify(query) !== '{}') {
console.log('app-mounted-query', query);
if (query.scene) {
let res = await indexApi.getShareSceneRecord(query.scene);
if (res.data.code == 200) {
let sceneObj = JSON.parse(res.data.data.scene);
let paramsObj = sceneObj && sceneObj.params ? JSON.parse(decodeURIComponent(sceneObj.params)) : {};
console.log('app-mounted-paramsObj', paramsObj)
if (paramsObj.offlineShopCode) {
// 存在门店参数
setStoreInfo({
offlineShopCode:paramsObj.offlineShopCode,
offlineShopName:paramsObj.offlineShopName,
});
}
}
}
}
// 商城配置
await this.shopConfiguration()
} catch (error) {
console.log('app-mounted-error', error);
}
console.log('app-mounted-结束')
},
methods: { methods: {
async setVisible(pageList, cb) { async setVisible(pageList, cb) {
// 首页显示条件 // 首页显示条件
......
...@@ -354,7 +354,7 @@ export default { ...@@ -354,7 +354,7 @@ export default {
console.log('----onReady') console.log('----onReady')
this.firstOpenPage = false; this.firstOpenPage = false;
}, },
onLoad(options) { async onLoad(options) {
if(this.$options) { if(this.$options) {
Object.assign(this.$data, this.$options.data()); Object.assign(this.$data, this.$options.data());
} }
...@@ -389,21 +389,31 @@ export default { ...@@ -389,21 +389,31 @@ export default {
} }
if(options.scene){ if(options.scene){
//新二维码扫码进入 //新二维码扫码进入
wx.nextTick(() => { let res = await indexApi.getShareSceneRecord(options.scene);
indexApi.getShareSceneRecord(options.scene).then(res=>{
log.info(res,'onLoad-getShareSceneRecord'); log.info(res,'onLoad-getShareSceneRecord');
if(res.data.code == '200'){ if(res.data.code == '200'){
this.page = res.data.data.pageUri; this.page = res.data.data.pageUri;
let paramsObj = JSON.parse(res.data.data.scene); let sceneObj = JSON.parse(res.data.data.scene);
if(paramsObj.spokesmanRelId){ this.h5Params = sceneObj;
if(sceneObj.spokesmanRelId){
wx.setStorage({ wx.setStorage({
key: "becomeInfo", key: "becomeInfo",
data: JSON.stringify(paramsObj) data: JSON.stringify(sceneObj)
}); });
} }
wx.setStorageSync('attractingCustomerChannelId',paramsObj.attractingCustomerChannelId); let paramsObj = sceneObj && sceneObj.params ? JSON.parse(decodeURIComponent(sceneObj.params)) : {};
wx.setStorageSync(this.$store.state.mixid+'storeId',paramsObj.storeId); this.h5Params = paramsObj;
wx.setStorageSync(this.$store.state.mixid+'sellerId',paramsObj.sellerId); console.log('app-mounted-paramsObj', paramsObj)
if (paramsObj.offlineShopCode) {
// 存在门店参数
setStoreInfo({
offlineShopCode:paramsObj.offlineShopCode,
offlineShopName:paramsObj.offlineShopName,
});
}
wx.setStorageSync('attractingCustomerChannelId',sceneObj.attractingCustomerChannelId);
wx.setStorageSync(this.$store.state.mixid+'storeId',sceneObj.storeId);
wx.setStorageSync(this.$store.state.mixid+'sellerId',sceneObj.sellerId);
log.info(res.data.data,'getShareSceneRecord') log.info(res.data.data,'getShareSceneRecord')
console.log(res.data.data,'----getShareSceneRecord') console.log(res.data.data,'----getShareSceneRecord')
log.info(wx.getStorageSync("openid"),'onLoad-openid'); log.info(wx.getStorageSync("openid"),'onLoad-openid');
...@@ -423,9 +433,7 @@ export default { ...@@ -423,9 +433,7 @@ export default {
}) })
} }
} }
}).catch((err)=>{ wx.nextTick(() => {
})
}); });
} }
if (options.from && options.from == "logout") { if (options.from && options.from == "logout") {
...@@ -548,6 +556,8 @@ export default { ...@@ -548,6 +556,8 @@ export default {
methods: { methods: {
reloadEnterShopRule() { reloadEnterShopRule() {
// 进店规则--首次进店调用 // 进店规则--首次进店调用
if (this.h5Params && this.h5Params.offlineShopCode) return;
console.log('home-methods-reloadEnterShopRule')
if (wx.getStorageSync("firstView")) { if (wx.getStorageSync("firstView")) {
console.log('reloadEnterShopRule-------1') console.log('reloadEnterShopRule-------1')
wx.removeStorageSync("firstView"); wx.removeStorageSync("firstView");
...@@ -601,11 +611,6 @@ export default { ...@@ -601,11 +611,6 @@ export default {
} }
// this.pageLoading = false; // this.pageLoading = false;
}, },
toUpdate() {
console.log("toUpdate");
// 切换门店重新加载
this.getThemeList();
},
toPageLoading() { toPageLoading() {
// this.pageLoading = true; // this.pageLoading = true;
}, },
......
...@@ -564,3 +564,22 @@ export function getStoreInfo() { ...@@ -564,3 +564,22 @@ export function getStoreInfo() {
offlineShopName: wx.getStorageSync("offlineShopName") || "" offlineShopName: wx.getStorageSync("offlineShopName") || ""
}; };
} }
/*获取当前页带参数的url*/
export function getCurrentPageUrlWithArgs(){
var pages = getCurrentPages() //获取加载的页面
if (pages.length == 0) return "";
var currentPage = pages[pages.length-1] //获取当前页面的对象
var url = currentPage.route //当前页面url
var options = currentPage.options //如果要获取url中所带的参数可以查看options
//拼接url的参数
var urlWithArgs = url + '?'
for(var key in options){
var value = options[key]
urlWithArgs += key + '=' + value + '&'
}
urlWithArgs = urlWithArgs.substring(0, urlWithArgs.length-1)
return urlWithArgs
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment