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 class="cu-btn phone-btn" @click="toPhoneLogin">
其他手机号登录</button> --> 其他手机号登录</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>
<view v-else class="page-content padding"> <view v-else class="page-content padding">
<view class="flex-col"> <view class="flex-col">
@ -53,6 +59,7 @@
password: '' password: ''
}, },
showPassword: false, showPassword: false,
isAgree: false
}; };
}, },
methods: { methods: {
@ -76,6 +83,13 @@
// //
toLogin() { toLogin() {
if (!this.isAgree) {
uni.showToast({
title: '请先同意商家入驻协议',
icon: 'none'
})
return
}
uni.login({ uni.login({
provider: 'weixin', //使 provider: 'weixin', //使
success: (loginRes) => { success: (loginRes) => {
@ -99,7 +113,22 @@
}) })
}, },
decryptPhoneNumber(e) { 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 = { const data = {
code: e.detail.code code: e.detail.code
} }
@ -194,6 +223,16 @@
uni.setStorageSync('barInfo', res.data) 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; justify-content: center;
align-items: center; align-items: center;
padding: 80rpx 32rpx; padding: 80rpx 32rpx;
border-radius: 24rpx 24rpx 0rpx 0rpx;
.title { .title {
font-family: Roboto; font-family: Roboto;
@ -253,6 +293,34 @@
font-weight: 500; font-weight: 500;
color: #979797; 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 { .page-content {
padding: 48rpx 32rpx; padding: 48rpx 32rpx;

View File

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

View File

@ -1,7 +1,7 @@
<template> <template>
<view class="page-content"> <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"> <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> --> <!-- <text class="cuIcon-weixin text-green margin-right-xs" style="font-size: 44rpx !important;"></text> -->
微信一键登录</button> 微信一键登录</button>
@ -12,7 +12,13 @@
其他手机号登录</button> --> 其他手机号登录</button> -->
<!-- <button class="cu-btn btn" style="margin-bottom: 100rpx;" @click="toReg">立即入驻</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> </view>
</template> </template>
@ -27,7 +33,7 @@
export default { export default {
data() { data() {
return { return {
isAgree: false
}; };
}, },
onLoad() { onLoad() {
@ -36,20 +42,24 @@
methods: { methods: {
// //
toLogin() { toLogin() {
if (!this.isAgree) {
uni.showToast({
title: '请先同意商家入驻协议',
icon: 'none'
})
return
}
uni.login({ uni.login({
provider: 'weixin', //使 provider: 'weixin',
success: (loginRes) => { success: (loginRes) => {
console.log(loginRes.code);
if (loginRes.code) { if (loginRes.code) {
uni.showLoading({ uni.showLoading({
mask: true mask: true
}) })
getOpenId(loginRes.code).then(res => { getOpenId(loginRes.code).then(res => {
console.log(res.token)
this.openId = res.openId this.openId = res.openId
if (res.token) { if (res.token) {
uni.setStorageSync('token', res.token) uni.setStorageSync('token', res.token)
//
this.getUserInfoFun() this.getUserInfoFun()
this.getBarInfoFun() this.getBarInfoFun()
} }
@ -59,20 +69,23 @@
}) })
}, },
decryptPhoneNumber(e) { decryptPhoneNumber(e) {
console.log(e.detail.code) if (!this.isAgree) {
uni.showToast({
title: '请先同意商家入驻协议',
icon: 'none'
})
return
}
const data = { const data = {
code: e.detail.code code: e.detail.code
} }
uni.showLoading() uni.showLoading()
phoneCodeLoginApi(data).then(res=>{ phoneCodeLoginApi(data).then(res=>{
console.log(res,'22222')
if (res.token) { if (res.token) {
uni.setStorageSync('token', res.token) uni.setStorageSync('token', res.token)
//
this.getUserInfoFun() this.getUserInfoFun()
this.getBarInfoFun() this.getBarInfoFun()
} }
}) })
}, },
// //
@ -81,7 +94,6 @@
if (res.user && res.user.barId) { if (res.user && res.user.barId) {
this.userInfo = res.user this.userInfo = res.user
uni.setStorageSync('userInfo', res.user) uni.setStorageSync('userInfo', res.user)
//
uni.reLaunch({ uni.reLaunch({
url: '/pages/index/index' url: '/pages/index/index'
}) })
@ -92,7 +104,6 @@
showCancel: true, showCancel: true,
success: (res) => { success: (res) => {
if (res.confirm) { if (res.confirm) {
console.log('确定')
uni.navigateTo({ uni.navigateTo({
url: '/pages/index/registration?openId=' + this.openId url: '/pages/index/registration?openId=' + this.openId
}) })
@ -100,7 +111,6 @@
} }
}) })
} }
uni.hideLoading() uni.hideLoading()
}) })
}, },
@ -143,6 +153,16 @@
// uni.navigateTo({ // uni.navigateTo({
// url: "/pages/index/phoneLogin" // 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 { .btn {
width: 686rpx; width: 686rpx;
height: 104rpx; height: 80rpx;
border-radius: 12rpx; border-radius: 12rpx;
// box-shadow: 0px 10px 24px 0px rgba(43, 45, 51, 0.2); // 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> </style>

View File

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