Files
frontend-app/components/code-comm/code-comm.vue
T
2025-08-06 20:25:41 +08:00

92 lines
2.3 KiB
Vue

<template>
<view class="comm-input-warp">
<!-- #ifdef APP-PLUS -->
<input :placeholder="$t('login.comm.code')" border="false" :v-model="modelValue" color="#EEEEEE" type="number"
@input="$emit('update:modelValue', $event.detail.value)" style="height: 64rpx;width: 70%;"></input>
<!-- #endif -->
<!-- #ifdef MP -->
<input :placeholder="$t('login.comm.code')" border="false" :v-model="modelValue" color="#EEEEEE" type="number"
@input="$emit('update:modelValue', $event.target.value)" style="height: 64rpx;width: 70%;"></input>
<!-- #endif -->
<view class="code-warp" v-if="countdown">
<up-count-down :time="60 * 1000" format="ss" @finish="getCode(false)"></up-count-down>
<text style="margin-left: 10rpx;">s</text>
<!-- <text style="margin-left: 10rpx;">{{$t('login.comm.reacquire.code')}}</text> -->
</view>
<view v-else class="code-warp" @click="getCode(true)">
<view>{{ $t('login.comm.get.code') }}</view>
</view>
<up-toast ref="uToastRef"></up-toast>
</view>
</template>
<script>
// import { ref } from 'vue';
// const uCodeRef = ref(null);
export default {
name: 'inputComm',
props: ['modelValue', 'codeNumberRef', 'emptyCountdownRef'],
watch: {
emptyCountdownRef(value, oldValue) {
if (value) {
this.countdown = true;
}
},
},
data() {
return {
countdown: false,
emptyCountdown: this.emptyCountdownRef,
inputCss: {
"height": '80rpx',
"background": "#F3F3F3FF",
"border-radius": "30rpx",
"border": "0rpx",
"padding-left": "16px",
},
}
},
emits: ['update:modelValue'],
mounted() {
},
methods: {
getCode(val) {
const emptyCountdown = this.emptyCountdown;
if (val) {
const codeNumber = this.codeNumberRef;
if (codeNumber) {
this.$emit('getCode');
} else {
this.$refs.uToastRef.show({
type: 'error',
message: this.$t('login.comm.email'),
});
return;
}
} else {
// uni.dialog.showMessage('请输入邮箱');
this.$refs.uToastRef.show({
type: 'error',
message: this.$t('login.comm.email'),
});
}
},
},
};
</script>
<style lang="less" scoped>
.code-warp {
width: 30%;
text-align: right;
display: flex;
justify-content: flex-end;
}
.wrap {
padding: 24rpx;
}
</style>