优化首页导航

This commit is contained in:
TOP糯米 2023-03-22 20:53:40 +08:00
parent 928e3dec86
commit 7801227096
7 changed files with 82 additions and 23 deletions

View File

@ -19,6 +19,9 @@ export default {
banner: {
url: "/wxapp/index/banner",
},
nav: {
url: "/wxapp/index/getindexmenu"
}
},
user: {
sendCode: {

View File

@ -283,6 +283,19 @@ function isType(param, type) {
return Object.prototype.toString.call(param) === t;
}
function getUrlParams(url) {
const params = {}
if (url.indexOf('?') > 0) {//判断是否有qurey
let parmas = url.slice(url.indexOf('?') + 1)//截取出query
const paramlists = parmas.split('&')//分割键值对
for (const param of paramlists) {
let a = param.split('=')
Object.assign(params, { [a[0]]: a[1] })//将键值对封装成对象
}
}
return params
}
export default {
time,
datetime,
@ -298,4 +311,5 @@ export default {
formatNumber,
chooseImage,
isType,
getUrlParams,
}

View File

@ -18,6 +18,30 @@ export default {
});
});
},
/**
* 导航列表
*/
navList() {
return new Promise((resolve, reject) => {
prototype.$request({
api: "index.nav",
}).then(response => {
if (response.code == 1) {
let list = [];
response.data.forEach(item => {
list.push({
id: item.id,
cover: item.logo,
name: item.title,
page: item.url,
})
});
return resolve(list);
}
return reject(response.msg);
}).catch(e => { });
});
},
/**
* 提交投诉
*/
@ -47,7 +71,15 @@ export default {
}
}).then(response => {
if (response.code == 1) {
return resolve(response.data);
let list = [];
response.data.forEach((item) => {
list.push({
id: item.id,
title: item.title,
content: item.message,
});
});
return resolve(list);
}
return reject(response.msg);
}).catch(e => { throw e; });

View File

@ -231,7 +231,7 @@ export default {
insurancePrice: (state) => state.service.insurancePrice,
}),
},
onLoad() {
onLoad(e) {
this.pageConfig = getApp().globalData.pageConfig;
// #ifdef MP-WEIXIN
uni.enableAlertBeforeUnload({
@ -241,6 +241,14 @@ export default {
this.$store.dispatch("service/insurancePrice");
this.$models.service.getInstallCate().then((list) => {
this.cateList = list;
if (e.id && e.id > 0) {
list.forEach((item) => {
if (item.id == e.id) {
this.cateId = item.id;
this.cateText = item.name;
}
});
}
});
},
onShow() {},

View File

@ -37,7 +37,7 @@
class="service-item"
v-for="(item, index) in installServiceList"
:key="index"
@click="toInstallService(item.id)"
@click="toService(item.page, item.id)"
>
<image class="service-icon" :src="item.cover" mode="scaleToFill" />
<text class="service-name limit-line clamp-1">
@ -125,7 +125,7 @@ export default {
WidgetModal,
},
onLoad() {
//
//
this.$request({
api: "index.banner",
}).then((response) => {
@ -135,20 +135,17 @@ export default {
});
});
});
//
//
this.$models.system.notifyList().then((list) => {
list.forEach((item) => {
this.notifyList.push({
id: item.id,
title: item.title,
content: item.message,
});
});
this.notifyList = list;
});
//
this.$models.service.getInstallCate().then((list) => {
//
this.$models.system.navList().then((list) => {
this.installServiceList = list;
});
/**
* 维修售后
*/
this.$models.service.getAfterMarketCate().then((list) => {
this.aftermarketServiceList = list;
});
@ -161,9 +158,14 @@ export default {
/**
* 服务分类
*/
toInstallService(id) {
this.$store.commit("system/indexCateId", id);
this.$utils.toPage("/pages/service/cate", {}, "switch");
toService(page) {
const params = this.$utils.getUrlParams(page);
if (page.indexOf("demand") > 0) {
this.$utils.toPage(page);
} else {
this.$store.commit("system/currentCateId", params.id);
this.$utils.toPage(page, {}, "switch");
}
},
/**
* 公告详情

View File

@ -57,7 +57,7 @@ export default {
},
computed: {
...mapState({
indexCateId: (state) => state.system.indexCateId,
currentCateId: (state) => state.system.currentCateId,
cartCount: (state) => state.cart.count,
}),
...mapGetters({
@ -90,12 +90,12 @@ export default {
this.loadCate();
},
onShow() {
this.newId = this.currentId = this.indexCateId;
this.newId = this.currentId = this.currentCateId;
},
onReady() {},
onHide() {
this.currentId = 0;
this.$store.commit("system/indexCateId", this.newId);
this.$store.commit("system/currentCateId", this.newId);
},
onReachBottom() {},
onPullDownRefresh() {},

View File

@ -1,12 +1,12 @@
export default {
namespaced: true,
state: {
indexCateId: 0,
currentCateId: 0,
},
getters: {},
mutations: {
indexCateId(state, data) {
state.indexCateId = data;
currentCateId(state, data) {
state.currentCateId = data;
}
},
actions: {}