【首页】

1. 清理多余的变量、方法
2. 清理 MP 消息模版的获取,貌似暂时没用到
pull/1/MERGE
YunaiV 2023-06-25 20:48:13 +08:00
parent 87bd79b8ee
commit 4c0704b5cd
1 changed files with 16 additions and 191 deletions

View File

@ -29,7 +29,7 @@
</view>
<!-- #endif -->
<!-- 首页展示 -->
<view class="page_content" :style="'margin-top:'+(marTop)+'px;'" v-if="navIndex == 0">
<view class="page_content" :style="'margin-top:'+(marTop)+'px;'" v-if="navIndex === 0">
<view class="mp-bg"></view>
<!-- banner -->
<view class="swiper" v-if="imgUrls.length">
@ -68,8 +68,8 @@
<!-- menu -->
<view class='nav acea-row' v-if="menus.length">
<block v-for="(item,index) in menus" :key="index">
<navigator class='item' v-if="item.show == '1'" :url='item.url' open-type='switchTab'
hover-class='none'>
<navigator class='item' v-if="item.show === '1'" :url='item.url' open-type='switchTab'
hover-class='none'>
<view class='pictrue'>
<image :src='item.pic'></image>
</view>
@ -115,8 +115,8 @@
<scroll-view class="scroll-view_H" style="width: 100%;" scroll-x="true" scroll-with-animation
:scroll-left="tabsScrollLeft" @scroll="scroll">
<view class="tab nav-bd" id="tab_list">
<view id="tab_item" :class="{ 'active': listActive == index}" class="item"
v-for="(item, index) in explosiveMoney" :key="index" @click="ProductNavTab(item,index)">
<view id="tab_item" :class="{ 'active': listActive === index}" class="item"
v-for="(item, index) in explosiveMoney" :key="index" @click="ProductNavTab(item,index)">
<view class="txt">{{item.name}}</view>
<view class="label">{{item.info}}</view>
</view>
@ -158,31 +158,23 @@
</template>
<script>
import Cache from '../../utils/cache';
var statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
const statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
let app = getApp();
import {
getIndexData,
getCoupons,
setCouponReceive
} from '@/api/api.js';
// #ifdef MP-WEIXIN
import { getTemlIds } from '@/api/api.js';
// #endif
import {
getShare
} from '@/api/public.js';
import { getShare } from '@/api/public.js';
import a_seckill from './components/a_seckill';
import b_combination from './components/b_combination';
import c_bargain from './components/c_bargain';
import goodList from '@/components/goodList';
import promotionGood from '@/components/promotionGood';
import { goShopDetail } from '@/libs/order.js'
import {
mapGetters
} from "vuex";
import { mapGetters } from "vuex";
import tabNav from '@/components/tabNav.vue'
import countDown from '@/components/countDown';
import { getProductHot, } from '@/api/store.js';
import recommend from '@/components/recommend';
import {
silenceBindingSpread
@ -208,84 +200,40 @@
},
data() {
return {
loaded: false,
loading: false,
statusBarHeight: statusBarHeight,
navIndex: 0,
navTop: [],
logoUrl: "",
imgUrls: [],
itemNew: [],
menus: [],
bastInfo: '',
fastInfo: '',
fastList: [],
firstInfo: '',
salesInfo: '',
indicatorDots: false,
circular: true,
autoplay: true,
interval: 3000,
duration: 500,
window: false,
iShidden: false,
navH: "",
newGoodsBananr: '',
couponList: [],
liveList: [],
hotList: [{
pic: '/static/images/hot_001.png'
}, {
pic: '/static/images/hot_002.png'
}, {
pic: '/static/images/hot_003.png'
}],
marTop: 0,
loadend: false,
loadTitle: '加载更多',
sortProduct: [],
where: {
cid: 0,
page: 1,
limit: 10,
},
is_switch: true,
hotPage: 1,
hotLimit: 10,
hotScroll: false,
explosiveMoney: [],
prodeuctTop: 0,
searchH: 0,
isFixed: false,
roll: [], //
site_name: '', //title
iSshowH: false,
configApi: {}, //
spikeList: [], //
point: '',
privacyStatus: false, //
tabsScrollLeft: 0, // tabs
scrollLeft: 0,
lineColor: 'red',
lineStyle: {}, // 线--
listActive: 0, //
duration: 0.2, // 线
// ========== ===========
goodScroll: true, //
ProductNavindex: 0,
listActive: 0, //
goodType: 1, // Type
params: { //
page: 1,
limit: 10,
},
loading: false,
tempArr: [], //
}
iSshowH: false,
}
},
watch: {
ProductNavindex(newVal) { //
this.setTabList()
},
listActive(newVal) { //
this.setTabList()
}
@ -312,27 +260,8 @@
} catch {}
}
});
let self = this
// #ifdef MP
//
this.navH = app.globalData.navHeight;
let info = uni.createSelectorQuery().select(".mp-header");
info.boundingClientRect(function(data) {
self.marTop = data.height
self.poTop = Number(data.height) + 84
}).exec()
// #endif
// #ifndef MP
this.navH = 0;
// #endif
this.isLogin && silenceBindingSpread();
// Promise.all([this.getAllCategory(), this.getIndexConfig()
// // , this.setVisit()
// ]);
this.getIndexConfig();
// #ifdef MP
this.getTemlIds()
// #endif
},
onShow() {
let self = this
@ -355,16 +284,12 @@
});
})
},
clickSort(index) {
this.listActive = index
},
// scroll-view
scroll(e) {
this.scrollLeft = e.detail.scrollLeft;
},
setTabList() {
this.$nextTick(() => {
//this.setLine()
this.scrollIntoView()
})
},
@ -380,51 +305,11 @@
})
})
},
// 线
setLine() {
let lineWidth = 0,
lineLeft = 0
this.getElementData(`#tab_item`, (data) => {
let el = data[this.listActive]
lineWidth = el.width / 2
// lineLeft = el.width * (this.currentIndex + 0.5) // item
lineLeft = el.width / 2 + (-data[0].left) + el.left
this.lineStyle = {
width: `${lineWidth}px`,
transform: `translateX(${lineLeft}px) translateX(-50%)`,
transitionDuration: `${this.duration}s`
};
})
},
getElementData(el, callback) {
uni.createSelectorQuery().in(this).selectAll(el).boundingClientRect().exec((data) => {
callback(data[0]);
});
},
xieyiApp() {
uni.navigateTo({
url: '/pages/users/web_page/index?webUel=https://admin.java.crmeb.net/useragreement/xieyi.html&title=协议内容'
})
},
// #ifdef MP
getTemlIds() {
for (var i in arrTemp) {
this.getTem(arrTemp[i]);
}
},
getTem(data) {
getTemlIds({
type: data
}).then(res => {
if (res.data) {
let arr = res.data.map((item) => {
return item.tempId
})
wx.setStorageSync('tempID' + data, arr);
}
})
},
// #endif
//
getIndexConfig: function() {
let that = this;
@ -446,10 +331,6 @@
this.getGroomList();
this.shareApi();
this.getcouponList();
// #ifdef H5
// that.subscribe = res.data.subscribe;
// #endif
})
},
getcouponList() {
@ -459,26 +340,6 @@
limit: 6
}).then(res => {
that.$set(that, "couponList", res.data);
//
// #ifdef MP
uni.getSetting({
success(res) {
if (!res.authSetting['scope.userInfo']) {
that.window = that.couponList.length ? true : false;
} else {
that.window = false;
that.iShidden = true;
}
}
});
// #endif
// #ifndef MP
if (that.isLogin) {
that.window = false;
} else {
that.window = res.data.length ? true : false;
}
// #endif
}).catch(err => {
return this.$util.Tips({
title: err
@ -516,12 +377,10 @@
this.listActive = index
this.goodType = parseInt(item.type)
this.listActive = index
this.ProductNavindex = index
this.tempArr = []
this.params.page = 1
this.goodScroll = true
let onloadH = true
this.getGroomList(onloadH)
this.getGroomList(true)
},
/**
* 商品精品推荐
@ -570,37 +429,10 @@
})
})
},
/**
* 获取我的推荐 TODO 芋艿没实现
*/
get_host_product: function() {
let that = this;
that.loading = true;
if (that.hotScroll) return
getProductHot(
that.hotPage,
that.hotLimit,
).then(res => {
that.hotPage++
that.hotScroll = res.data.list.length < that.hotLimit
that.hostProduct = that.hostProduct.concat(res.data.list)
});
},
fen2yuan(price) {
return Util.fen2yuan(price)
}
},
mounted() {
let self = this
// #ifdef H5
// H5
let appSearchH = uni.createSelectorQuery().select(".serch-wrapper");
appSearchH.boundingClientRect(function(data) {
self.searchH = data.height
}).exec()
// #endif
},
/**
* 用户点击右上角分享
*/
@ -615,20 +447,13 @@
},
// #endif
onReachBottom() {
if (this.navIndex == 0) {
if (this.navIndex === 0) {
//
if (this.params.page != 1) {
if (this.params.page !== 1) {
this.getGroomList();
}
} else {
//
if (this.sortProduct.length > 0) {
//this.get_product_list();
} else {
this.get_host_product();
}
}
},
}
}
</script>
<style>