From 77094dd01f0c6ff59b4fb4fa1105addf34b2398c Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期二, 16 六月 2026 18:49:03 +0800
Subject: [PATCH] 新增智能电表、空调管理
---
h5/pages/login.vue | 121 +++++++++++++++++-----------------------
1 files changed, 51 insertions(+), 70 deletions(-)
diff --git a/h5/pages/login.vue b/h5/pages/login.vue
index bfa42da..a7ce852 100644
--- a/h5/pages/login.vue
+++ b/h5/pages/login.vue
@@ -2,6 +2,7 @@
<view class="login">
<view class="login_title">娆㈣繋鐧诲綍</view>
<view class="login_title login_title2">闃滃畞鏂囦綋涓績</view>
+ <view v-if="devMockTip" class="dev-tip">{{ devMockTip }}</view>
<view class="login_list">
<view class="login_list_item">
<image src="@/static/login_ic_phone@2x.png" mode="widthFix" />
@@ -33,6 +34,9 @@
getRecordByUserPoint
} from '@/api'
+ import { devWechatMock } from '@/utils/config.js'
+ import { runWechatOAuthFlow } from '@/utils/wechatAuth.js'
+ import { requestLoginSmsCode } from '@/utils/loginSms.js'
import {
mapState,
mapMutations
@@ -48,7 +52,8 @@
},
ywinfo: {},
downTime: 0,
- code: ''
+ code: '',
+ devMockTip: devWechatMock.enabled ? `寮�鍙戞ā寮忥細妯℃嫙 openid ${devWechatMock.openId}` : ''
}
},
onLoad(option) {
@@ -67,65 +72,44 @@
}
},
onShow() {
- // return
- var that = this
- let url = window.location.href
- if (url.indexOf('code=') !== -1 || this.code) {
- let code = ''
- const query = url.split('?')
- for (const q of query) {
- if (q.indexOf('code=') !== -1) {
- let statusIndex = q.indexOf('&state')
- code = q.substring(q.indexOf('code=') + 5, statusIndex)
- }
- }
- ywWxAuthorize({
- code: code || this.code
- }).then(res => {
- if (res.code === 200) {
- // console.log('res', res);
+ const that = this
+ runWechatOAuthFlow({
+ authorizeApi: ywWxAuthorize,
+ fallbackCode: this.code,
+ onSuccess: (res) => {
+ if (res.data.openid) {
that.$store.commit('setOpenId', res.data.openid)
- if (res.data.token && res.data.token != '') {
- that.$store.commit('setToken', res.data.token)
- getUserInfo().then(ress => {
- that.$store.commit('setUserInfo', ress.data)
- })
- const ywinfo = this.ywinfo
- if (ywinfo.ywid && (ywinfo.type || ywinfo.type == 0)) {
- getRecordByUserPoint({
- pointCode: ywinfo.ywid
- }).then(res => {
- if (res.data && res.data.id) {
- uni.redirectTo({
- url: "/pages/polling/point?id=" + res.data.id
- })
- } else {
- uni.redirectTo({
- url: "/pages/polling/empty?message=" + res.message
- })
- }
- })
- } else {
- setTimeout(() => {
+ }
+ if (res.data.token && res.data.token != '') {
+ that.$store.commit('setToken', res.data.token)
+ getUserInfo().then(ress => {
+ that.$store.commit('setUserInfo', ress.data)
+ })
+ const ywinfo = this.ywinfo
+ if (ywinfo.ywid && (ywinfo.type || ywinfo.type == 0)) {
+ getRecordByUserPoint({
+ pointCode: ywinfo.ywid
+ }).then(res => {
+ if (res.data && res.data.id) {
uni.redirectTo({
- url: "/pages/index"
+ url: "/pages/polling/point?id=" + res.data.id
})
- }, 300)
- }
+ } else {
+ uni.redirectTo({
+ url: "/pages/polling/empty?message=" + res.message
+ })
+ }
+ })
+ } else {
+ setTimeout(() => {
+ uni.redirectTo({
+ url: "/pages/index"
+ })
+ }, 300)
}
}
- })
- } else {
- let url = 'https://zhcg.fnwtzx.com/fn_h5'
- // const appID = 'wx95ac1efb67f0330d'
- //let url = 'https://dmtest.ahapp.net/yunwei_h5'
- const appID = 'wx15dfdae9a19177f3'
- let uri = encodeURIComponent(url)
- let authURL =
- `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appID}&redirect_uri=${uri}&response_type=code&scope=snsapi_base#wechat_redirect`
- window.location.href = authURL
- }
-
+ }
+ })
},
methods: {
...mapMutations(["setToken", "setUserInfo"]),
@@ -182,20 +166,7 @@
},
sendSms() {
- this.downTime = 60
- let timer = setInterval(() => {
- if (this.downTime == 0) return clearInterval(timer)
- this.downTime = this.downTime - 1
- }, 1000)
- const {
- form
- } = this
- sendSMsPost({
- phone: form.phone,
- type: 0
- }).then(res => {
- this.showToast('鐭俊鍙戦�佹垚鍔�')
- })
+ requestLoginSmsCode(this, this.form.phone, sendSMsPost, { phone: this.form.phone, userType: 0 })
},
}
}
@@ -223,7 +194,17 @@
.login_title2 {
margin-top: 10rpx;
- margin-bottom: 80rpx;
+ margin-bottom: 40rpx;
+ }
+
+ .dev-tip {
+ width: 100%;
+ padding: 0 60rpx;
+ box-sizing: border-box;
+ font-size: 24rpx;
+ color: #e6a23c;
+ margin-bottom: 40rpx;
+ line-height: 1.5;
}
.login_list {
--
Gitblit v1.9.3