Browse Source

完成订单跳转

LinWuTai 5 days ago
parent
commit
bf734076f1
2 changed files with 46 additions and 7 deletions
  1. 15 0
      api/order.js
  2. 31 7
      pages/order/order.vue

+ 15 - 0
api/order.js

@@ -13,4 +13,19 @@ export function query(data) {
 		'method': 'post',
 		'data': data
 	})
+}
+
+/**
+ * 订单详情
+ * @param id 订单编号
+ */
+export function byId(id) {
+	return request({
+		'url': `/order/${id}`,
+		headers: {
+			isToken: true
+		},
+		'method': 'get',
+		'data': null
+	})
 }

+ 31 - 7
pages/order/order.vue

@@ -88,7 +88,7 @@
 <script setup>
 	import { ref } from 'vue'
 	import { onLoad, onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app'
-	import { query } from '@/api/order.js'
+	import { query, byId } from '@/api/order.js'
 	import { msgError, msgSuccess } from '@/utils/common'
 	
 	const searchInputStyle = {
@@ -133,13 +133,37 @@
 		},
 	])
 	function onItem(order) {
-		console.log('点击订单', order)
-		if (order.type === '8') {
-			// 研究报告
-		}
-		if (order.type === '9') {
-			// 培训课程
+		if (order.status === '2') {
+			uni.showToast({
+				title: '订单已关闭',
+				icon: 'none'
+			})
+			return
 		}
+		uni.showLoading({
+			title: '加载中...'
+		})
+		byId(order.id).then(res => {
+			if (res && res.message === 'success') {
+				uni.hideLoading()
+				const objId = res.data.objId
+				const title = res.data.title
+				if (res.data.objType === '8') {
+					uni.navigateTo({
+						url: `/pages/reportDetail/reportDetail?id=${objId}&title=${title}`
+					})
+				}
+				if (res.data.objType === '9') {
+					uni.navigateTo({
+						url: `/pages/goOnEdu/course/courseDetail/courseDetail?id=${objId}&title=${title}`
+					})
+				}
+			} else {
+				uni.hideLoading()
+			}
+		}).catch(e => {
+			uni.hideLoading()
+		})
 	}
 	function onPay(order) {
 		wx.requestPayment({