|
@@ -5,48 +5,11 @@
|
|
|
<icon class="bjcx-logo-box"></icon>
|
|
<icon class="bjcx-logo-box"></icon>
|
|
|
<view class="bjcx-logo-title">家政学</view>
|
|
<view class="bjcx-logo-title">家政学</view>
|
|
|
</view>
|
|
</view>
|
|
|
-
|
|
|
|
|
- <!-- 如果是APP分享过来的,显示微信授权界面 @getuserinfo="onWechatAuth"-->
|
|
|
|
|
-
|
|
|
|
|
<view v-if="fromAppShare" class="wechat-auth-box">
|
|
<view v-if="fromAppShare" class="wechat-auth-box">
|
|
|
<view class="auth-tips">欢迎使用小程序</view>
|
|
<view class="auth-tips">欢迎使用小程序</view>
|
|
|
- <button class="wechat-auth-btn" open-type="getUserInfo"@getuserinfo="onWechatAuth">
|
|
|
|
|
|
|
+ <button class="wechat-auth-btn" open-type="getPhoneNumber" @getphonenumber="onWechatAuth">
|
|
|
微信一键登录
|
|
微信一键登录
|
|
|
</button>
|
|
</button>
|
|
|
- <view class="switch-login" @click="switchToNormalLogin">使用账号登录</view>
|
|
|
|
|
- </view>
|
|
|
|
|
-
|
|
|
|
|
- <!-- 普通登录表单 -->
|
|
|
|
|
- <view v-else>
|
|
|
|
|
- <view class="login-input-box">
|
|
|
|
|
- <icon class="user-icon"></icon>
|
|
|
|
|
- <input class="login-input" type="text" v-model="userName" placeholder="请输入手机号"
|
|
|
|
|
- @input="userInputChange">
|
|
|
|
|
- <view class="close-btn" v-if="clearTelIcon" @click="clearTel"></view>
|
|
|
|
|
- </view>
|
|
|
|
|
- <view class="login-input-box">
|
|
|
|
|
- <icon class="tel-icon"></icon>
|
|
|
|
|
- <input class="login-input" placeholder="请输入证件号后六位" v-model="password" :password="showPassword"
|
|
|
|
|
- @input="passwordInputChange" />
|
|
|
|
|
- <text class="login-eye" :class="[!showPassword ? 'uni-eye-active' : '']"
|
|
|
|
|
- @click="changePassword"></text>
|
|
|
|
|
- <view class="close-btn" v-if="clearPwIcon" @click="clearPw"></view>
|
|
|
|
|
- </view>
|
|
|
|
|
-
|
|
|
|
|
- <!-- 协议勾选框和按钮 -->
|
|
|
|
|
- <view class="agreement-checkbox-box">
|
|
|
|
|
- <checkbox-group @change="handleChange">
|
|
|
|
|
- <checkbox class="agreement-checkbox-input" color="#3fd2a1" value="agree" :checked="isAgreed"
|
|
|
|
|
- style="transform:scale(0.7)" />
|
|
|
|
|
- </checkbox-group>
|
|
|
|
|
- <view class="agreement-text-box">
|
|
|
|
|
- 在使用当前小程序服务之前,请仔细阅读<view class="agreement-text" @click="agreeBtn('yhxy')">《诚祥学用户协议》</view>和<view
|
|
|
|
|
- @click="agreeBtn('ystk')" class="agreement-text">《诚祥学隐私政策》</view>,如您同意,请勾选后开始使用
|
|
|
|
|
- </view>
|
|
|
|
|
- </view>
|
|
|
|
|
-
|
|
|
|
|
- <button type="default" @click="handleLogin" :disabled="!isAgreed"
|
|
|
|
|
- class="phone-green-btn login-btn">登录</button>
|
|
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
@@ -80,186 +43,86 @@
|
|
|
const code = ref('')
|
|
const code = ref('')
|
|
|
|
|
|
|
|
const fromPage = ref('');
|
|
const fromPage = ref('');
|
|
|
|
|
+ const openId = ref('');
|
|
|
|
|
|
|
|
// 新增变量
|
|
// 新增变量
|
|
|
const fromAppShare = ref(false) // 是否来自APP分享
|
|
const fromAppShare = ref(false) // 是否来自APP分享
|
|
|
|
|
|
|
|
const store = useIsCanBack();
|
|
const store = useIsCanBack();
|
|
|
|
|
|
|
|
- onLoad((options) => {
|
|
|
|
|
- // 判断是否来自APP分享
|
|
|
|
|
|
|
+ onLoad((options) => {
|
|
|
if (options.from === 'appcx') {
|
|
if (options.from === 'appcx') {
|
|
|
- fromAppShare.value = true
|
|
|
|
|
id.value = options.id
|
|
id.value = options.id
|
|
|
- // APP分享过来直接显示微信授权界面,不需要自动弹窗
|
|
|
|
|
fromPage.value = options.from;
|
|
fromPage.value = options.from;
|
|
|
}
|
|
}
|
|
|
|
|
+ uni.login().then(res1 => {
|
|
|
|
|
+ console.log('res1', res1);
|
|
|
|
|
+ code.value = res1.code
|
|
|
|
|
+ httpApi.loginApplet({
|
|
|
|
|
+ code: res1.code,
|
|
|
|
|
+ }).then(result => {
|
|
|
|
|
+ console.log('result', result);
|
|
|
|
|
+ openId.value = result.data.openId
|
|
|
|
|
+ if (result.data.bind) {
|
|
|
|
|
+ // 保存用户信息
|
|
|
|
|
+ if (result.data.loginVo.type == 4) {
|
|
|
|
|
+ cacheManager.set('auth', result.data.loginVo)
|
|
|
|
|
+ store.setIsCanBack(false)
|
|
|
|
|
+ gotoPage();
|
|
|
|
|
+ } else if (result.data.loginVo.type == 6) {
|
|
|
|
|
+ cacheManager.set('auth', result.data.loginVo)
|
|
|
|
|
+ store.setIsCanBack(false)
|
|
|
|
|
+ gotoPage2();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ toast('登录失败,您的身份有误,请联系管理员。')
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ fromAppShare.value = true
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
getAllImg();
|
|
getAllImg();
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- // 切换到普通登录
|
|
|
|
|
- function switchToNormalLogin() {
|
|
|
|
|
- fromAppShare.value = false
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- function phoneBind() {
|
|
|
|
|
- uni.navigateTo({
|
|
|
|
|
- url: '/pages/Login/AliyunCaptcha?code='+code.value,
|
|
|
|
|
- events: {
|
|
|
|
|
- getCaptchaVerifyParam: (captchaVerifyParam) => {
|
|
|
|
|
- // 接收到验证码返回结果
|
|
|
|
|
- console.log('验证码返回结果:', captchaVerifyParam)
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- success: () => {
|
|
|
|
|
- console.log('跳转到验证码页面成功')
|
|
|
|
|
- },
|
|
|
|
|
- fail: (err) => {
|
|
|
|
|
- console.error('跳转到验证码页面失败:', err)
|
|
|
|
|
- toast('验证码加载失败,请重试')
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
// 微信授权登录
|
|
// 微信授权登录
|
|
|
- async function onWechatAuth(e) {
|
|
|
|
|
|
|
+ function onWechatAuth(e) {
|
|
|
if (e.detail.errMsg.includes('fail')) {
|
|
if (e.detail.errMsg.includes('fail')) {
|
|
|
toast('授权失败')
|
|
toast('授权失败')
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
uni.showLoading({
|
|
uni.showLoading({
|
|
|
title: '登录中'
|
|
title: '登录中'
|
|
|
})
|
|
})
|
|
|
- console.log('e', e);
|
|
|
|
|
|
|
+ console.log('e123123123', e);
|
|
|
try {
|
|
try {
|
|
|
- // 获取微信code
|
|
|
|
|
- const loginRes = await uni.login()
|
|
|
|
|
- console.log('loginRes', loginRes);
|
|
|
|
|
- code.value = loginRes.code
|
|
|
|
|
- // 调用后端微信登录接口
|
|
|
|
|
- const result = await httpApi.loginApplet({
|
|
|
|
|
- code: loginRes.code,
|
|
|
|
|
- userInfo: e.detail.userInfo
|
|
|
|
|
|
|
+ httpApi.bindApplet({
|
|
|
|
|
+ code: e.detail.code,
|
|
|
|
|
+ openId: openId.value,
|
|
|
|
|
+ }).then(result=>{
|
|
|
|
|
+ if (result.data.type == 4) {
|
|
|
|
|
+ cacheManager.set('auth', result.data)
|
|
|
|
|
+ store.setIsCanBack(false)
|
|
|
|
|
+ gotoPage();
|
|
|
|
|
+ } else if (result.data.type == 6) {
|
|
|
|
|
+ cacheManager.set('auth', result.data)
|
|
|
|
|
+ store.setIsCanBack(false)
|
|
|
|
|
+ gotoPage2();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ toast('登录失败,您的身份有误,请联系管理员。')
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
- console.log('result', result);
|
|
|
|
|
- console.log('result', result);
|
|
|
|
|
- phoneBind()
|
|
|
|
|
- // if (result.data.bind) {
|
|
|
|
|
- // // 保存用户信息
|
|
|
|
|
- // if (result.data.loginVo.type == 4) {
|
|
|
|
|
- // cacheManager.set('auth', result.data.loginVo)
|
|
|
|
|
- // store.setIsCanBack(false)
|
|
|
|
|
- // gotoPage();
|
|
|
|
|
- // } else if (result.data.loginVo.type == 6) {
|
|
|
|
|
- // cacheManager.set('auth', result.data.loginVo)
|
|
|
|
|
- // store.setIsCanBack(false)
|
|
|
|
|
- // gotoPage2();
|
|
|
|
|
- // } else {
|
|
|
|
|
- // toast('登录失败,您的身份有误,请联系管理员。')
|
|
|
|
|
- // }
|
|
|
|
|
- // } else {
|
|
|
|
|
- // // bind 为 false 未绑定
|
|
|
|
|
-
|
|
|
|
|
- // phoneBind()
|
|
|
|
|
- // }
|
|
|
|
|
|
|
+
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
- toast('微信登录失败')
|
|
|
|
|
|
|
+ toast('bindApplet失败')
|
|
|
} finally {
|
|
} finally {
|
|
|
uni.hideLoading()
|
|
uni.hideLoading()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 你原有的所有方法都不变
|
|
|
|
|
- function handleChange() {
|
|
|
|
|
- isAgreed.value = !isAgreed.value
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- function agreeBtn(code) {
|
|
|
|
|
- if (code === 'yhxy') {
|
|
|
|
|
- uni.navigateTo({
|
|
|
|
|
- url: "/pages/client/my/xieyi"
|
|
|
|
|
- })
|
|
|
|
|
- } else {
|
|
|
|
|
- uni.navigateTo({
|
|
|
|
|
- url: "/pages/client/my/zhengce"
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- function userInputChange(event) {
|
|
|
|
|
- if (event.detail.value.length > 0) {
|
|
|
|
|
- clearTelIcon.value = true;
|
|
|
|
|
- } else {
|
|
|
|
|
- clearTelIcon.value = false;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- function passwordInputChange(event) {
|
|
|
|
|
- if (event.detail.value.length > 0) {
|
|
|
|
|
- clearPwIcon.value = true;
|
|
|
|
|
- } else {
|
|
|
|
|
- clearPwIcon.value = false;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- function clearTel() {
|
|
|
|
|
- userName.value = '';
|
|
|
|
|
- clearTelIcon.value = false;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- function clearPw() {
|
|
|
|
|
- password.value = '';
|
|
|
|
|
- clearPwIcon.value = false;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- function changePassword() {
|
|
|
|
|
- showPassword.value = !showPassword.value;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- function handleLogin() {
|
|
|
|
|
- if (userName.value.length === 0) {
|
|
|
|
|
- toast('请输入手机号!')
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (password.value.length === 0) {
|
|
|
|
|
- toast('请输入密码!')
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- const trimmedUserName = userName.value;
|
|
|
|
|
- const trimmedPassword = password.value;
|
|
|
|
|
-
|
|
|
|
|
- uni.showLoading({
|
|
|
|
|
- title: '登录中'
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
- httpApi.loginTemp({
|
|
|
|
|
- type: 2,
|
|
|
|
|
- userName: trimmedUserName,
|
|
|
|
|
- password: trimmedPassword,
|
|
|
|
|
- }).then(res => {
|
|
|
|
|
- if (res.data.type === 4) {
|
|
|
|
|
- cacheManager.set('auth', res.data)
|
|
|
|
|
- store.setIsCanBack(false)
|
|
|
|
|
- gotoPage();
|
|
|
|
|
- } else if (res.data.type === 6) {
|
|
|
|
|
- cacheManager.set('auth', res.data)
|
|
|
|
|
- store.setIsCanBack(false)
|
|
|
|
|
- gotoPage2();
|
|
|
|
|
- } else {
|
|
|
|
|
- toast('登录失败,您的身份有误,请联系管理员。')
|
|
|
|
|
- }
|
|
|
|
|
- }).catch(err => {
|
|
|
|
|
- store.setIsCanBack(true)
|
|
|
|
|
- }).finally(err => {
|
|
|
|
|
- uni.hideLoading()
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
function gotoPage() {
|
|
function gotoPage() {
|
|
|
- console.log('ididid',id.value);
|
|
|
|
|
|
|
+ console.log('ididid', id.value);
|
|
|
if (id.value) {
|
|
if (id.value) {
|
|
|
uni.navigateTo({
|
|
uni.navigateTo({
|
|
|
url: `/pages/client/hetong/hetongInfo?id=` + id.value + `&from=${fromPage.value}`
|
|
url: `/pages/client/hetong/hetongInfo?id=` + id.value + `&from=${fromPage.value}`
|
|
@@ -272,7 +135,7 @@
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function gotoPage2() {
|
|
function gotoPage2() {
|
|
|
- console.log('ididid222222',id.value);
|
|
|
|
|
|
|
+ console.log('ididid222222', id.value);
|
|
|
if (id.value) {
|
|
if (id.value) {
|
|
|
uni.navigateTo({
|
|
uni.navigateTo({
|
|
|
url: `/pages/kehu/hetong/hetongInfo?id=` + id.value + `&from=${fromPage.value}`
|
|
url: `/pages/kehu/hetong/hetongInfo?id=` + id.value + `&from=${fromPage.value}`
|
|
@@ -317,4 +180,4 @@
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/* 你原有的所有样式都保持不变 */
|
|
/* 你原有的所有样式都保持不变 */
|
|
|
-</style>
|
|
|
|
|
|
|
+</style>
|