zssh-h5/pages/login.vue

109 lines
2.1 KiB
Vue
Raw Permalink Normal View History

2024-07-09 15:49:34 +08:00
<template>
<view class="login">
1111
参数123:{{vv}}
</view>
</template>
<script>
import urlencode from "urlencode"
export default {
data() {
return {
vv: ""
}
},
onLoad(options) {
alert(1212)
this.vv = window.location.href
// console.log(JSON.stringify(options.cmbdata))
},
methods: {
func(data) {
alert(3333)
this.vv = urlencode(data)
},
getcode() {
if (this.form.mobile == '') {
uni.showToast({
title: "手机号不能为空",
icon: "none"
})
return false
}
if (this.codemsg == "发送验证码" || this.codemsg == "重新发送") {
this.getphonecode()
this.codemsg = 30;
this.int = setInterval(() => {
this.codemsg -= 1;
if (this.codemsg == 0) {
clearInterval(this.int);
this.codemsg = "重新发送";
}
}, 1000);
}
},
getphonecode() {
this.api.gocode({
mobile: this.form.mobile
}).then((res) => {
console.log(res)
if (res.data.code == '200') {
uni.showToast({
title: "发送成功"
})
} else {
uni.showToast({
title: res.data.message,
icon: 'none'
})
}
})
},
getloadin() {
if (this.form.mobile == '') {
uni.showToast({
title: '请输入手机号',
icon: "none"
})
return false
}
if (this.form.code == '') {
uni.showToast({
title: '请输入验证码',
icon: "none"
})
return false
}
this.isload = true
this.api.gologin(this.form).then((res) => {
console.log(res)
if (res.data.code == '200') {
uni.showToast({
title: '登录成功',
duration: 1200
})
uni.setStorageSync('token', res.data.data.front_token)
uni.setStorageSync('name', res.data.data.name)
uni.setStorageSync('avatar', res.data.data.avatar)
setTimeout(function() {
uni.reLaunch({
url: '/pages/index/index'
})
}, 1200);
} else {
this.isload = false
uni.showToast({
title: res.data.message,
icon: 'none'
})
}
})
}
}
}
</script>
<style>
.login {}
</style>