jiuling 11 сар өмнө
parent
commit
be652d6784

+ 60 - 0
api/services/connect.js

@@ -10,6 +10,66 @@ import {
 import storage from "@/utils/storage.js";
 const request = http.request;
 
+/**
+ * 登出
+ * @returns {Promise} 登出结果
+ */
+export function webLogout() {
+    // 实际环境中应该调用后端登出接口
+	return http.request({
+		url: "/auth/logout",
+		method: Method.DELETE,
+		header: {
+		  'Authorization': `Bearer ${storage.getAccessToken()}`
+		},
+    //   success: (res) => {
+		  // console.log("退出登录请求",res);
+    //     if (res.data.code === 200) {
+    //       clearLoginState();
+    //       resolve(res);
+    //     } else {
+    //       reject(res.data.message || '登出失败');
+    //     }
+    //   },
+    //   fail: () => {
+    //     reject('网络错误,请稍后再试');
+    //   },
+    //   complete: () => {
+    //     // 无论成功失败都清除本地登录状态
+    //     clearLoginState();
+    //   }
+  });
+}
+/**
+ * H5用户手机号密码注册
+ * @param params
+ */
+export function register(params) {
+  return http.request({
+    url: "/auth/register",
+    method: Method.POST,
+    data:params,
+	header: {
+	'Client-Type':'H5',
+	},
+  });
+}
+
+/**
+ * H5用户手机号密码登录
+ * @param params
+ */
+export function phoneLogin(params) {
+  return http.request({
+    url: "/auth/login",
+    method: Method.POST,
+    data:params,
+	header: {
+	'Client-Type':'H5',
+	},
+  });
+}
+
 /**
  * 上传用户头像和昵称
  * @param params

+ 16 - 5
api/services/device.js

@@ -17,12 +17,13 @@ const userInfo = storage.getUserInfo()
 export function fetchDeviceOverview(fieldId) {
   const params = {};
   console.log("userInfo请求:",userInfo);
-  if (userInfo.userId) params.userId = userInfo.userId;
+  if (userInfo.userid) params.userId = userInfo.userid;
   if (fieldId) params.fieldId = fieldId;
   
   return http.request({
     url: 'uniapp/device/overview',
     method: Method.POST,
+	needToken: true,
     data: params
   });
 }
@@ -34,10 +35,11 @@ export function fetchDeviceOverview(fieldId) {
  * @returns {Promise} 设备列表
  */
 export function fetchDevicesByType(params) {
-if (userInfo.userId) params.userId = userInfo.userId;
+if (userInfo.userid) params.userId = userInfo.userid;
   return http.request({
     url: `uniapp/device/typeList`,
     method: Method.POST,
+	needToken: true,
     data: params
   });
 }
@@ -56,6 +58,7 @@ export function fetchDeviceList(params = {}) {
   return http.request({
     url: 'uniapp/device/list',
     method: Method.GET,
+	needToken: true,
     params: params
   });
 }
@@ -68,6 +71,7 @@ export function fetchDeviceList(params = {}) {
 export function getDeviceDetail(id) {
   return http.request({
     url: `uniapp/device/${id}`,
+	needToken: true,
     method: Method.GET
   });
 }
@@ -82,6 +86,7 @@ export function getDeviceCollectorDetail(deviceId, code) {
   return http.request({
     url: `uniapp/device/collector/detail/${deviceId}`,
     method: Method.GET,
+	needToken: true,
     params: code ? { code } : {}
   });
 }
@@ -95,6 +100,7 @@ export function addDevice(data) {
   return http.request({
     url: 'uniapp/device',
     method: Method.POST,
+	needToken: true,
     data: data
   });
 }
@@ -108,6 +114,7 @@ export function updateDevice(data) {
   return http.request({
     url: 'uniapp/device',
     method: Method.PUT,
+	needToken: true,
     data: data
   });
 }
@@ -121,6 +128,7 @@ export function deleteDevice(ids) {
   const idStr = Array.isArray(ids) ? ids.join(',') : ids;
   return http.request({
     url: `uniapp/device/${idStr}`,
+	needToken: true,
     method: Method.DELETE
   });
 }
@@ -138,7 +146,8 @@ export function fetchUserDeviceList(params = {}) {
     params: {
       ...params,
       userId: user.userId
-    }
+    },
+	needToken: true,
   });
 }
 
@@ -155,7 +164,8 @@ export function fetchFieldDeviceList(fieldId, params = {}) {
     params: {
       ...params,
       fieldId: fieldId
-    }
+    },
+	needToken: true
   });
 }
 
@@ -171,6 +181,7 @@ export function fetchDeviceTypeStats(fieldId) {
   return http.request({
     url: 'uniapp/device/stats/type',
     method: Method.GET,
-    params: params
+    params: params,
+	needToken: true,
   });
 } 

+ 7 - 3
api/services/field.js

@@ -17,8 +17,9 @@ export function fetchUserFieldList(pageNum = 1, pageSize = 10) {
 	return http.request({
 		url: 'uniapp/field/list/user',
 		method: Method.POST,
+		needToken: true,
 		data: {
-			userId: user.userId,
+			userId: user.userid,
 			params: {
 				pageNum: pageNum,
 				pageSize: pageSize
@@ -35,6 +36,7 @@ export function listFieldName(userId) {
 	return http.request({
 		url: `uniapp/field/name/${userId}`,
 		method: Method.GET,
+		needToken: true
 	});
 }
 
@@ -48,8 +50,9 @@ export function searchUserField(data) {
 	return http.request({
 		url: 'uniapp/field/search/user',
 		method: Method.POST,
+		needToken: true,
 		data:{
-			userId: user.userId,
+			userId: user.userid,
 			params: {
 				keyword:data.keyword,
 				pageNum: data.pageNum,
@@ -65,7 +68,8 @@ export function searchUserField(data) {
 export function countUserPlots() {
 	const user = storage.getUserInfo();
 	return http.request({
-		url: `uniapp/field/count/${user.userId}`,
+		url: `uniapp/field/count/${user.userid}`,
+		needToken: true,
 		method: Method.GET,
 	});
 }

+ 1 - 1
config/api.js

@@ -7,7 +7,7 @@ const dev = {
   // im: "https://im-api.pickmall.cn",
   dify: "http://localhost:9203",
   common: "https://common-api.pickmall.cn",
-  buyer: "http://localhost:8080",
+  buyer: "http://192.168.0.108:8080",
   // common: "http://192.168.0.113:8890",
   // buyer: "http://192.168.0.113:8888",
   // im: "http://192.168.0.113:8885",

+ 6 - 1
manifest.json

@@ -18,5 +18,10 @@
             "urlCheck" : false
         }
     },
-	"vueVersion": "2"
+    "vueVersion" : "2",
+    "h5" : {
+        "devServer" : {
+            "port" : 9000
+        }
+    }
 }

+ 14 - 0
pages.json

@@ -15,6 +15,20 @@
 	    "navigationStyle": "custom"
 	  }
 	},
+  {
+	  "path": "pages/login/register",
+	  "style": {
+	    "navigationBarTitleText": "注册",
+	    "navigationStyle": "custom"
+	  }
+	},
+	{
+		  "path": "pages/login/forget-password",
+		  "style": {
+		    "navigationBarTitleText": "忘记密码",
+		    "navigationStyle": "custom"
+		  }
+		},
 	{
 	  "path": "pages/userInfo/index",
 	  "style": {

+ 1 - 1
pages/dashboard/index.vue

@@ -641,7 +641,7 @@
 			console.log("userInfo", userInfo);
 			this.userData.nickname = userInfo.nickName || '未登录'
 			this.userData.avatar = userInfo.avatar || '/static/icons/user_icon.png'
-			this.userData.userId = userInfo.userId
+			this.userData.userId = userInfo.userid
 			
 			if(storage.getHasLogin()){
 				this.isLogin = true;

+ 5 - 4
pages/device/device-list/detail-camera.vue

@@ -249,7 +249,7 @@ export default {
         deviceType: 'weather' ,// 默认类型,会根据API返回更新
       	deviceTypeId:null,
 		streamUrl: '',
-        originalStreamUrl: 'ws://121.4.16.100:6080/rtp/34020000001110000001_34020000001320000012.live.flv',
+        originalStreamUrl: 'http://121.4.16.100:6080/rtp/34020000001110000001_34020000001320000012.live.flv',
 
       },
       isPlaying: false,
@@ -270,6 +270,7 @@ export default {
       // 模拟告警数据
       alertHistory: [],
       livePlayerContext: null, // 小程序视频上下文
+	  isRefreshing: false
     }
   },
   
@@ -281,9 +282,9 @@ export default {
     // 获取H5环境使用的流地址
     getH5StreamUrl() {
       // 首先尝试使用设备返回的流URL
-      if (this.deviceInfo.streamUrl) {
-        return this.deviceInfo.streamUrl;
-      }
+      // if (this.deviceInfo.streamUrl) {
+      //   return this.deviceInfo.streamUrl;
+      // }
       
       // 如果没有设备特定的URL,则使用默认原始流
       return this.deviceInfo.originalStreamUrl || config.streamServer.wsFlvServer;

+ 165 - 42
pages/login/forget-password.vue

@@ -70,18 +70,34 @@
         </view>
       </view>
       
-      <button class="submit-btn" @click="handleResetPassword">重置密码</button>
+      <button class="submit-btn" @click="handleResetPassword" :loading="isSubmitting">重置密码</button>
       
       <view class="login-link">
         <text>记得密码?</text>
         <text class="link" @click="navigateToLogin">立即登录</text>
       </view>
     </view>
+
+    <!-- #ifdef MP-WEIXIN -->
+    <view class="wechat-tip">
+      <text>微信用户可直接使用微信登录</text>
+      <button class="wechat-btn" @click="navigateToLogin">
+        <text class="wechat-icon">微</text>
+        <text>返回登录</text>
+      </button>
+    </view>
+    <!-- #endif -->
+    
+    <view class="notice">
+      <text class="notice-title">温馨提示</text>
+      <text class="notice-text">密码重置后,将使用新密码登录系统,请妥善保管您的密码。如有问题请联系客服。</text>
+    </view>
   </view>
 </template>
 
 <script>
-import { resetPassword, sendVerificationCode } from '@/api/services/auth.js';
+import storage from "@/utils/storage.js";
+// import { resetPassword, sendVerificationCode } from '@/api/services/auth.js';
 
 export default {
   data() {
@@ -96,7 +112,8 @@ export default {
       showConfirmPassword: false,
       codeBtnText: '获取验证码',
       codeBtnDisabled: false,
-      countdown: 60
+      countdown: 60,
+      isSubmitting: false
     }
   },
   methods: {
@@ -134,27 +151,39 @@ export default {
       // 发送验证码请求
       uni.showLoading({ title: '发送中...' })
       
-      // 使用授权服务发送验证码
-      sendVerificationCode({
-        phone: this.formData.phone,
-        type: 'reset'
-      })
-        .then(() => {
-          uni.showToast({
-            title: '验证码已发送',
-            icon: 'success'
-          });
-          this.startCountdown();
-        })
-        .catch(error => {
+      // 调用发送验证码接口
+      uni.request({
+        url: 'API_URL/user/sendCode', // 替换为实际接口地址
+        method: 'POST',
+        data: {
+          phone: this.formData.phone,
+          type: 'reset'
+        },
+        success: (res) => {
+          if (res.data.code === 200) {
+            uni.showToast({
+              title: '验证码已发送',
+              icon: 'success'
+            });
+            this.startCountdown();
+          } else {
+            uni.showToast({
+              title: res.data.msg || '发送失败,请稍后重试',
+              icon: 'none'
+            });
+          }
+        },
+        fail: (err) => {
           uni.showToast({
-            title: error,
+            title: '网络异常,请稍后重试',
             icon: 'none'
           });
-        })
-        .finally(() => {
+          console.error(err);
+        },
+        complete: () => {
           uni.hideLoading();
-        });
+        }
+      });
     },
     startCountdown() {
       this.codeBtnDisabled = true
@@ -226,35 +255,50 @@ export default {
     handleResetPassword() {
       if (!this.validateForm()) return
       
+      this.isSubmitting = true;
+      
       // 调用重置密码接口
       uni.showLoading({ title: '提交中...' })
       
-      // 使用授权服务重置密码
-      resetPassword({
-        phone: this.formData.phone,
-        code: this.formData.code,
-        password: this.formData.password
-      })
-        .then(() => {
-          uni.showToast({
-            title: '密码重置成功',
-            icon: 'success'
-          });
-          
-          // 延迟跳转到登录页
-          setTimeout(() => {
-            uni.navigateBack();
-          }, 1500);
-        })
-        .catch(error => {
+      // 调用重置密码接口
+      uni.request({
+        url: 'API_URL/user/resetPassword', // 替换为实际接口地址
+        method: 'POST',
+        data: {
+          phone: this.formData.phone,
+          code: this.formData.code,
+          password: this.formData.password
+        },
+        success: (res) => {
+          if (res.data.code === 200) {
+            uni.showToast({
+              title: '密码重置成功',
+              icon: 'success'
+            });
+            
+            // 延迟跳转到登录页
+            setTimeout(() => {
+              uni.navigateBack();
+            }, 1500);
+          } else {
+            uni.showToast({
+              title: res.data.msg || '重置失败,请稍后重试',
+              icon: 'none'
+            });
+          }
+        },
+        fail: (err) => {
           uni.showToast({
-            title: error,
+            title: '网络异常,请稍后重试',
             icon: 'none'
           });
-        })
-        .finally(() => {
+          console.error(err);
+        },
+        complete: () => {
           uni.hideLoading();
-        });
+          this.isSubmitting = false;
+        }
+      });
     }
   }
 }
@@ -368,4 +412,83 @@ export default {
   color: #4CAF50;
   margin-left: 10rpx;
 }
+
+/* 微信提示区域 */
+.wechat-tip {
+  margin-top: 60rpx;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+}
+
+.wechat-tip text {
+  font-size: 28rpx;
+  color: #666;
+  margin-bottom: 20rpx;
+}
+
+.wechat-btn {
+  width: 80%;
+  height: 90rpx;
+  background-color: #07C160;
+  color: #fff;
+  border-radius: 45rpx;
+  font-size: 32rpx;
+  font-weight: bold;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  border: none;
+  padding: 0;
+}
+
+.wechat-icon {
+  width: 40rpx;
+  height: 40rpx;
+  background-color: rgba(255, 255, 255, 0.2);
+  color: #fff;
+  border-radius: 20rpx;
+  font-size: 20rpx;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  margin-right: 10rpx;
+}
+
+/* 提示区域 */
+.notice {
+  margin-top: 60rpx;
+  padding: 30rpx;
+  background-color: #F5F5F5;
+  border-radius: 16rpx;
+}
+
+.notice-title {
+  font-size: 30rpx;
+  color: #333;
+  font-weight: bold;
+  margin-bottom: 10rpx;
+  display: block;
+}
+
+.notice-text {
+  font-size: 24rpx;
+  color: #666;
+  line-height: 1.6;
+}
+
+/* #ifdef H5 */
+/* H5特殊样式调整 */
+@media screen and (min-width: 768px) {
+  .forget-form {
+    max-width: 600rpx;
+    margin: 0 auto;
+  }
+  
+  .notice {
+    max-width: 600rpx;
+    margin: 60rpx auto 0;
+  }
+}
+/* #endif */
 </style> 

+ 203 - 7
pages/login/index.vue

@@ -14,11 +14,48 @@
 		</view>
 
 		<view class="login-section">
+			<!-- #ifdef H5 -->
+			<view class="form-container">
+				<view class="input-group">
+					<input type="text" v-model="phoneNumber" placeholder="请输入手机号" class="input-field" />
+				</view>
+				<view class="input-group">
+					<input type="password" v-model="password" placeholder="请输入密码" class="input-field" />
+				</view>
+				<!-- <view class="form-actions">
+					<text class="forgot-password" @click="navigateToForgetPassword">忘记密码?</text>
+				</view> -->
+				<button type="primary" class="login-btn" @click="handlePhoneLogin">登录</button>
+				<view class="register-link">
+					还没有账号?<text class="link" @click="navigateToRegister">立即注册</text>
+				</view>
+			</view>
+			<!-- #endif -->
 
+			<!-- #ifdef MP-WEIXIN -->
 			<button type="primary" class="wechat-login-btn" bindtap="getUserProfile" @click="getUserProfile()">
 				<view class="wechat-icon">微</view>
 				<text>一键登录</text>
 			</button>
+			<!-- #endif -->
+
+			<!-- #ifdef APP-PLUS -->
+			<view class="form-container">
+				<view class="input-group">
+					<input type="text" v-model="phoneNumber" placeholder="请输入手机号" class="input-field" />
+				</view>
+				<view class="input-group">
+					<input type="password" v-model="password" placeholder="请输入密码" class="input-field" />
+				</view>
+				<view class="form-actions">
+					<text class="forgot-password" @click="navigateToForgetPassword">忘记密码?</text>
+				</view>
+				<button type="primary" class="login-btn" @click="handlePhoneLogin">登录</button>
+				<view class="register-link">
+					还没有账号?<text class="link" @click="navigateToRegister">立即注册</text>
+				</view>
+			</view>
+			<!-- #endif -->
 		</view>
 
 		<view class="privacy-agreement">
@@ -35,7 +72,7 @@
 
 <script>
 	import {
-		mpAutoLogin
+		mpAutoLogin, phoneLogin
 	} from "@/api/services/connect.js";
 	import storage from "@/utils/storage.js";
 	export default {
@@ -53,7 +90,11 @@
 				nickName: "",
 				//微信头像
 				avatarUrl: "",
-				gender: ""
+				gender: "",
+				// H5登录信息
+				phoneNumber: "",
+				password: "",
+				loading: false
 			}
 		},
 		onLoad() {
@@ -61,6 +102,8 @@
 			// if (isLoggedIn()) {
 			// 	this.redirectToHome();
 			// }
+
+			// #ifdef MP-WEIXIN
 			//获取code
 			uni.login({
 				success: (res) => {
@@ -73,6 +116,7 @@
 					}
 				},
 			});
+			// #endif
 		},
 		methods: {
 			goBack() {
@@ -93,12 +137,96 @@
 					url: '/pages/privacy/index'
 				});
 			},
+			navigateToForgetPassword() {
+				uni.navigateTo({
+					url: '/pages/login/forget-password'
+				});
+			},
+			navigateToRegister() {
+				uni.navigateTo({
+					url: '/pages/login/register'
+				});
+			},
 			showAgreementWarning() {
 				uni.showToast({
 					title: '请同意用户协议和隐私政策',
 					icon: 'none'
 				});
 			},
+			// H5平台手机号密码登录方法
+			handlePhoneLogin() {
+				if (!this.agreed) {
+					uni.showToast({
+						title: "请同意用户协议和隐私政策",
+						icon: 'none'
+					})
+					return
+				}
+
+				if (!this.phoneNumber || !this.password) {
+					uni.showToast({
+						title: "请输入手机号和密码",
+						icon: 'none'
+					})
+					return
+				}
+
+				// 手机号验证
+				if (!/^1\d{10}$/.test(this.phoneNumber)) {
+					uni.showToast({
+						title: "请输入正确的手机号",
+						icon: 'none'
+					})
+					return
+				}
+
+				this.loading = true;
+				uni.showLoading({ title: '登录中...' })
+				const data = {
+					username: this.phoneNumber,
+					password: this.password,
+					phoneNumber:this.phoneNumber,
+				}
+				phoneLogin(data).then(res => {
+						console.log("res登录", res);
+						if (res.data.code === 200) {
+							// 登录成功
+							storage.setAccessToken(res.data.data.access_token);
+							storage.setUserInfo(res.data.data.userInfo);
+							storage.setHasLogin(true);
+
+							uni.showToast({
+								title: "登录成功!",
+								icon: "success",
+							});
+
+							// 登录成功后返回或跳转到首页
+							setTimeout(() => {
+								uni.navigateBack({
+									delta: 1,
+								});
+							}, 1500);
+						} else {
+							// 登录失败
+							uni.showToast({
+								title: res.data.msg || "登录失败,请检查账号密码",
+								icon: 'none'
+							});
+						}
+					})
+					.catch(err => {
+						uni.showToast({
+							title: "网络异常,请稍后重试",
+							icon: 'none'
+						});
+						console.error(err);
+					})
+					.finally(() => {
+						uni.hideLoading();
+						this.loading = false;
+					});
+			},
+			// 微信小程序登录方法
 			getUserProfile(e) {
 				if (!this.agreed) {
 					uni.showToast({
@@ -109,6 +237,7 @@
 				}
 				this.logingFlag = true;
 
+				// #ifdef MP-WEIXIN
 				if (this.code) {
 					// 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认
 					uni.getUserProfile({
@@ -147,12 +276,12 @@
 								storage.setUserInfo(apiRes.data.data.userInfo);
 								storage.setHasLogin(true);
 								// 用户手动授权头像昵称
-								if(apiRes.data.data.isNewUser){
+								if (apiRes.data.data.isNewUser) {
 									// 新用户跳转上传头像昵称界面
 									uni.navigateTo({
 										url: `/pages/userInfo/index?openId=${apiRes.data.data.userInfo.openId}`
 									});
-								}else{
+								} else {
 									// 老用户直接跳转首页
 									// wx.switchTab({
 									// 	url: '/pages/user/index'
@@ -171,6 +300,7 @@
 
 					this.logingFlag = false;
 				}
+				// #endif
 			},
 			redirectToHome() {
 				uni.navigateBack();
@@ -215,20 +345,20 @@
 		display: flex;
 		flex-direction: column;
 		align-items: center;
-		/* margin-bottom: 60rpx; */
+		margin-bottom: 60rpx;
 	}
 
 	.logo {
 		width: 150rpx;
 		height: 150rpx;
-		/* margin-bottom: 20rpx; */
+		margin-bottom: 20rpx;
 	}
 
 	.app-name {
 		font-size: 48rpx;
 		font-weight: bold;
 		color: #4CAF50;
-		/* margin-bottom: 10rpx; */
+		margin-bottom: 10rpx;
 	}
 
 	.app-slogan {
@@ -242,6 +372,61 @@
 		align-items: center;
 		padding: 20rpx 0;
 		position: relative;
+		width: 100%;
+	}
+
+	/* H5和APP表单样式 */
+	.form-container {
+		width: 100%;
+		margin-bottom: 30rpx;
+	}
+
+	.input-group {
+		margin-bottom: 30rpx;
+		width: 100%;
+	}
+
+	.input-field {
+		width: 100%;
+		height: 90rpx;
+		border-radius: 45rpx;
+		padding: 0 30rpx;
+		box-sizing: border-box;
+		background-color: #f5f5f5;
+		font-size: 28rpx;
+	}
+
+	.form-actions {
+		display: flex;
+		justify-content: flex-end;
+		margin-bottom: 30rpx;
+	}
+
+	.forgot-password {
+		font-size: 24rpx;
+		color: #666;
+	}
+
+	.login-btn {
+		width: 100%;
+		height: 90rpx;
+		background-color: #4CAF50;
+		color: #fff;
+		border-radius: 45rpx;
+		font-size: 32rpx;
+		font-weight: bold;
+		display: flex;
+		align-items: center;
+		justify-content: center;
+		border: none;
+		margin-bottom: 30rpx;
+	}
+
+	.register-link {
+		font-size: 24rpx;
+		color: #666;
+		text-align: center;
+		margin-top: 20rpx;
 	}
 
 	.login-bg {
@@ -301,4 +486,15 @@
 	.link {
 		color: #4CAF50;
 	}
+
+	/* #ifdef H5 */
+	/* H5特殊样式调整 */
+	@media screen and (min-width: 768px) {
+		.form-container {
+			max-width: 500rpx;
+			margin: 0 auto;
+		}
+	}
+
+	/* #endif */
 </style>

+ 178 - 81
pages/login/register.vue

@@ -20,7 +20,7 @@
         </view>
       </view>
       
-      <view class="form-group">
+<!--      <view class="form-group">
         <view class="input-group">
           <text class="input-icon">验</text>
           <input 
@@ -38,7 +38,7 @@
             {{ codeBtnText }}
           </text>
         </view>
-      </view>
+      </view> -->
       
       <view class="form-group">
         <view class="input-group">
@@ -82,7 +82,7 @@
         </view>
       </view>
       
-      <button class="register-btn" @click="handleRegister">立即注册</button>
+      <button class="register-btn" @click="handleRegister" :loading="isSubmitting">立即注册</button>
       
       <view class="login-link">
         <text>已有账号?</text>
@@ -99,11 +99,22 @@
         <text class="link" @click="navigateToPrivacy">隐私政策</text>
       </text>
     </view>
+
+    <!-- #ifdef MP-WEIXIN -->
+    <view class="wechat-register-tip">
+      <text>推荐使用微信一键登录</text>
+      <button class="wechat-register-btn" @click="navigateToLogin">
+        <text class="wechat-icon">微</text>
+        <text>一键登录</text>
+      </button>
+    </view>
+    <!-- #endif -->
   </view>
 </template>
 
 <script>
-import { register, sendVerificationCode } from '@/api/services/auth.js';
+import storage from "@/utils/storage.js";
+import { register } from '@/api/services/connect.js';
 
 export default {
   data() {
@@ -120,7 +131,8 @@ export default {
       agreed: true,
       codeBtnText: '获取验证码',
       codeBtnDisabled: false,
-      countdown: 60
+      countdown: 60,
+      isSubmitting: false
     }
   },
   methods: {
@@ -149,50 +161,62 @@ export default {
         url: '/pages/privacy/index'
       })
     },
-    getVerificationCode() {
-      if (this.codeBtnDisabled) return
+    // getVerificationCode() {
+    //   if (this.codeBtnDisabled) return
       
-      if (!this.formData.phone) {
-        uni.showToast({
-          title: '请输入手机号',
-          icon: 'none'
-        })
-        return
-      }
+    //   if (!this.formData.phone) {
+    //     uni.showToast({
+    //       title: '请输入手机号',
+    //       icon: 'none'
+    //     })
+    //     return
+    //   }
       
-      if (!/^1\d{10}$/.test(this.formData.phone)) {
-        uni.showToast({
-          title: '请输入正确的手机号',
-          icon: 'none'
-        })
-        return
-      }
+    //   if (!/^1\d{10}$/.test(this.formData.phone)) {
+    //     uni.showToast({
+    //       title: '请输入正确的手机号',
+    //       icon: 'none'
+    //     })
+    //     return
+    //   }
       
-      // 发送验证码请求
-      uni.showLoading({ title: '发送中...' })
+    //   // 发送验证码请求
+    //   uni.showLoading({ title: '发送中...' })
       
-      // 使用授权服务发送验证码
-      sendVerificationCode({
-        phone: this.formData.phone,
-        type: 'register'
-      })
-        .then(() => {
-          uni.showToast({
-            title: '验证码已发送',
-            icon: 'success'
-          });
-          this.startCountdown();
-        })
-        .catch(error => {
-          uni.showToast({
-            title: error,
-            icon: 'none'
-          });
-        })
-        .finally(() => {
-          uni.hideLoading();
-        });
-    },
+    //   // 调用发送验证码接口
+    //   uni.request({
+    //     url: 'API_URL/user/sendCode', // 替换为实际接口地址
+    //     method: 'POST',
+    //     data: {
+    //       phone: this.formData.phone,
+    //       type: 'register'
+    //     },
+    //     success: (res) => {
+    //       if (res.data.code === 200) {
+    //         uni.showToast({
+    //           title: '验证码已发送',
+    //           icon: 'success'
+    //         });
+    //         this.startCountdown();
+    //       } else {
+    //         uni.showToast({
+    //           title: res.data.msg || '发送失败,请稍后重试',
+    //           icon: 'none'
+    //         });
+    //       }
+    //     },
+    //     fail: (err) => {
+    //       uni.showToast({
+    //         title: '网络异常,请稍后重试',
+    //         icon: 'none'
+    //       });
+    //       console.error(err);
+    //     },
+    //     complete: () => {
+    //       uni.hideLoading();
+    //     }
+    //   });
+    // },
     startCountdown() {
       this.codeBtnDisabled = true
       this.codeBtnText = `${this.countdown}秒`
@@ -226,13 +250,13 @@ export default {
         return false
       }
       
-      if (!this.formData.code) {
-        uni.showToast({
-          title: '请输入验证码',
-          icon: 'none'
-        })
-        return false
-      }
+      // if (!this.formData.code) {
+      //   uni.showToast({
+      //     title: '请输入验证码',
+      //     icon: 'none'
+      //   })
+      //   return false
+      // }
       
       if (!this.formData.password) {
         uni.showToast({
@@ -271,36 +295,58 @@ export default {
         return
       }
       
+      this.isSubmitting = true;
+      
       // 调用注册接口
       uni.showLoading({ title: '注册中...' })
-      
-      // 使用授权服务注册
-      register({
-        phone: this.formData.phone,
-        code: this.formData.code,
-        password: this.formData.password,
-        nickname: this.formData.nickname || `用户${this.formData.phone.substr(-4)}`
-      })
-        .then(() => {
-          uni.showToast({
-            title: '注册成功',
-            icon: 'success'
-          });
-          
-          // 延迟跳转到登录页
-          setTimeout(() => {
-            uni.navigateBack();
-          }, 1500);
-        })
-        .catch(error => {
-          uni.showToast({
-            title: error,
-            icon: 'none'
-          });
-        })
-        .finally(() => {
-          uni.hideLoading();
-        });
+	  
+      const data = {
+          phoneNumber: this.formData.phone,
+          password: this.formData.password,
+          username: this.formData.nickname || `用户${this.formData.phone.substr(-4)}`
+        }
+		
+      // 调用注册接口
+	  register(data)
+	    .then(res => {
+			console.log("res注册",res);
+	      if (res.data.code === 200) {
+	        uni.showToast({
+	          title: '注册成功',
+	          icon: 'success'
+	        });
+	        storage.setUserInfo(data);
+	        // 自动登录
+	        // if (res.data.data && res.data.data.token) {
+	        //   storage.setAccessToken(res.data.data.token);
+	        //   storage.setUserInfo(data);
+	        //   storage.setHasLogin(true);
+	        // }
+	        
+	        // 延迟跳转到登录页或首页
+	        setTimeout(() => {
+	          uni.navigateBack({
+	            delta: 1,
+	          });
+	        }, 1500);
+	      } else {
+	        uni.showToast({
+	          title: res.data.msg || '注册失败,请稍后重试',
+	          icon: 'none'
+	        });
+	      }
+	    })
+	    .catch(err => {
+	      uni.showToast({
+	        title: '网络异常,请稍后重试',
+	        icon: 'none'
+	      });
+	      console.error(err);
+	    })
+	    .finally(() => {
+	      uni.hideLoading();
+	      this.isSubmitting = false;
+	    });
     }
   }
 }
@@ -419,7 +465,6 @@ export default {
   display: flex;
   align-items: center;
   justify-content: center;
-  margin-top: auto;
   padding: 40rpx 0;
 }
 
@@ -428,4 +473,56 @@ export default {
   color: #666;
   margin-left: 10rpx;
 }
+
+/* 微信注册提示 */
+.wechat-register-tip {
+  margin-top: 40rpx;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+}
+
+.wechat-register-tip text {
+  font-size: 28rpx;
+  color: #666;
+  margin-bottom: 20rpx;
+}
+
+.wechat-register-btn {
+  width: 80%;
+  height: 90rpx;
+  background-color: #07C160;
+  color: #fff;
+  border-radius: 45rpx;
+  font-size: 32rpx;
+  font-weight: bold;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  border: none;
+  padding: 0;
+}
+
+.wechat-icon {
+  width: 40rpx;
+  height: 40rpx;
+  background-color: rgba(255, 255, 255, 0.2);
+  color: #fff;
+  border-radius: 20rpx;
+  font-size: 20rpx;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  margin-right: 10rpx;
+}
+
+/* #ifdef H5 */
+/* H5特殊样式调整 */
+@media screen and (min-width: 768px) {
+  .register-form {
+    max-width: 600rpx;
+    margin: 0 auto;
+  }
+}
+/* #endif */
 </style> 

+ 25 - 3
pages/user/index.vue

@@ -6,7 +6,7 @@
 				<image class="avatar" :src="userInfo.avatar || '/static/icons/user_icon.png'"></image>
 				<view class="user-detail" v-if="isLogin">
 					<text class="nickname">{{userInfo.nickName}}</text>
-					<text class="user-id">性别: {{userInfo.sex == '0' ? '男' :'女' || '未知'}}</text>
+					<!-- <text class="user-id">性别: {{userInfo.sex == '0' ? '男' :'女' || '未知'}}</text> -->
 				</view>
 				<view class="user-detail" v-else>
 					<text class="login-text" @click="navigateToLogin">登录/注册</text>
@@ -90,7 +90,7 @@
 
 <script>
 	import {
-		logout
+		logout, webLogout
 	} from '@/api/services/connect.js';
 	import {
 		countUserPlots
@@ -170,7 +170,7 @@
 					console.log("执行Show",userInfo);
 					if (userInfo) {
 						this.userInfo = {
-							nickName: userInfo.nickName || '游客',
+							nickName: userInfo.username || '游客',
 							avatar: userInfo.avatar || '/static/icons/user_icon.png',
 							sex:userInfo.sex
 						};
@@ -216,6 +216,27 @@
 					content: '确认退出登录?',
 					success: (res) => {
 						if (res.confirm) {
+							// #ifdef H5
+							webLogout().then(res=>{
+								console.log("tuichu",res);
+								storage.setAccessToken("");
+								storage.setUserInfo({});
+								storage.setHasLogin(false)
+								this.isLogin = false;
+								this.userInfo = {
+									nickname: '游客',
+									id: '',
+									avatar: ''
+								};
+								this.plotInfo = {
+									total: 0,
+									active: 0,
+									idle: 0
+								}
+							})
+							// #endif
+							
+							// #ifdef APP-PLUS
 							logout().then(() => {
 								this.isLogin = false;
 								this.userInfo = {
@@ -224,6 +245,7 @@
 									avatar: '/static/icons/user_icon'
 								};
 							});
+							// #endif
 						}
 					}
 				})