wzj-boot/mini-app/src/components/mall/tab/mall-shopping.wpy

157 lines
3.2 KiB
Plaintext
Raw Normal View History

2021-01-15 22:56:32 +08:00
<wxs module="filters" lang="babel">
const parseImage = (imageKey) => {
return 'https://winery-1257413599.cos.ap-beijing.myqcloud.com/' + imageKey
}
module.exports.parseImage = parseImage;
</wxs>
2021-01-12 18:04:14 +08:00
<template>
2021-01-15 16:04:26 +08:00
<van-nav-bar
title="福利购"
/>
<view style="margin: 10px 10px 80px 10px;">
2021-01-12 18:04:14 +08:00
2021-01-15 16:04:26 +08:00
<van-image class="banner" :src="navDefine.HOME_BANNER.image" />
<van-row gutter="20">
<van-col span="8" style="font-weight: bold;font-size: 20px;">精选推荐</van-col>
<van-col offset="10" span="6">
<div>
<van-icon name="shopping-cart-o" color="#1989fa" />
<span style="margin-left: 5px;">购物车</span>
</div>
</van-col>
</van-row>
2021-01-19 14:02:55 +08:00
<div style="display: flex;flex-wrap: wrap;">
<div class="filter-button" v-for="(item,index) in filterButtons">
<van-button round size="small" :color=" currentFilter === item ? '#7232dd' : '#7232dd' "
:plain="currentFilter === item ? false : true" @tap="onFilterBtn(item)">{{item}}
</van-button>
</div>
</div>
2021-01-15 18:10:53 +08:00
<view v-for="(item, index) in records" :key="index"
style="margin-top: 10px;border: #fafafa 1px solid; border-radius: 10px;">
<van-card
:title="item.goodsName"
2021-01-15 22:56:32 +08:00
:desc="item.goodsAlias"
:price="item.goodsPrice"
:thumb="filters.parseImage(item.goodsFaceImg)"
2021-01-15 18:10:53 +08:00
@tap="onItem(item)"
>
2021-01-19 14:02:55 +08:00
<!-- <view slot="num" style="float:right;">-->
<!-- <div>{{'已优惠¥xx元'}}</div>-->
<!-- </view>-->
2021-01-15 18:10:53 +08:00
</van-card>
2021-01-15 22:56:32 +08:00
2021-01-15 18:10:53 +08:00
</view>
2021-01-17 02:43:05 +08:00
<div style="margin-top: 100px;" />
2021-01-12 18:04:14 +08:00
</view>
</template>
<script>
2021-01-15 22:56:32 +08:00
2021-01-12 18:04:14 +08:00
import wepy from '@wepy/core'
import store from '@/store'
2021-01-15 16:04:26 +08:00
import { mapActions, mapState } from '@wepy/x'
2021-01-15 12:00:20 +08:00
import appManager from '../../../appManager'
2021-01-15 18:10:53 +08:00
import mailApis from '../../../apis/mailApis'
import defaultMix from '../../../mixins/defaultMix'
2021-01-19 14:02:55 +08:00
import { goodsDetailPage } from '../../../store/constant/nav/pages'
2021-01-12 18:04:14 +08:00
wepy.component({
store,
hooks: {},
2021-01-15 18:10:53 +08:00
// mixins: [ defaultMix ],
2021-01-12 18:04:14 +08:00
data: {
active: 0,
2021-01-15 18:10:53 +08:00
records: [],
2021-01-15 16:04:26 +08:00
currentFilter: '全部',
2021-01-17 02:43:05 +08:00
filterButtons: ['全部']
2021-01-15 16:04:26 +08:00
2021-01-12 18:04:14 +08:00
},
2021-01-15 16:04:26 +08:00
computed: {
...mapState({
'imageDefine': state => state.imageDefine,
'user': state => state.user,
'navDefine': state => state.navDefine
})
},
2021-01-12 18:04:14 +08:00
methods: {
onItem(item) {
2021-01-19 14:02:55 +08:00
appManager.navigateTo(goodsDetailPage + `?id=${item.id}`)
2021-01-15 16:04:26 +08:00
},
onFilterBtn(item) {
console.log(item)
this.currentFilter = item
2021-01-15 18:10:53 +08:00
},
parseImage(imageKey) {
return 'https://winery-1257413599.cos.ap-beijing.myqcloud.com/' + imageKey
},
async init() {
2021-01-17 02:43:05 +08:00
this.isInit = false
const req = await mailApis.getGoodsList()
2021-01-17 02:43:05 +08:00
this.records = req.rows
this.isInit = true
2021-01-12 18:04:14 +08:00
}
},
ready() {
2021-01-15 22:56:32 +08:00
let i = 0
while (true) {
this.filterButtons.push('按钮按钮' + i)
i++
if (i > 8) {
break
}
}
2021-01-17 02:43:05 +08:00
this.init()
2021-01-12 18:04:14 +08:00
}
})
</script>
<config>
{
}
</config>
<style lang="less">
.header {
width: 100%;
height: 536rpx;
z-index: -10;
}
2021-01-15 16:04:26 +08:00
.banner {
border: #eeeeee 1px solid;
border-radius: 25px;
margin-top: 15px;
width: 100%;
height: 80px;
}
.filter-button {
margin-top: 10px;
margin-right: 10px;
}
2021-01-12 18:04:14 +08:00
</style>