123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- <template>
- <view class="">
- <!-- <u-navbar
- title="我的业绩"
- :placeholder="true"
- :autoBack="true"
- :safeAreaInsetTop="true"
- >
- </u-navbar> -->
- <view class="page-wrap">
- <view class="date u-flex"@click="pickerDateShow = true">
- <img class="img" src="../static/img/date-ico.png" alt="">
- {{checkDate}}
- </view>
- <u-datetime-picker
- :show="pickerDateShow"
- ref="datePicker"
- v-model="timestamp"
- mode="date"
- @cancel="pickerDateShow=false"
- :maxDate="new Date().getTime()"
- :formatter="formatter"
- @confirm="confirmDate"
- ></u-datetime-picker>
- </view>
- <mescroll-body class="" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
- <view class="page-wrap" v-show="dataList.length>0" >
- <view class="list">
- <view class="item" @click="goDetail(item.id)" v-for="item in dataList" :key="item.id">
- <view class="userinfo">
- 姓名:{{item.createBy}}/{{item.dept}}
- </view>
- <view class="goods-name">核销商品:{{item.goodsName}}</view>
- <view class="quantity">数量:{{item.quantity}}</view>
- <view class="bottom u-flex u-row-between">
- <text>{{item.checkTime}}</text>
- <u-icon name="arrow-right" color="#333" size="18"></u-icon>
- </view>
- </view>
- </view>
- </view>
- </mescroll-body>
- </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 {
- timestamp:undefined,
- pickerDateShow:false,
- downOption: {},
- // 上拉加载的配置(可选, 绝大部分情况无需配置)
- upOption: {
- page: {
- size: 10 // 每页数据的数量,默认10
- },
- noMoreSize: 5, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
- empty: {
- tip: '暂无相关数据'
- }
- },
- // ,{name:'安全学习',recordType:3}
- tabsList:[{name:'全部',recordType:''},{name:'答题',recordType:1},{name:'兑换码失效',recordType:4}],
- recordType:'',
- params:{
- checkDate:''
- },
- activeIndex:0,
- dataList: []
- }
- },
- onShow() {
-
- },
- onLoad() {
- this.timestamp = Number(new Date());
- this.checkDate = uni.$u.timeFormat(this.timestamp, 'yyyy年mm月dd日');
- this.params.checkDate = uni.$u.timeFormat(this.timestamp, 'yyyy-mm-dd');
- },
- onReady() {
- // 微信小程序需要用此写法
- this.$refs.datePicker.setFormatter(this.formatter)
- },
- methods: {
- /*下拉刷新的回调, 重置列表为第一页 (此处可删,mixins已默认)
- downCallback(){
- this.mescroll.resetUpScroll();
- },
- /*上拉加载的回调*/
- upCallback(page) {
- // 此处可以继续请求其他接口
- // if(page.num == 1){
- // // 请求其他接口...
- // }
-
- // 如果希望先请求其他接口,再触发upCallback,可参考以下写法
- // if(!this.params.id){
- // this.mescroll.endErr()
- // return // 此处return,先获取xx
- // }
-
- let pageNum = page.num; // 页码, 默认从1开始
- let pageSize = page.size; // 页长, 默认每页10条isAsc:0//时间排序 0:降序 1:升序 (默认星级降序排序)
- this.params = Object.assign(this.params,{pageNum:pageNum,pageSize:pageSize});
- this.$u.api.checkList(this.params).then(data => {
- console.log('data',JSON.parse(JSON.stringify(data)));
- // 接口返回的当前页数据列表 (数组)
- let curPageData = data.data.rows;
- this.totalAmount = data.data.total;
- 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 = curPageData.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();
- },
- itemClick(item){
- console.log('item',item);
- },
- confirmDate(e){
- console.log('confirmDate',e);
- this.pickerDateShow = false;
- this.checkDate = uni.$u.timeFormat(e.value, 'yyyy年mm月dd日');
- this.params.checkDate = uni.$u.timeFormat(e.value, 'yyyy-mm-dd');
- this.reloadList()
- },
- formatter(type, value) {
- if (type === 'year') {
- return `${value}年`
- }
- if (type === 'month') {
- return `${value}月`
- }
- if (type === 'day') {
- return `${value}日`
- }
- return value
- },
- goDetail(id){
- console.log('goDetail',id);
- uni.$u.route('/center/checkdetails', {
- id: id
- });
- }
- }
- }
- </script>
- <style>
- page{
- background-color: #F5F9FC;
- }
- </style>
- <style lang="scss" scoped>
- .list{
- border-radius: 8rpx;
- padding: 0 20rpx;
- .item{
- background-color: #fff;
- padding: 30rpx;
- background-color: #fff;
- margin-bottom: 20rpx;
- border-radius: 24rpx;
- font-size: 28rpx;
- font-family: PingFangSC-Regular, PingFang SC;
- font-weight: 400;
- color: #666666;
- line-height: 40rpx;
- .userinfo{
- font-size: 32rpx;
- font-weight: 600;
- color: #333333;
- line-height: 44rpx;
- margin-bottom: 14rpx;
- }
- .goods-name{
- margin-bottom: 12rpx;
- }
- .quantity{
- margin-bottom: 12rpx;
- }
- .bottom{
- font-size: 28rpx;
- font-weight: 400;
- color: #999999;
- line-height: 40rpx;
- }
- }
- }
- .date{
- width: fit-content;
- padding: 12rpx 20rpx;
- background-color: #fff;
- border-radius: 16rpx;
- font-size: 28rpx;
- font-weight: 400;
- color: #009AEF;
- line-height: 40rpx;
- .img{
- margin-right: 10rpx;
- }
- }
- </style>
|