diff --git a/src/main.js b/src/main.js index 0fa1ee4..6cac922 100644 --- a/src/main.js +++ b/src/main.js @@ -15,6 +15,39 @@ Vue.use(utils) Vue.config.productionTip = false Vue.use(ElementUI) +let env = process.env.NODE_ENV; +console.log(env) +Vue.prototype.VUE_APP_GLOBAL_TAGS = { + // 正式数据 + pc_all: 675, // pc-分类集合 + all_prod: 676, // 全部商品 + // mmy: 677, //米面油 + // twgh: 678, // 调味干货 + // xxls: 679, //休闲零食 + // qxrd: 680, // 禽畜肉蛋 + // xgsz: 681, //鲜果蔬菜 + // zhjs: 682, //组合集市 + pc_index_recommend: 683, //PC-首页-今日推荐 + pc_index_hot: 684, //pc-首页-热销排行 + pc_index_new: 685, // pc-首页-新品上市 +} +if (env === 'development') { + Vue.prototype.VUE_APP_GLOBAL_TAGS = { + // 测试数据 + pc_all: 662, // pc-分类集合 + all_prod: 663, // 全部商品 + // mmy: 664, //米面油 + // twgh: 665, // 调味干货 + // xxls: 666, //休闲零食 + // qxrd: 667, // 禽畜肉蛋 + // xgsz: 668, //鲜果蔬菜 + // zhjs: 669, //组合集市 + pc_index_recommend: 670, //PC-首页-今日推荐 + pc_index_hot: 671, //pc-首页-热销排行 + pc_index_new: 672, // pc-首页-新品上市 + } +} + // 配置图片懒加载 Vue.use(VueLazyload, { preLoad: 1.3, // 预加载高度比例 diff --git a/src/views/Index.vue b/src/views/Index.vue index 499c619..2b20224 100644 --- a/src/views/Index.vue +++ b/src/views/Index.vue @@ -34,17 +34,17 @@ export default { tagList: [], prouctList: [ { - id: 670, + id: this.VUE_APP_GLOBAL_TAGS.pc_index_recommend, title: "今日推荐", list: [], }, { - id: 671, + id: this.VUE_APP_GLOBAL_TAGS.pc_index_hot, title: "热销排行", list: [], }, { - id: 672, + id: this.VUE_APP_GLOBAL_TAGS.pc_index_new, title: "新品上市", list: [], }, @@ -122,7 +122,7 @@ export default { "/api/product/tag_list" ).then((res) => { this.tagList = res.data; - this.tagList[0].id = 662; + this.tagList[0].id = this.VUE_APP_GLOBAL_TAGS.pc_all; }); }, // 三个分类商品 diff --git a/src/views/ProductPage/Index.vue b/src/views/ProductPage/Index.vue index 4253fef..3e7754a 100644 --- a/src/views/ProductPage/Index.vue +++ b/src/views/ProductPage/Index.vue @@ -170,9 +170,9 @@ export default { "/api/product/tag_list" ).then((res) => { this.categories = res.data; - this.categories[0].id = 662; + this.categories[0].id = this.VUE_APP_GLOBAL_TAGS.pc_all; // 获取路由中的id参数 - const routeId = this.$route.query.id || 662; + const routeId = this.$route.query.id || this.VUE_APP_GLOBAL_TAGS.pc_all; if (routeId) { // 存储路由id this.id = routeId;