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

171 lines
3.7 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="福利购"
/>
2021-01-20 17:25:41 +08:00
<view class="" style="margin: 10px 16px 80px 16px;">
2021-01-12 18:04:14 +08:00
2021-01-15 16:04:26 +08:00
2021-01-20 15:28:25 +08:00
<van-image class="banner" :src="imageDefine.SHOPPING_BANNER" width="686rpx"
height="96px" />
2021-01-15 16:04:26 +08:00
2021-01-20 15:28:25 +08:00
<div style="margin-top: 20px;">
<van-row gutter="20">
<van-col span="8" style="font-weight: bold;font-size: 20px;">精选推荐</van-col>
<van-col offset="10" span="6">
<div @tap="onShppingCar">
<van-icon name="shopping-cart-o" color="#940D46" />
<span style="margin-left: 5px;">购物车</span>
</div>
</van-col>
</van-row>
</div>
2021-01-15 16:04:26 +08:00
2021-01-20 15:28:25 +08:00
<div style="display: flex;flex-wrap: wrap;margin-bottom: 10px;">
2021-01-19 14:02:55 +08:00
<div class="filter-button" v-for="(item,index) in filterButtons">
2021-01-20 15:28:25 +08:00
<van-button round size="small" :color="currentFilter.dictLabel === item.dictLabel ? '#940D46' : '#940D46' "
:plain="currentFilter.dictLabel === item.dictLabel ? false : true" @tap="onFilterBtn(item)">
{{item.dictLabel}}
2021-01-19 14:02:55 +08:00
</van-button>
</div>
</div>
2021-01-15 18:10:53 +08:00
<view v-for="(item, index) in records" :key="index"
2021-01-20 15:28:25 +08:00
style="margin-top: 10px;border: #fafafa 1px solid; border-radius: 10px;background-color: white;">
2021-01-15 18:10:53 +08:00
<van-card
:title="item.goodsName"
2021-01-20 15:28:25 +08:00
2021-01-15 22:56:32 +08:00
:price="item.goodsPrice"
:thumb="filters.parseImage(item.goodsFaceImg)"
2021-01-15 18:10:53 +08:00
@tap="onItem(item)"
>
2021-01-20 15:28:25 +08:00
<view slot="num" style="display: flex; justify-content: space-between;align-items: center;">
<span style="color: #999;">{{item.goodsAlias}}</span>
<van-image :src="imageDefine.LIST_BAG" width="30px" height="30px" />
</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-20 09:00:22 +08:00
import mallApis from '../../../apis/mallApis'
2021-01-15 18:10:53 +08:00
import defaultMix from '../../../mixins/defaultMix'
2021-01-19 14:02:55 +08:00
import { goodsDetailPage } from '../../../store/constant/nav/pages'
import xiao4rApis from '../../../apis/xiao4rApis'
2021-01-20 15:28:25 +08:00
import { navDefine } from '../../../store/constant/navDefine'
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: [],
currentFilter: {
dictLabel: '全部'
},
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
},
2021-01-20 15:28:25 +08:00
onShppingCar() {
appManager.navigateTo(navDefine.SHOPPING_CAR_LIST)
},
2021-01-15 16:04:26 +08:00
onFilterBtn(item) {
this.currentFilter = item
2021-01-20 15:28:25 +08:00
this.init(false)
2021-01-15 18:10:53 +08:00
},
2021-01-20 15:28:25 +08:00
async init(isFirst = true) {
2021-01-17 02:43:05 +08:00
this.isInit = false
2021-01-20 15:28:25 +08:00
if (isFirst) {
const dict = await xiao4rApis.getDicts('goods_type')
this.filterButtons = dict.data
}
let body = {}
2021-01-20 15:28:25 +08:00
if (this.currentFilter.dictLabel !== '全部') {
body.goodsType = this.currentFilter.dictValue
}
2021-01-20 15:28:25 +08:00
const req = await mallApis.getGoodsList(body)
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-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;
2021-01-20 15:28:25 +08:00
2021-01-15 16:04:26 +08:00
}
.filter-button {
margin-top: 10px;
margin-right: 10px;
}
2021-01-12 18:04:14 +08:00
</style>