123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- <template>
- <view class="good-list">
- <uni-nav-bar class="nav" @clickLeft='back' :border='false' backgroundColor='transparent' leftIcon='left'
- color='#FFF' title="我的水票" />
- <view class="content-money">
- <view class="conetnt-box">
- <view class="money-box">
- <view class="money">{{ allNumber }}</view>
- <view class="text">剩余总数</view>
- </view>
- <navigator url="./waterUse">
- <view class="topDetail">
- 使用记录
- </view>
- </navigator>
- </view>
- </view>
- <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
- <!-- 空白页 -->
- <!-- #ifdef H5 -->
- <empty src="../../static/error/emptyMyCart.png"
- v-if="navList[tabCurrentIndex].loaded === true && navList[tabCurrentIndex].orderList.length === 0">
- </empty>
- <!-- #endif -->
- <!-- #ifndef H5 -->
- <empty src="../static/error/emptyMyCart.png"
- v-if="navList[tabCurrentIndex].loaded === true && navList[tabCurrentIndex].orderList.length === 0">
- </empty>
- <!-- #endif -->
- <view class="good flex" v-for="item in navList[tabCurrentIndex].orderList">
- <image :src="item.product.image" mode="" class="good-image"></image>
- <view class="right">
- <view class="good-name ">
- <view class="clamp2">
- {{item.product.store_name}}
- </view>
- </view>
- <view class="good-key">
- {{item.product.keyword}}
- </view>
- <view class="good-price">
- 剩余<text class="num">{{item.certificate_num}}</text>张
- </view>
- </view>
- </view>
- <uni-load-more v-if="navList[tabCurrentIndex].orderList.length>0" :status="navList[tabCurrentIndex].loadingType"></uni-load-more>
- </scroll-view>
- </view>
- </template>
- <script>
- import {
- certificate
- } from '@/api/water.js';
- export default {
- data() {
- return {
- tabCurrentIndex: 0,
- navList: [{
- state: 0,
- text: '全部',
- loadingType: 'more',
- orderList: [],
- page: 1, //当前页数
- limit: 10 //每次信息条数
- }]
- };
- },
- computed: {
- allNumber() {
- const item = this.navList[0].orderList;
- let num = 0;
- for (let i = 0; i < item.length; i++) {
- num += item[i].certificate_num
- }
- return num
- }
- },
- onReachBottom() {
- this.getGoodList();
- },
- onLoad: function(option) {
- this.getGoodList();
- },
- methods: {
- // 返回退回
- back() {
- uni.reLaunch({
- url: '/pages/home/user'
- })
- },
- // 加载数据
- getGoodList(source) {
- //这里是将订单挂载到tab列表下
- let index = this.tabCurrentIndex;
- let navItem = this.navList[index];
- let state = navItem.state;
- console.log(navItem, '数据');
- if (source === 'tabChange' && navItem.loaded === true) {
- //tab切换只有第一次需要加载数据
- return;
- }
- if (navItem.loadingType === 'loading') {
- //防止重复加载
- return;
- }
- if (navItem.loadingType === 'noMore') {
- //防止重复加载
- return;
- }
- // 修改当前对象状态为加载中
- navItem.loadingType = 'loading';
- certificate({})
- .then(({
- data
- }) => {
- let arr = data.data
- console.log(arr, 'arr');
- navItem.orderList = navItem.orderList.concat(arr);
- // console.log(navItem.orderList);
- navItem.page++;
- if (navItem.limit == arr.length) {
- //判断是否还有数据, 有改为 more, 没有改为noMore
- navItem.loadingType = 'more';
- return;
- } else {
- //判断是否还有数据, 有改为 more, 没有改为noMore
- navItem.loadingType = 'noMore';
- }
- uni.hideLoading();
- this.$set(navItem, 'loaded', true);
- })
- .catch(e => {
- console.log(e);
- });
- },
- }
- };
- </script>
- <style lang="scss">
- .good-list {
- width: 750rpx;
- height: 100%;
- .good {
- background: #FFFFFF;
- box-shadow: 0px 0px 20px 0px rgba(50, 50, 52, 0.06);
- width: 100%;
- border-radius: 14rpx;
- margin-bottom: 20rpx;
- position: relative;
- padding: 20rpx;
- .good-image {
- width: 180rpx;
- height: 180rpx;
- background-color: #eee;
- border-radius: 10rpx;
- flex-shrink: 0;
- }
- .right {
- height: 180rpx;
- position: relative;
- .good-name {
- font-size: 28rpx;
- font-weight: bold;
- color: #333333;
- padding-left: 20rpx;
- }
- .good-key {
- font-size: 22rpx;
- font-weight: 500;
- color: #999999;
- padding-left: 20rpx
- }
- .good-price {
- font-size: 28rpx;
- font-weight: bold;
- position: absolute;
- bottom: 0rpx;
- padding: 0 20rpx;
- left: 0;
- right: 0rpx;
- .num {
- color: $color-red;
- }
- }
- }
- }
- }
- .list-scroll-content {
- height: calc(100% - 200px - var(--status-bar-height));
- padding: 20rpx;
- }
- .nav {
- position: fixed;
- top: 0;
- right: 0;
- left: 0;
- z-index: 998;
- }
- .content-money {
- position: relative;
- padding: 20rpx;
- padding-top: var(--status-bar-height);
- background: url('../../static/image/mywater.png') no-repeat;
- background-size: 100% 100%;
- height: 200px;
- .topDetail {
- position: absolute;
- right: 0;
- top: calc(70px + var(--status-bar-height));
- background-color: #FFF;
- padding: 5px 10px;
- border-top-left-radius: 10rpx;
- border-bottom-left-radius: 10rpx;
- line-height: 1;
- color: $base-color;
- font-size: $font-base;
- }
- .money-box {
- padding-top: 80px;
- text-align: center;
- color: #FFF;
- .text {
- font-size: $font-base;
- }
- .money {
- font-weight: bold;
- font-size: 82rpx;
- }
- }
- }
- /deep/ .empty-content{
- background: transparent;
- position: absolute;
- }
- </style>
|