整理代码

main
fanfan 8 months ago
parent ecff9470d3
commit 493fb320f5
  1. 115
      pages/login/index-2024-1-25.vue
  2. BIN
      static/wallet/wallet.png

@ -1,115 +0,0 @@
<template>
<view v-if="isLoad" class="login" :style="appThemeStyle">
<MpWeixin v-if="isMpWeixinAuth" @success="onGetUserInfoSuccess" />
<WxOfficial v-else-if="isWxOfficialAuth" @success="onGetUserInfoSuccess" />
<MpAlipay v-else-if="isMpAlipayAuth" @success="onGetUserInfoSuccess" />
<Main v-else :isParty="isParty" :partyData="partyData" :isMpWeixinMobile="isMpWeixinMobile" />
</view>
</template>
<script>
import Main from './components/main'
import MpWeixin from './components/mp-weixin'
import MpAlipay from './components/mp-alipay'
import WxOfficial from './components/wx-official'
import SettingKeyEnum from '@/common/enum/setting/Key'
import SettingModel from '@/common/model/Setting'
export default {
components: {
Main,
MpWeixin,
MpAlipay,
WxOfficial
},
data() {
return {
// [onLoadview]
isLoad: false,
// ()
setting: {},
//
isMpWeixinAuth: false,
//
isMpWeixinMobile: false,
//
isWxOfficialAuth: false,
//
isMpAlipayAuth: false,
//
isParty: false,
//
partyData: {}
}
},
/**
* 生命周期函数--监听页面加载
*/
async onLoad(options) {
//
await this.getRegisterSetting()
//
await this.setShowUserInfo()
//
this.isLoad = true
},
methods: {
// [--]
async getRegisterSetting() {
this.setting = await SettingModel.item(SettingKeyEnum.REGISTER.value, false)
},
/**
* 设置当前是否显示第三方授权登录
* - 条件1: 只有对应的客户端显示获取用户信息按钮, 例如微信小程序微信公众号
* - 条件2: 注册设置是否已开启该选项
*/
async setShowUserInfo() {
const app = this
//
const isMpWeixin = app.platform === 'MP-WEIXIN'
const isWxOfficial = app.platform === 'WXOFFICIAL'
const isMpAlipay = app.platform === 'MP-ALIPAY' && my.canIUse('getAuthCode')
//
app.isMpWeixinAuth = isMpWeixin && Boolean(app.setting.isOauthMpweixin)
app.isMpWeixinMobile = isMpWeixin && Boolean(app.setting.isOauthMobileMpweixin)
app.isWxOfficialAuth = isWxOfficial && Boolean(app.setting.isOauthWxofficial)
app.isMpAlipayAuth = isMpAlipay && Boolean(app.setting.isOauthMpAlipay)
},
//
onGetUserInfoSuccess(result) {
//
this.partyData = result
//
this.onShowRegister()
},
//
onShowRegister() {
//
if (this.partyData.oauth === 'MP-WEIXIN') {
this.isMpWeixinAuth = false
}
//
if (this.partyData.oauth === 'WXOFFICIAL') {
this.isWxOfficialAuth = false
}
//
if (this.partyData.oauth === 'MP-ALIPAY') {
this.isMpAlipayAuth = false
}
//
this.isParty = true
}
}
}
</script>
<style lang="scss" scoped>
</style>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

Loading…
Cancel
Save