zs 1 سال پیش
والد
کامیت
deb22ede04
2فایلهای تغییر یافته به همراه59 افزوده شده و 42 حذف شده
  1. 6 6
      pages/my/index.vue
  2. 53 36
      pagesHome/login/index.vue

+ 6 - 6
pages/my/index.vue

@@ -55,7 +55,7 @@
 	};
 	// 公共跳转
 	const toCommon = (e) => {
-		// if (user.value && user.value._id) {
+		if (user.value && user.value._id) {
 			if (e) {
 				uni.navigateTo({
 					url: `/${e}`
@@ -68,11 +68,11 @@
 					})
 				} catch (e) { }
 			}
-		// } else {
-		// 	uni.navigateTo({
-		// 		url: `/pagesHome/login/index`
-		// 	})
-		// }
+		} else {
+			uni.navigateTo({
+				url: `/pagesHome/login/index`
+			})
+		}
 	};
 </script>
 <style lang="scss" scoped>

+ 53 - 36
pagesHome/login/index.vue

@@ -49,6 +49,8 @@
 <script setup lang="ts">
 	import moment from 'moment';
 	import { getCurrentInstance, computed, ref } from 'vue';
+	//该依赖已内置不需要单独安装
+	import { onShow, onPullDownRefresh } from "@dcloudio/uni-app";
 	// 请求接口
 	const $api = getCurrentInstance()?.appContext.config.globalProperties.$api;
 	// openid
@@ -100,45 +102,60 @@
 		]
 	}
 	const uForm = ref(null);
+	onShow(() => {
+		if (openid.value) search();
+	})
+	// 查询
+	const search = async () => {
+		const res = await $api(`login/wxapp/${openid.value}`, 'POST', {});
+		if (res.errcode == '0') {
+			form.value = res.data
+		} else {
+			uni.showToast({
+				title: res.errmsg,
+				icon: 'none'
+			})
+		}
+	};
 	// 开始验证
 	const formSubmit = () => {
 		if (agree.value) {
-			// if (openid.value) {
-			uForm.value.validate().then(async res => {
-				console.log(form.value);
-			}).catch(err => {
-				console.log(err, '校验失败');
-			})
-			// uni.getUserProfile({
-			// 	desc: '用于展示',
-			// 	success: async function (res) {
-			// 		let parmas = {
-			// 			openid: openid.value,
-			// 			nickname: res.userInfo.nickName + moment().valueOf()
-			// 		}
-			// 		const arr = await $api(`user`, 'POST', parmas);
-			// 		if (arr.errcode == '0') {
-			// 			uni.setStorageSync('user', arr.data);
-			// 			uni.navigateBack({
-			// 				delta: 1
-			// 			})
-			// 		} else {
-			// 			uni.showToast({
-			// 				title: arr.errmsg,
-			// 				icon: 'error'
-			// 			});
-			// 		}
-			// 	},
-			// 	fail: function (err) {
-			// 		console.log(err);
-			// 	}
-			// })
-			// } else {
-			// 	uni.showToast({
-			// 		title: '系统更新中,请稍后再试!',
-			// 		icon: 'none'
-			// 	})
-			// }
+			if (openid.value) {
+				uForm.value.validate().then(async res => {
+					console.log(form.value);
+					// uni.getUserProfile({
+					// 	desc: '用于展示',
+					// 	success: async function (res) {
+					// 		let parmas = {
+					// 			openid: openid.value,
+					// 			nickname: res.userInfo.nickName + moment().valueOf()
+					// 		}
+					// 		const arr = await $api(`user`, 'POST', parmas);
+					// 		if (arr.errcode == '0') {
+					// 			uni.setStorageSync('user', arr.data);
+					// 			uni.navigateBack({
+					// 				delta: 1
+					// 			})
+					// 		} else {
+					// 			uni.showToast({
+					// 				title: arr.errmsg,
+					// 				icon: 'error'
+					// 			});
+					// 		}
+					// 	},
+					// 	fail: function (err) {
+					// 		console.log(err);
+					// 	}
+					// })
+				}).catch(err => {
+					console.log(err, '校验失败');
+				})
+			} else {
+				uni.showToast({
+					title: '系统更新中,请稍后再试!',
+					icon: 'none'
+				})
+			}
 		} else {
 			uni.showToast({
 				title: '请阅读并同意用户协议和隐私政策',