对接接口

This commit is contained in:
wangxiaowei
2025-12-17 00:45:31 +08:00
parent 977f7d4038
commit 018a784a8c
20 changed files with 455 additions and 816 deletions

View File

@ -26,16 +26,17 @@
<view class="mt-20rpx">
<wd-input v-model="model.mobile" type="text" placeholder="请输入账号" inputmode="numeric" no-border
custom-class="!bg-[#F6F7F8] !rounded-16rpx"
custom-input-class="!px-32rpx !h-104rpx" @input="Login.handleInputMobile" />
custom-input-class="!px-32rpx !h-104rpx"/>
</view>
</view>
<view class="mt-40rpx">
<view class="font-400 text-30rpx text-[#606266] leading-44rpx">密码</view>
<view class="mt-20rpx">
<wd-input v-model="model.passowrd" type="safe-password" placeholder="请输入密码" no-border
<view class="mt-20rpx password-input">
<wd-input v-model="model.passowrd" show-password placeholder="请输入密码" no-border
custom-class="!bg-[#F6F7F8] !rounded-16rpx"
custom-input-class="!px-32rpx !h-104rpx" />
custom-input-class="!px-32rpx !h-104rpx">
</wd-input>
</view>
</view>
@ -51,152 +52,84 @@
</view>
</template>
<script lang="ts" setup>
import { mobile as testMobile } from '@/utils/test'
import { router } from '@/utils/tools'
import { useToast } from 'wot-design-uni'
import { mobile as testMobile } from '@/utils/test'
import { router } from '@/utils/tools'
import { useToast } from 'wot-design-uni'
import { useUserStore } from '@/store'
const OSS = inject('OSS')
const toast = useToast()
const disabled = ref<boolean>(true)
const OSS = inject('OSS')
const toast = useToast()
/** 页面 **/
let pageType = 'login' // 页面类型 login:登录 edit:修改手机号
const page = ref<{ title: string, desc: string }>({ title: '其他手机号登录', desc: '请输入你要登录的手机号' })
const showEditSuccessPopup = ref<boolean>(false) // 显示手机号修改成功弹窗
const userId = ref<number>(0) // 用户ID修改手机号时需要传
/** 表单相关 **/
const model = reactive<{
mobile: string
passowrd: string
}>({
mobile: '15005837859',
passowrd: '123456'
})
/** 验证码倒计时 **/
const countDownTime = ref<number>(1 * 60 * 1000) // 60s倒计时
const startCountDown = ref<boolean>(false) // 是否开始倒计时
const countDown = ref<any>(null) // 倒计时组件
/** 表单相关 **/
const model = reactive<{
mobile: string
passowrd: string
}>({
mobile: '',
passowrd: ''
})
/** 结束 **/
onLoad((args) => {
/** 服务协议和隐私政策 **/
const agree = ref<boolean>(false)
/** 结束 **/
})
onLoad((args) => {
// 从个人登录页面进入
if (args.type === 'edit') {
userId.value = Number(args.userId) || 0 // userId仅做测试使用实际请传真实用户ID
const Login = {
// 登录
handleToLogin: async () => {
// TODO 如果是edit的话就是修改手机号
if (!testMobile(model.mobile)) {
toast.info('请输入正确的账号')
return
}
page.value.title = '修改手机号'
page.value.desc = '手机号一年内可修改2次'
pageType = 'edit'
if (!model.passowrd) {
toast.info('请输入密码')
return
}
uni.showLoading({
title: '登录中...'
})
try {
const userStore = useUserStore()
const res = await userStore.mobileLogin(model.mobile, model.passowrd, 1, 1, 1)
uni.hideLoading()
toast.success('登录成功')
setTimeout(() => {
router.navigateBack()
}, 1000)
} catch (error) {
toast.info('登录失败,请稍后重试')
uni.hideLoading
return
}
}
}
})
const Login = {
// 验证手机号
handleInputMobile: (e: { value: string }) => {
model.mobile = e.value
disabled.value = !testMobile(model.mobile)
},
// 发送验证码
handleCountDown: () => {
if (disabled.value) {
toast.show({
iconClass: 'info-circle',
msg: '手机号码错误请重新输入',
direction: 'vertical'
})
return
}
startCountDown.value = true
nextTick(() => {
countDown.value?.start()
// 发送验证码请求
})
},
// 验证码倒计时结束
handleFinishCountDown: () => {
startCountDown.value = false
},
// 登录
handleToLogin: () => {
// TODO 如果是edit的话就是修改手机号
if (pageType === 'login' && !agree.value) {
toast.show({
iconClass: 'info-circle',
msg: '请同意服务协议和隐私政策',
direction: 'vertical'
})
return
}
if (!testMobile(model.mobile)) {
toast.show({
iconClass: 'info-circle',
msg: '手机号码错误请重新输入',
direction: 'vertical'
})
return
}
if (!model.code) {
toast.show({
iconClass: 'info-circle',
msg: '验证码错误',
direction: 'vertical'
})
return
}
},
// 获取手机号
handleGetPhoneNumber: (e: object) => {
console.log("🚀 ~ e:", e)
},
handleAgree: (e: any) => {
console.log('e', e)
},
// 跳转到服务协议页面
handleToService: () => {
disabled.value = !disabled.value
console.log("🚀 ~ disabled:", disabled)
},
// 跳转到隐私政策页面
handleToPrivacy: () => {
},
// 修改手机成功后返回
handleToBack: () => {
uni.navigateBack()
}
}
</script>
<style lang="scss">
page {
background-color: #fff;
}
page {
background-color: #fff;
}
.login-bg {
background-color: #fff;
background-image: url(#{$OSS}images/store/login/image1.png);
background-size: 100% 420rpx;
background-repeat: no-repeat;
}
.login-bg {
background-color: #fff;
background-image: url(#{$OSS}images/store/login/image1.png);
background-size: 100% 420rpx;
background-repeat: no-repeat;
}
.password-input {
:deep() {
.wd-input__icon {
padding-right: 20rpx !important;
background: transparent !important;
}
}
}
</style>