Browse Source

[dev] 修复一点bug

天梦 2 years ago
parent
commit
480a0fa8c2
3 changed files with 57 additions and 20 deletions
  1. 1 0
      .gitignore
  2. 12 2
      pages.json
  3. 44 18
      pages/index/index.vue

+ 1 - 0
.gitignore

@@ -1,2 +1,3 @@
 node_modules
 uni_modules
+unpackage/dist

+ 12 - 2
pages.json

@@ -14,7 +14,7 @@
 			"path": "pages/index/index",
 			"style": {
 				// "navigationBarTitleText": "uni-app",
-				"navigationStyle": "custom",
+				"navigationStyle": "custom"
 			}
 		}
         ,{
@@ -58,5 +58,15 @@
 		"rpxCalcBaseDeviceWidth": 686
 		
 	},
-	"uniIdRouter": {}
+	"uniIdRouter": {},
+	"condition" : { //模式配置,仅开发期间生效
+		"current": 0, //当前激活的模式(list 的索引项)
+		"list": [
+			{
+				"name": "", //模式名称
+				"path": "", //启动页面,必选
+				"query": "" //启动参数,在页面的onLoad函数里面得到
+			}
+		]
+	}
 }

+ 44 - 18
pages/index/index.vue

@@ -6,7 +6,7 @@
 				<view class="tab-bar">
 					<view class="tab_item" v-for="(tab, index) in tabList" :key="index"
 						:class="{'active':tabActive==index}" @click="checkIndex(index)">
-						<text class="text">{{tab.title}}{{index===0?"("+orderList.length+")":""}}</text>
+						<text class="text">{{tab.title}}{{index===0 && tabList[0].leng>0?"("+tabList[0].leng+")":""}}</text>
 					</view>
 				</view>
 				<view class="search-bar">
@@ -110,8 +110,8 @@ import {releaseOrder} from "@/static/js/request.js"
 const userInfo = ref({})
 const searchVal = ref('')
 const tabList = ref([
-	{title:"今日待完成", status: 0},
-	{title:"历史处方", status: 1},
+	{title:"今日待完成", status: '0', leng:0},
+	{title:"历史处方", status: '1'},
 ])
 
 const currentStatus = ref(0)
@@ -161,6 +161,10 @@ const total = ref(0)
 const pageSize = ref(10)
 const status = ref('')
 
+const today =ref({
+	leng: 0,
+})
+
 
 // app.provide(ID_INJECTION_KEY, {
 // 	prefix: Math.floor(Math.random() * 10000),
@@ -183,7 +187,7 @@ onLoad(async () => {
 			currentUserId: parseInt(uni.getStorageSync('userId')) || 0,
 			page: page.value,
 			pageSize: pageSize.value,
-			status: currentStatus.value
+			status: '0'
 		})
 	}
 	
@@ -191,6 +195,9 @@ onLoad(async () => {
 	if (res.code === 200) {
 		total.value = res.total
 		orderList.value = res.rows
+		if(tabActive.value ==0){
+			tabList.value[0].leng = orderList.value.length
+		}
 	}
 })
 
@@ -210,7 +217,7 @@ const handleSearch = async()=>{
 	console.log('handleSearch searchVal', searchVal.value)
 	console.log('currentStatus.value', currentStatus.value)
 	searchVal.value = searchVal.value.trim()
-	if(currentStatus.value ===0 && searchVal.value) {
+	if(tabActive.value ===0 && searchVal.value) {
 		const params = {
 			token: uni.getStorageSync('token'),
 			data: JSON.stringify({
@@ -218,7 +225,7 @@ const handleSearch = async()=>{
 				name: searchVal.value,
 				page: page.value,
 				pageSize: pageSize.value,
-				status: currentStatus.value
+				status: tabList.value[tabActive.value].status
 			})
 		}
 		const {data:res} = await receiveOrderList(params)
@@ -227,7 +234,7 @@ const handleSearch = async()=>{
 			orderList.value = res.rows
 		}
 	}
-	if(currentStatus.value===1){
+	if(tabActive.value===1){
 		const params = {
 			token: uni.getStorageSync('token'),
 			data: JSON.stringify({
@@ -241,7 +248,7 @@ const handleSearch = async()=>{
 				preMzZy: searchPreMzZy.value || '',
 				page: page.value,
 				pageSize: pageSize.value,
-				status: currentStatus.value || 0
+				status: tabList.value[tabActive.value].status
 			})
 		}
 		console.log('params',params)
@@ -249,6 +256,9 @@ const handleSearch = async()=>{
 		if (res.code === 200) {
 			total.value = res.total
 			orderList.value = res.rows
+			if(tabActive.value ==0){
+				tabList.value[0].leng = orderList.value.length
+			}
 		}
 	}
 }
@@ -275,7 +285,7 @@ const handleRefresh = async()=>{
 				currentUserId: parseInt(uni.getStorageSync('userId')),
 				page: page.value,
 				pageSize: pageSize.value,
-				status: currentStatus.value
+				status: tabList.value[tabActive.value].status
 			})
 		}
 		
@@ -283,6 +293,9 @@ const handleRefresh = async()=>{
 		if (res.code === 200) {
 			total.value = res.total
 			orderList.value = res.rows
+			if(tabActive.value ==0){
+				tabList.value[0].leng = orderList.value.length
+			}
 		}
 	}
 }
@@ -388,22 +401,28 @@ const handleGetTags = (v)=>{
 // 更新处方列表
 const checkIndex = async(index) => {
 	tabActive.value = index
+	page.value= 1
+	console.log('index',index)
 	tabName.value = tabList.value[index].title
 	currentStatus.value = parseInt(tabList.value[index].status)
 	const token = uni.getStorageSync('token')
-	const params = {
-		token: token,
-		data: {
-			status: currentStatus.value,
+	const paramss = {
+		token: uni.getStorageSync('token'),
+		data:JSON.stringify({
+			currentUserId: parseInt(uni.getStorageSync('userId')),
 			page: page.value,
 			pageSize: pageSize.value,
-		}
+			status: tabList.value[tabActive.value].status
+		})
 	}
-	console.log('checkIndex params',params)
-	const {data:res} = await receiveOrderList(params)
+	console.log('checkIndex params',paramss)
+	const {data:res} = await receiveOrderList(paramss)
 	if (res.code === 200) {
 		total.value = res.total
 		orderList.value = res.rows
+		if(tabActive.value ==0){
+			tabList.value[0].leng = orderList.value.length
+		}
 	}
 }
 
@@ -421,7 +440,7 @@ const loadMoreList =async()=>{
 			name: searchVal.value,
 			page: page.value,
 			pageSize: pageSize.value,
-			status: currentStatus.value
+			status: tabActive.value + ''
 		})
 	}
 	const {data:res} = await receiveOrderList(params)
@@ -434,6 +453,10 @@ const loadMoreList =async()=>{
 		})
 		
 		console.log('orderList.value after',orderList.value)
+		if(tabActive.value ==0){
+			console.log('tabActive===',)
+			tabList.value[0].leng = orderList.value.length
+		}
 	}
 }
 
@@ -447,13 +470,16 @@ const loadPreList = async()=>{
 			name: searchVal.value,
 			page: page.value,
 			pageSize: pageSize.value,
-			status: currentStatus.value
+			status: tabList.value[tabActive.value].status
 		})
 	}
 	const {data:res} = await receiveOrderList(params)
 	if (res.code === 200) {
 		total.value = res.total
 		orderList.value = res.rows
+		if(tabActive ==0){
+			tabList.value[0].leng = orderList.value.length
+		}
 	}
 }