Chore(首页):代码格式化&去掉多余的引用
This commit is contained in:
+149
-192
@@ -191,7 +191,7 @@
|
||||
<view class="item flex" v-for="(item,index) in bastList" :key="index" slot="slot{{index}}">
|
||||
<template v-if="item.storeName==='swiper'">
|
||||
<swiper class="item bannar-swiper" autoplay circular>
|
||||
<swiper-item v-for="swipe in bannarList" :key="swipe">
|
||||
<swiper-item v-for="swipe in bannerList" :key="swipe">
|
||||
<image :src="swipe.pic" mode="aspectFit" @click="goGoodsConByProductID(swipe)"/>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
@@ -244,34 +244,21 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {mapGetters} from 'vuex';
|
||||
|
||||
import PromotionGood from '@/components/PromotionGood';
|
||||
import CouponWindow from '@/components/CouponWindow';
|
||||
import CountDown from "@/components/CountDown";
|
||||
import hxNavbar from "@/components/hx-navbar/hx-navbar.vue"
|
||||
import imgBox from '@/components/imageTypeSet/imagebox.vue'
|
||||
|
||||
import {getCouponReceive, noticeDetail, noticeList} from "@/api/user";
|
||||
import {getHomeData, getShareImage} from '@/api/public';
|
||||
import {getProducts} from "@/api/store";
|
||||
import {sharpBannar} from "@/api/goods";
|
||||
import NP from "number-precision";
|
||||
|
||||
import { mapGetters } from 'vuex'
|
||||
import { getCouponReceive, noticeDetail, noticeList } from '@/api/user'
|
||||
import { getHomeData, getShareImage } from '@/api/public'
|
||||
import { getProducts } from '@/api/store'
|
||||
import { sharpBannar } from '@/api/goods'
|
||||
import NP from 'number-precision'
|
||||
import { pageListenMixins } from '@/mixins/pageListenMixins'
|
||||
|
||||
var that;
|
||||
export default {
|
||||
name: 'Index',
|
||||
name: 'IndexPage',
|
||||
components: {
|
||||
imgBox,
|
||||
PromotionGood,
|
||||
CouponWindow,
|
||||
CountDown,
|
||||
hxNavbar
|
||||
imgBox
|
||||
},
|
||||
mixins: [pageListenMixins],
|
||||
data: function () {
|
||||
data() {
|
||||
return {
|
||||
currentIndex: 0,
|
||||
speed: 200,
|
||||
@@ -293,7 +280,7 @@ export default {
|
||||
menus: [],
|
||||
menuArr: [[], []],
|
||||
roll: [],
|
||||
cityName: "",
|
||||
cityName: '',
|
||||
activity: [],
|
||||
groupGoods: [],
|
||||
activityOne: {},
|
||||
@@ -370,9 +357,9 @@ export default {
|
||||
liveList: [],
|
||||
broadcastStyle2: {
|
||||
speed: 100,
|
||||
font_size: "32", //字体大小(rpx)
|
||||
text_color: "#333", //字体颜色
|
||||
back_color: "red", //背景色
|
||||
font_size: '32', //字体大小(rpx)
|
||||
text_color: '#333', //字体颜色
|
||||
back_color: 'red', //背景色
|
||||
},
|
||||
bslImglist: [],
|
||||
statusBarHeight: 64,
|
||||
@@ -380,8 +367,8 @@ export default {
|
||||
preSaleList: [], // 预售商品
|
||||
month: 0, // 每日特价:月
|
||||
date: 0, // 每日特价:日
|
||||
bannarList: [], // 尖货推荐横幅
|
||||
shareAppImg: "", // 发送给朋友
|
||||
bannerList: [], // 尖货推荐横幅
|
||||
shareAppImg: '', // 发送给朋友
|
||||
isOldUser: true, // 老用户弹窗
|
||||
oldUserPopup: {},
|
||||
contentHomestay: {},
|
||||
@@ -392,48 +379,40 @@ export default {
|
||||
scrollTop: 0
|
||||
}
|
||||
},
|
||||
computed: mapGetters(["userInfo", 'isLogin']),
|
||||
onLoad: function (options) {
|
||||
that = this;
|
||||
this.init();
|
||||
getShareImage().then(({data}) => this.shareAppImg = data);
|
||||
computed: mapGetters(['userInfo', 'isLogin']),
|
||||
onLoad(options) {
|
||||
const _this = this
|
||||
_this.init()
|
||||
getShareImage().then(({ data }) => _this.shareAppImg = data)
|
||||
uni.getSystemInfo({
|
||||
success: (e) => {
|
||||
let statusBar = 0;
|
||||
let customBar = 0;
|
||||
|
||||
let statusBar = 0
|
||||
let customBar = 0
|
||||
// #ifdef MP-WEIXIN
|
||||
statusBar = e.statusBarHeight
|
||||
const custom = uni.getMenuButtonBoundingClientRect()
|
||||
customBar = custom.bottom + custom.top - e.statusBarHeight
|
||||
// #endif
|
||||
|
||||
that.statusBarHeight = customBar;
|
||||
//两列商品宽度
|
||||
that.hotGoodsColumnWidth = (e.screenWidth - uni.upx2px(90)) / 2 + 'px';
|
||||
//状态栏图片高度
|
||||
that.bgImgHeight = statusBar + 'px';
|
||||
|
||||
_this.statusBarHeight = customBar
|
||||
// 两列商品宽度
|
||||
_this.hotGoodsColumnWidth = (e.screenWidth - uni.upx2px(90)) / 2 + 'px'
|
||||
// 状态栏图片高度
|
||||
_this.bgImgHeight = statusBar + 'px'
|
||||
}
|
||||
});
|
||||
|
||||
this.testAni()
|
||||
})
|
||||
},
|
||||
onShow: function () {
|
||||
const today = new Date();
|
||||
this.month = today.getMonth() + 1;
|
||||
this.date = today.getDate();
|
||||
|
||||
//如果已经登录获取用户信息
|
||||
onShow() {
|
||||
const today = new Date()
|
||||
this.month = today.getMonth() + 1
|
||||
this.date = today.getDate()
|
||||
// 如果已经登录获取用户信息
|
||||
if (this.isLogin) {
|
||||
this.$store.dispatch("getUser", true);
|
||||
|
||||
//获取最新一条消息
|
||||
this.getUnreadMsgList();
|
||||
this.$store.dispatch('getUser', true)
|
||||
// 获取最新一条消息
|
||||
this.getUnreadMsgList()
|
||||
}
|
||||
|
||||
// 获取团购商品
|
||||
this.getGroupGoods();
|
||||
this.getGroupGoods()
|
||||
// fix bug#1113
|
||||
// if (this.bastList.length > 0) {
|
||||
// this.getBastList()
|
||||
@@ -457,105 +436,101 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
let that = this;
|
||||
|
||||
sharpBannar().then(({data}) => {
|
||||
this.bannarList = data.banner
|
||||
|
||||
uni.showLoading({
|
||||
title: '加载中'
|
||||
});
|
||||
const _this = this
|
||||
sharpBannar().then(response => {
|
||||
_this.bannerList = response.data.banner
|
||||
uni.showLoading({ title: '加载中' })
|
||||
getHomeData().then(res => {
|
||||
that.logoUrl = res.data.logoUrl;
|
||||
that.$set(that, 'banner', res.data.banner);
|
||||
const { data } = res
|
||||
_this.logoUrl = data.logoUrl
|
||||
_this.$set(_this, 'banner', data.banner)
|
||||
|
||||
that.$set(that, 'menus', res.data.menus)
|
||||
res.data.menus?.forEach((item, index) => {
|
||||
_this.$set(_this, 'menus', data.menus)
|
||||
data.menus?.forEach((item, index) => {
|
||||
if (index % 2 === 0) {
|
||||
that.menuArr[0].push(item)
|
||||
_this.menuArr[0].push(item)
|
||||
} else {
|
||||
that.menuArr[1].push(item)
|
||||
_this.menuArr[1].push(item)
|
||||
}
|
||||
})
|
||||
|
||||
that.$set(that, 'roll', res.data.roll);
|
||||
that.$set(that, 'userList', res.data.lotteryRecord); //滚动会员信息
|
||||
that.$set(that, 'info', res.data.info);
|
||||
that.$set(that, 'firstList', res.data.firstList.map((item) => {
|
||||
item.price = that.$force2Decimal(item.price);
|
||||
//如果已经登录获取用户信息
|
||||
if (that.$store.getters.token && that.userInfo) {
|
||||
var p = NP.times(item.price, NP.divide(parseFloat(that.userInfo.discount),
|
||||
100))
|
||||
item.vipPrice = that.$force2Decimal(p);
|
||||
_this.$set(_this, 'roll', data.roll)
|
||||
// 滚动会员信息
|
||||
_this.$set(_this, 'userList', data.lotteryRecord)
|
||||
_this.$set(_this, 'info', data.info)
|
||||
_this.$set(_this, 'firstList', data.firstList.map((item) => {
|
||||
item.price = _this.$force2Decimal(item.price)
|
||||
// 如果已经登录获取用户信息
|
||||
if (_this.$store.getters.token && _this.userInfo) {
|
||||
const p = NP.times(item.price, NP.divide(parseFloat(_this.userInfo.discount), 100))
|
||||
item.vipPrice = _this.$force2Decimal(p)
|
||||
}
|
||||
return item;
|
||||
}));
|
||||
that.$set(that, 'oldUserPopup', res.data.oldUserPopup)
|
||||
that.$set(that, 'contentHomestay', res.data.contentHomestay)
|
||||
that.$set(that, 'contentFestival', res.data.contentFestival)
|
||||
that.$set(that, 'countyFamous', res.data.countyFamous)
|
||||
return item
|
||||
}))
|
||||
_this.$set(_this, 'oldUserPopup', data.oldUserPopup)
|
||||
_this.$set(_this, 'contentHomestay', data.contentHomestay)
|
||||
_this.$set(_this, 'contentFestival', data.contentFestival)
|
||||
_this.$set(_this, 'countyFamous', data.countyFamous)
|
||||
|
||||
// 处理时令尝鲜轮播图所需数据
|
||||
const foodLen = res.data.seasonalFood.productsCarousels.length;
|
||||
const foods = res.data.seasonalFood.productsCarousels;
|
||||
let groupList = [];
|
||||
const foodLen = data.seasonalFood.productsCarousels.length
|
||||
const foods = data.seasonalFood.productsCarousels
|
||||
const groupList = []
|
||||
if (foodLen) {
|
||||
const count = 4;
|
||||
const count = 4
|
||||
for (let i = 0; i < foodLen; i += count) {
|
||||
groupList.push(foods.slice(i, i + count))
|
||||
}
|
||||
}
|
||||
res.data.seasonalFood.groupList = groupList;
|
||||
that.$set(that, 'seasonalFood', res.data.seasonalFood)
|
||||
data.seasonalFood.groupList = groupList
|
||||
_this.$set(_this, 'seasonalFood', data.seasonalFood)
|
||||
|
||||
if (that.firstList.length > 0) {
|
||||
that.newGoods = that.firstList[0];
|
||||
if (_this.firstList.length > 0) {
|
||||
_this.newGoods = _this.firstList[0]
|
||||
}
|
||||
|
||||
that.$set(that, 'likeInfo', res.data.likeInfo.map((item) => {
|
||||
item.price = that.$force2Decimal(item.price);
|
||||
item.otPrice = that.$force2Decimal(item.otPrice);
|
||||
//如果已经登录获取用户信息
|
||||
if (that.$store.getters.token && that.userInfo) {
|
||||
var p = NP.times(item.price, NP.divide(parseFloat(that.userInfo.discount),
|
||||
100))
|
||||
item.vipPrice = that.$force2Decimal(p);
|
||||
_this.$set(_this, 'likeInfo', data.likeInfo.map((item) => {
|
||||
item.price = _this.$force2Decimal(item.price)
|
||||
item.otPrice = _this.$force2Decimal(item.otPrice)
|
||||
// 如果已经登录获取用户信息
|
||||
if (_this.$store.getters.token && _this.userInfo) {
|
||||
const p = NP.times(item.price, NP.divide(parseFloat(_this.userInfo.discount), 100))
|
||||
item.vipPrice = _this.$force2Decimal(p)
|
||||
}
|
||||
return item;
|
||||
}));
|
||||
return item
|
||||
}))
|
||||
|
||||
setTimeout(() => {
|
||||
//伴手礼图片
|
||||
var imgs = [];
|
||||
that.likeInfo.forEach((item) => {
|
||||
imgs.push(item.image);
|
||||
// 伴手礼图片
|
||||
const imgs = []
|
||||
_this.likeInfo.forEach((item) => {
|
||||
imgs.push(item.image)
|
||||
})
|
||||
that.$set(that, 'bslImglist', imgs);
|
||||
|
||||
that.seriesWidth = 770 * imgs.length - 20;
|
||||
that.duration = Math.floor(that.seriesWidth / that.speed * 1000);
|
||||
_this.$set(_this, 'bslImglist', imgs)
|
||||
_this.seriesWidth = 770 * imgs.length - 20
|
||||
_this.duration = Math.floor(_this.seriesWidth / _this.speed * 1000)
|
||||
}, 1)
|
||||
|
||||
for (let i = 0; i < res.data.bastList.length; i++) {
|
||||
res.data.bastList[i].hide = true;
|
||||
for (let i = 0; i < data.bastList.length; i++) {
|
||||
data.bastList[i].hide = true
|
||||
}
|
||||
that.$set(that, 'bastList', res.data.bastList);
|
||||
that.$set(that, 'lovely', res.data.lovely);
|
||||
that.$set(that, 'benefit', res.data.benefit);
|
||||
that.$set(that, 'couponList', res.data.couponList);
|
||||
_this.$set(_this, 'bastList', data.bastList)
|
||||
_this.$set(_this, 'lovely', data.lovely)
|
||||
_this.$set(_this, 'benefit', data.benefit)
|
||||
_this.$set(_this, 'couponList', data.couponList)
|
||||
|
||||
that.$set(that, 'companyName', res.data.companyName);
|
||||
that.$set(that, 'companyAddress', res.data.companyAddress);
|
||||
that.$set(that, 'companyTel', res.data.companyTel);
|
||||
that.$set(that, 'companyLogo', res.data.companyLogo);
|
||||
_this.$set(_this, 'companyName', data.companyName)
|
||||
_this.$set(_this, 'companyAddress', data.companyAddress)
|
||||
_this.$set(_this, 'companyTel', data.companyTel)
|
||||
_this.$set(_this, 'companyLogo', data.companyLogo)
|
||||
|
||||
that.$set(that, 'dailyGoodsList', res.data.dailyGoodsList);
|
||||
that.$set(that, 'preSaleList', res.data.preSaleList);
|
||||
|
||||
uni.hideLoading();
|
||||
});
|
||||
});
|
||||
_this.$set(_this, 'dailyGoodsList', data.dailyGoodsList)
|
||||
_this.$set(_this, 'preSaleList', data.preSaleList)
|
||||
uni.hideLoading()
|
||||
}).catch(() => {
|
||||
uni.hideLoading()
|
||||
})
|
||||
})
|
||||
},
|
||||
getBastList() {
|
||||
getHomeData().then(res => {
|
||||
@@ -569,61 +544,48 @@ export default {
|
||||
})
|
||||
},
|
||||
getGroupGoods() {
|
||||
var params = {
|
||||
getProducts({
|
||||
page: 1,
|
||||
limit: 1,
|
||||
sid: 19, //团购id=19
|
||||
news: 0,
|
||||
priceOrder: "",
|
||||
salesOrder: ""
|
||||
}
|
||||
var _this = this;
|
||||
|
||||
getProducts(params)
|
||||
.then(res => {
|
||||
_this.groupGoods = res.data;
|
||||
})
|
||||
.catch(err => {
|
||||
|
||||
})
|
||||
},
|
||||
clickItem(data) {
|
||||
this.goGoodsCon(data);
|
||||
},
|
||||
msgConfirm: function () {
|
||||
that.$refs.popup.close();
|
||||
},
|
||||
goPreSale: function () {
|
||||
this.$yrouter.push("/v4/views/preSale/preSale")
|
||||
},
|
||||
goOffer: function () {
|
||||
this.$yrouter.push("/v4/views/offer/offer")
|
||||
},
|
||||
setMsgReaded: function (mid) {
|
||||
noticeDetail({
|
||||
id: mid
|
||||
priceOrder: '',
|
||||
salesOrder: ''
|
||||
}).then(res => {
|
||||
this.groupGoods = res.data
|
||||
})
|
||||
},
|
||||
getUnreadMsgList: function () {
|
||||
var params = {
|
||||
clickItem(data) {
|
||||
this.goGoodsCon(data)
|
||||
},
|
||||
msgConfirm: function () {
|
||||
this.$refs.popup.close()
|
||||
},
|
||||
goPreSale: function () {
|
||||
this.$yrouter.push('/v4/views/preSale/preSale')
|
||||
},
|
||||
goOffer: function () {
|
||||
this.$yrouter.push('/v4/views/offer/offer')
|
||||
},
|
||||
setMsgReaded(mid) {
|
||||
noticeDetail({ id: mid })
|
||||
},
|
||||
getUnreadMsgList() {
|
||||
noticeList({
|
||||
limit: 10,
|
||||
page: 1
|
||||
}
|
||||
let that = this;
|
||||
noticeList(params).then(res => {
|
||||
}).then(res => {
|
||||
if (res.data && res.data.length > 0) {
|
||||
var msg = res.data[0];
|
||||
const msg = res.data[0]
|
||||
if (msg.readFlag == 'RF0') {
|
||||
that.unReadMessageInfo = msg;
|
||||
that.$refs.popup.open();
|
||||
that.setMsgReaded(msg.id);
|
||||
this.unReadMessageInfo = msg
|
||||
this.$refs.popup.open()
|
||||
this.setMsgReaded(msg.id)
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
call: function () {
|
||||
|
||||
call() {
|
||||
if (this.companyTel != undefined && this.companyTel.length > 0) {
|
||||
uni.makePhoneCall({
|
||||
// 手机号
|
||||
@@ -636,10 +598,8 @@ export default {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.$dialog.error('电话为空');
|
||||
this.$dialog.error('电话为空')
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
goRoll(item) {
|
||||
if (item.uniapp_url) {
|
||||
@@ -647,7 +607,7 @@ export default {
|
||||
}
|
||||
},
|
||||
goGoodSearch() {
|
||||
this.$yrouter.push('/pages/shop/GoodSearch/index');
|
||||
this.$yrouter.push('/pages/shop/GoodSearch/index')
|
||||
},
|
||||
goGoodsCon(item) {
|
||||
this.$yrouter.push({
|
||||
@@ -655,7 +615,7 @@ export default {
|
||||
query: {
|
||||
id: item.id
|
||||
}
|
||||
});
|
||||
})
|
||||
},
|
||||
goGoodsConByProductID(item, from) {
|
||||
this.$yrouter.push({
|
||||
@@ -665,19 +625,16 @@ export default {
|
||||
activityId: item.id,
|
||||
from
|
||||
}
|
||||
});
|
||||
})
|
||||
},
|
||||
|
||||
changeOldPopup(state) {
|
||||
this.isOldUser = state;
|
||||
this.isOldUser = state
|
||||
},
|
||||
|
||||
goHomeStay(stay) {
|
||||
if (stay.uniappUrl) {
|
||||
this.$global.commonJump(stay.uniappUrl)
|
||||
return
|
||||
}
|
||||
|
||||
if (stay.type === 2 && stay.isLinkToProduct) {
|
||||
this.$yrouter.push({
|
||||
path: '/pages/shop/GoodsCon/index',
|
||||
@@ -691,13 +648,20 @@ export default {
|
||||
uni.navigateTo({url: '/pkg_product/views/homestay?id=' + stay.id})
|
||||
}
|
||||
},
|
||||
|
||||
goFestival() {
|
||||
uni.navigateTo({url: '/pkg_product/views/festival'})
|
||||
},
|
||||
tapOld() {
|
||||
this.isOldUser = false
|
||||
const {type, text, jumpTime, pageLevel, url, params, couponId} = this.oldUserPopup
|
||||
const {
|
||||
type,
|
||||
text,
|
||||
jumpTime,
|
||||
pageLevel,
|
||||
url,
|
||||
params,
|
||||
couponId
|
||||
} = this.oldUserPopup
|
||||
if (couponId != null) {
|
||||
getCouponReceive(couponId).then(res => {
|
||||
if (res.status === 200) {
|
||||
@@ -725,13 +689,6 @@ export default {
|
||||
this.$global.levelJump(pageLevel, url, params)
|
||||
}
|
||||
},
|
||||
|
||||
testAni() {
|
||||
const query = uni.createSelectorQuery().in(this).select('.index')
|
||||
query.fields({size: true, scrollOffset: true}, (data) => {
|
||||
console.log(JSON.stringify(data))
|
||||
}).exec()
|
||||
},
|
||||
setTopHandle() {
|
||||
uni.pageScrollTo({
|
||||
scrollTop: 0,
|
||||
@@ -739,7 +696,7 @@ export default {
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
|
||||
Reference in New Issue
Block a user