Browse Source

[完善] 商品详情路由分发

twodate
邓平艺 4 years ago
parent
commit
a7e34bc4ca
  1. 6
      pages/goodsDetail/index.vue
  2. 22
      pages/route/index.vue

6
pages/goodsDetail/index.vue

@ -135,7 +135,8 @@
imagePath: '', imagePath: '',
userToken: '', userToken: '',
wxCode: '', wxCode: '',
onceCode: ''
onceCode: '',
pt: 1
} }
}, },
computed: { computed: {
@ -147,6 +148,7 @@
}, },
onLoad(options) { onLoad(options) {
this.goods_id = options.id; this.goods_id = options.id;
this.pt = options.pt || 1;
this.getGoodsDetail(); this.getGoodsDetail();
this.getWxCode() this.getWxCode()
}, },
@ -305,7 +307,7 @@
toAddOrder() { toAddOrder() {
let goods_id = this.goods_detail.id; let goods_id = this.goods_detail.id;
let goods_specs_id = this.goods_detail.specs[0].id let goods_specs_id = this.goods_detail.specs[0].id
this.$url('/pages/order/confirm-order?goods_id=' + goods_id + '&goods_specs_id=' + goods_specs_id);
this.$url('/pages/order/confirm-order?goods_id=' + goods_id + '&goods_specs_id=' + goods_specs_id +'&pt='+ this.pt);
}, },
// //
lookImg(index) { lookImg(index) {

22
pages/route/index.vue

@ -6,12 +6,18 @@
/* 路由分发页面仅供跳转页面 */ /* 路由分发页面仅供跳转页面 */
export default { export default {
onLoad(options){ onLoad(options){
this.routeToPage(options);
if(this.$shared.isValueType(options.scene) != 'undefined'){
const scene = decodeURIComponent(options.scene); //
const par = this.strToObj(scene);
this.routeToPage(par);
}else{
this.routeToPage(options); //
}
}, },
methods: { methods: {
// //
routeToPage(options){ routeToPage(options){
if(options.route == 'goods_detail'){
if(options.route == 'goods_detail' || options.route == 'goods'){
options.page_url = '/pages/goodsDetail/index'; options.page_url = '/pages/goodsDetail/index';
this.joinPagePath(options); this.joinPagePath(options);
}else if(options.route == 'home'){ }else if(options.route == 'home'){
@ -45,6 +51,18 @@
}else{ }else{
this.$url(path, {type: 'redirect'}); this.$url(path, {type: 'redirect'});
} }
},
// key=value&key=value
strToObj(str){
let obj = {};
if(!str) return obj;
let arr = str.split('&');
arr.map(item => {
let a = item.split('=');
obj[a[0]] = a[1];
});
return obj;
} }
} }
} }

Loading…
Cancel
Save