123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- import router from '../router/index';
- import GET from '@/utils/tool/GET';
- export default {
- onLoad(params){
- // 执行解析目录
- try {
- this.name = this.__route__.split('/').pop();
- } catch (e) {
- console.error('catch fail ---> name',this.__route__);
- this.name = this.__route__;
- }
- // 制作 params 列表
- this.$params = Object.assign(params, params.query) || {};
- this.$storage_params = Object.assign({},this.$params);
- this.$memoryParams = router.memoryGet(this.name) || {};
- // 执行解析
- for (let key in this.$params) {
- if (this.$params.hasOwnProperty(key) && typeof this.$params[key]==='string' && this.$params[key].indexOf('{') === 0) {
- try {
- this.$params[key] = JSON.parse(this.$params[key]);
- } catch (e) {
- }
- }
- }
- // 解析针对 直播跳转商品详情 custom_params 执行合并
- if (this.$params['custom_params']) {
- let useCustomParams = decodeURIComponent(decodeURIComponent(this.$params['custom_params']));
- try {
- this.$params['custom_params'] = JSON.parse(useCustomParams);
- this.$params = Object.assign(this.$params,this.$params['custom_params']);
- } catch (e) {
- this.$params['custom_params'] = useCustomParams;
- }
- }
- let scene = {};
- /* 如果存在扫码等情况进入获取参数列表 */
- this.$params.scene && GET.decode(this.$params.scene,(key,value)=>{
- this.$params[key] = value;
- });
- if (params.scene) {
- this.$params['scene_encode_string'] = params.scene;
- this.$params['scene'] = scene;
- }
- for (let key in this.$params) {
- if (this.$params.hasOwnProperty(key) && typeof this.$params[key] === 'string') {
- this.$params[key] = decodeURIComponent(this.$params[key]);
- }
- }
- },
- created(){
- this.$params = {};
- }
- }
|