cloud_admin_app/pagesCenter/billingPage/billingMean/billingMean.vue

140 lines
2.7 KiB

<template>
<view class="main-page">
<cc-couponList colors="#e54d42" :couponList="orderData.orderList"></cc-couponList>
</view>
<view v-if="orderData.orderList == null || orderData.orderList.length == 0">
<up-empty mode="order">
</up-empty>
</view>
</template>
<script setup>
import sheep from '@/sheep';
import config from '@/common/config/config.js';
import {
reactive,
ref,
} from "vue";
import {
onLoad,
onShow,
onReachBottom,
onUnload,
onHide,
onTabItemTap,
onPullDownRefresh
} from "@dcloudio/uni-app";
//
const orderData = ref({ //请求的订单列表
orderList: [],
orderAskIng: []
})
const couponList = ref([
// {
// name: '满105减5',
// dates: '2023-07-09 2023-08-02',
// frequency: 3
// status: 0,
// money: 105,
// sub: 5
// },
// {
// name: '满200减10',
// dates: '2023-07-19 2023-08-22',
// status: 0,
// money: 200,
// sub: 10
// }, {
// name: '满100减10',
// dates: '2023-05-09 2023-06-02',
// status: 1,
// money: 100,
// sub: 10
// },
// {
// name: '满400减20',
// dates: '2023-04-09 2023-05-08',
// status: 1,
// money: 400,
// sub: 20
// }
])
const page = ref(1) //触底加载增加的页数
const totalPages = ref() //总页数,用于判断是否加载完
const getlist = async (type) => {
let data = {
pageNo: page.value,
pageSize: 10,
}
await uni.$request({
url: config.baseUrl + 'app-api/cloud/set-meal-records/page',
data: data
}).then(res => {
// console.log(res, '列表')
if (res.data.code == 0) {
if (type == 0) {
handle_dates(res.data.data.list, 0)
} else {
handle_dates(res.data.data.list, 1)
}
totalPages.value = res.data.data.total
}
}).catch((err) => {
uni.showToast({
title: '加载失败',
duration: 2000,
icon: 'error'
});
})
}
const handle_dates = (column, type) => {
let str_array = []
for (let item of column) {
let str_item = {
id: item.id,
name: item.name,
dates: item.effective,
frequency: item.frequency,
status: item.frequency,
money: item.payPrice / 100,
sub: 5
}
str_array.push(str_item)
}
if (type == 0) {
orderData.value.orderList = str_array
} else {
orderData.orderList = orderData.orderList.concat(str_array)
}
}
//
onShow(() => {
page.value = 1
})
onLoad(() => {
getlist(0)
})
onReachBottom(async () => {
if (orderData.value.orderList < totalPages.value) {
page.value += 1
await getlist(1)
// orderData.orderList = orderData.orderList.concat(orderData.orderAskIng)
} else {
uni.$u.toast('没有更多啦');
}
})
//
</script>
<style lang='less' scoped>
.main-page {
padding: 30rpx;
}
</style>