123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 |
- <template>
- <view class="content">
- <view class="top-fixed">
- <u-tabs
- :current="status"
- :scrollable="false"
- :list="tabs"
- lineColor="#C39A58"
- @change="statusChange">
- </u-tabs>
- </view>
- <mescroll-body top="88rpx" bottom="0" ref="mescrollRef" @init="mescrollInit" :down="downOption" :up="upOption" @down="downCallback" @up="upCallback">
- <view class="coupon-box" >
- <view class="item" v-for="(item) in dataList">
- <view class="left" >
- <image v-if="item.status==0" src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/0fdd75d89db84458886d38e615011048.png" mode="widthFix"></image>
- <image v-if="item.status!=0" src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/d950e4c7af1e4464be1a7777e9dca576.png" mode="widthFix"></image>
- <view style="z-index: 999;">
- ¥<span class="num" v-if="item.price!=null">{{item.price.toFixed(2)}}</span>
- </view>
- <view class="pic-num" v-if="item.minPrice!=null" >满{{item.minPrice.toFixed(2)}}元可用</view>
- </view>
- <view class="right">
- <view class="title">
- {{item.title}}
- </view>
- <view class="btns">
- <view v-if="item.status==0||item.status==2" >{{item.limitTime}} 到期</view>
- <view v-if="item.status==1">使用时间 {{item.useTime}}</view>
- <view class="bnt gray" v-if="item.status==1" >已使用</view>
- <view class="bnt gray" v-if="item.status==2" >已过期</view>
- <view class="btn" v-if="item.status==0" >可使用</view>
- </view>
- </view>
- </view>
- </view>
- </mescroll-body>
- </view>
- </template>
- <script>
- import { getMyCouponList } from '@/api/user.js'
- import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
- export default {
- name: 'UserCoupon',
- props: {},
- mixins: [MescrollMixin], // 使用mixin
- data: function() {
- return {
- tabs:[
- {
- id:0,
- name:'待使用'
- },
- {
- id:1,
- name:'已使用'
- },
- {
- id:2,
- name:'已过期'
- }
-
- ],
- status:0,
- mescroll:null,
- downOption: { //下拉刷新
- use:true,
- auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
- },
- upOption: {
- onScroll:false,
- use: true, // 是否启用上拉加载; 默认true
- page: {
- pae: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
- size: 10 // 每页数据的数量,默认10
- },
- noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
- textNoMore:"已经到底了",
- empty: {
- icon:'https://cos.his.cdwjyyh.com/fs/20240423/cf4a86b913a04341bb44e34bb4d37aa2.png',
- tip: '暂无数据'
- }
- },
- dataList: []
- }
- },
- watch: {
-
- },
-
- onShow() {
-
- },
- methods: {
- statusChange(item){
- console.log(item)
- this.status=item.id
- this.mescroll.resetUpScroll()
- },
- navTo(url){
- uni.navigateTo({
- url: url
- })
- },
- mescrollInit(mescroll) {
- this.mescroll = mescroll;
- },
- /*下拉刷新的回调 */
- downCallback() {
- this.mescroll.resetUpScroll()
- },
- /*上拉加载的回调*/
- upCallback(page) {
- //联网加载数据
- var that = this;
- var data = {
- status:this.status,
- pageNum: page.num,
- pageSize: page.size
- };
- getMyCouponList(data).then(res => {
- if(res.code==200){
- if (page.num == 1) {
- that.dataList = res.data.list;
-
- } else {
- that.dataList = that.dataList.concat(res.data.list);
-
- }
- that.mescroll.endBySize(res.data.list.length, res.data.total);
-
- }else{
- uni.showToast({
- icon:'none',
- title: "请求失败",
- });
- that.dataList = null;
- that.mescroll.endErr();
- }
- });
- },
- },
- }
- </script>
- <style lang="less" scoped>
- .content{
- height: 100%;
- .top-fixed{
- width: 100%;
- position: fixed;
- top: 0;
- left: 0;
- z-index: 10;
- height: 88upx;
- background-color: #fff;
- }
- .coupon-box{
- width: 100%;
- padding: 15rpx;
- display: flex;
- flex-direction: column;
- align-items: flex-start;
- justify-content: flex-start;
- box-sizing: border-box;
- .item{
- width: 100%;
- display: flex;
- align-items: center;
- justify-content: flex-start;
- margin-bottom: 16rpx;
- height:170rpx;
- &:last-child{
- margin-bottom: 0rpx;
- }
- .left{
- color: #fff;
- font-size: 36rpx;
- font-weight: bold;
- text-align: center;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- position: relative;
- width: 230rpx;
- image{
- position: absolute;
- width: 230rpx;
- height:170rpx;
- color: #fff;
- }
- .num{
- font-size: 40rpx;
- }
- .pic-num{
- font-size: 20rpx;
- z-index: 99;
- }
- }
- .right{
-
- display: flex;
- flex-direction: column;
- align-items: flex-start;
- justify-content: flex-start;
- height:170rpx;
- width: calc(100% - 230rpx);
- padding: 0 17rpx 0 24rpx;
- background-color: #fff;
- box-sizing: border-box;
- .title{
- width: 100%;
- font-size: 0.3 * 100rpx;
- color: #282828;
- height: 0.93 * 100rpx;
- line-height: 0.93 * 100rpx;
- border-bottom: 1px solid #f0f0f0;
- }
- .btns{
- display: flex;
- align-items: center;
- justify-content: space-between;
- width: 100%;
- font-size: 0.2 * 100rpx;
- color: #999;
- height: 0.76 * 100rpx;
- .btn{
- width: 1.36 * 100rpx;
- height: 0.44 * 100rpx;
- border-radius: 0.22 * 100rpx;
- font-size: 0.22 * 100rpx;
- color: #fff;
- text-align: center;
- line-height: 0.44 * 100rpx;
- background-color: #C39A58;
- .gray{
- background-color: #ccc;
- }
- }
-
- }
- }
- }
-
- }
-
- }
-
-
-
- </style>
|