gamemall/src/pages/index.wpy

109 lines
2.3 KiB
Plaintext

<style lang="less">
.product-list {
width: 750rpx;
background: #f7f7f7;
}
.product-list .item {
background:#fff;
padding:15rpx;
margin-bottom:15rpx;
}
.product-list .item_img {
height:390rpx;
width: 100%;
border: 1px solid #eee;
border-radius:6rpx;
}
.product-list .info{
padding:5rpx;
color:#666;
font-size:26rpx;
line-height:35rpx;
display:flex;
align-items:center;
}
</style>
<template>
<view class="container">
<view class="product-list">
<repeat for="{{records}}" item="item" >
<view class="item" @tap="gameTap({{item._id}})" >
<image class="item_img" src="{{item.main_img}}" mode="aspectFit"></image>
<view class="info">
<view>品名:</view><view>{{item.name}} </view>
</view>
<view class="info">
<view>规格:</view><view>{{item.size}} </view>
</view>
<view class="info">
<view>状态:</view><view>尚未开启抢购 </view>
</view>
</view>
</repeat>
</view>
<zanLoadmore :loading.sync="loading" :nodata.sync="noData" :nomore.sync="noMore" nomore_str="更多活动敬请期待"></zanLoadmore>
</view>
</template>
<script>
import wepy from 'wepy'
import http from '../utils/http';
import zanLoadmore from '../components/zan-loadmore';
export default class Index extends wepy.page {
config = {
navigationBarTitleText: '商品列表'
};
components = {
zanLoadmore: zanLoadmore
};
mixins = [];
data = {
loading: false,
noData: false,
noMore: true,
records: []
};
methods = {
gameTap(id) {
let item;
for(let record of this.records) {
if (record._id === id) {
item = record;
break;
}
}
if (item) {
let paramStr = JSON.stringify(item);
wepy.navigateTo({
url: '/pages/detail?item=' + paramStr
})
}
}
};
events = {
};
onLoad() {
this.queryRecords();
}
async queryRecords() {
let self = this;
try {
let res = await http.post('/api/weapp/gift_list', {});
this.records = res.records;
this.$apply();
} catch (err) {
console.log(err);
}
}
}
</script>