deming/pages/shop/index.vue

269 lines
6.9 KiB
Vue
Raw Normal View History

2020-06-11 01:34:23 +00:00
<template>
<view class="shop">
<view class="top">
2020-06-18 06:57:26 +00:00
<image src="/static/image/shop/1.png" class="local"></image>
<view class="add" @click="chooseArea=true">
<text class="u-line-1">{{ area }}</text>
<image src="/static/image/shop/2.png"></image>
2020-06-11 01:34:23 +00:00
</view>
2020-07-08 00:43:39 +00:00
<view @click="sousuo">
<u-search placeholder="日照香炉生紫烟" v-model="keyword" :show-action="false" bg-color="#fff" border-color="#999999" :disabled="true"></u-search>
</view>
2020-06-30 10:06:50 +00:00
<image src="/static/image/shop/3.png" class="mnue" @click="toClassifyPage"></image>
2020-06-11 01:34:23 +00:00
</view>
2020-06-30 10:06:50 +00:00
<u-swiper :list="list" mode="dot" @click="clickImage"></u-swiper>
2020-06-11 01:34:23 +00:00
<view class="chengnuo">
<view>
2020-06-18 06:57:26 +00:00
<image src="/static/image/shop/4.png"></image>
2020-06-11 01:34:23 +00:00
<text>免费洗衣</text>
</view>
<view>
2020-06-18 06:57:26 +00:00
<image src="/static/image/shop/5.png"></image>
2020-06-11 01:34:23 +00:00
<text>全国包邮</text>
</view>
<view>
2020-06-18 06:57:26 +00:00
<image src="/static/image/shop/6.png"></image>
2020-06-11 01:34:23 +00:00
<text>延误必赔</text>
</view>
<view>
2020-06-18 06:57:26 +00:00
<image src="/static/image/shop/7.png"></image>
2020-06-11 01:34:23 +00:00
<text>上门取件</text>
</view>
</view>
2020-06-30 10:06:50 +00:00
<!-- <view class="fenlei">
2020-06-19 10:07:11 +00:00
<shopitem v-for="item in 5" class="item"></shopitem>
2020-06-30 10:06:50 +00:00
</view> -->
2020-06-11 01:34:23 +00:00
<view class="fenlei">
2020-06-30 10:06:50 +00:00
<shopitem v-for="item in goodsClassify" :key="item.gc_id" :info="item" class="item"></shopitem>
2020-06-11 01:34:23 +00:00
</view>
<view class="hr" style="margin-top:80rpx"></view>
2020-07-15 08:21:43 +00:00
<recommend v-if="JSON.stringify(recommendedSpike) != '{}'" :recommendData="recommendedSpike" type="spike"></recommend>
2020-06-11 01:34:23 +00:00
<view class="hr" style="margin-top:40rpx"></view>
2020-07-15 08:21:43 +00:00
<seckill v-if="spikeList.length"></seckill>
<view v-if="spikeList.length" class="hr" style="margin-top:40rpx"></view>
<!-- <recommend></recommend> -->
<!-- <view class="hr" style="margin-top:40rpx"></view> -->
2020-06-11 08:12:04 +00:00
<group></group>
<image class="lingquan"></image>
<youhq></youhq>
<view class="hr" style="margin-top:40rpx"></view>
2020-06-18 06:57:26 +00:00
<list :classifyList="classifyList" :goodsList="goodsList"></list>
2020-06-29 09:24:57 +00:00
<view class="cart" @click="toCartPage">
<image src="/static/image/common/3.png"></image>
</view>
2020-06-18 06:57:26 +00:00
<u-picker mode="region" :params="areaParams" v-model="chooseArea" @confirm="setArea"></u-picker>
2020-06-11 01:34:23 +00:00
</view>
</template>
<script>
import shopitem from "@/components/shop/shop-item/index"
import recommend from "@/components/shop/recommend/index"
import seckill from "@/components/shop/seckill/index"
2020-06-11 08:12:04 +00:00
import group from "@/components/shop/group/index"
import youhq from "@/components/shop/youhq/index"
2020-06-11 08:37:52 +00:00
import list from "../../components/shop/list/index"
2020-06-11 01:34:23 +00:00
export default {
name:"shop",
components:{
shopitem,
recommend,
2020-06-11 08:12:04 +00:00
seckill,
group,
2020-06-11 08:37:52 +00:00
youhq,
list
2020-06-11 01:34:23 +00:00
},
data(){
return {
2020-06-30 10:06:50 +00:00
area: "请选择",
2020-06-18 06:57:26 +00:00
chooseArea: false,
areaParams: {
province: true,
city: true,
area: false
},
2020-06-11 01:34:23 +00:00
keyword:"",
2020-06-30 10:06:50 +00:00
list:[],
goodsClassify: [], // 商品分类
2020-06-18 06:57:26 +00:00
classifyList: [],
2020-07-15 08:21:43 +00:00
goodsList: [],
recommendedSpike: {}, // 秒杀推荐
spikeList: [], // 全部秒杀列表
2020-06-11 01:34:23 +00:00
}
2020-06-18 06:57:26 +00:00
},
onLoad() {
2020-06-30 10:06:50 +00:00
this.getShopTopList();
2020-06-18 06:57:26 +00:00
this.getGoodsRecommend();
},
2020-07-15 08:21:43 +00:00
onShow() {
// console.log(this.$store.shop.state.count);
this.getRecommendedSpike();
this.getSpikeList();
},
2020-06-18 06:57:26 +00:00
methods: {
2020-07-08 00:43:39 +00:00
sousuo(){
// console.log(123)
this.$u.route({
url:"pageB/search/index"
})
},
2020-06-30 10:06:50 +00:00
getShopTopList() {
this.$u.api.getShopTopList().then((res)=>{
if (res.errCode == 0) {
let temp = [];
res.data.banner.forEach(item => {
temp.push({
image: item.adv_code,
adv_link: item.adv_link,
adv_id: item.adv_id,
})
})
this.list = temp;
this.goodsClassify = res.data.goodsclass;
}
})
},
2020-07-15 08:21:43 +00:00
getRecommendedSpike() {
this.$u.api.recommendedSpike().then(res => {
if(res.errCode == 0) this.recommendedSpike = res.data;
console.log(this.recommendedSpike);
})
},
// 全部秒杀
getSpikeList() {
this.$u.api.getSpikeList({ page: 0 }).then(res => {
if(res.errCode == 0) this.spikeList = res.data;
})
},
2020-06-18 06:57:26 +00:00
getGoodsRecommend() {
this.$u.api.getGoodsRecommend({
page: 1,
}).then((res)=>{
if (res.errCode == 0) {
this.classifyList = res.data.classifyList;
this.goodsList = res.data.goodsList;
// console.log(this.classifyList);
}
})
},
2020-06-30 10:06:50 +00:00
clickImage(index) {
console.log(index);
console.log(this.list[index]);
},
2020-06-18 06:57:26 +00:00
setArea(e) {
// console.log(e);
this.area = e.city.label;
2020-06-29 09:24:57 +00:00
},
toCartPage() {
uni.navigateTo({
url: '/pageC/cart/index'
});
2020-06-30 10:06:50 +00:00
},
toClassifyPage() {
uni.navigateTo({
url: '/pageC/classify/index'
});
},
2020-06-18 06:57:26 +00:00
},
2020-06-11 01:34:23 +00:00
}
</script>
<style lang="scss" scoped>
.shop{
padding: 0 33rpx;
.top{
width: 100%;
height: 88rpx;
display: flex;
align-items: center;
.local{
width: 31rpx;
height: 37rpx;
}
}
.add{
width: 115rpx;
height: 25rpx;
display: flex;
font-size: 26rpx;
color: #333;
justify-content: space-between;
align-items: center;
margin-left: 14rpx;
margin-right: 37rpx;
2020-06-18 06:57:26 +00:00
> text {
width: 80rpx;
}
2020-06-11 01:34:23 +00:00
>image{
width: 24rpx;
height: 15rpx;
}
}
.mnue{
width: 35rpx;
height: 26rpx;
margin-left: 36rpx;
}
.chengnuo{
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 24rpx;
>view{
display: flex;
align-items: center;
>image{
width: 23rpx;
height: 23rpx;
}
>text{
font-size: 22rpx;
color: #999;
margin-left: 8rpx;
}
}
}
.fenlei{
display: flex;
2020-06-30 10:06:50 +00:00
// justify-content: space-between;
2020-06-11 01:34:23 +00:00
margin-top: 30rpx;
2020-06-30 10:06:50 +00:00
flex-wrap: wrap;
> view {
margin-bottom: 30rpx;
&:not(:nth-child(5n)) {
margin-right: 70rpx;
}
}
2020-06-11 01:34:23 +00:00
}
.hr{
width: 750rpx;
margin-left: -33rpx;
height: 20rpx;
background-color: #ececec;
}
2020-06-11 08:12:04 +00:00
.lingquan{
width: 750rpx;
height: 177rpx;
margin-left: -33rpx;
margin-top: 29rpx;
background-color: #ececec;
}
2020-06-29 09:24:57 +00:00
.cart {
position: fixed;
right: 30rpx;
bottom: 300rpx;
width: 100rpx;
height: 100rpx;
background: rgba(253, 211, 96, 1);
box-shadow: 0rpx 10rpx 6rpx 0rpx rgba(253,211,96,0.34);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
> image {
width: 56rpx;
height: 54rpx;
}
}
2020-06-11 01:34:23 +00:00
}
</style>