xbx #60

Merged
theluyuan merged 9 commits from xbx into master 2020-10-20 17:09:35 +08:00
2 changed files with 141 additions and 17 deletions
Showing only changes of commit 146bfcaf46 - Show all commits

View File

@ -446,6 +446,9 @@ export async function getarchives(): Promise<[Countries[],Willsay[]]>{
return [(await get<Countries[]>("countries")).data, (await get<Willsay[]>("willsay")).data]; return [(await get<Countries[]>("countries")).data, (await get<Willsay[]>("willsay")).data];
} }
export async function getwillsay(): Promise<Willsay[]>{
return (await get<Willsay[]>("willsay")).data;
}
/** /**
* *
@ -569,4 +572,52 @@ export async function cancellive(id: number, status: number){
message.error(res.msg); message.error(res.msg);
return false; return false;
} }
}
/**
*
*/
export async function checksmscode(phone: string, smscode: string){
const res = await get("checkSmscode",{phone, smscode});
if(res.code == 0){
return true;
}else{
message.error(res.msg);
return false;
}
}
export async function register(data: any){
const res = await post<any>("register",{
mobile: data.phone,
code: data.quhao,
password: data.pass,
topassword: data.passtow,
name: data.name,
email: data.emil,
mtongue: data.muyu,
tlanguage: data.jiaoshou
})
if(res.code == 0){
message.success(res.msg)
if(!saveValue("token", res.data.api_token) && !saveValue("memberid", res.data.memberid) ){
message.error("存储错误, 请允许网页使用本地存储!")
return false;
}else{
setToken();
store.commit("login", true);
store.dispatch("setUserInfo");
// router.push("/mine/archives")
}
return true;
}else{
message.error(res.msg)
return false;
}
} }

View File

@ -66,6 +66,7 @@
class="shuru" class="shuru"
placeholder="请输入您的密码" placeholder="请输入您的密码"
type="password" type="password"
v-model:value="userinfo.pass"
/> />
</a-form-item> </a-form-item>
<a-form-item label="设置密码" class="form-item"> <a-form-item label="设置密码" class="form-item">
@ -73,23 +74,23 @@
class="shuru" class="shuru"
placeholder="请再次输入您的密码" placeholder="请再次输入您的密码"
type="password" type="password"
v-model:value="userinfo.passtow"
/> />
</a-form-item> </a-form-item>
<a-form-item label="姓名" class="form-item"> <a-form-item label="姓名" class="form-item">
<a-input class="shuru" placeholder="请输入您的姓名" /> <a-input class="shuru" placeholder="请输入您的姓名" v-model:value="userinfo.name" />
</a-form-item> </a-form-item>
<a-form-item label="邮箱" class="form-item"> <a-form-item label="邮箱" class="form-item">
<a-input class="shuru" placeholder="请输入您的邮箱" /> <a-input class="shuru" placeholder="请输入您的邮箱" v-model:value="userinfo.emil" />
</a-form-item> </a-form-item>
<a-form-item label="母语" class="form-item"> <a-form-item label="母语" class="form-item">
<a-input class="shuru" placeholder="请输入您的母语" /> <a-input class="shuru" placeholder="请输入您的母语" v-model:value="userinfo.muyu" />
</a-form-item> </a-form-item>
<a-form-item label="教授" class="form-item"> <a-form-item label="教授" class="form-item">
<a-select class="getcode" placeholder="请选择您的教授"> <a-select v-model:value="userinfo.jiaoshou" class="getcode" style="color: #111;" placeholder="请选择您的教授">
<a-select-option value="Zhejiang"> <a-select-option v-for="(item, index) in willsay" :key="index" :value="item.languageid" >
中国+0086 {{ item.name }}
</a-select-option> </a-select-option>
<a-select-option value="Jiangsu"> Jiangsu </a-select-option>
</a-select> </a-select>
</a-form-item> </a-form-item>
</div> </div>
@ -136,9 +137,10 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent, reactive, ref } from "vue"; import { defineComponent, reactive, ref, toRaw } from "vue";
import NavTop from "@/components/NavTop.vue"; import NavTop from "@/components/NavTop.vue";
import { sendsms } from '@/api'; import { checksmscode, getwillsay, register, sendsms } from '@/api';
import { message } from 'ant-design-vue';
export default defineComponent({ export default defineComponent({
name: "Sign", name: "Sign",
@ -149,12 +151,23 @@ export default defineComponent({
wrapperCol: 14, wrapperCol: 14,
}; };
const time = ref(60); // const time = ref(60); //
const phone = reactive({ const phone = ref({
quhao:"86", quhao:"86",
phone: "", phone: "",
code: "" code: ""
}); });
const userinfo = ref({
pass: "",
passtow: "",
name: "",
emil: "",
muyu: "",
jiaoshou: ""
})
const willsay = ref<any>();
getwillsay().then((res) => {
willsay.value = res;
})
/** /**
* @param * @param
* 点击获取验证码 触发60S倒计时 * 点击获取验证码 触发60S倒计时
@ -163,10 +176,14 @@ export default defineComponent({
const getcode: () => void = () => { const getcode: () => void = () => {
console.log(11111); console.log(11111);
if (lock) { if (lock) {
return; return;
}
if(phone.value.phone == ""){
message.error("手机号不能为空");
return ;
} }
lock = true; lock = true;
sendsms(phone.quhao + phone.phone, 0); sendsms(phone.value.quhao + phone.value.phone, 0);
const timestep = setInterval(() => { const timestep = setInterval(() => {
console.log(phone); console.log(phone);
time.value = time.value - 1; time.value = time.value - 1;
@ -190,13 +207,67 @@ export default defineComponent({
const stepnow = ref(1); // const stepnow = ref(1); //
function yanzheng(){
if(userinfo.value.pass == ""){
message.error("密码不能为空")
return false
}
if(userinfo.value.passtow == ""){
message.error("密码不能为空")
return false
}
if(userinfo.value.name == ""){
message.error("姓名不能为空")
return false
}
if(userinfo.value.emil == ""){
message.error("邮箱不能为空")
return false
}
if(userinfo.value.muyu == ""){
message.error("母语不能为空")
return false
}
if(userinfo.value.jiaoshou == ""){
message.error("请选择教授语言")
return false
}
return true;
}
/** /**
*@param e 跳到哪一步 *@param e 跳到哪一步
* 步骤条跳到某一步 * 步骤条跳到某一步
*/ */
const next: (e: number) => void = (e: number) => {
stepnow.value = e; async function next (e: number) {
}; switch (e) {
case 2:{
console.log(e)
if(phone.value.phone == ""){
message.error("手机号不能为空")
return ;
}else if(phone.value.code == ""){
message.error("验证码不能为空")
return ;
}
const res = await checksmscode(phone.value.quhao + phone.value.phone, phone.value.code);
if(res){
stepnow.value = e;
}
break;
}
case 3: {
console.log(userinfo.value)
const yz = yanzheng();
if(yz){
const res = await register({...toRaw(phone.value), ...toRaw(userinfo.value)});
if(res){
stepnow.value = e;
}
}
}
}
}
return { return {
formLayout, formLayout,
getcode, getcode,
@ -205,7 +276,9 @@ export default defineComponent({
ifagree, ifagree,
stepnow, stepnow,
next, next,
phone phone,
userinfo,
willsay
}; };
}, },
}); });