下拉刷新更新

This commit is contained in:
GaoHao
2025-01-08 16:18:20 +08:00
parent c8dbc0f550
commit 7cbadc5638
9 changed files with 167 additions and 166 deletions

View File

@@ -1,27 +1,26 @@
<template>
<view class="containerView">
<view class="cu-form-group"
style="margin: 30upx;border: 2upx solid whitesmoke;margin-bottom: 20px;border-radius: 30px">
<view class="cu-form-group" >
<view class="title">手机号</view>
<input type="number" :value="mobile" placeholder="请输入手机号" maxlength="11" data-key="mobile"
<input type="number" :value="data.mobile" placeholder="请输入手机号" maxlength="11" data-key="mobile"
@input="inputChange" />
</view>
<view class="cu-form-group"
style="margin: 30upx;border: 2upx solid whitesmoke;margin-bottom: 20px;border-radius: 30px">
<view class="cu-form-group" >
<text class="title">验证码</text>
<input type="number" :value="code" placeholder="请输入验证码" maxlength="6" data-key="code" @input="inputChange"
<input type="number" :value="data.code" placeholder="请输入验证码" maxlength="6" data-key="code" @input="inputChange"
@confirm="toLogin" />
<button class="send-msg" @click="sendMsg" :disabled="sendIng">{{ sendTime }}</button>
<button class="send-msg" @click="sendMsg" :disabled="data.sendIng">{{ data.sendTime }}</button>
</view>
<button class="confirm-btn" @click="toLogin" :disabled="loginIng">立即绑定</button>
<button class="confirm-btn" @click="toLogin">立即绑定</button>
</view>
</template>
<script>
<script setup>
import { reactive } from 'vue';
import { onLoad} from '@dcloudio/uni-app'
import {setSendMsg,forgetPwd} from '@/api/login/login.js';
import { setSendMsg, bind} from '@/api/login/login.js';
let data = reactive({
mobile: '',
code: '',
@@ -30,8 +29,7 @@
sendTime: '获取验证码',
count: 60,
type: '',
})
})
onLoad((option) => {
if (option.type) {
data.type = option.type
@@ -55,113 +53,116 @@
data.count = count - 1;
data.sendIng = true;
data.sendTime = count - 1 + '秒后重新获取';
setTimeout(data.countDown.bind(data), 1000);
setTimeout(countDown.bind(this), 1000);
}
}
function sendMsg() {
const {
mobile
} = data;
if (!mobile) {
data.$queue.showToast("请输入手机号");
async function sendMsg() {
const { mobile } = data;
if (!data.mobile) {
uni.showToast({ title: '请输入手机号', icon: 'none', })
} else if (mobile.length !== 11) {
data.$queue.showToast("请输入正确的手机号");
uni.showToast({ title: '请输入正确的手机号', icon: 'none', })
} else {
data.$queue.showLoading("正在发送验证码...");
http.request({
url: 'app/Login/sendMsg/' + mobile + '/gzg',
}).then(res => {
if (res.code === 0) {
data.sendIng = true;
uni.showToast({ title: '验证码发送成功请注意查收', icon: 'none', })
data.countDown();
} else {
uni.showModal({
showCancel: false,
title: '短信发送失败',
content: res.msg ? res.msg : '请一分钟后再获取验证码'
});
}
uni.hideLoading();
uni.showLoading({
title: '正在发送验证码...'
})
let res = await setSendMsg(data.mobile,'gzg')
uni.hideLoading();
console.log(res)
if (res.code == 0) {
data.sendIng = true;
uni.showToast({ title: '验证码发送成功请注意查收', icon: 'none', })
countDown();
} else {
uni.showModal({
showCancel: false,
title: '短信发送失败',
content: res.msg ? res.msg : '请一分钟后再获取验证码'
});
}
}
}
function toLogin() {
async function toLogin() {
const {
mobile,
code
} = data;
let userId = this.$queue.getData("userId");
if (!mobile) {
if (!data.mobile) {
uni.showToast({ title: '请输入手机号', icon: 'none', })
} else if (mobile.length !== 11) {
} else if (data.mobile.length !== 11) {
uni.showToast({ title: '请输入正确的手机号', icon: 'none', })
} else if (!code) {
} else if (!data.code) {
uni.showToast({ title: '请输入验证码', icon: 'none', })
} else {
uni.showLoading({ title: '正在绑定中...' })
let openId = this.$queue.getData('openId') ? this.$queue.getData('openId') : '';
let openidnickname = this.$queue.getData('openidnickname') ? this.$queue.getData('openidnickname') :
'';
let openidheadimgurl = this.$queue.getData('openidheadimgurl') ? this.$queue.getData(
'openidheadimgurl') : '';
let invitation = this.$queue.getData('inviterCode') ? this.$queue.getData('inviterCode') : '';
let userId = this.$queue.getData('userId') ? this.$queue.getData('userId') : '';
http.request({
url: `app/Login/registerCode`,
method: 'post',
data: {
let res = await bind({
phone: mobile,
wxId: openId,
userId: userId,
inviterCode: invitation,
avatar: openidheadimgurl,
userName: openidnickname,
// wxId: openId,
// userId: userId,
// inviterCode: invitation,
// avatar: openidheadimgurl,
// userName: openidnickname,
msg: code
}
}).then(res => {
if (res.code === 0) {
this.$queue.setData("token", res.token);
this.$queue.setData('userId', res.user.userId);
this.$queue.setData('userName', res.user.userName);
this.$queue.setData('phone', res.user.phone);
this.$queue.setData('avatar', res.user.avatar ? res.user.avatar :
'../../static/logo.png');
this.$queue.showToast('绑定成功');
uni.showToast({ title: '绑定成功', icon: 'none', })
setTimeout(function() {
uni.navigateBack()
}, 1000)
} else {
uni.showModal({
showCancel: false,
title: '绑定失败',
content: res.msg,
});
}
uni.hideLoading();
});
})
uni.hideLoading();
uni.setStorageSync('token', res.token)
uni.setStorageSync('userInfo', res.user)
uni.showToast({ title: '绑定成功', icon: 'none', })
setTimeout(function() {
uni.navigateBack()
}, 1000)
}
}
</script>
<style lang='scss'>
<style lang='scss' scoped>
page {
background: #ffffff;
}
.cu-form-group{
background-color: #ffffff;
padding: 1rpx 30rpx;
display: flex;
align-items: center;
min-height: 80rpx;
justify-content: space-between;
margin: 30rpx;
border: 2rpx solid whitesmoke;
margin-bottom: 40rpx;
border-radius: 60rpx
}
.title{
text-align: justify;
padding-right: 30rpx;
font-size: 30rpx;
position: relative;
height: 60rpx;
line-height: 60rpx;
flex-shrink: 0;
}
uni-input{
flex: 1;
font-size: 15px;
color: #555;
padding-right: 10px;
}
.send-msg {
border-radius: 30px;
color: white;
height: 30px;
font-size: 14px;
line-height: 30px;
background: #557EFD;
border-radius: 30px;
color: white;
height: 30px;
font-size: 14px;
line-height: 30px;
background: #ff7581;
}
.containerView {
@@ -178,14 +179,14 @@
.confirm-btn {
width: 600upx;
height: 80upx;
line-height: 80upx;
border-radius: 60upx;
margin-top: 32upx;
background: #557EFD;
width: 300px;
height: 42px;
line-height: 42px;
border-radius: 30px;
margin-top: 70px;
background: #ff7581;
color: #ffffff;
font-size: 32upx;
font-size: 16px;
&:after {
border-radius: 60px;