feat: 登陆弹窗优化,添加商家入驻协议页面,登录页面优化,添加添加企业微信二维码,啤酒币页面逻辑判定。

This commit is contained in:
davy 2025-04-01 20:53:26 +08:00
parent 30c802cd05
commit 94415fbff8
4 changed files with 214 additions and 33 deletions

View File

@ -9,7 +9,13 @@
<!-- <button class="cu-btn phone-btn" @click="toPhoneLogin">
其他手机号登录</button> -->
<text class="sub-title">我已阅读并同意商家入驻协议</text>
<view class="agreement-box">
<checkbox-group @change="checkboxChange" class="checkbox-group">
<checkbox value="1" :checked="isAgree" color="#19367A" class="checkbox" />
<text class="agreement-text">我已阅读并同意</text>
<text class="link" @click="toAgreement">商家入驻协议</text>
</checkbox-group>
</view>
</view>
<view v-else class="page-content padding">
<view class="flex-col">
@ -53,6 +59,7 @@
password: ''
},
showPassword: false,
isAgree: false
};
},
methods: {
@ -76,6 +83,13 @@
//
toLogin() {
if (!this.isAgree) {
uni.showToast({
title: '请先同意商家入驻协议',
icon: 'none'
})
return
}
uni.login({
provider: 'weixin', //使
success: (loginRes) => {
@ -99,7 +113,22 @@
})
},
decryptPhoneNumber(e) {
console.log(e.detail.code)
if (!this.isAgree) {
uni.showToast({
title: '请先同意商家入驻协议',
icon: 'none'
})
return
}
if (!e.detail.code) {
uni.showToast({
title: '获取手机号失败,请重试',
icon: 'none'
})
return
}
const data = {
code: e.detail.code
}
@ -194,6 +223,16 @@
uni.setStorageSync('barInfo', res.data)
})
},
//
checkboxChange(e) {
this.isAgree = e.detail.value.length > 0
},
//
toAgreement() {
uni.navigateTo({
url: '/pages/index/userAgreement'
})
},
}
}
@ -209,6 +248,7 @@
justify-content: center;
align-items: center;
padding: 80rpx 32rpx;
border-radius: 24rpx 24rpx 0rpx 0rpx;
.title {
font-family: Roboto;
@ -253,6 +293,34 @@
font-weight: 500;
color: #979797;
}
.agreement-box {
display: flex;
justify-content: center;
align-items: center;
margin-top: 20rpx;
.checkbox-group {
display: flex;
align-items: center;
.checkbox {
transform: scale(0.8);
margin-right: 8rpx;
}
.agreement-text {
font-size: 24rpx;
color: #666666;
margin-right: 4rpx;
}
.link {
font-size: 24rpx;
color: #19367A;
}
}
}
}
.page-content {
padding: 48rpx 32rpx;

View File

@ -167,6 +167,14 @@
{
"navigationBarTitleText" : ""
}
},
{
"path": "pages/index/userAgreement",
"style": {
"navigationBarTitleText": "商家入驻协议",
"navigationBarBackgroundColor": "#19367A",
"navigationBarTextStyle": "white"
}
}

View File

@ -1,7 +1,7 @@
<template>
<view class="page-content">
<view style="margin: 0rpx auto 200rpx;color: #0B0E26;font-size: 36rpx;font-weight: bold;">欢迎加入枝点</view>
<view style="margin: 0rpx auto 200rpx;color: #0B0E26;font-size: 36rpx;font-weight: bold;">欢迎加入啤啤猩球</view>
<button class="cu-btn btn bg-zd margin-bottom text-white" @click="toLogin">
<!-- <text class="cuIcon-weixin text-green margin-right-xs" style="font-size: 44rpx !important;"></text> -->
微信一键登录</button>
@ -12,7 +12,13 @@
其他手机号登录</button> -->
<!-- <button class="cu-btn btn" style="margin-bottom: 100rpx;" @click="toReg">立即入驻</button> -->
<view class="agree-text">我已阅读并同意商家入驻协议</view>
<view class="agreement-box">
<checkbox-group @change="checkboxChange" class="checkbox-group">
<checkbox value="1" :checked="isAgree" color="#19367A" class="checkbox" />
<text class="agreement-text">我已阅读并同意</text>
<text class="link" @click="toAgreement">商家入驻协议</text>
</checkbox-group>
</view>
</view>
</template>
@ -27,7 +33,7 @@
export default {
data() {
return {
isAgree: false
};
},
onLoad() {
@ -36,20 +42,24 @@
methods: {
//
toLogin() {
if (!this.isAgree) {
uni.showToast({
title: '请先同意商家入驻协议',
icon: 'none'
})
return
}
uni.login({
provider: 'weixin', //使
provider: 'weixin',
success: (loginRes) => {
console.log(loginRes.code);
if (loginRes.code) {
uni.showLoading({
mask: true
})
getOpenId(loginRes.code).then(res => {
console.log(res.token)
this.openId = res.openId
if (res.token) {
uni.setStorageSync('token', res.token)
//
this.getUserInfoFun()
this.getBarInfoFun()
}
@ -59,20 +69,23 @@
})
},
decryptPhoneNumber(e) {
console.log(e.detail.code)
if (!this.isAgree) {
uni.showToast({
title: '请先同意商家入驻协议',
icon: 'none'
})
return
}
const data = {
code: e.detail.code
}
uni.showLoading()
phoneCodeLoginApi(data).then(res=>{
console.log(res,'22222')
if (res.token) {
uni.setStorageSync('token', res.token)
//
this.getUserInfoFun()
this.getBarInfoFun()
}
})
},
//
@ -81,7 +94,6 @@
if (res.user && res.user.barId) {
this.userInfo = res.user
uni.setStorageSync('userInfo', res.user)
//
uni.reLaunch({
url: '/pages/index/index'
})
@ -92,7 +104,6 @@
showCancel: true,
success: (res) => {
if (res.confirm) {
console.log('确定')
uni.navigateTo({
url: '/pages/index/registration?openId=' + this.openId
})
@ -100,7 +111,6 @@
}
})
}
uni.hideLoading()
})
},
@ -143,6 +153,16 @@
// uni.navigateTo({
// url: "/pages/index/phoneLogin"
// })
},
//
toAgreement() {
uni.navigateTo({
url: '/pages/index/userAgreement'
})
},
//
checkboxChange(e) {
this.isAgree = e.detail.value.length > 0
}
}
}
@ -169,10 +189,41 @@
.btn {
width: 686rpx;
height: 104rpx;
height: 80rpx;
border-radius: 12rpx;
// box-shadow: 0px 10px 24px 0px rgba(43, 45, 51, 0.2);
}
.agreement-box {
position: fixed;
bottom: 100rpx;
left: 0;
right: 0;
display: flex;
justify-content: center;
align-items: center;
.checkbox-group {
display: flex;
align-items: center;
justify-content: center;
.checkbox {
transform: scale(0.8);
margin-right: 8rpx;
}
.agreement-text {
font-size: 24rpx;
color: #666666;
margin-right: 4rpx;
}
.link {
font-size: 24rpx;
color: #19367A;
}
}
}
}
</style>

View File

@ -109,25 +109,33 @@
},
data() {
return {
loading: true,
statusBaeHeight: 40,
userInfo: null,
loading: true,
barInfo: null,
myScanData: {}
myScanData: null,
isLoggedIn: false,
statusBaeHeight: 40
};
},
onLoad() {
this.statusBaeHeight = uni.getWindowInfo.statusBarHeight
},
onShow() {
this.userInfo = uni.getStorageSync('userInfo')
if (this.userInfo) {
this.loading = false
this.checkLoginStatus()
if (this.isLoggedIn) {
this.getBarInfoFun()
this.getMyScanDataFun()
}
},
methods: {
//
checkLoginStatus() {
const token = uni.getStorageSync('token')
const userInfo = uni.getStorageSync('userInfo')
this.isLoggedIn = !!(token && userInfo)
this.userInfo = userInfo
this.loading = false
},
loginSuccess() {
this.userInfo = uni.getStorageSync('userInfo')
this.getBarInfoFun()
@ -135,21 +143,51 @@
},
//
getBarInfoFun() {
if (!this.isLoggedIn) return
getBarInfo().then(res => {
if (res.code === 200) {
this.barInfo = res.data
}
}).catch(err => {
console.error('获取酒吧信息失败:', err)
uni.showToast({
title: '获取酒吧信息失败',
icon: 'none'
})
})
},
//
getMyScanDataFun() {
if (!this.isLoggedIn) return
getMyScanData().then(res => {
if (res.code === 200) {
this.myScanData = res.data
}
}).catch(err => {
console.error('获取扫码数据失败:', err)
uni.showToast({
title: '获取扫码数据失败',
icon: 'none'
})
})
},
//
toPage(index) {
if (!uni.getStorageSync('token') && index != 5) {
//
if (index === 5) {
uni.navigateTo({
url: '/pagesMy/addAiad'
})
return
}
//
if (!this.isLoggedIn) {
this.$refs.loginRef.open()
return
}
//
switch (index) {
case 1: //
uni.switchTab({
@ -171,11 +209,6 @@
url: '/pagesMy/myAddress'
})
break;
case 5: //
uni.navigateTo({
url: '/pagesMy/addAiad'
})
break;
case 6: //
uni.navigateTo({
url: '/pagesMy/feedback'
@ -185,24 +218,45 @@
uni.navigateTo({
url: '/pagesMy/setting'
})
break;
default:
break;
}
},
// 退
logout() {
if (!this.isLoggedIn) return
uni.showModal({
title: '提示',
content: '确定要退出登录吗?',
success: (res) => {
if (res.confirm) {
uni.clearStorageSync()
//
uni.removeStorageSync('token')
uni.removeStorageSync('userInfo')
this.isLoggedIn = false
this.userInfo = null
this.barInfo = null
this.myScanData = null
//
uni.reLaunch({
url: '/pages/index/chooseLogin'
})
}
}
})
},
//
closeLoginPopup() {
this.$refs.loginRef.close()
},
//
toLogin() {
uni.navigateTo({
url: '/pages/index/registration'
})
}
}
}