You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

141 lines
3.9 KiB

<template>
<view>
<haiNaBaiXianIndexPage
v-if="Vsign == 'haiNaBaiXian' && isShow"
></haiNaBaiXianIndexPage>
<hongFuQiTianIndexPage
v-else-if="Vsign == 'hongFuQiTian' && isShow"
></hongFuQiTianIndexPage>
<chengXinRuYiIndexPage
v-else-if="Vsign == 'chengXinRuYi' && isShow"
></chengXinRuYiIndexPage>
<baiLiTiaoTiIndexPage
v-else-if="Vsign == 'baiLiTiaoYi' && isShow"
></baiLiTiaoTiIndexPage>
<indexPage v-else-if="Vsign == 'default' && isShow"></indexPage>
</view>
</template>
<script>
var app = getApp();
import { mapState, mapActions } from "vuex";
import indexPage from "../themes/default/index.vue";
import haiNaBaiXianIndexPage from "../themes/haiNaBaiXian/index.vue";
import hongFuQiTianIndexPage from "../themes/hongFuQiTian/index.vue";
import chengXinRuYiIndexPage from "../themes/chengXinRuYi/index.vue";
import baiLiTiaoTiIndexPage from "../themes/baiLiTiaoTi/index.vue";
export default {
components: {
indexPage,
haiNaBaiXianIndexPage,
baiLiTiaoTiIndexPage,
chengXinRuYiIndexPage,
hongFuQiTianIndexPage,
},
data() {
return {
opt: {},
isShow: false,
};
},
computed: {
...mapState({
vOpt: (state) => {
return state.opt;
},
Vsign: (state) => {
return state.sign;
},
VnavHeightTop: (state) => {
return state.navHeightTop;
},
VNavFixed: (state) => {
return state.navFixed;
},
}),
},
onLoad(opt) {
const that = this;
if (opt) {
that.opt = app.getopts(opt);
that.opt.bid = that.opt.id ? that.opt.id : 1;
console.log("打印onLoad的参数opt", that.opt);
// 获取本地bid,sign
uni.getStorage({
key: "shop_data",
success: function (res) {
// 本地数据获取成功
// 如果传入的bid等于本地获取到的bid,就直接使用本地数据;
if (that.opt.bid == res.data.bid) {
that.$set(that.opt, "bid", parseInt(res.data.bid));
that.acOpt(that.opt);
that.acSign(res.data.sign);
that.isShow = true;
} else {
// 否则重新发送请求获取数据
that.getData(that.opt);
}
},
fail: function () {
// 本地数据获取失败,重新发送请求获取数据
that.getData(that.opt);
},
});
}
this.acNavFixed(false);
},
methods: {
...mapActions([
"acOpt",
"acSign",
"acPagecontent",
"acNavFixed",
]),
getData(opt) {
const that = this;
that.acOpt(opt);
that.acNavFixed(false);
let shopData = {};
app.get("/ApiBusiness/themeSgin", { bid: opt.bid }, function (res) {
const { data } = res;
if (data) {
shopData = data;
// 主题改变时,把存储在state的pagecontentList清空
const pagecontent = [];
that.acPagecontent(pagecontent);
app.post("/ApiBusiness/follow", { bid: opt.bid }, function (res) {
that.$set(shopData, "attention", res.data.followCount);
that.$set(shopData, "isFollow", res.data.isFollow);
// 公共头部信息
uni.setStorage({
key: "header_data",
data: shopData,
});
const sign = data.sign;
uni.setStorage({
key: "shop_data",
data: {
bid: opt.bid,
sign: sign,
},
});
that.acSign(sign);
that.isShow = true;
});
}
});
},
},
onPageScroll(e) {
// e.scrollTop 获取页面的滚动高度
// console.log("打印滚动高度",e.scrollTop,this.VnavHeightTop)
if (e.scrollTop >= this.VnavHeightTop) {
this.acNavFixed(true);
} else {
this.acNavFixed(false);
}
},
};
</script>