fix:对接高德地图,修复地图bug
This commit is contained in:
+17
-12
@@ -8,16 +8,16 @@
|
||||
<view class="title">{{ $t('auth.loginTitle') }}</view>
|
||||
<view class="subtitle">{{ $t('auth.loginDesc') }}</view>
|
||||
|
||||
<!-- 微信一键手机号快捷登录(推荐) -->
|
||||
<!-- 支付宝一键手机号快捷登录(推荐) -->
|
||||
<button v-if="!isAgreed" class="btn primary" @click="handleLoginClick">
|
||||
{{ $t('auth.getPhoneNumber') }}
|
||||
</button>
|
||||
<button v-else class="btn primary" open-type="getPhoneNumber" @getphonenumber="onGetPhoneNumber">
|
||||
<button v-else class="btn primary" open-type="getAuthorize" scope="phoneNumber" @getAuthorize="onGetPhoneNumber">
|
||||
{{ $t('auth.getPhoneNumber') }}
|
||||
</button>
|
||||
|
||||
<!-- 仅微信登录(不授权手机号时使用) -->
|
||||
<!-- <button class="btn outline" @click="onWeChatLogin">仅微信登录</button> -->
|
||||
<!-- 仅支付宝登录(不授权手机号时使用) -->
|
||||
<!-- <button class="btn outline" @click="onAlipayLogin">仅支付宝登录</button> -->
|
||||
|
||||
<view class="agreement-box">
|
||||
<checkbox-group @change="onAgreementChange">
|
||||
@@ -38,7 +38,7 @@
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { wxLogin, getUserPhoneNumber, getUserInfo } from '../../util/index.js'
|
||||
import { alipayLogin, getUserPhoneNumber, getUserInfo } from '../../util/index.js'
|
||||
import { useI18n } from '@/utils/i18n.js'
|
||||
|
||||
const { t: $t } = useI18n()
|
||||
@@ -113,12 +113,12 @@
|
||||
uni.reLaunch({ url: target })
|
||||
}
|
||||
|
||||
const onWeChatLogin = async () => {
|
||||
const onAlipayLogin = async () => {
|
||||
try {
|
||||
// 先检查是否同意协议
|
||||
await checkAgreement()
|
||||
|
||||
await wxLogin()
|
||||
await alipayLogin()
|
||||
uni.showToast({ title: $t('auth.loginSuccess'), icon: 'success' })
|
||||
await navigateAfterLogin()
|
||||
} catch (error) {
|
||||
@@ -129,16 +129,21 @@
|
||||
}
|
||||
|
||||
const onGetPhoneNumber = async (e) => {
|
||||
if (!e || e.detail.errMsg !== 'getPhoneNumber:ok') {
|
||||
// 支付宝获取手机号的回调处理
|
||||
if (!e || !e.detail || !e.detail.response) {
|
||||
uni.showToast({ title: $t('auth.phoneCancelled'), icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
// 先微信登录,获取 token
|
||||
await wxLogin()
|
||||
// 再用微信返回的临时 code 换取手机号
|
||||
await getUserPhoneNumber(e.detail.code)
|
||||
// 先支付宝登录,获取 token
|
||||
await alipayLogin()
|
||||
// 再用支付宝返回的授权码换取手机号
|
||||
// 支付宝的授权码在 e.detail.response 中
|
||||
const authCode = e.detail.response?.response?.code || e.detail.response?.code
|
||||
if (authCode) {
|
||||
await getUserPhoneNumber(authCode)
|
||||
}
|
||||
uni.showToast({ title: $t('auth.loginSuccess'), icon: 'success' })
|
||||
await navigateAfterLogin()
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user