@@ -198,35 +198,8 @@ export default {
198198 confirmStatus: false , // 确认选择
199199 }
200200 },
201- async created (){
202- // 获取从msite页面传递过来的参数
203- this .geohash = this .$route .query .geohash ;
204- this .headTitle = this .$route .query .title ;
205- this .foodTitle = this .headTitle ;
206- this .restaurant_category_id = this .$route .query .restaurant_category_id ;
207- // 防止刷新页面时,vuex状态丢失,经度纬度需要重新获取,并存入vuex
208- if (! this .latitude ) {
209- // 获取位置信息
210- let res = await msiteAdress (this .geohash );
211- // 记录当前经度纬度进入vuex
212- this .RECORD_ADDRESS (res);
213- }
214- // 获取category分类左侧数据
215- this .category = await foodCategory (this .latitude , this .longitude );
216- // 初始化时定位当前category分类左侧默认选择项,在右侧展示出其sub_categories列表
217- this .category .forEach (item => {
218- if (this .restaurant_category_id == item .id ) {
219- this .categoryDetail = item .sub_categories ;
220- }
221- });
222- // 获取筛选列表的配送方式
223- this .Delivery = await foodDelivery (this .latitude , this .longitude );
224- // 获取筛选列表的商铺活动
225- this .Activity = await foodActivity (this .latitude , this .longitude );
226- // 记录support_ids的状态,默认不选中,点击状态取反,status为true时为选中状态
227- this .Activity .forEach ((item , index ) => {
228- this .support_ids [index] = {status: false , id: item .id };
229- })
201+ created (){
202+ this .initData ();
230203 },
231204 mixins: [getImgPath],
232205 components: {
@@ -242,6 +215,37 @@ export default {
242215 ... mapMutations ([
243216 ' RECORD_ADDRESS'
244217 ]),
218+ // 初始化获取数据
219+ async initData (){
220+ // 获取从msite页面传递过来的参数
221+ this .geohash = this .$route .query .geohash ;
222+ this .headTitle = this .$route .query .title ;
223+ this .foodTitle = this .headTitle ;
224+ this .restaurant_category_id = this .$route .query .restaurant_category_id ;
225+ // 防止刷新页面时,vuex状态丢失,经度纬度需要重新获取,并存入vuex
226+ if (! this .latitude ) {
227+ // 获取位置信息
228+ let res = await msiteAdress (this .geohash );
229+ // 记录当前经度纬度进入vuex
230+ this .RECORD_ADDRESS (res);
231+ }
232+ // 获取category分类左侧数据
233+ this .category = await foodCategory (this .latitude , this .longitude );
234+ // 初始化时定位当前category分类左侧默认选择项,在右侧展示出其sub_categories列表
235+ this .category .forEach (item => {
236+ if (this .restaurant_category_id == item .id ) {
237+ this .categoryDetail = item .sub_categories ;
238+ }
239+ });
240+ // 获取筛选列表的配送方式
241+ this .Delivery = await foodDelivery (this .latitude , this .longitude );
242+ // 获取筛选列表的商铺活动
243+ this .Activity = await foodActivity (this .latitude , this .longitude );
244+ // 记录support_ids的状态,默认不选中,点击状态取反,status为true时为选中状态
245+ this .Activity .forEach ((item , index ) => {
246+ this .support_ids [index] = {status: false , id: item .id };
247+ })
248+ },
245249 // 点击顶部三个选项,展示不同的列表,选中当前选项进行展示,同时收回其他选项
246250 async chooseType (type ){
247251 if (this .sortBy !== type) {
0 commit comments