123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- <template>
- <view class="container">
- <view class="order-tab">
- <u-tabs :list="tabList" :is-scroll="false" :current="tabIndex" @change="changeTabs" font-size="30" active-color="#52A63A"
- inactive-color="#666666" :bold="false" height="90"></u-tabs>
- </view>
- <scroll-view class="order-list" scroll-y="true" @scrolltolower="handleLoadMore(1)" v-if="tabIndex==0">
- <orderItem v-for="(item, index) in orderList1" :key="index" :orderData="item" :tabIndex="tabIndex + 1"></orderItem>
- <view style="padding: 10px 0" v-if="!orderList1.length || isOver1">
- <u-divider color="#909399" border-color="#909399" bg-color="#f7f7f7">没有更多了</u-divider>
- </view>
- </scroll-view>
- <scroll-view class="order-list" scroll-y="true" @scrolltolower="handleLoadMore(2)" v-else-if="tabIndex==1">
- <orderItem v-for="(item, index) in orderList2" :key="index" :orderData="item" :tabIndex="tabIndex + 1" @reasetList="reasetList()"></orderItem>
- <view style="padding: 10px 0" v-if="!orderList2.length || isOver2">
- <u-divider color="#909399" border-color="#909399" bg-color="#f7f7f7">没有更多了</u-divider>
- </view>
- </scroll-view>
- <scroll-view class="order-list" scroll-y="true" @scrolltolower="handleLoadMore(3)" v-else-if="tabIndex==2">
- <orderItem v-for="(item, index) in orderList3" :key="index" :orderData="item" :tabIndex="tabIndex + 1" @reasetList="reasetList()"></orderItem>
- <view style="padding: 10px 0" v-if="!orderList3.length || isOver3">
- <u-divider color="#909399" border-color="#909399" bg-color="#f7f7f7">没有更多了</u-divider>
- </view>
- </scroll-view>
- <scroll-view class="order-list" scroll-y="true" @scrolltolower="handleLoadMore(4)" v-else-if="tabIndex==3">
- <orderItem v-for="(item, index) in orderList4" :key="index" :orderData="item" :tabIndex="tabIndex + 1" @reasetList="reasetList()"></orderItem>
- <view style="padding: 10px 0" v-if="!orderList4.length || isOver4">
- <u-divider color="#909399" border-color="#909399" bg-color="#f7f7f7">没有更多了</u-divider>
- </view>
- </scroll-view>
- <scroll-view class="order-list" scroll-y="true" @scrolltolower="handleLoadMore(5)" v-else-if="tabIndex==4">
- <orderItem v-for="(item, index) in orderList5" :key="index" :orderData="item" :tabIndex="tabIndex + 1" @reasetList="reasetList()"></orderItem>
- <view style="padding: 10px 0" v-if="!orderList5.length || isOver5">
- <u-divider color="#909399" border-color="#909399" bg-color="#f7f7f7">没有更多了</u-divider>
- </view>
- </scroll-view>
- <u-top-tips ref="uTips"></u-top-tips>
- </view>
- </template>
- <script>
- const NET = require('@/utils/request')
- const API = require('@/config/api')
- import orderItem from '@/pagesMain/orderItem.vue'
- export default {
- components: {
- orderItem
- },
- data() {
- return {
- tabIndex: 0,
- tabList: [{
- name: '全部'
- }, {
- name: '待付款'
- }, {
- name: '待发货'
- }, {
- name: '待收货'
- }, {
- name: '待评价'
- }, ],
- pageIndex1: 1,
- isOver1: false,
- orderList1: [],
- pageIndex2: 1,
- isOver2: false,
- orderList2: [],
- pageIndex3: 1,
- isOver3: false,
- orderList3: [],
- pageIndex4: 1,
- isOver4: false,
- orderList4: [],
- pageIndex5: 1,
- isOver5: false,
- orderList5: [],
- }
- },
- onLoad(options) {
- this.tabIndex = options.type - 1
- this.getOrderList(options.type)
- },
- onShow() {
- },
- onReady(options) {},
- onPullDownRefresh() {
- this['isOver' + (this.tabIndex + 1)] = false
- this['pageIndex' + (this.tabIndex + 1)] = 1
- this['orderList' + (this.tabIndex + 1)] = []
- this.getOrderList(this.tabIndex + 1, 'refresh')
- },
- methods: {
- // 切换tab
- changeTabs(index) {
- this.tabIndex = index;
- this.reasetList()
- },
- // 刷新数据
- reasetList() {
- this['isOver' + (this.tabIndex + 1)] = false
- this['pageIndex' + (this.tabIndex + 1)] = 1
- this['orderList' + (this.tabIndex + 1)] = []
- this.getOrderList(this.tabIndex + 1)
- },
- // 懒加载
- handleLoadMore(type) {
- if (!this['isOver' + type]) {
- this['pageIndex' + type]++
- this.getOrderList(type)
- }
- },
- // 获取全部商品
- getOrderList(type, refresh) {
- NET.request(API.getOrderList + this['pageIndex' + type] + '/10', {
- flag: type,
- }, 'GET').then(res => {
- if (refresh == 'refresh') {
- uni.stopPullDownRefresh();
- }
- this['isOver' + type] = res.data.list.length != 10
- this['orderList' + type] = this['orderList' + type].concat(res.data.list)
- }).catch(error => {
- this.$refs.uTips.show({
- title: error.data.msg,
- type: 'warning',
- })
- })
- },
- }
- }
- </script>
- <style>
- page {
- background-color: #f7f7f7;
- }
- </style>
- <style lang="less" scoped>
- page {
- width: 100%;
- height: 100%;
- }
- .container {
- width: 100%;
- // height: 100%;
- float: left;
- padding-top: 45px;
- background-color: #f7f7f7;
- position: relative;
- .order-tab {
- width: 100%;
- height: 45px;
- float: left;
- position: fixed;
- top: 0;
- }
- .order-list {
- width: calc(100% - 30px);
- height: calc(100% - 46px);
- float: left;
- margin: 0 15px;
- box-sizing: border-box;
- padding-top: 10px;
- }
- }
- </style>
|