shop_uniapp/components/group-list/group-list.vue

170 lines
6.1 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<mescroll-uni ref="mescrollRef" top="80rpx" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
<view class="group-list">
<navigator v-for="(item, index) in groupList" :key="index" class="item bg-white mt20" hover-class="none"
:url="'/bundle/pages/order_details/order_details?id=' + item.order_id">
<view class="group-header row-between">
<view>
<view v-if="item.team_end_time">{{item.team_end_time}}</view>
<view v-else>
<view class="row" v-if="getTeamCountTime(item) >= 0">
<view class="sm mr10">{{item.shop_name}}</view>
</view>
</view>
</view>
<view :class="item.status == 2 ? 'muted' : 'primary'">{{getGroupStatus(item.status)}}
</view>
</view>
<view class="group-con">
<view v-if="item.identity_text" class="team-chief xs white">{{item.identity_text}}</view>
<order-goods :team="{need: item.need}"
:list="[{people_num: item.people_num,name: item.name, spec_value_str: item.spec_value_str,image: item.image,goods_num: item.count, goods_id: item.goods_id, goods_price: item.order_amount}]">
</order-goods>
<view class="all-price row-end">
<text class="muted xs">共{{item.count}}件商品,总金额:</text>
<price-format show-subscript :subscript-size="30" :first-size="30" :second-size="30"
:price="item.order_amount"></price-format>
</view>
</view>
<view class="group-footer row" v-if="item.pay_status == 0">
<view style="flex: 1"></view>
<view>
<navigator v-if="item.pay_status == 0" hover-class="none"
:url="'/pages/order_details/order_details?id=' + item.order_id">
<button size="sm" class="br60 lighter btn" type="primary" hover-class="none">
去付款
</button>
</navigator>
</view>
</view>
</navigator>
</view>
</mescroll-uni>
</template>
<script>
import {getUserGroup} from '@/api/activity';
import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
import MescrollMoreItemMixin from "@/components/mescroll-uni/mixins/mescroll-more-item.js";
export default {
mixins: [MescrollMixin, MescrollMoreItemMixin],
data() {
return {
groupList: [],
downOption: {
auto: false
},
upOption: {
auto: true,
noMoreSize: 1,
empty: {
icon: `${this.$aliOSS}uniapp/goods_null.png`,
tip: '暂无拼团~',
fixed: true
}
},
};
},
props: {
groupType: {
type: Number
}
},
methods: {
upCallback(page) {
this.$getUserGroup(page.num, page.size);
},
$getUserGroup(pageNum = 1, pageSize = 10) {
let {groupType} = this;
getUserGroup({
'type': groupType,
'page_no': pageNum,
'page_size': pageSize
}).then(res => {
if (res) {
let curPageData = res.data.list;
let curPageLen = curPageData.length;
let hasNext = !!res.data.more;
if (pageNum == 1) this.lists = [];
console.log(hasNext)
this.groupList = this.lists.concat(curPageData);
this.mescroll.endSuccess(curPageLen, hasNext);
}
}).catch(() => {
this.mescroll.endErr()
})
}
},
computed: {
getGroupStatus() {
return (status) => {
var text = ''
switch (status) {
case 0:
text = '拼团中';
break;
case 1:
text = '拼团成功';
break;
case 2:
text = '拼团失败';
break;
}
return text
}
},
getTeamCountTime() {
return (item) => item.count_time = Math.min(item.found_end_time, item.end_time) - Date.now() / 1000
}
}
};
</script>
<style lang="scss">
@import '@/styles/base.scss';
.group-list {
min-height: calc(100vh - 80rpx);
padding: 0 20rpx;
overflow: hidden;
.item {
border-radius: 10rpx;
position: relative;
.group-header {
height: 80rpx;
padding: 0 24rpx;
border-bottom: 1px dotted #E5E5E5;
}
.team-chief {
position: absolute;
z-index: 100;
top: 105rpx;
padding: 4rpx 20rpx;
border-radius: 0 60rpx 60rpx 0;
background: linear-gradient(87deg, #F95F2F 0%, #FF2C3C 100%);
}
.all-price {
text-align: right;
padding: 0 24rpx 20rpx;
}
.group-footer {
height: 100rpx;
border-top: $-solid-border;
padding: 0 24rpx;
.btn {
width: 244rpx;
}
}
}
}
</style>