2 Commity 8e3796f951 ... 7ac148d112

Autor SHA1 Wiadomość Data
  ymy 7ac148d112 Merge branch 'master' of http://47.107.53.207:3000/ymy/bc_wx_applet 9 miesięcy temu
  ymy 00912896f8 1 10 miesięcy temu

+ 1 - 1
env/dev.js

@@ -1,5 +1,5 @@
 const ENV_PATH = {
-  serverPath: 'http://47.107.53.207:8914', // 请求前缀地址
+  serverPath: 'https://www.boxuetech.top/ch/prod-api', // 请求前缀地址
   //serverFilePath: 'https://lsfdev.benyuntech.com/data/access', // 文件前缀地址
   appId: 'wxfc1ae62fd810717d', // 小程序 appid
   appName: '销售小程序', // 小程序名称(登录页面显示的名称)

+ 8 - 14
pages.json

@@ -7,18 +7,18 @@
 			}
 		},
 		{
-			"path": "pages/classify/classify",
+			"path": "pages/home/home",
 			"style": {
 				"navigationBarTitleText": "首页",
 				"enablePullDownRefresh": false
 			}
 		},
-		{
-			"path": "pages/index/index",
-			"style": {
-				"navigationBarTitleText": "首页"
-			}
-		},
+		// {
+		// 	"path": "pages/index/index",
+		// 	"style": {
+		// 		"navigationBarTitleText": "首页"
+		// 	}
+		// },
 		{
 			"path": "pages/user/user",
 			"style": {
@@ -126,17 +126,11 @@
 		"borderStyle": "black",
 		"backgroundColor": "#ffffff",
 		"list": [{
-				"pagePath": "pages/index/index",
+				"pagePath": "pages/home/home",
 				"iconPath": "static/ic_hone.png",
 				"selectedIconPath": "static/ic_hone.png",
 				"text": "首页"
 			},
-			// {
-			// 	"pagePath": "pages/classify/classify",
-			// 	"iconPath": "static/ic_hone.png",
-			// 	"selectedIconPath": "static/ic_hone.png",
-			// 	"text": "分类"
-			// },
 			{
 				"pagePath": "pages/index/home",
 				"iconPath": "static/ic_hone.png",

+ 2 - 2
pages/diningList/diningList.vue

@@ -96,8 +96,8 @@
 				}
 				uni.setStorageSync("carl", carl)
 				console.log('---------------------', carl)
-				uni.navigateTo({
-					url: `/pages/classify/classify`
+				uni.switchTab({
+					url: `/pages/home/home`
 				})
 			},
 			async fatchDate() {

+ 25 - 72
pages/classify/classify.vue → pages/home/home.vue

@@ -12,8 +12,9 @@
 				<view class="container">
 					<u-tag plain :text="cList.openState ? '营业中' : '离线'" :type="cList.openState ? 'success' : 'error'"
 						size="mini"></u-tag>
-					<view @click="btnIc">
-						<u-icon :label="cList.name" labelPos="left" size="16" name="arrow-down"></u-icon>
+					<view>
+						<text>{{cList.name}}</text>
+						<!-- <u-icon :label="cList.name" labelPos="left" size="16" name="arrow-down"></u-icon> -->
 					</view>
 				</view>
 				<u-col span="3">
@@ -43,6 +44,7 @@
 				</view>
 			</view>
 		</view>
+		<my-gap :height="10" />
 		<specPopup class='spec-box' ref="specPopup" :cardMsg="cardMsg" @update-shopmsg="handleUpdateShopMsg"
 			@addShop="carListMeg">
 		</specPopup>
@@ -56,8 +58,7 @@
 			<view class="balance dflex-c background-gradient" @click="toBuy">去结算</view>
 		</view>
 		<cartPopupVue ref="cartPopup" @selected-changed="handleSelectedChanged" />
-		<u-modal ref="uModal" :show="modalShow" :title="modalTitle" :content="modalContent" :closeable="true"
-			@close="modalClose" @confirm="confirm"></u-modal>
+
 	</view>
 </template>
 
@@ -80,56 +81,32 @@
 				iconPeople: iconPeople,
 				shoppingCart: shoppingCart,
 				tags: 1,
-				txts: 0,
-				carList: [],
+				txts: 1,
+				carList: {},
 				goods: [],
 				total: 0,
 				cList: {},
 				cardMsg: {},
 				selectedList: [],
-				buyCount: 0,
-				modalShow: false,
-				modalTitle: '您还未登录',
-				modalContent: '您是否确定要登录'
+				buyCount: 0
 			}
 		},
 		onLoad() {
-			const token = uni.getStorageSync('token')
-			if (token) {
-				const e = uni.getStorageSync('carl')
-				this.cList = e
-				this.fatchDate()
-				this.carListMeg()
-				this.tables()
-				uni.$on('register_refresh', () => {
-					this.fatchDate()
-					this.carListMeg()
-					this.tables()
-					this.total = 0
-				})
-			} else {
-				this.modalShow = true;
-			}
+			const e = uni.getStorageSync('carl')
+			this.cList = e
+			this.fatchDate()
+			this.carListMeg()
 		},
 		methods: {
-			modalClose() {
-				this.modalShow = false;
-			},
-			confirm() {
-				//调用登录方法,autoLogin方法在mian.js中
-				this.autoLogin()
-				this.modalShow = false
-			},
 			// 加购
 			goCart(e) {
-				// console.log('================', e)
 				this.cardMsg = e
 				this.$nextTick(() => {
 					this.$refs.specPopup.open();
 				});
 			},
 			handleSelectedChanged(selectedItems) {
-				//console.log('选中的数据:', selectedItems)
+				console.log('选中的数据:', selectedItems)
 				this.carList = selectedItems
 				this.carListMeg()
 				this.totalPrice()
@@ -157,6 +134,8 @@
 
 				// 将总价格转换回浮点数(以元为单位)
 				this.total = (total / 100).toFixed(2);
+
+				console.log('total', this.total);
 			},
 			showCart() {
 				this.$nextTick(() => {
@@ -169,47 +148,31 @@
 				})
 			},
 			toDetial(e) {
-				// console.log('eeeeee====================', e)
+				console.log('eeeeee====================', e)
 				const data = {
 					spuId: e.spuId,
 					tobyC: this.buyCount
 				}
 				uni.navigateTo({
-					url: `/pages/goodDetail/goodDetail?data=${encodeURIComponent(JSON.stringify(data))}`
+				  url: `/pages/goodDetail/goodDetail?data=${encodeURIComponent(JSON.stringify(data))}`
 				})
 			},
 			toBuy() {
-				// console.log('e========carList', this.carList)
-				const carlist = {
-					carlist: this.carList,
-					total: this.total
-				}
-				if (carlist.carlist.length <= 0) {
-					// this.$refs.uNotify.show({'请选择'})
-					uni.showToast({
-						title: '请选择',
-						icon: 'error',
-						duration: 2000
-					});
-				} else {
-					uni.navigateTo({
-						url: `/pages/order/submitOrder/submitOrder?data=${encodeURIComponent(JSON.stringify(carlist))}`
-					})
-					this.$nextTick(() => {
-						this.$refs.cartPopup.setShow(false)
-						this.total = 0
-					})
-				}
+				console.log('e========carList', this.carList)
+				// uni.navigateTo({
+				// 	url: `/pages/order/submitOrder/submitOrder`
+				// })
 			},
 			onOrder() {
 				uni.navigateTo({
-					url: `/pages/order/myOrder/myOrder?type=0`
+					url: `/pages/order/myOrder/myOrder`
 				})
 			},
 			onMyInfo() {
 				const info = {
 					customerPhone: this.cList.customerPhone
 				}
+				console.log('======================', info)
 				uni.setStorageSync("info", info)
 				uni.navigateTo({
 					url: `/pages/user/user`
@@ -220,16 +183,16 @@
 				var queryParmas = {
 					id: this.cList.id
 				}
-				// console.log('idididididid', queryParmas)
+				console.log('idididididid', queryParmas)
 				const result = await this.$request('post', '/sale/diningCarProduct/queryDiningCarProduct', queryParmas,
 					true)
 				if (result) {
-					// this.goods = result.rows
 					const queIds = new Set(result.rows.map(item => item.spuId));
 					const spuIds = Array.from(queIds).join(',');
 					const res = await this.$request('get', `/item/spu/queryByIds?spuIds=${spuIds}`)
 					const data = res.data
 					this.goods = data.filter(item => item.status !== 1)
+					console.log('res', res.data)
 				}
 			},
 			async carListMeg() {
@@ -240,16 +203,6 @@
 					const carList = res.data
 					this.buyCount = carList.length
 				}
-			},
-			async tables() {
-				const params = {
-					storeId: this.cList.id
-				}
-				const res = await this.$request('get', '/order/tradeOrder/queryTradeOrder', params)
-				if (res) {
-					console.log('result', res.rows)
-					this.txts = res.rows.length
-				}
 			}
 		}
 	}

+ 2 - 1
pages/index/index.vue

@@ -20,10 +20,11 @@
 				},{
 					img:'../../static/banner2.png'
 				}],
+				dinnerId:''
 			}
 		},
 		onLoad() {
-
+			this.dinnerId = uni.getStorageSync('dinnerId');
 		},
 		methods: {
 			searchClick(){

+ 31 - 124
pages/login/login.vue

@@ -1,118 +1,3 @@
-<!-- <template>
-	<view>
-		<image :src="src" class="img"></image>
-		<view class="btn">
-			<view style="width: 80%;">
-				<u-button v-if="canIUseGetUserProfile" shape="circle" color="linear-gradient(to right, #F54319, #FF6D20)"
-					@click="getUserProfile">选择餐车</u-button>
-			</view>
-		</view>
-	</view>
-</template>
-
-<script>
-	export default {
-		name: 'MyLogin',
-		data() {
-			return {
-				infoData: {},
-				src: '../../static/first.png',
-				userInfo: {},
-				hasUserInfo: false,
-				canIUseGetUserProfile: wx.getUserProfile ? true : false,
-			}
-		},
-		methods: {
-			getUserProfile() {
-				wx.login({
-					success: async (e) => {
-						console.log('数据:', e)
-						try {
-							const result = await this.$request('post', '/auth/miniLogin', {
-								tenantId: '000000',
-								clientId: '8871d05eacc4406083d3bb0a085b6999',
-								code: e.code
-							})
-							console.log('登录成功:', result);
-							if (result && result.result !== false) {
-								var token = result.data.accessToken;
-								var haveOpenid = result.data.openId;
-								var tenantId = result.data.tenantId
-								uni.setStorageSync("token", token);
-								wx.getUserProfile({
-									desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
-									success: (res) => {
-										this.setData({
-											userInfo: res.userInfo,
-											hasUserInfo: true
-										})
-									}
-								})
-								console.log('userInfo', this.userInfo)
-								uni.navigateTo({
-									url: `/pages/diningList/diningList`
-								});
-							} else {
-								// 处理错误情况
-							}
-						} catch (error) {
-							// 处理请求失败的情况
-							console.error('登录失败:', error);
-						}
-					}
-				})
-
-				// let that = this;
-				// wx.login({
-				// 	success: function(e) {
-				// 		console.log('数据:', e)
-
-				// 		uni.request({
-				// 			url: 'http://36.137.224.81:8030/auth/miniLogin?tenantId=000000&code=' + e
-				// 				.code,
-				// 			header: {
-				// 				"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8", //
-				// 				// "Content-Type": "application/json;charset=UTF-8", //
-				// 			},
-				// 			method: 'post',
-				// 			success: res => {
-				// 				console.log('登录成功:', res)
-				// 				uni.hideLoading()
-				// 				var token = res.data.data.accessToken;
-				// 				console.log('token:', token)
-				// 				uni.setStorageSync("token", token);
-				// 				uni.navigateTo({
-				// 					url: `/pages/classify/classify`
-				// 				})
-				// 				// if (res.data.code == 200) {
-				// 				// 	that.infoData = res.data.data
-				// 				// }
-				// 			},
-				// 			fail: err => {
-				// 				uni.hideLoading()
-				// 			}
-				// 		})
-				// 	}
-				// })
-
-			}
-		}
-	}
-</script>
-
-<style lang="scss" scoped>
-	.img {
-		height: 375px;
-		width: 100%;
-	}
-
-	.btn {
-		display: flex;
-		justify-content: center;
-		align-items: center;
-		margin-top: 20px;
-	}
-</style> -->
 <template>
 	<view>
 		<image :src="src" class="img"></image>
@@ -135,11 +20,33 @@
 				canIUseGetUserProfile: false,
 			}
 		},
-		onLoad() {
+		onLoad(e) {
 			// 检查微信版本是否支持 getUserProfile
 			if (wx.getUserProfile) {
 				this.canIUseGetUserProfile = true;
 			}
+			uni.setStorageSync('dinnerId', '1806258588536201217')
+			if(e.id){
+				uni.setStorageSync('dinnerId', e.id)
+			}
+			
+			let infoData = uni.getStorageSync('infoData');
+			if(infoData){
+				try{
+					infoData = JSON.parse(infoData)
+					// console.log('用户数据',infoData)
+					if (infoData.expire_in && Date.now() / 1000 - infoData.time > infoData.expire_in) {
+					  uni.removeStorageSync('infoData')
+					  return null
+					}
+					
+					if(infoData && infoData.access_token){
+						uni.switchTab({
+							url:'/pages/home/home'
+						})
+					}
+				}catch(e){}
+			}
 		},
 		methods: {
 			getUserProfile() {
@@ -158,13 +65,8 @@
 								// 发送code到开发者服务器换取用户信息
 								const result = await this.$request('post', '/auth/miniLogin', {
 									tenantId: '000000',
-									// clientId: 'e5cd7e4891bf95d1d19206ce24a7b32e',
 									code: loginRes.code
 								})
-								// headers: {
-								// 	isToken: false,
-								// 	repeatSubmit: false
-								// },
 									console.log('登录成功:', result);
 								if (result && result.data !== false) {
 									// 保存token
@@ -172,10 +74,15 @@
 									uni.setStorageSync("openId", result.data.open_id);
 									//uni.setStorageSync("tenantId", result.data.tenantId);
 									uni.setStorageSync("appUserId", result.data.app_user_id);
+									
+									let d = result.data;
+									d.time = Date.now() / 1000;
+									uni.setStorageSync('infoData', JSON.stringify(d))
+									
 									// 跳转到下一个页面
-									uni.navigateTo({
-										url: `/pages/diningList/diningList`
-									});
+									uni.switchTab({
+										url:'/pages/home/home'
+									})
 								} else {
 									// 处理错误情况
 								}

+ 1 - 1
pages/login/qrCode.vue

@@ -15,7 +15,7 @@ export default {
   methods: {
     async createQRCode() {
       // 生成二维码
-      const qrcode = await this.generateQRCode('pages/classify/classify');
+      const qrcode = await this.generateQRCode('pages/home/home');
       this.qrCodeImage = qrcode;
     },
     async generateQRCode(sceneStr) {