首页标题优化-0715

master
Lee-1203 2022-07-15 09:04:30 +08:00
parent 272cad2f57
commit b7162acc09
19 changed files with 72 additions and 54 deletions

View File

@ -189,10 +189,12 @@
// //
getSecondList(index){ getSecondList(index){
this.secondList=[]; this.secondList=[];
if(this.cateList[index].has_children){ if(this.cateList.length>0){
this.secondList = this.cateList[index].children; if(this.cateList[index].has_children){
}else{ this.secondList = this.cateList[index].children;
this.isTips = true; }else{
this.isTips = true;
}
} }
}, },
// //

View File

@ -57,7 +57,7 @@
import productList from '@/components/product-list/product-list.vue'; import productList from '@/components/product-list/product-list.vue';
import navTab from '@/components/nav-tab/nav-tab.vue'; import navTab from '@/components/nav-tab/nav-tab.vue';
import pullList from '@/components/pull-list/pull-list.vue'; import pullList from '@/components/pull-list/pull-list.vue';
import {getCartNum,userInfoEv} from '@/jsFile/public-api.js'; import {getCartNum} from '@/jsFile/public-api.js';
import {mapState} from 'vuex'//mapState import {mapState} from 'vuex'//mapState
export default { export default {
components:{ components:{
@ -88,7 +88,7 @@
total:0, // total:0, //
totalAll:-1,// totalAll:-1,//
ifLoading:true, ifLoading:true,
indexTitle:'首页',// indexTitle:'',//
} }
}, },
computed:{ computed:{
@ -102,17 +102,14 @@
if(res.code == 0){ if(res.code == 0){
this.getHomeData(); this.getHomeData();
this.getArticleNav(); this.getArticleNav();
userInfoEv(); this.userInfoEv();
this.getCompanyList(op.business_id);
} }
}) })
}else{ }else{
this.getHomeData(); this.getHomeData();
this.getArticleNav(); this.getArticleNav();
userInfoEv(); this.userInfoEv();
this.getCompanyList(uni.getStorageSync('business_id'));
} }
this.getCompanyList(uni.getStorageSync('business_id'));
}, },
onShow() { onShow() {
this.playTimer = setTimeout(()=>{ this.playTimer = setTimeout(()=>{
@ -147,6 +144,16 @@
this.isplay =false; this.isplay =false;
}, },
methods: { methods: {
//
userInfoEv(){
this.$requst.get('/api/user/info').then(res=>{
if(res.code==0){
uni.setStorageSync('business_id',res.data.business_id);
uni.setStorageSync('business_code',res.data.business_code);
this.getCompanyList(res.data.business_id);
}
})
},
// //
getCompanyList(business_id){ getCompanyList(business_id){
this.$requst.post('/api/business/info',{business_id:business_id}).then(res=>{ this.$requst.post('/api/business/info',{business_id:business_id}).then(res=>{

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -347,10 +347,12 @@ var _default = {
// 查询二级分类 // 查询二级分类
getSecondList: function getSecondList(index) { getSecondList: function getSecondList(index) {
this.secondList = []; this.secondList = [];
if (this.cateList[index].has_children) { if (this.cateList.length > 0) {
this.secondList = this.cateList[index].children; if (this.cateList[index].has_children) {
} else { this.secondList = this.cateList[index].children;
this.isTips = true; } else {
this.isTips = true;
}
} }
}, },
// 跳转详情页 // 跳转详情页

View File

@ -255,7 +255,7 @@ var _default = {
total: 0, //数量 total: 0, //数量
totalAll: -1, //总数 totalAll: -1, //总数
ifLoading: true, ifLoading: true,
indexTitle: '首页' //标题 indexTitle: '' //标题
}; };
}, },
computed: _objectSpread({}, computed: _objectSpread({},
@ -269,17 +269,14 @@ var _default = {
if (res.code == 0) { if (res.code == 0) {
_this.getHomeData(); _this.getHomeData();
_this.getArticleNav(); _this.getArticleNav();
(0, _publicApi.userInfoEv)(); _this.userInfoEv();
_this.getCompanyList(op.business_id);
} }
}); });
} else { } else {
this.getHomeData(); this.getHomeData();
this.getArticleNav(); this.getArticleNav();
(0, _publicApi.userInfoEv)(); this.userInfoEv();
this.getCompanyList(uni.getStorageSync('business_id'));
} }
this.getCompanyList(uni.getStorageSync('business_id'));
}, },
onShow: function onShow() {var _this2 = this; onShow: function onShow() {var _this2 = this;
this.playTimer = setTimeout(function () { this.playTimer = setTimeout(function () {
@ -314,16 +311,26 @@ var _default = {
this.isplay = false; this.isplay = false;
}, },
methods: { methods: {
// 查询用户信息
userInfoEv: function userInfoEv() {var _this3 = this;
this.$requst.get('/api/user/info').then(function (res) {
if (res.code == 0) {
uni.setStorageSync('business_id', res.data.business_id);
uni.setStorageSync('business_code', res.data.business_code);
_this3.getCompanyList(res.data.business_id);
}
});
},
// 查询工厂列表 // 查询工厂列表
getCompanyList: function getCompanyList(business_id) {var _this3 = this; getCompanyList: function getCompanyList(business_id) {var _this4 = this;
this.$requst.post('/api/business/info', { business_id: business_id }).then(function (res) { this.$requst.post('/api/business/info', { business_id: business_id }).then(function (res) {
if (res.code == 0) { if (res.code == 0) {
_this3.indexTitle = res.data.alias; _this4.indexTitle = res.data.alias;
} }
}); });
}, },
// 获取首页数据 // 获取首页数据
getHomeData: function getHomeData() {var _this4 = this; getHomeData: function getHomeData() {var _this5 = this;
this.$requst.get('/api/index/home').then(function (res) { this.$requst.get('/api/index/home').then(function (res) {
if (res.code == 0) { if (res.code == 0) {
var bannerArr = []; var bannerArr = [];
@ -336,15 +343,15 @@ var _default = {
bannerArr.push(obj); bannerArr.push(obj);
}); });
_this4.bannerList = bannerArr; _this5.bannerList = bannerArr;
_this4.recommendList = res.data['banner-next-2']; _this5.recommendList = res.data['banner-next-2'];
_this4.productList = res.data.spu; _this5.productList = res.data.spu;
_this4.ifLoading = false; _this5.ifLoading = false;
} }
}); });
}, },
// 获取文章栏目 // 获取文章栏目
getArticleNav: function getArticleNav() {var _this5 = this; getArticleNav: function getArticleNav() {var _this6 = this;
this.$requst.get('/api/archives/category').then(function (res) { this.$requst.get('/api/archives/category').then(function (res) {
if (res.code == 0) { if (res.code == 0) {
res.data.forEach(function (item) { res.data.forEach(function (item) {
@ -352,11 +359,11 @@ var _default = {
id: item.id, id: item.id,
name: item.title }; name: item.title };
_this5.navTabList.push(obj); _this6.navTabList.push(obj);
}); });
_this5.articleNavId = _this5.navTabList[0].id; _this6.articleNavId = _this6.navTabList[0].id;
// 获取文章列表 // 获取文章列表
_this5.getArticleList(); _this6.getArticleList();
} }
}); });
}, },
@ -372,7 +379,7 @@ var _default = {
} }
}, },
// 获取文章列表 // 获取文章列表
getArticleList: function getArticleList() {var _this6 = this; getArticleList: function getArticleList() {var _this7 = this;
uni.showLoading({ uni.showLoading({
title: '加载中' }); title: '加载中' });
@ -383,20 +390,20 @@ var _default = {
this.$requst.get('/api/archives/list', params).then(function (res) { this.$requst.get('/api/archives/list', params).then(function (res) {
if (res.code == 0) { if (res.code == 0) {
_this6.total = res.data.total; _this7.total = res.data.total;
var newArr = []; var newArr = [];
res.data.list.forEach(function (item) { res.data.list.forEach(function (item) {
var obj = { var obj = {
id: item.id, id: item.id,
title: item.title, title: item.title,
time: _this6.dateFormat(item.published_at.replace(/-/g, '/')), time: _this7.dateFormat(item.published_at.replace(/-/g, '/')),
src: item.cover }; src: item.cover };
newArr.push(obj); newArr.push(obj);
}); });
_this6.articleList = newArr; _this7.articleList = newArr;
if (_this6.articleList.length == _this6.total) { if (_this7.articleList.length == _this7.total) {
_this6.totalAll = _this6.total; _this7.totalAll = _this7.total;
} }
} }
uni.hideLoading(); uni.hideLoading();