diff --git a/components/cart/cart.vue b/components/cart/cart.vue index b4a0ec88..f701aacd 100644 --- a/components/cart/cart.vue +++ b/components/cart/cart.vue @@ -26,7 +26,7 @@ - {{ plugins_realstore_info.buy_use_type_list[plugins_realstore_buy_use_type_index]['name'] }} + {{ plugins_realstore_info.buy_use_type_list[plugins_realstore_buy_use_type_active_index]['name'] }} @@ -393,7 +393,7 @@ // 门店插件数据 plugins_realstore_data: null, plugins_realstore_info: null, - plugins_realstore_buy_use_type_index: 0, + plugins_realstore_buy_use_type_active_index: 0, plugins_realstore_choice_status: false, // 智能工具箱插件 plugins_intellectstools_data: null, @@ -537,9 +537,10 @@ if (this.cart_type_value == 'realstore' && (this.plugins_realstore_info || null) != null) { // 门店购物车初始化、避免上一个页面更改了门店下单类型 this.realstore_cart_data_init(); - // 门店请求参数 + // 门店请求参数 + var type_data = this.$refs.realstore_cart.buy_use_type_data(); var post_data = { - buy_use_type_index: this.plugins_realstore_buy_use_type_index, + buy_use_type_data_index: type_data.data_index, id: this.plugins_realstore_info.id, }; this.get_cart_data(type, app.globalData.get_request_url('cartdata', 'detail', 'realstore'), post_data); @@ -1053,9 +1054,10 @@ ids: ids.join(','), }; // 是否门店模式 - if (this.cart_type_value == 'realstore' && (this.plugins_realstore_info || null) != null) { + if (this.cart_type_value == 'realstore' && (this.plugins_realstore_info || null) != null) { + var type_data = this.$refs.realstore_cart.buy_use_type_data(); + data['buy_use_type_data_index'] = type_data.data_index; data['realstore_id'] = this.plugins_realstore_info.id; - data['buy_use_type_index'] = this.plugins_realstore_buy_use_type_index; } return data; }, @@ -1255,9 +1257,10 @@ if ((this.plugins_realstore_info || null) != null) { // 初始化门店购物车 this.$refs.realstore_cart.init({ source: 'system-cart', info: this.plugins_realstore_info }); - // 初始当前门店下单类型 + // 初始当前门店下单类型 + var type_data = this.$refs.realstore_cart.buy_use_type_data(); this.setData({ - plugins_realstore_buy_use_type_index: this.$refs.realstore_cart.get_buy_use_type_index(), + plugins_realstore_buy_use_type_active_index: type_data.active_index, }); } }, @@ -1271,7 +1274,7 @@ realstore_buy_type_switch_back_event(params) { this.setData({ data_list_loding_status: 1, - plugins_realstore_buy_use_type_index: params.index, + plugins_realstore_buy_use_type_active_index: params.buy_use_type_active_index, }); // 重新加载数据 this.get_data(); diff --git a/components/choice-location/choice-location.vue b/components/choice-location/choice-location.vue index 989cb54d..0436458a 100644 --- a/components/choice-location/choice-location.vue +++ b/components/choice-location/choice-location.vue @@ -3,7 +3,7 @@ - + @@ -12,7 +12,7 @@ {{ location.text || '' }} - + @@ -75,8 +75,8 @@ default: true, }, propLeftImgValue: { - type: Array, - default: [], + type: [Array,String], + default: '', }, propLeftIconValue: { type: String, @@ -87,8 +87,8 @@ default: true, }, propRightImgValue: { - type: Array, - default: [], + type: [Array,String], + default: '', }, propRightIconValue: { type: String, diff --git a/components/realstore-cart/realstore-cart.vue b/components/realstore-cart/realstore-cart.vue index c4fe3c88..a2415355 100644 --- a/components/realstore-cart/realstore-cart.vue +++ b/components/realstore-cart/realstore-cart.vue @@ -13,7 +13,7 @@ {{$t('realstore-cart.realstore-cart.v437n6')}} - {{$t('realstore-cart.realstore-cart.6bmc34')}}({{info.buy_use_type_list[buy_use_type_index]['name']}}) + {{$t('realstore-cart.realstore-cart.6bmc34')}}({{info.buy_use_type_list[buy_use_type_active_index]['name']}}) @@ -28,7 +28,7 @@ - + @@ -64,7 +64,7 @@ {{$t('realstore-cart.realstore-cart.v437n6')}} - {{$t('realstore-cart.realstore-cart.6bmc34')}}{{info.buy_use_type_list[buy_use_type_index]['name']}}) + {{$t('realstore-cart.realstore-cart.6bmc34')}}{{info.buy_use_type_list[buy_use_type_active_index]['name']}}) @@ -166,8 +166,8 @@ // 临时操作数据 temp_opt_data: null, // 下单类型 - cache_buy_use_type_index_key: 'cache_plugins_realstore_buy_use_type_index_', - buy_use_type_index: 0, + cache_buy_use_type_active_index_key: 'cache_plugins_realstore_buy_use_type_active_index_', + buy_use_type_active_index: 0, // 下单类型选择弹窗 buy_use_type_choice_list: [], buy_use_type_choice_status: false, @@ -232,10 +232,10 @@ }); // 商品来源 - var index = this.get_buy_use_type_index(); + var type_data = this.buy_use_type_data(); if(this.source == 'goods' && (params.realstore_id || null) == null) { // 调用父级需要重新加载数据 - this.$emit('RefreshLoadingEvent', {buy_use_type_index: index, realstore_id: this.info.id}); + this.$emit('RefreshLoadingEvent', {buy_use_type_active_index: type_data.active_index, buy_use_type_data_index: type_data.data_index, realstore_id: this.info.id}); } else { // 非系统购物车来源 if(this.source != 'system-cart') { @@ -284,7 +284,7 @@ // 是否需要弹出下单类型选择 // 打开开关,并且店铺必须存在下单类型 - var cache_index = this.get_cache_buy_use_type_index(); + var cache_index = this.get_cache_buy_use_type_active_index(); if((this.base || null) != null && parseInt(this.base.is_tips_user_choice_buy_use_type || 0) == 1 && (cache_index === null || cache_index === '') && (this.info.buy_use_type_list || null) != null && this.info.buy_use_type_list.length > 1 && (this.info.status_info || null) != null && this.info.status_info.status == 1) { // 门店、商品是否开启了弹窗提示 var key = 'is_tips_user_choice_buy_use_type_'+this.params.source+'_detail'; @@ -311,15 +311,15 @@ } } - // 设置下单类型 - this.setData({ - buy_use_type_index: index, - }); - // 获取购物车数据 this.get_cart_data(); } } + + // 设置下单类型 + this.setData({ + buy_use_type_active_index: type_data.active_index, + }); } } }, @@ -404,10 +404,9 @@ // 是否限制类型 var limit_type = this.info.starting_price_limit_type_list || []; if(limit_type.length > 0) { - var index = this.get_buy_use_type_index(); - var buy_use_type = this.info.buy_use_type_list[index]; - if(limit_type.indexOf(buy_use_type['index']) != -1 || limit_type.indexOf(buy_use_type['index'].toString()) != -1) { - return buy_use_type['name'] + this.$t('realstore-cart.realstore-cart.miv944')+ this.propCurrencySymbol + starting_price; + var type_data = this.buy_use_type_data(); + if(limit_type.indexOf(type_data.data_index) != -1 || limit_type.indexOf(type_data.data_index.toString()) != -1) { + return temp['name'] + this.$t('realstore-cart.realstore-cart.miv944')+ this.propCurrencySymbol + starting_price; } } else { return this.$t('realstore-cart.realstore-cart.miv944') + this.propCurrencySymbol + starting_price; @@ -879,11 +878,11 @@ // 下单类型确认处理 buy_use_type_confirm_handle(self, index) { self.setData({ - buy_use_type_index: index, + buy_use_type_active_index: index, settlement_btn_loading: true, realstore_goods_data_cart_loading: true, }); - uni.setStorageSync(self.cache_buy_use_type_index_key+self.info.id, index); + uni.setStorageSync(self.cache_buy_use_type_active_index_key+self.info.id, index); // 获取购物车数据、系统购物车来源则不执行 if(this.source != 'system-cart') { @@ -891,7 +890,8 @@ } // 下单类型切换回调 - self.$emit('BuyTypeSwitchEvent', {index: index, buy_use_type_index: this.get_buy_use_type_index(), realstore_id: this.info.id}); + var type_data = this.buy_use_type_data(); + self.$emit('BuyTypeSwitchEvent', {buy_use_type_active_index: type_data.active_index, buy_use_type_data_index: type_data.data_index, realstore_id: this.info.id}); }, // 下单类型弹窗关闭 @@ -903,38 +903,42 @@ }, // 获取使用类型数据索引、默认在店0 - get_buy_use_type_index() { + buy_use_type_data() { + // 不在店铺设置的类型列表则默认0 + var data = { + active_index: 0, + data_index: 0, + } + // 门店信息 if((this.info || null) != null) { // 用户未设置类型则使用默认的 - var index = this.get_cache_buy_use_type_index(); - if(index === null || index === '') { + var active_index = this.get_cache_buy_use_type_active_index(); + if(active_index !== null && active_index !== '') { + var temp = this.info.buy_use_type_list[active_index] || null; + if(temp != null) { + data['active_index'] = active_index; + data['data_index'] = temp.index; + } + } else { // 是否默认类型 if(this.info.default_buy_use_type != undefined && this.info.default_buy_use_type != -1) { // 不在店铺设置的类型列表则默认0 - var temp_index = null; for (var i in this.info.buy_use_type_list) { if(this.info.buy_use_type_list[i]['index'] == this.info.default_buy_use_type) { - temp_index = i; + data['active_index'] = i; + data['data_index'] = this.info.buy_use_type_list[i]['index']; + break; } } - if(temp_index !== null) { - index = temp_index; - } } } - - // 不在店铺设置的类型列表则默认0 - if(this.info.buy_use_type_list[index] == undefined) { - index = 0; - } - return index; } - return 0; + return data; }, // 获取下单类型缓存数据 - get_cache_buy_use_type_index() { - return uni.getStorageSync(this.cache_buy_use_type_index_key+this.info.id); + get_cache_buy_use_type_active_index() { + return uni.getStorageSync(this.cache_buy_use_type_active_index_key+this.info.id); }, // 请求参数处理 @@ -943,11 +947,8 @@ request_params_merge(data, type = 'init') { // 用户使用类型 if((this.info || null) != null && (this.info.buy_use_type_list || null) != null && this.info.buy_use_type_list.length > 0) { - var index = this.get_buy_use_type_index(); - if(this.info.buy_use_type_list[index] == undefined) { - index = 0; - } - data['buy_use_type_index'] = index; + var type_data = this.buy_use_type_data(); + data['buy_use_type_data_index'] = type_data.data_index; } // 初始化 @@ -994,9 +995,11 @@ var goods = this.cart.data[e.currentTarget.dataset.index]; goods['id'] = goods.goods_id; app.globalData.goods_data_cache_handle(goods.id, goods); - + // 调用公共打开url地址 - app.globalData.url_event(e); + var type_data = this.buy_use_type_data(); + var url = '/pages/goods-detail/goods-detail?id=' + goods.id + '&is_opt_back=1&buy_use_type_data_index=' + type_data.data_index + '&realstore_id=' + this.info.id; + app.globalData.url_open(url); } } } diff --git a/pages/buy/buy.vue b/pages/buy/buy.vue index d57db617..a8722ea1 100644 --- a/pages/buy/buy.vue +++ b/pages/buy/buy.vue @@ -1137,7 +1137,7 @@ // 是否门店模式下 if (this.is_realstore_model) { // 覆盖选择的门店下单类型参数索引值 - upd_data['params'] = {...this.params, ...{buy_use_type_index: this.buy_site_model_list[index]['index']}}; + upd_data['params'] = {...this.params, ...{buy_use_type_data_index: this.buy_site_model_list[index]['index']}}; } this.setData(upd_data); diff --git a/pages/goods-detail/goods-detail.vue b/pages/goods-detail/goods-detail.vue index 8337f8a6..ae75afea 100644 --- a/pages/goods-detail/goods-detail.vue +++ b/pages/goods-detail/goods-detail.vue @@ -1489,6 +1489,7 @@ // 下单类型切换事件、数据刷新事件 refresh_loading_event(params) { + console.log(params) this.setData({params: {...this.params, ...params}}); this.init(); } diff --git a/pages/plugins/realstore/detail/detail.vue b/pages/plugins/realstore/detail/detail.vue index 3ebb3162..696981b1 100644 --- a/pages/plugins/realstore/detail/detail.vue +++ b/pages/plugins/realstore/detail/detail.vue @@ -44,7 +44,7 @@ - {{ info.buy_use_type_list[buy_use_type_index]['name'] }} + {{ info.buy_use_type_list[buy_use_type_active_index]['name'] }} @@ -159,7 +159,7 @@ - + @@ -326,7 +326,6 @@ is_base_mode: 0, is_base_mode_show_type: 0, is_cart_nav: false, - buy_use_type_index: 0, params: null, is_first: 1, scroll_top: 0, @@ -352,7 +351,7 @@ { name: this.$t('goods-detail.goods-detail.567uhg'), value: 1 }, ], // 下单类型 - buy_use_type_index: 0, + buy_use_type_active_index: 0, // 排序导航 search_nav_sort_index: 0, search_nav_sort_list: [{ @@ -587,8 +586,9 @@ } // 下单类型索引 + var type_data = this.buy_use_type_data(); this.setData({ - buy_use_type_index: this.get_buy_use_type_index(), + buy_use_type_active_index: type_data.active_index, }); // 获取数据、仅首次调用,获取列表接口 @@ -809,8 +809,9 @@ } else { if ((this.$refs.goods_buy || null) != null) { var buy_params = this.params; + var type_data = this.buy_use_type_data(); buy_params['buy_event_type'] = 'cart'; - buy_params['buy_use_type_index'] = this.get_buy_use_type_index(); + buy_params['buy_use_type_data_index'] = type_data.data_index; buy_params['realstore_id'] = this.info.id; this.$refs.goods_buy.init(temp_goods, buy_params); } @@ -1029,7 +1030,7 @@ // 下单类型切换事件回调 buy_type_switch_event(params) { this.setData({ - buy_use_type_index: params.index, + buy_use_type_active_index: params.buy_use_type_active_index, data_page: 1, }); this.reset_scroll(); @@ -1037,8 +1038,8 @@ }, // 获取使用类型数据索引、默认在店0 - get_buy_use_type_index() { - return this.$refs.realstore_cart.get_buy_use_type_index(); + buy_use_type_data() { + return this.$refs.realstore_cart.buy_use_type_data(); }, // 商品事件 @@ -1050,7 +1051,9 @@ app.globalData.goods_data_cache_handle(goods.id, goods); // 调用公共打开url地址 - app.globalData.url_event(e); + var type_data = this.buy_use_type_data(); + var url = '/pages/goods-detail/goods-detail?id=' + goods.id + '&is_opt_back=1&buy_use_type_data_index=' + type_data.data_index + '&realstore_id=' + this.info.id; + app.globalData.url_open(url); } },