mirror of
https://gitee.com/qingqing-coconut-tea/RcKtFezyRAZX
synced 2026-07-21 10:32:32 +08:00
init
This commit is contained in:
103
wechat/pages/bind-phone/bind-phone.js
Normal file
103
wechat/pages/bind-phone/bind-phone.js
Normal file
@@ -0,0 +1,103 @@
|
||||
// pages/bind-phone/bind-phone.js
|
||||
// 绑定手机号逻辑处理
|
||||
|
||||
const api = require('../../services/api')
|
||||
|
||||
Page({
|
||||
data: {
|
||||
phone: '',
|
||||
verifyCode: '',
|
||||
openid: '',
|
||||
countdown: 0,
|
||||
sendBtnText: '获取验证码',
|
||||
loading: false
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
if (options.openid) {
|
||||
this.setData({ openid: options.openid })
|
||||
}
|
||||
},
|
||||
|
||||
onPhoneInput(e) {
|
||||
this.setData({ phone: e.detail.value })
|
||||
},
|
||||
|
||||
onVerifyCodeInput(e) {
|
||||
this.setData({ verifyCode: e.detail.value })
|
||||
},
|
||||
|
||||
onSendVerifyCode() {
|
||||
const phone = this.data.phone.trim()
|
||||
|
||||
if (!phone) {
|
||||
wx.showToast({ title: '请输入手机号', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
api.sendSmsCode({ phone }).then(res => {
|
||||
if (res.code === 200) {
|
||||
wx.showToast({ title: '验证码已发送', icon: 'success' })
|
||||
this.startCountdown()
|
||||
} else {
|
||||
wx.showToast({ title: res.message || '发送失败', icon: 'none' })
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
startCountdown() {
|
||||
let seconds = 60
|
||||
this.setData({ countdown: seconds, sendBtnText: `${seconds}s` })
|
||||
|
||||
const timer = setInterval(() => {
|
||||
seconds--
|
||||
if (seconds <= 0) {
|
||||
clearInterval(timer)
|
||||
this.setData({ countdown: 0, sendBtnText: '获取验证码' })
|
||||
} else {
|
||||
this.setData({ sendBtnText: `${seconds}s` })
|
||||
}
|
||||
}, 1000)
|
||||
},
|
||||
|
||||
doBind() {
|
||||
const { phone, verifyCode, openid } = this.data
|
||||
|
||||
if (!phone.trim()) {
|
||||
wx.showToast({ title: '请输入手机号', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
if (!verifyCode.trim()) {
|
||||
wx.showToast({ title: '请输入验证码', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
this.setData({ loading: true })
|
||||
|
||||
api.bindPhone({
|
||||
phone: phone.trim(),
|
||||
verifyCode: verifyCode.trim(),
|
||||
openid: openid
|
||||
}).then(res => {
|
||||
this.setData({ loading: false })
|
||||
if (res.code === 200) {
|
||||
wx.showToast({ title: '绑定成功', icon: 'success' })
|
||||
setTimeout(() => {
|
||||
wx.navigateBack()
|
||||
}, 1500)
|
||||
} else {
|
||||
wx.showToast({ title: res.message || '绑定失败', icon: 'none' })
|
||||
}
|
||||
}).catch(() => {
|
||||
this.setData({ loading: false })
|
||||
wx.showToast({ title: '绑定失败', icon: 'none' })
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* @联系作者:16768118056
|
||||
* @描述:(此项目非免费分享)源码百分百可用,搞定毕设不发愁,支持远程调试安装、二次开发、定制、讲解、文档类。
|
||||
* @访问:https://www.notmaker.com/detail/8326a897119d4542896c863a69d7bbe7/gtt20260415,查看完整运行演示。
|
||||
*/
|
||||
11
wechat/pages/bind-phone/bind-phone.json
Normal file
11
wechat/pages/bind-phone/bind-phone.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"usingComponents": {},
|
||||
"navigationBarTitleText": "绑定手机号",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
|
||||
/**
|
||||
* @联系作者:16768118056
|
||||
* @描述:(此项目非免费分享)源码百分百可用,搞定毕设不发愁,支持远程调试安装、二次开发、定制、讲解、文档类。
|
||||
* @访问:https://www.notmaker.com/detail/8326a897119d4542896c863a69d7bbe7/gtt20260415,查看完整运行演示。
|
||||
*/
|
||||
32
wechat/pages/bind-phone/bind-phone.wxml
Normal file
32
wechat/pages/bind-phone/bind-phone.wxml
Normal file
@@ -0,0 +1,32 @@
|
||||
<!-- pages/bind-phone/bind-phone.wxml -->
|
||||
<!-- 绑定手机号视图 -->
|
||||
|
||||
<view class="bind-phone-container">
|
||||
<view class="header">
|
||||
<text class="title">绑定手机号</text>
|
||||
<text class="subtitle">为了保障您的账号安全,请绑定手机号</text>
|
||||
</view>
|
||||
|
||||
<view class="form">
|
||||
<view class="form-item">
|
||||
<text class="iconfont icon-phone form-icon"></text>
|
||||
<input class="form-input" type="number" maxlength="11" placeholder="请输入手机号" bindinput="onPhoneInput" value="{{phone}}" />
|
||||
</view>
|
||||
|
||||
<view class="form-item verify-code-item">
|
||||
<text class="iconfont icon-verify form-icon"></text>
|
||||
<input class="form-input" type="number" maxlength="6" placeholder="请输入验证码" bindinput="onVerifyCodeInput" value="{{verifyCode}}" />
|
||||
<button class="send-code-btn {{countdown > 0 ? 'disabled' : ''}}" bindtap="onSendVerifyCode" disabled="{{countdown > 0}}">
|
||||
{{sendBtnText}}
|
||||
</button>
|
||||
</view>
|
||||
|
||||
<button class="bind-btn" bindtap="doBind" loading="{{loading}}">绑定</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
/**
|
||||
* @联系作者:16768118056
|
||||
* @描述:(此项目非免费分享)源码百分百可用,搞定毕设不发愁,支持远程调试安装、二次开发、定制、讲解、文档类。
|
||||
* @访问:https://www.notmaker.com/detail/8326a897119d4542896c863a69d7bbe7/gtt20260415,查看完整运行演示。
|
||||
*/
|
||||
93
wechat/pages/bind-phone/bind-phone.wxss
Normal file
93
wechat/pages/bind-phone/bind-phone.wxss
Normal file
@@ -0,0 +1,93 @@
|
||||
/* pages/bind-phone/bind-phone.wxss */
|
||||
/* 绑定手机号页面样式 */
|
||||
|
||||
.bind-phone-container {
|
||||
min-height: 100vh;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
padding: 80rpx 60rpx 60rpx;
|
||||
}
|
||||
|
||||
.header {
|
||||
text-align: center;
|
||||
margin-bottom: 60rpx;
|
||||
}
|
||||
|
||||
.title {
|
||||
display: block;
|
||||
font-size: 48rpx;
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
font-size: 28rpx;
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
|
||||
.form {
|
||||
background-color: #fff;
|
||||
border-radius: 24rpx;
|
||||
padding: 60rpx 40rpx;
|
||||
box-shadow: 0 20rpx 60rpx rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.form-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
padding: 24rpx 0;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.form-icon {
|
||||
font-size: 40rpx;
|
||||
color: #667eea;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.form-input {
|
||||
flex: 1;
|
||||
height: 60rpx;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.verify-code-item {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.send-code-btn {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
padding: 12rpx 20rpx;
|
||||
font-size: 24rpx;
|
||||
color: #667eea;
|
||||
background-color: #fff;
|
||||
border: 1rpx solid #667eea;
|
||||
border-radius: 24rpx;
|
||||
}
|
||||
|
||||
.send-code-btn.disabled {
|
||||
color: #999;
|
||||
border-color: #ddd;
|
||||
}
|
||||
|
||||
.bind-btn {
|
||||
margin-top: 40rpx;
|
||||
height: 88rpx;
|
||||
line-height: 88rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
border-radius: 44rpx;
|
||||
}
|
||||
|
||||
/**
|
||||
* @联系作者:16768118056
|
||||
* @描述:(此项目非免费分享)源码百分百可用,搞定毕设不发愁,支持远程调试安装、二次开发、定制、讲解、文档类。
|
||||
* @访问:https://www.notmaker.com/detail/8326a897119d4542896c863a69d7bbe7/gtt20260415,查看完整运行演示。
|
||||
*/
|
||||
Reference in New Issue
Block a user