Browse Source

完成收藏列表接口接入、订单列表接口接入

LinWuTai 1 week ago
parent
commit
4aac62b122
4 changed files with 139 additions and 98 deletions
  1. 16 0
      api/order.js
  2. 1 1
      pages.json
  3. 5 2
      pages/collect/collect.vue
  4. 117 95
      pages/order/order.vue

+ 16 - 0
api/order.js

@@ -0,0 +1,16 @@
+import request from '@/utils/request'
+
+/**
+ * 订单列表
+ * @param {Object} data 参数
+ */
+export function query(data) {
+	return request({
+		'url': '/order/list',
+		headers: {
+			isToken: true
+		},
+		'method': 'post',
+		'data': data
+	})
+}

+ 1 - 1
pages.json

@@ -165,7 +165,7 @@
 			"path": "pages/order/order",
 			"style": {
 				"navigationBarTitleText": "我的订单",
-				"enablePullDownRefresh": false,
+				"enablePullDownRefresh": true,
 				"app-plus": {
 					"titleNView": false
 				}

+ 5 - 2
pages/collect/collect.vue

@@ -76,7 +76,7 @@
 			value: 1
 		},
 		{
-			label: '继续教育',
+			label: '培训课程',
 			value: 2
 		},
 	]
@@ -126,7 +126,10 @@
 		})
 	}
 	
-	function onSearchTypeChange(val) {}
+	function onSearchTypeChange(val) {
+		searchForm.value.type = searchType[val].value
+		onSearchConfirm()
+	}
 	
 	function onClickReport(report) {
 		uni.navigateTo({

+ 117 - 95
pages/order/order.vue

@@ -27,6 +27,14 @@
 				></u-tabs>
 			</view>
 		</view>
+		<u-empty
+			mode="data"
+			v-if="list.length === 0"
+			iconSize="120"
+			textSize="58"
+			text="暂无数据"
+		>
+		</u-empty>
 		<view class="list-box">
 			<view class="list-item-box" v-for="item in list" :key="item.id">
 				<view class="title-box">
@@ -39,7 +47,7 @@
 								订单编号:
 							</view>
 							<view class="text">
-								{{item.number}}
+								{{item.orderNo}}
 							</view>
 						</view>
 						<view class="info-item-box">
@@ -47,21 +55,25 @@
 								订单时间:
 							</view>
 							<view class="text">
-								{{item.time}}
+								{{item.buyDate}}
 							</view>
 						</view>
 					</view>
 					<view class="price-box">
 						<view class="text" v-if="item.status === 1">
-							实付款:&nbsp;¥{{item.price}}元
+							实付款:&nbsp;¥{{item.buyPrice}}元
 						</view>
 						<view class="button" v-if="item.status === 0">
 							已关闭
 						</view>
+						<view class="button" v-if="item.status === 2">
+							订单取消/关闭
+						</view>
 					</view>
 				</view>
 			</view>
 		</view>
+		<uni-load-more v-show="visualLoadMore" :status="loadMoreStatus"></uni-load-more>
 		<view class="buttom-block"></view>
 		<view class="bottom-box">
 			<view class="button" @click="onToInvoiceApplication">
@@ -73,7 +85,8 @@
 
 <script setup>
 	import { ref } from 'vue'
-	import { onLoad } from '@dcloudio/uni-app'
+	import { onLoad, onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app'
+	import { query } from '@/api/order.js'
 	
 	const searchInputStyle = {
 		backgroundColor: '#E5E5E5'
@@ -84,121 +97,130 @@
 			value: 0
 		},
 		{
-			label: '市场研究',
-			value: 1
-		},
-		{
-			label: '继续教育',
-			value: 2
-		},
-		{
-			label: '会费',
-			value: 3
+			label: '研究报告',
+			value: 8
 		},
 		{
-			label: '业务水平认证考试',
-			value: 4
+			label: '培训课程',
+			value: 9
 		},
 	]
+	const pageNum = ref(1)
+	const pageSize = ref(10)
+	const visualLoadMore = ref(false)
+	const loadMoreStatus = ref('more')
 	const searchForm = ref({
 		keyword: '',
-		type: 0
+		type: 0,
+		pageNumber: 1,
+		pageSize: 10
 	})
-	function onSearchTypeChange(val) {
-		console.log('搜索表单', searchForm.value)
-	}
 	
 	const list = ref([
 		{
 			id: '01',
 			title: '【市场研究】2024年11月广州市中介促成二手住宅市场交易简报',
-			number: '123456789987654321',
-			time: '2023年8月8日',
-			price: '9.9',
-			status: 1
-		},
-		{
-			id: '02',
-			title: '【市场研究】2024年11月广州市中介促成二手住宅市场交易简报',
-			number: '123456789987654321',
-			time: '2023年8月8日',
-			price: '9.9',
-			status: 0
-		},
-		{
-			id: '03',
-			title: '【市场研究】2024年11月广州市中介促成二手住宅市场交易简报',
-			number: '123456789987654321',
-			time: '2023年8月8日',
-			price: '9.9',
-			status: 1
-		},
-		{
-			id: '04',
-			title: '【市场研究】2024年11月广州市中介促成二手住宅市场交易简报',
-			number: '123456789987654321',
-			time: '2023年8月8日',
-			price: '9.9',
-			status: 1
-		},
-		{
-			id: '05',
-			title: '【市场研究】2024年11月广州市中介促成二手住宅市场交易简报',
-			number: '123456789987654321',
-			time: '2023年8月8日',
-			price: '9.9',
-			status: 1
-		},
-		{
-			id: '06',
-			title: '【市场研究】2024年11月广州市中介促成二手住宅市场交易简报',
-			number: '123456789987654321',
-			time: '2023年8月8日',
-			price: '9.9',
-			status: 1
-		},
-		{
-			id: '07',
-			title: '【市场研究】2024年11月广州市中介促成二手住宅市场交易简报',
-			number: '123456789987654321',
-			time: '2023年8月8日',
-			price: '9.9',
-			status: 1
-		},
-		{
-			id: '08',
-			title: '【市场研究】2024年11月广州市中介促成二手住宅市场交易简报',
-			number: '123456789987654321',
-			time: '2023年8月8日',
-			price: '9.9',
-			status: 1
-		},
-		{
-			id: '09',
-			title: '【市场研究】2024年11月广州市中介促成二手住宅市场交易简报',
-			number: '123456789987654321',
-			time: '2023年8月8日',
-			price: '9.9',
-			status: 1
-		},
-		{
-			id: '10',
-			title: '【市场研究】2024年10月广州市中介促成二手住宅市场交易简报',
-			number: '123456789987654321',
-			time: '2023年8月8日',
-			price: '9.9',
+			type: 8,
+			orderNo: '123456789987654321',
+			buyDate: '2023年8月8日',
+			buyPrice: 9.9,
+			invoice: true,
 			status: 1
 		},
 	])
 	
+	function onSearchConfirm() {
+		searchForm.value.pageNumber = 1
+		pageNum.value = 1
+		onSearch()
+	}
+	
+	function onSearchClear() {
+		searchForm.value.keyword = null
+		searchForm.value.pageNumber = 1
+		pageNum.value = 1
+		onSearch()
+	}
+	
+	function onSearch() {
+		loadMoreStatus.value = 'more'
+		query(searchForm.value).then(res => {
+			if (res && res.message === 'success') {
+				list.value = res.data
+				if (res.count === 0) {
+					visualLoadMore.value = false
+				}
+			}
+		})
+	}
+	
+	function onSearchTypeChange(val) {
+		searchForm.value.type = searchType[val].value
+		onSearchConfirm()
+	}
+	
 	// 前往发票申请
 	function onToInvoiceApplication() {
 		uni.navigateTo({
 			url: '/pages/InvoiceApplication/InvoiceApplication'
 		})
 	}
+	onPullDownRefresh((e) => {
+		searchForm.value.pageNumber = 1
+		loadMoreStatus.value = 'more'
+		query(searchForm.value).then(res => {
+			if (res && res.message === 'success') {
+				list.value = res.data
+				if (res.count === 0) {
+					visualLoadMore.value = false
+				}
+				uni.showToast({
+					title: '刷新成功',
+					icon: 'success',
+					duration: 2000
+				})
+			}
+			uni.stopPullDownRefresh()
+		})
+	})
+	
+	onReachBottom(async () => {
+		if (loadMoreStatus.value === 'noMore') {
+			uni.showToast({
+				title: '没有更多啦>﹏<',
+				icon: 'none'
+			})
+			return
+		}
+		visualLoadMore.value = true
+		loadMoreStatus.value = 'loading'
+		searchForm.value.pageNum++
+		query(searchForm.value).then(res => {
+			if (res && res.message === 'success') {
+				if (res.data) {
+					if (res.count >= list.value.length) {
+						if (list.value.length === res.count) {
+							loadMoreStatus.value = 'noMore'
+							visualLoadMore.value = true
+						} else {
+							list.value.push(...res.data)
+							loadMoreStatus.value = 'more'
+							visualLoadMore.value = false
+						}							
+					} else {
+						loadMoreStatus.value = 'noMore'
+						visualLoadMore.value = true
+					}
+				} else {
+					loadMoreStatus.value = 'noMore'
+					visualLoadMore.value = true
+				}
+			}
+		})
+	})
 	
 	onLoad(() => {
+		onSearch()
 	})
 </script>