123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232 |
- <template>
- <view class="page-wrap">
- <u-navbar
- title="积分商城"
- :autoBack="true"
- :safeAreaInsetTop="true"
- >
- </u-navbar>
- <view class="header">
- <u--image class="image" :src="staticUrl+'/img/credits-header.png'" width="100%" height="260rpx"></u--image>
- <view class="inner">
- <view class="top u-flex u-row-between">
- <text>积分商城</text>
- <view class="right u-flex">
- <u-icon name="error-circle" color="#fff" size="34rpx"></u-icon>
- <text>规则</text>
- </view>
- </view>
- <view class="num">64565</view>
- <view class="bottom">
- <text>积分明细</text>
- </view>
- </view>
- </view>
- <view class="tabs-wrap">
- <u-tabs
- :list="tabsList"
- lineColor="#00A447"
- :activeStyle="{color:'#333','font-weight': '600','font-size':'30rpx'}"
- :inactiveStyle="{color:'#999'}"
- @click="tabsClick"></u-tabs>
- </view>
- <view class="">
- <mescroll-body class="" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
- <view class="credit-product u-flex u-flex-wrap">
- <view class="credit-product-item" v-for="(item,index) in dataList" :key="item.id">
- <view class="pic">
- <u--image class="image" :src="item.mainImg" width="100%" height="340rpx"></u--image>
- </view>
- <view class="text">
- <view class="til ellipsis-2">
- {{item.title||'测试标题测试标题测试标题测试标题测试标题测试标题'}}
- </view>
- <view class="price">¥54.00</view>
- <view class="bottom u-flex u-row-between">
- <text>+20000积分</text>
- <text class="btn">兑换</text>
- </view>
- </view>
- </view>
- </view>
- </mescroll-body>
- </view>
- </view>
- </template>
- <script>
- // 引入mescroll-mixins.js
- import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
- export default {
- mixins: [MescrollMixin], // 使用mixin
- data() {
- return {
- staticUrl:this.$commonConfig.staticUrl,
- tabsList:[
- {name:'全部'},
- {name:'推荐'},
- {name:'美食'},
- {name:'饮料'},
- {name:'住行'},
- {name:'其他'}
- ],
- typeId:'',
- dataList:[{id:1},{id:2},{id:3}],
- }
- },
- onShow() {
- },
- onLoad() {
- },
- methods: {
- /*下拉刷新的回调, 重置列表为第一页 (此处可删,mixins已默认)
- downCallback(){
- this.mescroll.resetUpScroll();
- },
- /*上拉加载的回调*/
- upCallback(page) {
- // 此处可以继续请求其他接口
- // if(page.num == 1){
- // // 请求其他接口...
- // }
-
- // 如果希望先请求其他接口,再触发upCallback,可参考以下写法
- // if(!this.hasTypeId){
- // this.shopNewsType();
- // return // 此处return,先获取xx
- // }
-
- let pageNum = page.num; // 页码, 默认从1开始
- let pageSize = page.size; // 页长, 默认每页10条
-
- let params = {
- pageNum : page.num,
- pageSize : page.size,
- type : this.typeId,
- }
- // console.log('this.params',params);
- this.$u.api.shopNewsList(params).then(data => {
- console.log('data',JSON.parse(JSON.stringify(data)));
- // 接口返回的当前页数据列表 (数组)
- let curPageData = data.data.rows;
- // console.log('curPageData',JSON.parse(JSON.stringify(curPageData)));
- // 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
- let curPageLen = curPageData.length;
- // 接口返回的总页数 (如列表有26个数据,每页10条,共3页; 则totalPage=3)
- // let totalPage = data.data.data.totalPage;
- // 接口返回的总数据量(如列表有26个数据,每页10条,共3页; 则totalSize=26)
- let totalSize = data.data.total;
- // 接口返回的是否有下一页 (true/false)
- // let hasNext = data.xxx;
- // console.log('totalPage',totalPage,'curPageLen',curPageLen);
- //设置列表数据
- if(page.num == 1) this.dataList = []; //如果是第一页需手动置空列表
- this.dataList = this.dataList.concat(curPageData); //追加新数据
- // 请求成功,隐藏加载状态
- //方法一(推荐): 后台接口有返回列表的总页数 totalPage
- // this.mescroll.endByPage(curPageLen, totalPage);
- //方法二(推荐): 后台接口有返回列表的总数据量 totalSize
- this.mescroll.endBySize(curPageLen, totalSize);
- }).catch(err => {
- this.mescroll.endErr()
- console.log(err)
- });
-
- },
- /*若希望重新加载列表,只需调用此方法即可(内部会自动page.num=1,再主动触发up.callback)*/
- reloadList() {
- this.mescroll.resetUpScroll();
- },
- tabsClick(item){
- this.typeId = item.id;
- this.reloadList()
- // console.log('item',item);
- },
- }
- }
- </script>
- <style>
- page{
- background-color: #F5F5F5;
- }
- </style>
- <style lang="scss" scoped>
- .header{
- color: #fff;
- position: relative;
- height: 260rpx;
- margin-bottom: 30rpx;
- /deep/ .u-image{
- position: absolute;
- left: 0;
- right: 0;
- top: 0;
- z-index: -1;
- }
- .inner{
- padding: 40rpx;
- .top{
- font-size: 26rpx;
- text{margin-left: 10rpx;}
- margin-bottom: 30rpx;
- }
- .num{
- font-size: 50rpx;
- font-weight: 600;
- color: #FFFFFF;
- line-height: 58rpx;
- }
- .bottom{
- text-align: right;
- text{
- display: inline-block;
- padding: 4rpx 20rpx;
- background: rgba(0,0,0,0.2);
- color: #fff;
- border-radius: 23rpx;
- font-size: 22rpx;
- }
- }
- }
- }
- .tabs-wrap{
- background-color: #fff;
- margin-bottom: 10rpx;
- }
- .credit-product{
- margin-top: 20rpx;
- &-item{
- width: 47%;
- background-color: #fff;
- margin-bottom: 30rpx;
- &:nth-child(even){
- margin-left: 6%;
- }
- .text{
- padding: 20rpx;
- .price{
- margin-top: 17rpx;
- font-size: 24rpx;
- font-weight: 600;
- color: #FF3C3F;
- line-height: 33rpx;
- }
- }
- .bottom{
- font-size: 30rpx;
- font-weight: 600;
- color: #00A447;
- line-height: 42rpx;
- .btn{
- font-size: 22rpx;
- font-weight: 400;
- color: #FFFFFF;
- padding: 5rpx 18rpx;
- background: #00A447;
- border-radius: 4px;
- }
- }
- }
- }
- </style>
|