RegisterAccount.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <template>
  2. <div class="center">
  3. <div class="item">
  4. <span
  5. style="color: #bbb; font-size: 21px; padding-top: 7px"
  6. class="icon iconfont icon-wode"
  7. ></span>
  8. <input
  9. type="text"
  10. v-model="name"
  11. :placeholder="L['请输入用户名']"
  12. class="input"
  13. />
  14. <div data-type="userName" class="cancel" @click="clearInputVal">
  15. <span style="color: #bbb" class="iconfont icon-cuowu"></span>
  16. </div>
  17. <div class="error" v-if="nameErrorMsg">
  18. <span
  19. style="color: #e1251b; font-size: 14px"
  20. class="iconfont icon-jubao"
  21. ></span>
  22. {{ nameErrorMsg }}
  23. </div>
  24. </div>
  25. <div class="item password">
  26. <span
  27. style="color: #bbb; font-size: 21px; padding-top: 7px"
  28. class="icon iconfont icon-mima1"
  29. ></span>
  30. <input
  31. :type="showPwdFlag ? 'text' : 'password'"
  32. v-model="password"
  33. :placeholder="L['请输入6~20位英文、数字、符号']"
  34. class="input"
  35. />
  36. <div class="cancel" @click="isShowPwd">
  37. <span
  38. :style="{
  39. color: '#bbb',
  40. fontSize: showPwdFlag ? '20px' : '16px',
  41. }"
  42. :class="{
  43. iconfont: true,
  44. 'icon-bukejian11': !showPwdFlag,
  45. 'icon-kejian': showPwdFlag,
  46. show_pwd: showPwdFlag,
  47. }"
  48. ></span>
  49. </div>
  50. </div>
  51. <div class="item confirm">
  52. <span style="color: #bbb; font-size: 21px; padding-top: 7px" class="icon"
  53. ><img src="/pwd_confirm.png" alt=""
  54. /></span>
  55. <input
  56. class="input"
  57. v-model="confirmPassword"
  58. :type="showConfirmPwdFlag ? 'text' : 'password'"
  59. :placeholder="L['register']['请确认密码']"
  60. @blur="checkPwdMatched"
  61. />
  62. <div class="cancel" @click="isShowConfirmPwd">
  63. <span
  64. :style="{
  65. color: '#bbb',
  66. fontSize: showConfirmPwdFlag ? '20px' : '16px',
  67. }"
  68. :class="{
  69. iconfont: true,
  70. 'icon-bukejian11': !showConfirmPwdFlag,
  71. 'icon-kejian': showConfirmPwdFlag,
  72. show_pwd: showConfirmPwdFlag,
  73. }"
  74. ></span>
  75. </div>
  76. </div>
  77. <div class="error" v-if="checkErrorMsg">
  78. <span
  79. style="color: #e1251b; font-size: 14px"
  80. class="iconfont icon-jubao"
  81. ></span>
  82. {{ checkErrorMsg }}
  83. </div>
  84. <a
  85. href="javascript:void(0)"
  86. @click="joinForFree"
  87. :class="{ submit: true, disabled: joinForFreeDisabled }"
  88. >{{ L["去注册"] }}</a
  89. >
  90. <div class="agree_wrap">
  91. <input
  92. type="checkbox"
  93. :class="{ checkbox: true, default: true, checked: agreeFlag }"
  94. />
  95. <span class="agree_selected iconfont icon-finish" @click="agree" />
  96. <span class="text">
  97. {{ L["我同意"]
  98. }}<nuxt-link
  99. target="_blank"
  100. class="agreement"
  101. :to="`/member/login/agreement?type=1`"
  102. >
  103. {{ L["《用户注册协议》"] }}</nuxt-link
  104. >
  105. <nuxt-link
  106. target="_blank"
  107. class="agreement"
  108. :to="`/member/login/agreement?type=2`"
  109. >{{ L["《隐私政策》"] }}
  110. </nuxt-link>
  111. </span>
  112. </div>
  113. <div class="error" v-if="agreeErrorMsg">
  114. <span
  115. style="color: #e1251b; font-size: 14px"
  116. class="iconfont icon-jubao"
  117. ></span>
  118. {{ agreeErrorMsg }}
  119. </div>
  120. </div>
  121. </template>
  122. <script setup>
  123. import { getCurLanguage } from "@/composables/common.js";
  124. import { showMessage } from "@/utils/common";
  125. const L = getCurLanguage();
  126. const agreeFlag = ref(false); //同意注册协议标识,默认不同意
  127. const agreeErrorMsg = ref(); // 协议错误提示
  128. const name = ref(""); //用户名
  129. const nameErrorMsg = ref(""); //用户名错误提示
  130. const checkErrorMsg = ref(""); // 密码一致性错误提示
  131. const password = ref(""); //密码
  132. const confirmPassword = ref(""); //二次确认密码
  133. const showPwdFlag = ref(false); //密码是否明文显示,默认密文
  134. const showConfirmPwdFlag = ref(false); // 二次密码是否明文显示,默认密文
  135. const joinForFreeDisabled = computed(
  136. () => !name.value || !password.value || !confirmPassword.value
  137. );
  138. const isPasswordMatched = computed(() => password.value === confirmPassword.value)
  139. const clearInputVal = () => {
  140. name.value = "";
  141. };
  142. //密码是否显示
  143. const isShowPwd = () => {
  144. showPwdFlag.value = !showPwdFlag.value;
  145. };
  146. // 二次确认密码是否显示
  147. const isShowConfirmPwd = () => {
  148. showConfirmPwdFlag.value = !showConfirmPwdFlag.value;
  149. };
  150. //是否同意用户注册协议
  151. const agree = () => {
  152. agreeFlag.value = !agreeFlag.value;
  153. };
  154. const joinForFree = () => {
  155. if (!isPasswordMatched) return;
  156. if (!agreeFlag.value) {
  157. agreeErrorMsg.value = L["请同意用户注册协议及隐私政策"];
  158. return false;
  159. }
  160. agreeErrorMsg.value = "";
  161. };
  162. const checkPwdMatched = () => {
  163. checkErrorMsg.value = isPasswordMatched.value ? "" : L["register"]["两次输入的密码不一致"];
  164. };
  165. watch(name, (val) => {
  166. nameErrorMsg.value = val ? "" : L["请输入用户名"];
  167. });
  168. </script>
  169. <style lang="scss" scoped>
  170. .center {
  171. padding: 30px 30px 40px;
  172. .item {
  173. position: relative;
  174. margin-top: 15px;
  175. border-radius: 2px;
  176. &:first-child {
  177. margin-top: 0;
  178. }
  179. .icon {
  180. position: absolute;
  181. left: 1px;
  182. top: 1px;
  183. width: 50px;
  184. text-align: center;
  185. height: 38px;
  186. background: #f8f8f8;
  187. img {
  188. width: 20px;
  189. }
  190. }
  191. .input {
  192. border: 1px solid #e8e8e8;
  193. height: 40px;
  194. padding: 0 44px 0 60px;
  195. width: 326px;
  196. }
  197. &.code {
  198. .input {
  199. padding-right: 10px;
  200. width: 150px;
  201. }
  202. }
  203. }
  204. .cancel {
  205. position: absolute;
  206. right: 0;
  207. top: 1px;
  208. width: 44px;
  209. height: 38px;
  210. cursor: pointer;
  211. :before {
  212. position: absolute;
  213. top: 9px;
  214. left: 14px;
  215. }
  216. }
  217. .error {
  218. margin-top: 10px;
  219. position: relative;
  220. color: $colorMain;
  221. height: 16px;
  222. line-height: 16px;
  223. }
  224. .submit {
  225. display: block;
  226. margin-top: 35px;
  227. background: $colorMain;
  228. color: #fff;
  229. text-align: center;
  230. border-radius: 2px;
  231. height: 45px;
  232. line-height: 45px;
  233. font-size: 18px;
  234. letter-spacing: 0px;
  235. &:hover {
  236. opacity: 0.9;
  237. }
  238. &.disabled {
  239. background-color: #909399;
  240. pointer-events: none;
  241. }
  242. }
  243. .agree_wrap {
  244. margin-top: 11px;
  245. height: 14px;
  246. line-height: 14px;
  247. color: #999;
  248. padding-left: 2px;
  249. position: relative;
  250. cursor: pointer;
  251. .agree_selected {
  252. color: #fff;
  253. position: absolute;
  254. top: 1px;
  255. left: 3px;
  256. z-index: 2;
  257. font-size: 13px;
  258. }
  259. .checkbox {
  260. width: 14px;
  261. height: 14px;
  262. display: inline-block;
  263. vertical-align: top;
  264. position: relative;
  265. outline: none;
  266. -webkit-appearance: none;
  267. background: none;
  268. border: none;
  269. box-sizing: border-box;
  270. cursor: pointer;
  271. box-shadow: none;
  272. &.checked {
  273. &:before {
  274. background: $colorMain;
  275. border-color: $colorMain;
  276. }
  277. }
  278. &:before {
  279. border: 1px solid #ddd;
  280. background: #fff;
  281. z-index: 1;
  282. position: absolute;
  283. top: 0;
  284. left: 0;
  285. content: " ";
  286. display: block;
  287. width: 100%;
  288. height: 100%;
  289. box-sizing: border-box;
  290. }
  291. }
  292. .text {
  293. margin-left: 5px;
  294. display: inline-block;
  295. vertical-align: top;
  296. .agreement {
  297. color: #000;
  298. &:hover {
  299. text-decoration: underline;
  300. }
  301. }
  302. }
  303. }
  304. }
  305. </style>