uniapp
store写了公用方法,每个页面请求接收
onLoad(option) {
uni.showLoading({
title: '加载中',
});
if (option.scene) {
let obj = {};
this.$store.dispatch('setting/setOption', option.scene).then((res) => {
obj = res;
this.option = obj;
this.id = obj.id;
this.getInfo();
});
} else {
this.option = option;
this.id = option.id;
this.getInfo();
}
},
//处理option scene 扫码传的参数
setOption({ commit }, str) {
return new Promise((resolve, reject) => {
let scene = decodeURIComponent(str);
let arr = scene.split('&');
let obj = {};
arr.forEach((item) => {
obj[item.split('=')[0]] = item.split('=')[1];
});
resolve(obj);
});
},