ymy 6 months ago
parent
commit
c2fd8ba886
2 changed files with 50 additions and 12 deletions
  1. 8 3
      pages/diningList/diningList.vue
  2. 42 9
      pages/login/login.vue

+ 8 - 3
pages/diningList/diningList.vue

@@ -8,7 +8,7 @@
 		</view>
 
 		<view class="contain" style="margin: 10px 0;" v-for="(item, index)  in tableData" :key="index" @click.self="carList(item)">
-			<view class="box" :class="{ 'boxed-border': item.defaultState == 2 }">
+			<view class="box" :class="{ 'boxed-border': currentData.id == item.id }">
 				<view class="container">
 					<view class="text-container">
 						<view class="flex-item">{{item.name ? item.name : '无' }}</view>
@@ -20,7 +20,7 @@
 					<u-icon name="phone" size="28" @click.prevent="call(item)" aa='1'></u-icon>
 					<u-icon style="margin-left: 10px;" name="info-circle" size="28" @click.stop="btnIC(item)"></u-icon>
 				</view>
-				<view :class="{ 'btnbor': item.defaultState==2 }" v-if="item.defaultState==2">
+				<view :class="{ 'btnbor': currentData.id== item.id }" v-if="currentData.id == item.id">
 					<!-- <u-tag text="当前" bgColor='#FF6D20' borderColor='#FF6D20' icon="checkmark-circle"></u-tag> -->
 					<image src="../../static/danqian.png" class="img-ding"></image>
 				</view>
@@ -35,7 +35,8 @@
 			return {
 				seaName: '',
 				orderinfo: {},
-				tableData: [{
+				tableData: [
+					{
 						name: '23333',
 						tags: 1,
 						showBorder: true,
@@ -57,12 +58,16 @@
 					total: 0,
 					totalPage: 0
 				},
+				currentData:null,
 				status: 'loading'
 			}
 		},
 		created() {
 			this.fatchDate()
 		},
+		onLoad() {
+			this.currentData = uni.getStorageSync("carl");
+		},
 		methods: {
 			searchClick(e) {
 				this.seaName = e

+ 42 - 9
pages/login/login.vue

@@ -54,6 +54,7 @@
 					title: '温馨提示',
 					content: '亲,授权微信登录后才能正常使用小程序功能',
 				})
+				let that = this;
 				wx.getUserProfile({
 					desc: '获取用户信息',
 					success: (res) => {
@@ -75,14 +76,7 @@
 									let d = result.data;
 									d.time = Date.now() / 1000;
 									uni.setStorageSync('infoData', JSON.stringify(d))
-									
-									// 跳转到下一个页面
-									// uni.switchTab({
-									// 	url:'/pages/home/home'
-									// })
-									uni.navigateTo({
-										url: `/pages/diningList/diningList`
-									});
+									that.initdining()
 								} else {
 									// 处理错误情况
 								}
@@ -96,7 +90,7 @@
 									"profilePhoto": res.userInfo.avatarUrl
 								}
 								console.log('userInfo', userInfo)
-								this.$request('post', '/system/user/editSysUser',
+								that.$request('post', '/system/user/editSysUser',
 									userInfo, true)
 							},
 							fail: (error) => {
@@ -108,6 +102,45 @@
 						console.error('获取用户信息失败:', error);
 					}
 				})
+			},
+			//获取餐车信息
+			async initdining() {
+				const response = await this.$request('post', '/sale/diningCar/queryDiningCar', {
+					"isAsc": "desc",
+					"orderByColumn": "createTime"});
+				if(response.code == 200) {
+					let current;
+					if(response.rows.length > 0){
+						for(const item of response.rows){
+							if(item.defaultState == '2'){
+								current = item;
+								break
+							}
+						}
+					}
+					if(current) {
+						const carl = {
+							id: current.id,
+							customerPhone: current.customerPhone,
+							name: current.name,
+							openState: current.openState
+						}
+						uni.setStorageSync("carl", carl)
+						// 跳转到下一个页面
+						uni.switchTab({
+							url:'/pages/home/home'
+						})
+					}else{
+						uni.navigateTo({
+							url: `/pages/diningList/diningList`
+						});
+					}
+				}else{
+					wx.showModal({
+						title: '温馨提示',
+						content: '系统异常!',
+					})
+				}
 			}
 		}
 	}