init
This commit is contained in:
@@ -0,0 +1,456 @@
|
||||
<template>
|
||||
<!-- 空登陆页 -->
|
||||
<s-layout navbar="inner" title="登录" color="#19203b">
|
||||
<view class="login">
|
||||
<view class="login_top_img w100" :style="{ top: -height + 'px' }">
|
||||
<image :src="$url + 'index/login_bg1.png'" mode="widthFix" class="w100" />
|
||||
</view>
|
||||
<view class="login_con w100 flex-column ju-between">
|
||||
<view class="login_top">
|
||||
<view class="font-Heavy size52 c0">Hello!</view>
|
||||
<view class="font-Heavy size52 c0">欢迎使用优购商城</view>
|
||||
</view>
|
||||
<view class="flex1 bottomCon">
|
||||
<view class="login_bottom">
|
||||
<view class="size40 f500 title">{{ dataObj.con[type].title }}</view>
|
||||
<view class="form">
|
||||
<uni-forms ref="form" label-position="top">
|
||||
<view v-for="(v, i) in dataObj.con[type].arr" :key="i">
|
||||
<uni-forms-item
|
||||
:required="false"
|
||||
:label="dataObj.formArr[v].title"
|
||||
:name="dataObj.formArr[v].value"
|
||||
>
|
||||
<view class="flex-center border_bottom">
|
||||
<uni-easyinput
|
||||
v-model="formData[dataObj.formArr[v].value]"
|
||||
:placeholder="dataObj.formArr[v].placeholder"
|
||||
:type="dataObj.formArr[v].type"
|
||||
:inputBorder="false"
|
||||
:maxlength="dataObj.formArr[v].max"
|
||||
/>
|
||||
<view v-if="v == 2" class="c_primary size28" @click="getCode">{{
|
||||
num > 0 && num < 60 ? num + 's后重新获取' : '获取验证码'
|
||||
}}</view>
|
||||
</view>
|
||||
</uni-forms-item>
|
||||
</view>
|
||||
</uni-forms>
|
||||
</view>
|
||||
<view class="flex-row ju-between size28 btns">
|
||||
<view class="flex-row">
|
||||
<view class="">{{ dataObj.con[type].text }}</view>
|
||||
<view
|
||||
class="c_primary"
|
||||
@click="typeChange(dataObj.btns[dataObj.con[type].btn1].value)"
|
||||
>{{ dataObj.btns[dataObj.con[type].btn1].text }}</view
|
||||
>
|
||||
</view>
|
||||
<view
|
||||
class="c_primary"
|
||||
@click="typeChange(dataObj.btns[dataObj.con[type].btn2].value)"
|
||||
v-if="dataObj.con[type].btn2"
|
||||
>{{ dataObj.btns[dataObj.con[type].btn2]?.text }}</view
|
||||
>
|
||||
</view>
|
||||
<view class="submit-btn" @click="$debounce(sub, 1000)">
|
||||
{{ dataObj.con[type].sub }}
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="radio-box">
|
||||
<radio-group @change="radioChange">
|
||||
<label class="flex-center">
|
||||
<radio color="#FA7E31" class="radio" value="1" :checked="false" />
|
||||
<view class="flex-center size24">
|
||||
我已阅读并同意
|
||||
<text class="c_primary" @click="go(2)">《用户服务协议》</text>
|
||||
和
|
||||
<text class="c_primary" @click="go(1)">《隐私政策》</text>
|
||||
</view>
|
||||
</label>
|
||||
</radio-group>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</s-layout>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive } from 'vue';
|
||||
import sheep from '@/sheep';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import { gethotupdatelist } from '@/sheep/api/index/index';
|
||||
import AuthUtil from '@/sheep/api/member/auth';
|
||||
let type = ref(2);
|
||||
let formData = reactive({});
|
||||
let num = ref(0);
|
||||
let dataObj = reactive({
|
||||
con: {
|
||||
1: {
|
||||
title: '验证码登录',
|
||||
arr: [1, 2],
|
||||
text: '还没账号?',
|
||||
btn1: 1,
|
||||
btn2: 2,
|
||||
sub: '立即登录',
|
||||
toast: '登录成功',
|
||||
},
|
||||
2: {
|
||||
title: '密码登录',
|
||||
arr: [1, 3],
|
||||
text: '还没账号?',
|
||||
btn1: 1,
|
||||
btn2: 3,
|
||||
sub: '立即登录',
|
||||
toast: '登录成功',
|
||||
},
|
||||
3: {
|
||||
title: '用户注册',
|
||||
arr: [1, 4, 5],
|
||||
// arr: [1, 2, 4, 5],
|
||||
text: '已有账号,',
|
||||
btn1: 4,
|
||||
btn2: 3,
|
||||
sub: '立即注册',
|
||||
toast: '注册成功',
|
||||
},
|
||||
4: {
|
||||
title: '忘记密码',
|
||||
arr: [1, 2, 4, 5],
|
||||
text: '已有账号,',
|
||||
btn1: 4,
|
||||
btn2: 2,
|
||||
sub: '修改密码',
|
||||
toast: '修改成功',
|
||||
},
|
||||
},
|
||||
formArr: {
|
||||
1: {
|
||||
title: '手机号',
|
||||
type: 'number',
|
||||
value: 'mobile',
|
||||
max: 11,
|
||||
placeholder: '请输入手机号',
|
||||
},
|
||||
2: {
|
||||
title: '验证码',
|
||||
type: 'number',
|
||||
value: 'code',
|
||||
max: 4,
|
||||
placeholder: '请输入验证码',
|
||||
},
|
||||
3: {
|
||||
title: '密码',
|
||||
type: 'password',
|
||||
value: 'password',
|
||||
placeholder: '请输入密码',
|
||||
},
|
||||
4: {
|
||||
title: '设置密码',
|
||||
type: 'password',
|
||||
value: 'password',
|
||||
placeholder: '请输入您的密码',
|
||||
},
|
||||
5: {
|
||||
title: '确认密码',
|
||||
type: 'password',
|
||||
value: 'confirmPassword',
|
||||
placeholder: '请再次输入您的密码',
|
||||
},
|
||||
},
|
||||
btns: {
|
||||
1: {
|
||||
text: '去注册',
|
||||
value: 3,
|
||||
},
|
||||
2: {
|
||||
text: '密码登录',
|
||||
value: 2,
|
||||
},
|
||||
// 3: {
|
||||
// text: '验证码登录',
|
||||
// value: 1,
|
||||
// },
|
||||
4: {
|
||||
text: '去登录',
|
||||
value: 2,
|
||||
},
|
||||
},
|
||||
});
|
||||
const rules = reactive({
|
||||
mobile: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入手机号',
|
||||
trigger: 'blur',
|
||||
},
|
||||
{
|
||||
pattern: /^1[3456789]\d{8}$/,
|
||||
message: '手机号格式不正确',
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
code: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入验证码',
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
password: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入密码',
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const typeChange = (val) => {
|
||||
console.log(val);
|
||||
type.value = val;
|
||||
clearInterval(timer.value);
|
||||
num.value = 0;
|
||||
};
|
||||
const radioValue = ref();
|
||||
const radioChange = (e) => {
|
||||
radioValue.value = e.detail.value;
|
||||
};
|
||||
const sub = async () => {
|
||||
if (!radioValue.value) {
|
||||
uni.showToast({
|
||||
title: '请阅读服务协议和隐私协议',
|
||||
duration: 1000,
|
||||
icon: 'none',
|
||||
});
|
||||
return;
|
||||
}
|
||||
let arr = dataObj.con[type.value].arr;
|
||||
let obj = {};
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
if (!formData[dataObj.formArr[arr[i]].value]) {
|
||||
uni.showToast({
|
||||
title: dataObj.formArr[arr[i]].placeholder,
|
||||
icon: 'none',
|
||||
});
|
||||
return;
|
||||
}
|
||||
obj[dataObj.formArr[arr[i]].value] = formData[dataObj.formArr[arr[i]].value];
|
||||
}
|
||||
let url = '';
|
||||
switch (type.value) {
|
||||
case 1: //密码登录
|
||||
url = AuthUtil.smsLogin;
|
||||
break;
|
||||
case 2: //验证码登录
|
||||
url = AuthUtil.login;
|
||||
break;
|
||||
case 3: //注册
|
||||
if (obj.password != obj.confirmPassword) {
|
||||
uni.showToast({
|
||||
title: '两次密码不一致',
|
||||
icon: 'none',
|
||||
});
|
||||
return;
|
||||
}
|
||||
url = AuthUtil.register;
|
||||
break;
|
||||
case 4: //忘记密码
|
||||
break;
|
||||
}
|
||||
url(obj).then((res) => {
|
||||
if (res.code === 0) {
|
||||
if (type.value == 3) {
|
||||
typeChange(2);
|
||||
return;
|
||||
}
|
||||
sheep.$store('user').getInfo();
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({ url: '/pages/index/index' });
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
};
|
||||
let timer = ref();
|
||||
const getCode = () => {
|
||||
if (num.value > 0 && num.value < 60) {
|
||||
return;
|
||||
}
|
||||
if (!radioValue.value) {
|
||||
uni.showToast({
|
||||
title: '请阅读服务协议和隐私协议',
|
||||
duration: 1000,
|
||||
icon: 'none',
|
||||
});
|
||||
return;
|
||||
}
|
||||
// 发送验证码
|
||||
if (!formData.mobile) {
|
||||
uni.showToast({
|
||||
title: '请输入手机号',
|
||||
icon: 'none',
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
sendCode();
|
||||
}
|
||||
};
|
||||
const sendCode = async () => {
|
||||
let numType = 1;
|
||||
switch (type.value) {
|
||||
case 1: //验证码登录1
|
||||
numType = 1;
|
||||
break;
|
||||
case 2: //密码登录1
|
||||
numType = 1;
|
||||
break;
|
||||
case 3: //注册6
|
||||
numType = 6;
|
||||
break;
|
||||
case 4: //忘记密码4
|
||||
numType = 4;
|
||||
break;
|
||||
}
|
||||
AuthUtil.sendSmsCode(formData.mobile, numType).then((res) => {
|
||||
if (res.code === 0) {
|
||||
num.value = 60;
|
||||
timer.value = setInterval(() => {
|
||||
num.value--;
|
||||
if (num.value <= 0) {
|
||||
clearInterval(timer.value);
|
||||
num.value = 60;
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
};
|
||||
const go = (type) => {
|
||||
uni.navigateTo({ url: '/pages/home/agreement?type=' + type });
|
||||
};
|
||||
onLoad(async () => {});
|
||||
let sysInfo = uni.getSystemInfoSync();
|
||||
const windowHeight = sysInfo.windowHeight;
|
||||
let height = ref(0);
|
||||
height.value = sysInfo.statusBarHeight + uni.upx2px(88);
|
||||
|
||||
const wgtUp = async () => {
|
||||
// console.log(plus.runtime);
|
||||
|
||||
let res = await gethotupdatelist();
|
||||
if (res.code !== 0) return;
|
||||
let filePath = res.data.filePath;
|
||||
let localVersion = uni.getSystemInfoSync().appWgtVersion;
|
||||
if (res.data.versionNumber != localVersion) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '发现新的版本,是否更新?',
|
||||
confirmColor: '#FA7E31',
|
||||
success: (res) => {
|
||||
downloadFile(filePath);
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
const downloadFile = (url) => {
|
||||
uni.downloadFile({
|
||||
url: url,
|
||||
success: (downloadResult) => {
|
||||
uni.showToast({
|
||||
title: '更新中....',
|
||||
icon: 'none',
|
||||
});
|
||||
if (downloadResult) {
|
||||
if (downloadResult.statusCode === 200) {
|
||||
plus.runtime.install(
|
||||
downloadResult.tempFilePath,
|
||||
{
|
||||
force: true,
|
||||
},
|
||||
function () {
|
||||
uni.showModal({
|
||||
title: '成功提示',
|
||||
content: '热更新成功,请重启应用',
|
||||
confirmColor: '#FA7E31',
|
||||
showCancel: false,
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
plus.runtime.restart(); //自动重启软件
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
function (e) {
|
||||
uni.showModal({
|
||||
title: '失败提示',
|
||||
content: e,
|
||||
showCancel: false,
|
||||
confirmColor: '#FA7E31',
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.login {
|
||||
position: relative;
|
||||
min-height: 100vh;
|
||||
.login_top_img {
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
}
|
||||
.login_con {
|
||||
position: relative;
|
||||
height: 100vh;
|
||||
padding-top: 50rpx;
|
||||
box-sizing: border-box;
|
||||
z-index: 1;
|
||||
// position: absolute;
|
||||
// top: 166rpx;
|
||||
// left: 0;
|
||||
// z-index: 2;
|
||||
// background-color: #F2F4F7;
|
||||
}
|
||||
}
|
||||
.login_top {
|
||||
padding-left: 50rpx;
|
||||
margin-bottom: 48rpx;
|
||||
}
|
||||
.bottomCon {
|
||||
background-color: #ffffff;
|
||||
border-radius: 80rpx 80rpx 0 0;
|
||||
}
|
||||
.login_bottom {
|
||||
// background: linear-gradient(144deg, #19203b 0%, #070c18 100%);
|
||||
padding: 60rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.border_bottom {
|
||||
border-bottom: 1px solid #999999;
|
||||
}
|
||||
.submit-btn {
|
||||
margin-top: 18rpx;
|
||||
}
|
||||
.radio-box {
|
||||
padding-top: 100rpx;
|
||||
padding-bottom: 60rpx;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
.radio {
|
||||
transform: scale(0.6);
|
||||
}
|
||||
.btns {
|
||||
margin-top: 70rpx;
|
||||
}
|
||||
.title {
|
||||
margin-bottom: 70rpx;
|
||||
}
|
||||
:deep(.uni-radio-input) {
|
||||
background-color: transparent;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user