kitchendDevice/pageTwo/login/login.vue

319 lines
7.0 KiB
Vue
Raw Normal View History

2023-09-08 15:17:21 +08:00
<template>
<view class="content">
2025-03-25 10:17:30 +08:00
<view class="bg"></view>
2025-12-29 16:54:56 +08:00
2023-09-08 15:17:21 +08:00
<view class="top">
2025-12-29 16:54:56 +08:00
<view class="language">
<picker mode="selector" @change="changeClickLanguage" :range="languageList" range-key="name"
:value="levelInd">
<view>
{{$t('titleLanguage')}}
<icon class="iconfont icon-arrow-down"></icon>
</view>
</picker>
</view>
<view class="logo">
<image></image>
<text>Wendu</text>
</view>
2023-09-08 15:17:21 +08:00
</view>
2025-03-25 10:17:30 +08:00
<view class="login box_shadow">
2025-12-22 09:34:09 +08:00
<view class="title">{{$t("titleLogin")}}</view>
2025-03-25 10:17:30 +08:00
<view class="toggle cblue" @click="handleToggle">
2025-12-22 09:34:09 +08:00
{{$t("titleToggleLogin")}}
2025-03-25 10:17:30 +08:00
</view>
2023-09-08 15:17:21 +08:00
<view class="editem">
2025-03-25 10:17:30 +08:00
<view class="item">
2025-12-27 15:47:56 +08:00
<view class="text">{{$t("infoEmail")}}</view>
2025-03-25 10:17:30 +08:00
<view class="input">
<input v-model="phone" />
</view>
2023-09-08 15:17:21 +08:00
</view>
2025-03-25 10:17:30 +08:00
<!-- 验证码登录 -->
<view class="item " v-if="isCode">
2025-12-22 09:34:09 +08:00
<view class="text">{{$t("titleCode")}}</view>
2025-03-25 10:17:30 +08:00
<view class="input yanzhengma">
<input class="uni-input" v-model="code" />
<button class="code" type="none" @click="handleCode" v-model="code"
2025-12-22 09:34:09 +08:00
:disabled="disabled">{{second<60 ? second+$t("titleSendCodeRetry"):$t("titleSendCode")}}
2025-03-25 10:17:30 +08:00
</button>
2023-09-08 15:17:21 +08:00
</view>
2025-03-25 10:17:30 +08:00
</view>
<!-- 密码登录 -->
<view class="item " v-else>
2025-12-22 09:34:09 +08:00
<view class="text">{{$t("titlePassword")}}</view>
2025-03-25 10:17:30 +08:00
<view class="input">
<input class="uni-input" v-model="password" />
</view>
</view>
<view class="forget " v-if="!isCode">
2025-12-22 09:34:09 +08:00
<text @click="handlePassword('forgetPassword')">{{$t("titleForgotPassword")}}</text>
2023-09-08 15:17:21 +08:00
</view>
</view>
2025-03-25 10:17:30 +08:00
<view class="xieyi">
<checkbox-group @change="checkboxChange" class="group">
<label>
2025-12-22 09:34:09 +08:00
<checkbox :value="1" style="transform:scale(0.7)" />{{$t("titleAgreementText")}}
2025-03-25 10:17:30 +08:00
<!-- <text @click.stop @click="handleUserXieyi" class="blue">用户协议</text> -->
2025-12-22 09:34:09 +08:00
<text @click.stop @click="handlexieyi" class="blue">{{$t("titleAgreementContntText")}}</text>
2025-03-25 10:17:30 +08:00
</label>
</checkbox-group>
</view>
2025-12-22 09:34:09 +08:00
<view class="btnlogin" @click="handleTelLogin">{{$t("titleLogin")}}</view>
2025-03-25 10:17:30 +08:00
<view class="btngroup" @click="handlePassword('register')">
2025-12-22 09:34:09 +08:00
<text>{{$t("titleRegister")}}</text>
2023-09-08 15:17:21 +08:00
</view>
</view>
</view>
</template>
<script>
2025-12-29 16:54:56 +08:00
import {
mapState
} from "vuex";
2023-09-08 15:17:21 +08:00
export default {
data() {
return {
phone: "",
code: "",
2025-03-25 10:17:30 +08:00
password: "",
2023-09-08 15:17:21 +08:00
disabled: false,
second: 60,
2025-03-25 10:17:30 +08:00
value: 0,
isCode: true,
2025-04-02 09:49:39 +08:00
loginCode: "",
2025-12-29 16:54:56 +08:00
levelInd: 0,
}
},
computed: {
...mapState(["user", 'configInfo', "setLocale"]),
languageList() {
let that = this
let languageList = this.configInfo.language_arr
that.levelInd = languageList.findIndex(ite => ite.key == this.setLocale)
return languageList
2023-09-08 15:17:21 +08:00
}
},
2025-04-02 09:49:39 +08:00
onLoad() {
2025-12-22 09:34:09 +08:00
let that = this
uni.setNavigationBarTitle({
title: that.$t('titleLogin')
})
2025-04-02 09:49:39 +08:00
},
2023-09-08 15:17:21 +08:00
methods: {
2025-03-25 10:17:30 +08:00
checkboxChange(e) {
this.value = e.detail.value.length ? e.detail.value[0] : "0"
},
2025-12-29 16:54:56 +08:00
// 语言切换
changeClickLanguage(e) {
let that = this
let key = that.languageList[e.target.value].key
let val = that.languageList[e.target.value].val
that.levelInd = e.target.value
that.$model.getSetLanguage({
language: val,
}).then(res => {
that.$i18n.locale = key
uni.setStorageSync('language', key)
that.$store.commit('changeLocale', key)
that.$store.dispatch("getHomeConfig")
that.handleTabBarItem()
})
},
handleTabBarItem() {
let that = this
uni.setTabBarItem({
index: 0,
text: that.$t('titleHome')
})
uni.setTabBarItem({
index: 1,
text: that.$t('titleCount')
})
uni.setTabBarItem({
index: 2,
text: that.$t('titleMe')
})
},
2023-09-08 15:17:21 +08:00
// 登录、
handleTelLogin() {
let that = this
2025-03-25 10:17:30 +08:00
if (that.value == 0) {
2025-12-22 09:34:09 +08:00
that.$tools.msg(that.$t("verifyAgreement"))
2023-09-08 15:17:21 +08:00
return
}
2025-12-27 15:47:56 +08:00
if (!(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(that.phone))) {
2025-12-22 09:34:09 +08:00
that.$tools.msg(that.$t("verifyEmailCorrect"))
2025-03-25 10:17:30 +08:00
return
}
if (that.isCode && !that.code) {
2025-12-22 09:34:09 +08:00
that.$tools.msg(that.$t("verifyCode"))
2023-09-08 15:17:21 +08:00
return
}
2025-03-25 10:17:30 +08:00
if (!that.isCode && !that.password) {
2025-12-22 09:34:09 +08:00
that.$tools.msg(that.$t("verifyPassword"))
2025-03-25 10:17:30 +08:00
return
}
2025-12-29 16:54:56 +08:00
let val = that.languageList[that.levelInd].val
2025-03-25 10:17:30 +08:00
this.$model.getonlogin({
data: that.phone,
validate_data: that.isCode ? that.code : that.password,
2025-12-29 16:54:56 +08:00
validate_type: that.isCode ? 'code' : 'password',
language: val
2023-09-08 15:17:21 +08:00
}).then(res => {
2025-03-25 10:17:30 +08:00
console.log("data", res.data)
that.$tools.msg(res.msg)
if (res.code != 0) return
2025-12-22 09:34:09 +08:00
that.$tools.msg(that.$t("msgLoginSuccess"))
2023-09-08 15:17:21 +08:00
uni.setStorageSync('token', res.data.token)
2025-12-29 16:54:56 +08:00
that.$store.dispatch("getUserInfo")
2025-03-25 10:17:30 +08:00
setTimeout(function() {
uni.reLaunch({
url: "/pages/index/index"
})
}, 2000)
2023-09-08 15:17:21 +08:00
}).catch(err => {})
},
// 获取验证码
handleCode() {
let that = this
2025-12-27 15:47:56 +08:00
if (!(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(that.phone))) {
2025-12-22 09:34:09 +08:00
that.$tools.msg(that.$t("verifyEmailCorrect"))
2023-09-08 15:17:21 +08:00
return
}
//
that.$model.getSendCode({
2025-03-25 10:17:30 +08:00
data: that.phone,
2023-09-08 15:17:21 +08:00
}).then(res => {
console.log(res)
if (res.code != 0) {
2025-03-25 10:17:30 +08:00
that.$tools.msg(res.msg)
2023-09-08 15:17:21 +08:00
return
}
that.disabled = true
let interval = setInterval(() => {
--that.second
}, 1000)
setTimeout(() => {
clearInterval(interval)
that.disabled = false
that.second = 60
}, 60000)
}).catch(err => {})
},
2025-04-02 09:49:39 +08:00
handleIsTel() {
if (this.value == 0) {
2025-12-22 09:34:09 +08:00
this.$tools.msg(that.$t("verifyAgreement"))
2025-04-02 09:49:39 +08:00
return
}
},
// 切换登录
2025-03-25 10:17:30 +08:00
handleToggle() {
this.phone = ""
this.isCode = !this.isCode
},
handlePassword(text) {
uni.navigateTo({
url: "/pageTwo/login/forgetPassword?type=" + text
})
},
handlexieyi() {
2023-09-08 15:17:21 +08:00
let that = this
2025-03-25 10:17:30 +08:00
uni.navigateTo({
2025-04-02 09:49:39 +08:00
url: "/pageTwo/webview/webview?url=https://tc.pcxbc.com/kitchenscale_all/privacy_index.html"
2025-03-25 10:17:30 +08:00
})
2023-09-08 15:17:21 +08:00
},
2025-03-25 10:17:30 +08:00
handleUserXieyi() {
let that = this
}
2023-09-08 15:17:21 +08:00
}
}
</script>
2025-03-25 10:17:30 +08:00
<style scoped lang="scss">
@import "@/assets/login.scss";
2023-09-08 15:17:21 +08:00
.content {
2025-03-25 10:17:30 +08:00
width: 100%;
2023-09-08 15:17:21 +08:00
height: 100vh;
}
2025-03-25 10:17:30 +08:00
.xieyi {
font-size: 28rpx;
color: #999;
2025-11-25 14:21:22 +08:00
margin-left: 20rpx;
2023-09-08 15:17:21 +08:00
text {
2025-03-25 10:17:30 +08:00
color: $maincolor;
2023-09-08 15:17:21 +08:00
}
}
2025-03-25 10:17:30 +08:00
.href {
width: auto;
2023-09-08 15:17:21 +08:00
}
2025-04-02 09:49:39 +08:00
2025-12-29 16:54:56 +08:00
.language {
position: absolute;
top: 0;
left: 15px;
background: #fff;
padding: 5px 20px;
border-radius: 10px;
picker {
width: 100%;
view {
display: flex;
2025-12-30 13:48:36 +08:00
align-items: center;
2025-12-29 16:54:56 +08:00
}
}
}
2025-04-02 09:49:39 +08:00
.wxbtn {
width: 100%;
position: absolute;
2025-11-25 14:21:22 +08:00
margin-top: 60rpx;
2025-04-02 09:49:39 +08:00
top: 80%;
icon {
2025-11-25 14:21:22 +08:00
font-size: 50rpx;
2025-04-02 09:49:39 +08:00
color: #28c445;
}
text {
display: block;
// width: 100%;
margin-top: 5px;
2025-11-25 14:21:22 +08:00
font-size: 24rpx;
2025-04-02 09:49:39 +08:00
// color: #666;
text-align: center;
border-bottom: 1px solid blue;
color: blue;
}
button {
line-height: initial;
display: flex;
flex-wrap: wrap;
padding: 0;
justify-content: center;
}
button::after {
display: none;
}
view {
width: 100%;
}
image {
2025-11-25 14:21:22 +08:00
width: 60rpx;
height: 60rpx;
2025-04-02 09:49:39 +08:00
border-radius: 50%;
}
}
2025-03-25 10:17:30 +08:00
</style>