diff --git a/package2/login/login.vue b/package2/login/login.vue index c75aafa..f2411dc 100644 --- a/package2/login/login.vue +++ b/package2/login/login.vue @@ -89,6 +89,10 @@ + + + {{inviteSkipTipText}} + @@ -108,7 +112,9 @@ areaKind: 1, inviteContext: { inviterId: '', regionId: '' }, inviteLat: '', - inviteLng: '' + inviteLng: '', + inviteSkipTipVisible: false, + inviteSkipTipText: '' } }, computed: { @@ -150,6 +156,9 @@ this.goAfterLogin(false) } }, + onUnload() { + clearTimeout(this._inviteSkipTipTimer) + }, methods: { syncInviteContext(option) { rememberInviteParams(option || {}) @@ -193,6 +202,17 @@ } return payload }, + showInviteSkipToast(message) { + clearTimeout(this._inviteSkipTipTimer) + this.inviteSkipTipText = message + this.inviteSkipTipVisible = true + return new Promise((resolve) => { + this._inviteSkipTipTimer = setTimeout(() => { + this.inviteSkipTipVisible = false + resolve(true) + }, 1500) + }) + }, ensureInviteRegionMatched() { if (!this.hasInviteContext()) return Promise.resolve(true) return new Promise((resolve) => { @@ -210,16 +230,13 @@ resolve(true) return } - this.tui.toast('当前定位不在邀请区域内,无法领取拉新奖励') - resolve(false) + this.showInviteSkipToast('定位不在邀请区域内,邀请人无法获得奖励').then(resolve) }).catch(() => { - this.tui.toast('区域校验失败,请稍后再试') - resolve(false) + this.showInviteSkipToast('区域校验失败,邀请人无法获得奖励').then(resolve) }) }, fail: () => { - this.tui.toast('需要授权定位后领取拉新奖励') - resolve(false) + this.showInviteSkipToast('未授权定位,邀请人无法获得奖励').then(resolve) } }) }) @@ -246,46 +263,40 @@ const that = this this.loginLoading = true - this.ensureInviteRegionMatched().then((matched) => { - if (!matched) { - that.loginLoading = false - return - } - uni.login({ - provider: 'weixin', - success(loginRes) { - that.getWechatProfile().then((profile) => { - that.cacheWechatProfile(profile) - const loginPayload = Object.assign({ - jsCode: loginRes.code, - customId: that.customId, - wechatName: profile.nickName || uni.getStorageSync('nickname') || that.defaultWechatName, - userType: '2' - }, that.getInvitePayload()) - that.tui.request('/user/login', 'post', loginPayload, false, false).then((res) => { - that.loginLoading = false - if (res.code == 200) { - that.saveLoginResult(res.result) - if (!res.result || !res.result.user || res.result.user.mobile == null || res.result.user.mobile === '') { - that.needPhoneAuth = true - that.tui.toast('绑定手机号,解锁完整半径') - } else { - that.enterHome() - } + uni.login({ + provider: 'weixin', + success(loginRes) { + that.getWechatProfile().then((profile) => { + that.cacheWechatProfile(profile) + const loginPayload = Object.assign({ + jsCode: loginRes.code, + customId: that.customId, + wechatName: profile.nickName || uni.getStorageSync('nickname') || that.defaultWechatName, + userType: '2' + }, that.getInvitePayload()) + that.tui.request('/user/login', 'post', loginPayload, false, false).then((res) => { + that.loginLoading = false + if (res.code == 200) { + that.saveLoginResult(res.result) + if (!res.result || !res.result.user || res.result.user.mobile == null || res.result.user.mobile === '') { + that.needPhoneAuth = true + that.tui.toast('绑定手机号,解锁完整半径') } else { - that.tui.toast(res.message) + that.enterHome() } - }).catch(() => { - that.loginLoading = false - that.tui.toast('登录失败,请稍后再试') - }) + } else { + that.tui.toast(res.message) + } + }).catch(() => { + that.loginLoading = false + that.tui.toast('登录失败,请稍后再试') }) - }, - fail() { - that.loginLoading = false - that.tui.toast('微信登录失败,请稍后再试') - } - }) + }) + }, + fail() { + that.loginLoading = false + that.tui.toast('微信登录失败,请稍后再试') + } }) }, getWechatProfile() { @@ -335,10 +346,6 @@ this.phoneLoading = true this.ensureInviteRegionMatched().then((matched) => { - if (!matched) { - this.phoneLoading = false - return - } const phonePayload = Object.assign({ code: e.detail.code }, this.getInvitePayload()) @@ -1142,4 +1149,24 @@ transform: translateY(-8rpx); } } + + .invite-skip-tip { + position: fixed; + left: 50%; + top: 50%; + z-index: 9999; + width: 560rpx; + max-width: calc(100vw - 96rpx); + padding: 26rpx 30rpx; + box-sizing: border-box; + border-radius: 28rpx; + background: rgba(18, 59, 49, 0.94); + color: #ffffff; + font-size: 27rpx; + font-weight: 700; + line-height: 1.55; + text-align: center; + box-shadow: 0 24rpx 70rpx rgba(18, 59, 49, 0.24); + transform: translate(-50%, -50%); + }