yzxy-mobile/pages/login.vue

136 lines
4.6 KiB
Vue
Raw Normal View History

2024-08-26 17:24:26 +08:00
<template>
<view class="logo flex_column flex_items">
<image :src="logoimg" style="width: 226rpx;height: 226rpx;margin-top:100rpx;"></image>
<text class="f44" style="color: #333;">欢迎来到分发平台</text>
<view class="mt60 plr30">
<!-- <van-field v-model="form.name" label="" placeholder="账号"
style="width: 696rpx;background: #F7F6FF;border-radius: 24rpx;height: 110rpx;line-height:78rpx;" />
<van-field class="mt30" type="password" v-model="form.password" label="" placeholder="密码"
style="width: 696rpx;background: #F7F6FF;border-radius: 24rpx;height: 110rpx;line-height:78rpx" /> -->
<view class="mt30 flex_start flex_items"
style="width: 696rpx;background: #F7F6FF;border-radius: 24rpx;height: 110rpx;line-height:78rpx">
<van-field v-model="form.phone" label="" placeholder="手机号"
style="width: 696rpx;background: #F7F6FF;border-radius: 24rpx;height: 110rpx;line-height:78rpx;" />
<view class="f28" style="color: #1676FE;width:200rpx;" @click="getshouji">{{codemsg}}</view>
</view>
<van-field v-model="form.mobile_code" class="mt30" label="" placeholder="手机验证码"
style="width: 696rpx;background: #F7F6FF;border-radius: 24rpx;height: 110rpx;line-height:78rpx;" />
<view class="mt30 flex_start flex_items"
style="width: 696rpx;background: #F7F6FF;border-radius: 24rpx;height: 110rpx;line-height:78rpx">
<van-field v-model="form.verify_code" label="" placeholder="验证码"
style="width: 696rpx;background: #F7F6FF;border-radius: 24rpx;height: 110rpx;line-height:78rpx;" />
<image class="ml20" :src="codeimg" @click="getcode" mode="" style="width:500rpx;height:90rpx;"></image>
</view>
<!-- <view class="mt30 flex_start flex_items"
style="width: 696rpx;background: #F7F6FF;border-radius: 24rpx;height: 110rpx;line-height:78rpx">
<van-field v-model="form.phone" label="" placeholder="手机号"
style="width: 696rpx;background: #F7F6FF;border-radius: 24rpx;height: 110rpx;line-height:78rpx;" />
<view class="f28" style="color: #1676FE;width:200rpx;" @click="getshouji">{{codemsg}}</view>
</view>
<van-field v-model="form.mobilecode" class="mt30" label="" placeholder="手机验证码"
style="width: 696rpx;background: #F7F6FF;border-radius: 24rpx;height: 110rpx;line-height:78rpx;" /> -->
</view>
<van-button :loading="loading" loading-text="登录中..." @click="gologin" class="f32 f-center mt60"
style="margin-top: 60rpx;width: 696rpx;height: 108rpx;line-height: 108rpx;color: #fff;background: linear-gradient(90deg, #B72027 0%, #0D0E5C 100%);border-radius: 12rpx;">立即登录</van-button>
</view>
</template>
<script>
export default {
data() {
return {
logoimg: require('@/static/logo.png'),
codeimg: "",
form: {
// name: "",
// password: "",
verify_code: "",
uuid: "",
phone: "",
mobilecode: ""
},
loading: false,
codemsg: "发送验证码",
}
},
onLoad() {
this.getcode()
},
methods: {
getcode() {
this.api.getcode().then((res) => {
this.codeimg = res.data.data.img
this.form.uuid = res.data.data.uuid
})
},
getshouji() {
if (this.form.mobile == '') {
uni.showToast({
title: "手机号不能为空",
icon: "none"
})
return false
}
if (this.codemsg == "发送验证码" || this.codemsg == "重新发送") {
this.getphonecode()
this.codemsg = 5;
this.int = setInterval(() => {
this.codemsg -= 1;
if (this.codemsg == 0) {
clearInterval(this.int);
this.codemsg = "重新发送";
}
}, 1000);
}
},
getphonecode() {
this.api.getpp({
phone: this.form.phone
}).then((res) => {
console.log(res)
if (res.data.code == '200') {
uni.showToast({
title: "发送成功"
})
} else {
uni.showToast({
title: res.data.message,
icon: 'none'
})
}
})
},
gologin() {
this.loading = true
this.api.login(this.form).then((res) => {
console.log(res)
if (res.data.code == 200) {
uni.setStorageSync("token", res.data.data.token);
uni.setStorageSync("site_id", res.data.data.site_id);
uni.setStorageSync("user_id", res.data.data.id);
uni.setStorageSync("adminname", res.data.data.name);
uni.setStorageSync("nickname", res.data.data.nickname);
uni.switchTab({
url: '/pages/index/index'
})
} else {
this.loading = false
uni.showToast({
title: res.data.message,
icon: 'none'
})
}
})
}
}
}
</script>
<style>
page {
background-image: url('~@/static/lbg.png') !important;
background-size: 100% 100%;
}
</style>