123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- <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>
- </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>
- </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>
- </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>
- </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>
- </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
- },
- onShow(options) {
- this['pageIndex' + (this.tabIndex + 1)] = 1
- this['isOver' + (this.tabIndex + 1)] = false
- this['orderList' + (this.tabIndex + 1)] = []
- this.getOrderList(this.tabIndex + 1)
- },
- onPullDownRefresh() {
- this['pageIndex' + (this.tabIndex + 1)] = 1
- this['isOver' + (this.tabIndex + 1)] = false
- 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)
- if (this['orderList' + type].length) {
- this['orderList' + type].forEach(v => {
- v.noPick = true
- if (v.products.some(vv => {return vv.productType == 3} )) {
- v.noPick = false
- }
- })
- }
- }).catch(error => {
- this.$refs.uTips.show({
- title: error.data.msg,
- type: 'warning',
- })
- })
- },
- }
- }
- </script>
- <style lang="less" scoped>
- page {
- width: 100%;
- height: 100%;
- }
- .container {
- width: 100%;
- height: 100%;
- float: left;
- background-color: #f7f7f7;
- .order-tab {
- width: 100%;
- height: 45px;
- float: left;
- }
- .order-list {
- width: calc(100% - 30px);
- height: calc(100% - 46px);
- float: left;
- margin: 0 15px;
- box-sizing: border-box;
- padding-top: 15px;
- }
- }
- </style>
|