| 1 | <template> | 1 | <template> | 
| 2 | -  <view class="login-page"> |  |  | 
| 3 | -    <!-- 公共组件-每个页面必须引入 --> |  |  | 
| 4 | - |  |  | 
| 5 | -    <public-module></public-module> |  |  | 
| 6 | - |  |  | 
| 7 | -    <view class="u-flex login-main"> |  |  | 
| 8 | -      <view class="content"> |  |  | 
| 9 | -        <view class="hello login-text-muted">您好,</view> |  |  | 
| 10 | - |  |  | 
| 11 | -        <view class="hello-welcome login-text-muted">欢迎来到ThingsKit!</view> |  |  | 
| 12 | -      </view> |  |  | 
| 13 | -    </view> |  |  | 
| 14 | - |  |  | 
| 15 | -    <view class="f__login"> |  |  | 
| 16 | -      <view class="loginPhone"> |  |  | 
| 17 | -        <view class="form-row u-flex"> |  |  | 
| 18 | -          <view class="v-input" |  |  | 
| 19 | -            ><input |  |  | 
| 20 | -              type="text" |  |  | 
| 21 | -              v-model="loginForm.username" |  |  | 
| 22 | -              maxlength="32" |  |  | 
| 23 | -              placeholder="请输入登录账号" |  |  | 
| 24 | -          /></view> |  |  | 
| 25 | - |  |  | 
| 26 | -          <u-icon></u-icon> |  |  | 
| 27 | -        </view> |  |  | 
| 28 | - |  |  | 
| 29 | -        <view class="form-row u-flex"> |  |  | 
| 30 | -          <view class="v-input" |  |  | 
| 31 | -            ><input |  |  | 
| 32 | -              type="text" |  |  | 
| 33 | -              v-model="loginForm.password" |  |  | 
| 34 | -              maxlength="32" |  |  | 
| 35 | -              placeholder="请输入登录密码" |  |  | 
| 36 | -              :password="!showPassword" |  |  | 
| 37 | -          /></view> |  |  | 
| 38 | - |  |  | 
| 39 | -          <view class="v-password" @click="showPasswordMode"> |  |  | 
| 40 | -            <u-icon |  |  | 
| 41 | -              color="#9a9a9a" |  |  | 
| 42 | -              width="18" |  |  | 
| 43 | -              height="15" |  |  | 
| 44 | -              :name="showPassword ? '/static/eye.png' : '/static/eye-hide.png'" |  |  | 
| 45 | -            ></u-icon> |  |  | 
| 46 | -          </view> |  |  | 
| 47 | - |  |  | 
| 48 | -          <u-icon></u-icon> |  |  | 
| 49 | -        </view> |  |  | 
| 50 | - |  |  | 
| 51 | -        <button class="submit" size="default" @click="onSubmitFunc"> |  |  | 
| 52 | -          <text class="text">登录</text> |  |  | 
| 53 | -        </button> |  |  | 
| 54 | - |  |  | 
| 55 | -        <view class="u-flex row-item"> |  |  | 
| 56 | -          <view class="row-phone login-text-gray" @click="openCodeFunc" |  |  | 
| 57 | -            >手机验证码登录</view |  |  | 
| 58 | -          > |  |  | 
| 59 | - |  |  | 
| 60 | -          <view class="row-reset login-text-gray" @click="findPassrordFunc" |  |  | 
| 61 | -            >忘记密码</view |  |  | 
| 62 | -          > |  |  | 
| 63 | -        </view> |  |  | 
| 64 | - |  |  | 
| 65 | -        <view class="u-flex link-login"> |  |  | 
| 66 | -          <view class="link-text login-text-gray">第三方账号登录</view> |  |  | 
| 67 | - |  |  | 
| 68 | -          <view style="height: 20rpx"></view> |  |  | 
| 69 | - |  |  | 
| 70 | -          <button class="link-image" @tap="onWenxinAuthorization"> |  |  | 
| 71 | -            <image |  |  | 
| 72 | -              class="image" |  |  | 
| 73 | -              src="../../static/weixin.png" |  |  | 
| 74 | -              mode="aspectFill" |  |  | 
| 75 | -            ></image> |  |  | 
| 76 | -          </button> |  |  | 
| 77 | -        </view> |  |  | 
| 78 | -      </view> |  |  | 
| 79 | -    </view> |  |  | 
| 80 | -  </view> |  |  | 
| 81 | -</template> |  |  | 
| 82 | - |  |  | 
| 83 | -<script> |  |  | 
| 84 | -import { mapMutations, mapActions } from "vuex"; |  |  | 
| 85 | - |  |  | 
| 86 | -import { loginApp } from "@/config/login"; |  |  | 
| 87 | - |  |  | 
| 88 | -import baseUrl from "@/config/baseUrl.js"; |  |  | 
| 89 | - |  |  | 
| 90 | -import WXBizDataCrypt from "@/config/WXBizDataCrypt.js"; |  |  | 
| 91 | - |  |  | 
| 92 | -import { appId, appSecrect } from "@/config/constant.js"; |  |  | 
| 93 | - |  |  | 
| 94 | -export default { |  |  | 
| 95 | -  data() { |  |  | 
| 96 | -    return { |  |  | 
| 97 | -      loginForm: { |  |  | 
| 98 | -        username: "", | 2 | +	<view class="login-page"> | 
|  |  | 3 | +		<!-- 公共组件-每个页面必须引入 --> | 
| 99 |  | 4 |  | 
| 100 | -        password: "", |  |  | 
| 101 | -      }, | 5 | +		<public-module></public-module> | 
| 102 |  | 6 |  | 
| 103 | -      showPassword: false, | 7 | +		<view class="u-flex login-main"> | 
|  |  | 8 | +			<view class="content"> | 
|  |  | 9 | +				<view class="hello login-text-muted">您好,</view> | 
| 104 |  | 10 |  | 
| 105 | -      code: "", | 11 | +				<view class="hello-welcome login-text-muted">欢迎来到ThingsKit!</view> | 
|  |  | 12 | +			</view> | 
|  |  | 13 | +		</view> | 
| 106 |  | 14 |  | 
| 107 | -      openid: "", |  |  | 
| 108 | -    }; |  |  | 
| 109 | -  }, | 15 | +		<view class="f__login"> | 
|  |  | 16 | +			<view class="loginPhone"> | 
|  |  | 17 | +				<view class="form-row u-flex"> | 
|  |  | 18 | +					<view class="v-input"><input type="text" v-model="loginForm.username" maxlength="32" placeholder="请输入登录账号" /></view> | 
| 110 |  | 19 |  | 
| 111 | -  onLoad() { |  |  | 
| 112 | -    wx.login({ |  |  | 
| 113 | -      success: (res) => { |  |  | 
| 114 | -        if (res.code) { |  |  | 
| 115 | -          this.code = res.code; | 20 | +					<u-icon></u-icon> | 
|  |  | 21 | +				</view> | 
| 116 |  | 22 |  | 
| 117 | -          //这里获取openid |  |  | 
| 118 | -        } else { |  |  | 
| 119 | -          return; |  |  | 
| 120 | -        } |  |  | 
| 121 | -      }, |  |  | 
| 122 | -    }); |  |  | 
| 123 | -  }, | 23 | +				<view class="form-row u-flex"> | 
|  |  | 24 | +					<view class="v-input"><input type="text" v-model="loginForm.password" maxlength="32" placeholder="请输入登录密码" :password="!showPassword" /></view> | 
| 124 |  | 25 |  | 
| 125 | -  methods: { |  |  | 
| 126 | -    ...mapMutations(["setUserInfo"]), | 26 | +					<view class="v-password" @click="showPasswordMode"> | 
|  |  | 27 | +						<u-icon color="#9a9a9a" width="18" height="15" :name="showPassword ? '/static/eye.png' : '/static/eye-hide.png'"></u-icon> | 
|  |  | 28 | +					</view> | 
| 127 |  | 29 |  | 
| 128 | -    ...mapActions(["updateBadgeTotal"]), | 30 | +					<u-icon></u-icon> | 
|  |  | 31 | +				</view> | 
| 129 |  | 32 |  | 
| 130 | -    //微信授权登录 | 33 | +				<button class="submit" size="default" @click="onSubmitFunc"><text class="text">登录</text></button> | 
| 131 |  | 34 |  | 
| 132 | -    //#ifdef MP-WEIXIN | 35 | +				<view class="u-flex row-item"> | 
|  |  | 36 | +					<view class="row-phone login-text-gray" @click="openCodeFunc">手机验证码登录</view> | 
| 133 |  | 37 |  | 
| 134 | -    onWenxinAuthorization() { |  |  | 
| 135 | -      wx.getUserProfile({ |  |  | 
| 136 | -        desc: "微信第三方授权", | 38 | +					<view class="row-reset login-text-gray" @click="findPassrordFunc">忘记密码</view> | 
|  |  | 39 | +				</view> | 
| 137 |  | 40 |  | 
| 138 | -        success: (reswenxin) => { |  |  | 
| 139 | -          console.log("res=======>", reswenxin); | 41 | +				<view class="u-flex link-login"> | 
|  |  | 42 | +					<view class="link-text login-text-gray">第三方账号登录</view> | 
| 140 |  | 43 |  | 
| 141 | -          if ( |  |  | 
| 142 | -            reswenxin.errMsg === "getUserProfile:ok" && |  |  | 
| 143 | -            reswenxin.encryptedData |  |  | 
| 144 | -          ) { |  |  | 
| 145 | -            console.log("获取code", this.code); | 44 | +					<view style="height: 20rpx"></view> | 
| 146 |  | 45 |  | 
| 147 | -            //获取用户信息 |  |  | 
| 148 | - |  |  | 
| 149 | -            let obj = { |  |  | 
| 150 | -              avatarUrl: reswenxin.userInfo.avatarUrl, |  |  | 
| 151 | - |  |  | 
| 152 | -              thirdUserId: this.openid, |  |  | 
| 153 | -            }; |  |  | 
| 154 | - |  |  | 
| 155 | -            //判断是否需要绑定 |  |  | 
| 156 | - |  |  | 
| 157 | -            uni.$u.http |  |  | 
| 158 | - |  |  | 
| 159 | -              .get(`/yt/third/login/${this.code}`) | 46 | +					<button class="link-image" @tap="onWenxinAuthorization"><image class="image" src="../../static/weixin.png" mode="aspectFill"></image></button> | 
|  |  | 47 | +				</view> | 
|  |  | 48 | +			</view> | 
|  |  | 49 | +		</view> | 
|  |  | 50 | +	</view> | 
|  |  | 51 | +</template> | 
| 160 |  | 52 |  | 
| 161 | -              .then((res) => { |  |  | 
| 162 | -                console.log("Res", res); | 53 | +<script> | 
|  |  | 54 | +import { mapMutations, mapActions } from 'vuex'; | 
| 163 |  | 55 |  | 
| 164 | -                //设置全局变量openId | 56 | +import { loginApp } from '@/config/login'; | 
| 165 |  | 57 |  | 
| 166 | -                // getApp().globalData.openId = res.data.openid; | 58 | +import baseUrl from '@/config/baseUrl.js'; | 
| 167 |  | 59 |  | 
| 168 | -                if ( |  |  | 
| 169 | -                  res.token == "" || |  |  | 
| 170 | -                  (res.token == null && res.refreshToken) |  |  | 
| 171 | -                ) { |  |  | 
| 172 | -                  //需要绑定 | 60 | +import WXBizDataCrypt from '@/config/WXBizDataCrypt.js'; | 
| 173 |  | 61 |  | 
| 174 | -                  let userInfo = { |  |  | 
| 175 | -                    isThirdLogin: true, //用于判断是否是第三方登录并且需要绑定账号 | 62 | +import { appId, appSecrect } from '@/config/constant.js'; | 
| 176 |  | 63 |  | 
| 177 | -                    avatar: obj.avatarUrl, |  |  | 
| 178 | -                  }; | 64 | +export default { | 
|  |  | 65 | +	data() { | 
|  |  | 66 | +		return { | 
|  |  | 67 | +			loginForm: { | 
|  |  | 68 | +				username: '', | 
| 179 |  | 69 |  | 
| 180 | -                  this.setUserInfo(userInfo); | 70 | +				password: '' | 
|  |  | 71 | +			}, | 
| 181 |  | 72 |  | 
| 182 | -                  //设置全局变量openId | 73 | +			showPassword: false, | 
| 183 |  | 74 |  | 
| 184 | -                  getApp().globalData.openId = res.refreshToken; | 75 | +			code: '', | 
| 185 |  | 76 |  | 
| 186 | -                  uni.reLaunch({ |  |  | 
| 187 | -                    url: "../../pages/personal/personal", |  |  | 
| 188 | -                  }); |  |  | 
| 189 | -                } else { |  |  | 
| 190 | -                  // 不需要绑定,直接第三方登录使用 | 77 | +			openid: '' | 
|  |  | 78 | +		}; | 
|  |  | 79 | +	}, | 
| 191 |  | 80 |  | 
| 192 | -                  let resObj = { |  |  | 
| 193 | -                    refreshToken: res.refreshToken, | 81 | +	onLoad() { | 
|  |  | 82 | +		wx.login({ | 
|  |  | 83 | +			success: res => { | 
|  |  | 84 | +				if (res.code) { | 
|  |  | 85 | +					this.code = res.code; | 
| 194 |  | 86 |  | 
| 195 | -                    isToken: res.token, |  |  | 
| 196 | -                  }; | 87 | +					//这里获取openid | 
|  |  | 88 | +				} else { | 
|  |  | 89 | +					return; | 
|  |  | 90 | +				} | 
|  |  | 91 | +			} | 
|  |  | 92 | +		}); | 
|  |  | 93 | +	}, | 
| 197 |  | 94 |  | 
| 198 | -                  let userInfo = { |  |  | 
| 199 | -                    ...resObj, | 95 | +	methods: { | 
|  |  | 96 | +		...mapMutations(['setUserInfo']), | 
| 200 |  | 97 |  | 
| 201 | -                    token: true, //token用于判断是否登录 | 98 | +		...mapActions(['updateBadgeTotal']), | 
| 202 |  | 99 |  | 
| 203 | -                    isThirdLoginAndNoDind: true, //用于判断是否是第三方登录并且不需要绑定账号 |  |  | 
| 204 | -                  }; | 100 | +		//微信授权登录 | 
| 205 |  | 101 |  | 
| 206 | -                  if (userInfo.token) { |  |  | 
| 207 | -                    this.setUserInfo(userInfo); |  |  | 
| 208 | -                  } | 102 | +		//#ifdef MP-WEIXIN | 
| 209 |  | 103 |  | 
| 210 | -                  uni.showToast({ |  |  | 
| 211 | -                    title: "第三方账号登录成功~", | 104 | +		onWenxinAuthorization() { | 
|  |  | 105 | +			wx.getUserProfile({ | 
|  |  | 106 | +				desc: '微信第三方授权', | 
| 212 |  | 107 |  | 
| 213 | -                    icon: "none", |  |  | 
| 214 | -                  }); | 108 | +				success: reswenxin => { | 
|  |  | 109 | +					console.log('res=======>', reswenxin); | 
| 215 |  | 110 |  | 
| 216 | -                  this.saveUserInfo(); | 111 | +					if (reswenxin.errMsg === 'getUserProfile:ok' && reswenxin.encryptedData) { | 
|  |  | 112 | +						console.log('获取code', this.code); | 
| 217 |  | 113 |  | 
| 218 | -                  this.getAlarmTotalData(); | 114 | +						//获取用户信息 | 
| 219 |  | 115 |  | 
| 220 | -                  uni.reLaunch({ |  |  | 
| 221 | -                    url: "../../pages/personal/personal", |  |  | 
| 222 | -                  }); |  |  | 
| 223 | -                } |  |  | 
| 224 | -              }) | 116 | +						let obj = { | 
|  |  | 117 | +							avatarUrl: reswenxin.userInfo.avatarUrl, | 
| 225 |  | 118 |  | 
| 226 | -              .catch((e) => { |  |  | 
| 227 | -                uni.$u.toast(e.data?.message); |  |  | 
| 228 | -              }); |  |  | 
| 229 | -          } |  |  | 
| 230 | -        }, | 119 | +							thirdUserId: this.openid | 
|  |  | 120 | +						}; | 
| 231 |  | 121 |  | 
| 232 | -        fail: (res) => { |  |  | 
| 233 | -          //拒绝授权 | 122 | +						//判断是否需要绑定 | 
| 234 |  | 123 |  | 
| 235 | -          return; |  |  | 
| 236 | -        }, |  |  | 
| 237 | -      }); |  |  | 
| 238 | -    }, | 124 | +						uni.$u.http | 
| 239 |  | 125 |  | 
| 240 | -    //#endif | 126 | +							.get(`/yt/third/login/${this.code}`) | 
| 241 |  | 127 |  | 
| 242 | -    saveUserInfo() { |  |  | 
| 243 | -      //储存个人信息 | 128 | +							.then(res => { | 
|  |  | 129 | +								console.log('Res', res); | 
| 244 |  | 130 |  | 
| 245 | -      uni.$u.http.get("/yt/user/me/info").then((res) => { |  |  | 
| 246 | -        if (res) { |  |  | 
| 247 | -          this.setUserInfo(res); |  |  | 
| 248 | -        } |  |  | 
| 249 | -      }); |  |  | 
| 250 | -    }, | 131 | +								//设置全局变量openId | 
| 251 |  | 132 |  | 
| 252 | -    async getAlarmTotalData() { |  |  | 
| 253 | -      const res = await uni.$u.http.get("/yt/homepage/app"); |  |  | 
| 254 | -      if (res) { |  |  | 
| 255 | -        //异步实时更新告警徽标数 |  |  | 
| 256 | -        this.updateBadgeTotal(res.totalAlarm.activedAlarm); |  |  | 
| 257 | -      } |  |  | 
| 258 | -    }, | 133 | +								// getApp().globalData.openId = res.data.openid; | 
| 259 |  | 134 |  | 
| 260 | -    onSubmitFunc() { |  |  | 
| 261 | -      if (this.loginForm.username == "") { |  |  | 
| 262 | -        return uni.$u.toast("请输入登录账号~"); |  |  | 
| 263 | -      } |  |  | 
| 264 | -      const passReg = |  |  | 
| 265 | -        /^(?=.*?[A-Z])(?=(.*[a-z]){1,})(?=(.*[\d]){1,})(?=(.*[\W]){1,})(?!.*\s).{8,}$/; | 135 | +								if (res.token == '' || (res.token == null && res.refreshToken)) { | 
|  |  | 136 | +									//需要绑定 | 
| 266 |  | 137 |  | 
| 267 | -      if (this.loginForm.password == "") { |  |  | 
| 268 | -        uni.showToast({ |  |  | 
| 269 | -          title: "请输入登录密码~", | 138 | +									let userInfo = { | 
|  |  | 139 | +										isThirdLogin: true, //用于判断是否是第三方登录并且需要绑定账号 | 
| 270 |  | 140 |  | 
| 271 | -          icon: "none", |  |  | 
| 272 | -        }); |  |  | 
| 273 | -        return; |  |  | 
| 274 | -      } else if (!passReg.test(this.loginForm.password)) { |  |  | 
| 275 | -        uni.showToast({ |  |  | 
| 276 | -          title: |  |  | 
| 277 | -            "密码格式不正确(至少一个大写英文字母、至少一个小写英文字母、至少一位数字、至少一个特殊字符、最少八个字符)~", | 141 | +										avatar: obj.avatarUrl | 
|  |  | 142 | +									}; | 
| 278 |  | 143 |  | 
| 279 | -          icon: "none", | 144 | +									this.setUserInfo(userInfo); | 
| 280 |  | 145 |  | 
| 281 | -          duration: 3000, |  |  | 
| 282 | -        }); | 146 | +									//设置全局变量openId | 
| 283 |  | 147 |  | 
| 284 | -        return; |  |  | 
| 285 | -      } |  |  | 
| 286 | -      uni.$u.http |  |  | 
| 287 | -        .post("/auth/login", this.loginForm) | 148 | +									getApp().globalData.openId = res.refreshToken; | 
| 288 |  | 149 |  | 
| 289 | -        .then((res) => { |  |  | 
| 290 | -          if (res) { |  |  | 
| 291 | -            // 储存登录信息 | 150 | +									uni.reLaunch({ | 
|  |  | 151 | +										url: '../../pages/personal/personal' | 
|  |  | 152 | +									}); | 
|  |  | 153 | +								} else { | 
|  |  | 154 | +									// 不需要绑定,直接第三方登录使用 | 
| 292 |  | 155 |  | 
| 293 | -            let resObj = { |  |  | 
| 294 | -              refreshToken: res.refreshToken, | 156 | +									let resObj = { | 
|  |  | 157 | +										refreshToken: res.refreshToken, | 
| 295 |  | 158 |  | 
| 296 | -              isToken: res.token, |  |  | 
| 297 | -            }; | 159 | +										isToken: res.token | 
|  |  | 160 | +									}; | 
| 298 |  | 161 |  | 
| 299 | -            let userInfo = { |  |  | 
| 300 | -              ...resObj, | 162 | +									let userInfo = { | 
|  |  | 163 | +										...resObj, | 
| 301 |  | 164 |  | 
| 302 | -              token: true, //token用于判断是否登录 | 165 | +										token: true, //token用于判断是否登录 | 
| 303 |  | 166 |  | 
| 304 | -              isThirdLogin: false, |  |  | 
| 305 | -            }; | 167 | +										isThirdLoginAndNoDind: true //用于判断是否是第三方登录并且不需要绑定账号 | 
|  |  | 168 | +									}; | 
| 306 |  | 169 |  | 
| 307 | -            if (userInfo.token) { |  |  | 
| 308 | -              this.setUserInfo(userInfo); |  |  | 
| 309 | -            } | 170 | +									if (userInfo.token) { | 
|  |  | 171 | +										this.setUserInfo(userInfo); | 
|  |  | 172 | +									} | 
| 310 |  | 173 |  | 
| 311 | -            uni |  |  | 
| 312 | -              .showToast({ |  |  | 
| 313 | -                title: "登录成功~", | 174 | +									uni.showToast({ | 
|  |  | 175 | +										title: '第三方账号登录成功~', | 
| 314 |  | 176 |  | 
| 315 | -                icon: "none", |  |  | 
| 316 | -              }) |  |  | 
| 317 | -              .then((res) => { |  |  | 
| 318 | -                /** | 177 | +										icon: 'none' | 
|  |  | 178 | +									}); | 
| 319 |  | 179 |  | 
| 320 | -							 * 有些时候不起作用 | 180 | +									this.saveUserInfo(); | 
| 321 |  | 181 |  | 
| 322 | -							 */ | 182 | +									this.getAlarmTotalData(); | 
| 323 |  | 183 |  | 
| 324 | -                // uni.navigateBack({ | 184 | +									uni.reLaunch({ | 
|  |  | 185 | +										url: '../../pages/personal/personal' | 
|  |  | 186 | +									}); | 
|  |  | 187 | +								} | 
|  |  | 188 | +							}) | 
| 325 |  | 189 |  | 
| 326 | -                // 	delta: 1 | 190 | +							.catch(e => { | 
|  |  | 191 | +								uni.$u.toast(e.data?.message); | 
|  |  | 192 | +							}); | 
|  |  | 193 | +					} | 
|  |  | 194 | +				}, | 
| 327 |  | 195 |  | 
| 328 | -                // }); | 196 | +				fail: res => { | 
|  |  | 197 | +					//拒绝授权 | 
| 329 |  | 198 |  | 
| 330 | -                // #ifdef APP-PLUS||MP | 199 | +					return; | 
|  |  | 200 | +				} | 
|  |  | 201 | +			}); | 
|  |  | 202 | +		}, | 
| 331 |  | 203 |  | 
| 332 | -                uni.reLaunch({ |  |  | 
| 333 | -                  url: "/pages/personal/personal", |  |  | 
| 334 | -                }); | 204 | +		//#endif | 
| 335 |  | 205 |  | 
| 336 | -                // #endif |  |  | 
| 337 | -              }); | 206 | +		saveUserInfo() { | 
|  |  | 207 | +			//储存个人信息 | 
| 338 |  | 208 |  | 
| 339 | -            this.saveUserInfo(); | 209 | +			uni.$u.http.get('/yt/user/me/info').then(res => { | 
|  |  | 210 | +				if (res) { | 
|  |  | 211 | +					this.setUserInfo(res); | 
|  |  | 212 | +				} | 
|  |  | 213 | +			}); | 
|  |  | 214 | +		}, | 
| 340 |  | 215 |  | 
| 341 | -            this.getAlarmTotalData(); |  |  | 
| 342 | -          } |  |  | 
| 343 | -        }) | 216 | +		async getAlarmTotalData() { | 
|  |  | 217 | +			const res = await uni.$u.http.get('/yt/homepage/app'); | 
|  |  | 218 | +			if (res) { | 
|  |  | 219 | +				//异步实时更新告警徽标数 | 
|  |  | 220 | +				this.updateBadgeTotal(res.totalAlarm.activedAlarm); | 
|  |  | 221 | +			} | 
|  |  | 222 | +		}, | 
| 344 |  | 223 |  | 
| 345 | -        .catch((e) => { |  |  | 
| 346 | -          uni.$u.toast(e.data?.message); |  |  | 
| 347 | -        }); |  |  | 
| 348 | -    }, | 224 | +		onSubmitFunc() { | 
|  |  | 225 | +			if (this.loginForm.username == '') { | 
|  |  | 226 | +				return uni.$u.toast('请输入登录账号~'); | 
|  |  | 227 | +			} | 
|  |  | 228 | +			const passReg = /^(?=.*?[A-Z])(?=(.*[a-z]){1,})(?=(.*[\d]){1,})(?=(.*[\W]){1,})(?!.*\s).{8,}$/; | 
| 349 |  | 229 |  | 
| 350 | -    openCodeFunc() { |  |  | 
| 351 | -      uni.navigateTo({ |  |  | 
| 352 | -        url: "../other/code", |  |  | 
| 353 | -      }); |  |  | 
| 354 | -    }, | 230 | +			if (this.loginForm.password == '') { | 
|  |  | 231 | +				uni.showToast({ | 
|  |  | 232 | +					title: '请输入登录密码~', | 
| 355 |  | 233 |  | 
| 356 | -    findPassrordFunc() { |  |  | 
| 357 | -      uni.navigateTo({ |  |  | 
| 358 | -        url: "../other/findPassword", |  |  | 
| 359 | -      }); |  |  | 
| 360 | -    }, | 234 | +					icon: 'none' | 
|  |  | 235 | +				}); | 
|  |  | 236 | +				return; | 
|  |  | 237 | +			} else if (!passReg.test(this.loginForm.password)) { | 
|  |  | 238 | +				uni.showToast({ | 
|  |  | 239 | +					title: '密码格式不正确(至少一个大写英文字母、至少一个小写英文字母、至少一位数字、至少一个特殊字符、最少八个字符)~', | 
| 361 |  | 240 |  | 
| 362 | -    showPasswordMode() { |  |  | 
| 363 | -      this.showPassword = !this.showPassword; |  |  | 
| 364 | -    }, |  |  | 
| 365 | -  }, | 241 | +					icon: 'none', | 
|  |  | 242 | + | 
|  |  | 243 | +					duration: 3000 | 
|  |  | 244 | +				}); | 
|  |  | 245 | + | 
|  |  | 246 | +				return; | 
|  |  | 247 | +			} | 
|  |  | 248 | +			uni.$u.http | 
|  |  | 249 | +				.post('/auth/login', this.loginForm) | 
|  |  | 250 | + | 
|  |  | 251 | +				.then(res => { | 
|  |  | 252 | +					if (res) { | 
|  |  | 253 | +						// 储存登录信息 | 
|  |  | 254 | + | 
|  |  | 255 | +						let resObj = { | 
|  |  | 256 | +							refreshToken: res.refreshToken, | 
|  |  | 257 | + | 
|  |  | 258 | +							isToken: res.token | 
|  |  | 259 | +						}; | 
|  |  | 260 | + | 
|  |  | 261 | +						let userInfo = { | 
|  |  | 262 | +							...resObj, | 
|  |  | 263 | + | 
|  |  | 264 | +							token: true, //token用于判断是否登录 | 
|  |  | 265 | + | 
|  |  | 266 | +							isThirdLogin: false | 
|  |  | 267 | +						}; | 
|  |  | 268 | + | 
|  |  | 269 | +						if (userInfo.token) { | 
|  |  | 270 | +							this.setUserInfo(userInfo); | 
|  |  | 271 | +						} | 
|  |  | 272 | + | 
|  |  | 273 | +						uni | 
|  |  | 274 | +							.showToast({ | 
|  |  | 275 | +								title: '登录成功~', | 
|  |  | 276 | + | 
|  |  | 277 | +								icon: 'none' | 
|  |  | 278 | +							}) | 
|  |  | 279 | +							.then(async res => { | 
|  |  | 280 | +								this.saveUserInfo(); | 
|  |  | 281 | +								await this.getAlarmTotalData(); | 
|  |  | 282 | +								uni.reLaunch({ | 
|  |  | 283 | +									url: '/pages/personal/personal' | 
|  |  | 284 | +								}); | 
|  |  | 285 | +							}); | 
|  |  | 286 | +					} | 
|  |  | 287 | +				}) | 
|  |  | 288 | + | 
|  |  | 289 | +				.catch(e => { | 
|  |  | 290 | +					uni.$u.toast(e.data?.message); | 
|  |  | 291 | +				}); | 
|  |  | 292 | +		}, | 
|  |  | 293 | + | 
|  |  | 294 | +		openCodeFunc() { | 
|  |  | 295 | +			uni.navigateTo({ | 
|  |  | 296 | +				url: '../other/code' | 
|  |  | 297 | +			}); | 
|  |  | 298 | +		}, | 
|  |  | 299 | + | 
|  |  | 300 | +		findPassrordFunc() { | 
|  |  | 301 | +			uni.navigateTo({ | 
|  |  | 302 | +				url: '../other/findPassword' | 
|  |  | 303 | +			}); | 
|  |  | 304 | +		}, | 
|  |  | 305 | + | 
|  |  | 306 | +		showPasswordMode() { | 
|  |  | 307 | +			this.showPassword = !this.showPassword; | 
|  |  | 308 | +		} | 
|  |  | 309 | +	} | 
| 366 | }; | 310 | }; | 
| 367 | </script> | 311 | </script> | 
| 368 |  | 312 |  | 
| 369 | <style lang="scss" scoped> | 313 | <style lang="scss" scoped> | 
| 370 | -@import "./static/login.scss"; | 314 | +@import './static/login.scss'; | 
| 371 |  | 315 |  | 
| 372 | /deep/ button { | 316 | /deep/ button { | 
| 373 | -  background: rgba(0, 0, 0, 0); | 317 | +	background: rgba(0, 0, 0, 0); | 
| 374 | } | 318 | } | 
| 375 | -</style> | 319 | +</style> |