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);
        });
    },
posted @ 2020-11-23 10:33  gggggggxin  阅读(516)  评论(1编辑  收藏  举报