123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376 |
- <template>
- <div class="center">
- <div class="item">
- <span
- style="color: #bbb; font-size: 21px; padding-top: 7px"
- class="icon iconfont icon-wode"
- ></span>
- <input
- type="text"
- v-model="name"
- :placeholder="L['请输入用户名']"
- class="input"
- />
- <div data-type="userName" class="cancel" @click="clearInputVal">
- <span style="color: #bbb" class="iconfont icon-cuowu"></span>
- </div>
- <div class="error" v-if="nameErrorMsg">
- <span
- style="color: #e1251b; font-size: 14px"
- class="iconfont icon-jubao"
- ></span>
- {{ nameErrorMsg }}
- </div>
- </div>
- <div class="item password">
- <span
- style="color: #bbb; font-size: 21px; padding-top: 7px"
- class="icon iconfont icon-mima1"
- ></span>
- <input
- :type="showPwdFlag ? 'text' : 'password'"
- v-model="password"
- :placeholder="L['请输入6~20位英文、数字、符号']"
- class="input"
- />
- <div class="cancel" @click="isShowPwd">
- <span
- :style="{
- color: '#bbb',
- fontSize: showPwdFlag ? '20px' : '16px',
- }"
- :class="{
- iconfont: true,
- 'icon-bukejian11': !showPwdFlag,
- 'icon-kejian': showPwdFlag,
- show_pwd: showPwdFlag,
- }"
- ></span>
- </div>
- </div>
- <div class="item confirm">
- <span style="color: #bbb; font-size: 21px; padding-top: 7px" class="icon"
- ><img src="/register/pwd_confirm.png" alt=""
- /></span>
- <input
- class="input"
- v-model="confirmPassword"
- :type="showConfirmPwdFlag ? 'text' : 'password'"
- :placeholder="L['register']['请确认密码']"
- @blur="checkPwdMatched"
- />
- <div class="cancel" @click="isShowConfirmPwd">
- <span
- :style="{
- color: '#bbb',
- fontSize: showConfirmPwdFlag ? '20px' : '16px',
- }"
- :class="{
- iconfont: true,
- 'icon-bukejian11': !showConfirmPwdFlag,
- 'icon-kejian': showConfirmPwdFlag,
- show_pwd: showConfirmPwdFlag,
- }"
- ></span>
- </div>
- </div>
- <div class="error" v-if="checkErrorMsg">
- <span
- style="color: #e1251b; font-size: 14px"
- class="iconfont icon-jubao"
- ></span>
- {{ checkErrorMsg }}
- </div>
- <el-button
- @click="joinForFree"
- :class="{ submit: true, disabled: joinForFreeDisabled }"
- :disabled="joinForFreeDisabled"
- :loading="joinForFreeLoading"
- >{{ L["去注册"] }}</el-button
- >
- <div class="agree_wrap">
- <input
- type="checkbox"
- :class="{ checkbox: true, default: true, checked: agreeFlag }"
- />
- <span class="agree_selected iconfont icon-finish" @click="agree" />
- <span class="text">
- {{ L["我同意"]
- }}<nuxt-link
- target="_blank"
- class="agreement"
- :to="`/member/login/agreement?type=1`"
- >
- {{ L["《用户注册协议》"] }}</nuxt-link
- >
- <nuxt-link
- target="_blank"
- class="agreement"
- :to="`/member/login/agreement?type=2`"
- >{{ L["《隐私政策》"] }}
- </nuxt-link>
- </span>
- </div>
- <div class="error" v-if="agreeErrorMsg">
- <span
- style="color: #e1251b; font-size: 14px"
- class="iconfont icon-jubao"
- ></span>
- {{ agreeErrorMsg }}
- </div>
- </div>
- </template>
- <script setup>
- import { getCurLanguage } from "@/composables/common.js";
- import { showMessage } from "@/utils/common";
- const L = getCurLanguage();
- const emits = defineEmits(["success"]);
- const props = defineProps({
- email: {
- type: String,
- default: "",
- },
- });
- const agreeFlag = ref(false); //同意注册协议标识,默认不同意
- const agreeErrorMsg = ref(); // 协议错误提示
- const name = ref(""); //用户名
- const nameErrorMsg = ref(""); //用户名错误提示
- const checkErrorMsg = ref(""); // 密码一致性错误提示
- const password = ref(""); //密码
- const confirmPassword = ref(""); //二次确认密码
- const showPwdFlag = ref(false); //密码是否明文显示,默认密文
- const showConfirmPwdFlag = ref(false); // 二次密码是否明文显示,默认密文
- const joinForFreeLoading = ref(false);
- const joinForFreeDisabled = computed(
- () => !name.value || !password.value || !confirmPassword.value
- );
- const isPasswordMatched = computed(
- () => password.value === confirmPassword.value
- );
- const clearInputVal = () => {
- name.value = "";
- };
- //密码是否显示
- const isShowPwd = () => {
- showPwdFlag.value = !showPwdFlag.value;
- };
- // 二次确认密码是否显示
- const isShowConfirmPwd = () => {
- showConfirmPwdFlag.value = !showConfirmPwdFlag.value;
- };
- //是否同意用户注册协议
- const agree = () => {
- agreeFlag.value = !agreeFlag.value;
- };
- const joinForFree = () => {
- if (!isPasswordMatched.value) return;
- if (!agreeFlag.value) {
- agreeErrorMsg.value = L["请同意用户注册协议及隐私政策"];
- return false;
- }
- agreeErrorMsg.value = "";
- // 注册账号
- joinForFreeLoading.value = true;
- post("/v3/member/front/active/register", {
- confirmPassword: confirmPassword.value,
- email: props.email,
- nickName: name.value,
- password: password.value,
- })
- .then((res) => {
- if (res.state === 200) {
- showMessage({
- message: L["register"]["注册成功"],
- type: "success",
- });
- emits("success");
- } else {
- showMessage({
- message: res.msg,
- type: "warning",
- });
- }
- })
- .finally(() => {
- joinForFreeLoading.value = false;
- });
- };
- const checkPwdMatched = () => {
- checkErrorMsg.value = isPasswordMatched.value
- ? ""
- : L["register"]["两次输入的密码不一致"];
- };
- watch(name, (val) => {
- nameErrorMsg.value = val ? "" : L["请输入用户名"];
- });
- </script>
- <style lang="scss" scoped>
- .center {
- padding: 30px 30px 40px;
- .item {
- position: relative;
- margin-top: 15px;
- border-radius: 2px;
- &:first-child {
- margin-top: 0;
- }
- .icon {
- position: absolute;
- left: 1px;
- top: 1px;
- width: 50px;
- text-align: center;
- height: 38px;
- background: #f8f8f8;
- img {
- width: 20px;
- }
- }
- .input {
- border: 1px solid #e8e8e8;
- height: 40px;
- padding: 0 44px 0 60px;
- width: 326px;
- }
- &.code {
- .input {
- padding-right: 10px;
- width: 150px;
- }
- }
- }
- .cancel {
- position: absolute;
- right: 0;
- top: 1px;
- width: 44px;
- height: 38px;
- cursor: pointer;
- :before {
- position: absolute;
- top: 9px;
- left: 14px;
- }
- }
- .error {
- margin-top: 10px;
- position: relative;
- color: $colorMain;
- height: 16px;
- line-height: 16px;
- }
- .submit {
- margin-top: 35px;
- background: $colorMain;
- color: #fff;
- text-align: center;
- border-radius: 2px;
- width: 100%;
- height: 45px;
- font-size: 18px;
- letter-spacing: 0px;
- &:hover {
- opacity: 0.9;
- }
- &.disabled {
- background-color: #909399;
- }
- }
- .agree_wrap {
- margin-top: 11px;
- height: 14px;
- line-height: 14px;
- color: #999;
- padding-left: 2px;
- position: relative;
- cursor: pointer;
- .agree_selected {
- color: #fff;
- position: absolute;
- top: 1px;
- left: 3px;
- z-index: 2;
- font-size: 13px;
- }
- .checkbox {
- width: 14px;
- height: 14px;
- display: inline-block;
- vertical-align: top;
- position: relative;
- outline: none;
- -webkit-appearance: none;
- background: none;
- border: none;
- box-sizing: border-box;
- cursor: pointer;
- box-shadow: none;
- &.checked {
- &:before {
- background: $colorMain;
- border-color: $colorMain;
- }
- }
- &:before {
- border: 1px solid #ddd;
- background: #fff;
- z-index: 1;
- position: absolute;
- top: 0;
- left: 0;
- content: " ";
- display: block;
- width: 100%;
- height: 100%;
- box-sizing: border-box;
- }
- }
- .text {
- margin-left: 5px;
- display: inline-block;
- vertical-align: top;
- .agreement {
- color: #000;
- &:hover {
- text-decoration: underline;
- }
- }
- }
- }
- }
- </style>
|