<template>
<view class="content">
<view class="list">
<view
class="goods-box-single"
v-for="(goodsItem, goodsIndex) in goodsList" :key="goodsIndex"
<image class="goods-img" :src="goodsItem.package.pic" mode="aspectFill"></image>
<view class="right">
<text class="title clamp">{{goodsItem.package.title}}</text>
<text class="orderNo">订单号:{{goodsItem.order_no}}</text>
<text class="time">下单时间:{{goodsItem.pay_time | time}}</text>
<text v-if="goodsItem.finish_state!=0" class="time">消费时间:{{goodsItem.finish_time | time}}</text>
<text class="time">过期时间:{{goodsItem.expire_time | time}}</text>
<text class="price">总价:¥{{goodsItem.pay_price}}</text>
</view>
<view class="status">
<text v-if="!goodsItem.isexpire" class="title">{{goodsItem.finish_state==0 ? '待使用' : '已消费'}}</text>
<view v-else class="title">
已过期
</view>
<button v-if="goodsItem.finish_state==0 && !goodsItem.isexpire" type="primary" class="no-border confirm-btn" @click="showCode(goodsItem.hexiao_code)">查看</button>
</view>
</view>
</view>
</view>
</template>
<script>
import { transformTime } from '../../utils/auth.js';
export default {
data() {
return {
member:[],
goodsList :[],
}
},
filters: {
time: function(res) {
return transformTime(res * 1000, 1);
}
},
onLoad() {
this.loadData();
},
methods: {
async loadData() {
uni.showLoading({
title: '加载中'
});
await this.getStorage();
uni.request({
url: this.$url+'index.php/shop/api.member.order/list',
method:'POST',
data: {
mid:this.member.id,
openid:this.member.openid,
},
success: (res) => {
console.log('datadat',res.data);
this.goodsList=res.data.data;
// this.isexpire = this.goodsList.expire;
uni.hideLoading();
},
fail: (res) => {
console.log('fail',res.data);
console.log(res.data);
uni.hideLoading();
}
});
},
async getStorage(){
let _this=this;
uni.getStorage({
key: 'member',
success: function (res) {
_this.member=res.data;
console.log(_this.member.phone);
}
});
return new Promise((resolve, reject) => {
uni.getStorage({
key: 'openId',
success: function (res) {
_this.openId=res.data;
resolve('suc'); // 千万别忘写!!!
}
});
})
},
showCode(code){
uni.showModal({
title: '消费码',
content: code,
showCancel:false,
success: function (res) {
if (res.confirm) {
console.log('用户点击确定');
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
}
}
}
</script>
<style lang="scss">
page, .content{
background: $page-color-base;
height: 100%;
}
.list{
width: 100%;
}
/ 单条商品 /
.goods-box-single{
display: flex;
padding: 20upx;
margin: 20upx 0;
background-color: #fff;
.goods-img{
display: block;
width: 150upx;
height: 150upx;
margin-top:30upx;
}
.right{
flex: 1;
display: flex;
flex-direction: column;
padding: 0 30upx 0 24upx;
overflow: hidden;
font-size: $font-sm;
color: $font-color-dark;
line-height: 1.5;
.title{
font-size: $font-base;
}
.price{
// &:before{
// content: '¥';
// font-size: $font-sm;
// margin: 0 2upx 0 8upx;
// }
}
}
.status{
font-size: $font-sm;
text-align: right;
.title{
display: block;
padding-bottom: 15upx;
}
.confirm-btn{
margin-top: 30upx;
}
}
}
</style>
0 个回复