active.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <template>
  2. <div class="sld_login">
  3. <div class="sld_login_header">
  4. <div class="content">
  5. <router-link tag="a" class="l_logo" :to="`/`">
  6. <img
  7. class="img"
  8. :src="filtersStore.getSiteLogo"
  9. :onerror="defaultImg"
  10. alt
  11. />
  12. </router-link>
  13. <div class="r_register_wrap">
  14. {{ L["已有账号?"] }}
  15. <a
  16. href="javascript:void(0)"
  17. class="go_register_btn"
  18. @click="goToPage('/login')"
  19. >
  20. {{ L["去登录"] }}
  21. </a>
  22. </div>
  23. </div>
  24. </div>
  25. <div class="sld_login_content">
  26. <img
  27. class="bg"
  28. :src="ImgBG?ImgBG:configInfo.main_user_register_bg + ''"
  29. :onerror="defaultBgImg"
  30. alt
  31. />
  32. <div class="login">
  33. <div class="login_box">
  34. <div class="top">
  35. <div class="item1">{{ L["邮箱注册账号激活"] }}</div>
  36. </div>
  37. <div class="center">
  38. <div class="item password">
  39. <span
  40. style="color: #bbb; font-size: 21px; padding-top: 7px"
  41. class="icon iconfont icon-wode"
  42. ></span>
  43. <input
  44. type="text"
  45. v-model="name"
  46. :placeholder="L['请输入用户名']"
  47. class="input"
  48. />
  49. <div
  50. data-type="userName"
  51. class="cancel"
  52. @click="clearInputVal('name')"
  53. >
  54. <span style="color: #bbb" class="iconfont icon-cuowu"></span>
  55. </div>
  56. </div>
  57. <div class="item password">
  58. <span
  59. style="color: #bbb; font-size: 21px; padding-top: 7px"
  60. class="icon iconfont icon-mima1"
  61. ></span>
  62. <input
  63. :type="showPwdFlag ? 'text' : 'password'"
  64. v-model="password"
  65. :placeholder="L['请输入6~20位英文、数字、符号']"
  66. class="input"
  67. />
  68. <div class="cancel" @click="isShowPwd">
  69. <span
  70. :style="{
  71. color: '#bbb',
  72. fontSize: showPwdFlag ? '20px' : '16px',
  73. }"
  74. :class="{
  75. iconfont: true,
  76. 'icon-bukejian11': !showPwdFlag,
  77. 'icon-kejian': showPwdFlag,
  78. show_pwd: showPwdFlag,
  79. }"
  80. ></span>
  81. </div>
  82. </div>
  83. <div class="item password">
  84. <span
  85. style="color: #bbb; font-size: 18px; padding-top: 8px"
  86. class="icon iconfont icon-yanzhengma2"
  87. ></span>
  88. <input
  89. type="text"
  90. v-model="imgCode"
  91. :placeholder="L['请输入图形验证码']"
  92. class="input"
  93. />
  94. <img :src="showCodeImg" class="img_code" @click="getImgCode" />
  95. </div>
  96. <div class="error">
  97. <span
  98. v-if="errorMsg"
  99. style="color: #e1251b; font-size: 14px"
  100. class="iconfont icon-jubao"
  101. ></span>
  102. {{ errorMsg }}
  103. </div>
  104. <a
  105. href="javascript:void(0)"
  106. @click="activeEmail"
  107. class="login_btn"
  108. >{{ L["立即注册"] }}</a
  109. >
  110. <div class="agree_wrap">
  111. <input
  112. type="checkbox"
  113. :class="{ checkbox: true, default: true, checked: agreeFlag }"
  114. />
  115. <span
  116. class="agree_selected iconfont icon-finish"
  117. @click="agree"
  118. />
  119. <span class="text">
  120. {{ L["我同意"]
  121. }}<router-link
  122. target="_blank"
  123. class="agreement"
  124. :to="`/agreement?type=1`"
  125. >
  126. {{ L["《用户注册协议》"] }}</router-link
  127. >
  128. <router-link
  129. target="_blank"
  130. class="agreement"
  131. :to="`/agreement?type=2`"
  132. >{{ L["《隐私政策》"] }}
  133. </router-link>
  134. </span>
  135. </div>
  136. </div>
  137. <div
  138. :class="{
  139. bottom: true,
  140. flex_row_between_center: wxEnable == 1,
  141. flex_row_end_center: wxEnable != 1,
  142. }"
  143. >
  144. <!-- <img v-if="wxEnable==1" src="@/assets/wechat_login.png" alt="" @click="wetChatLogin">-->
  145. <a href="javascript:void(0)" @click="goToPage('/login')">{{
  146. L["已有账号,去登录"]
  147. }}</a>
  148. </div>
  149. </div>
  150. </div>
  151. </div>
  152. </div>
  153. </template>
  154. <script setup>
  155. import { useRoute, useRouter } from "vue-router";
  156. import { ref, getCurrentInstance, onMounted, watch } from "vue";
  157. import { ElMessage } from "element-plus";
  158. import {useUserInfo} from '@/store/user.js'
  159. // import { lang_zn } from "@/assets/language/zh";
  160. import { getCurLanguage } from '@/composables/common.js';
  161. import { useFiltersStore } from "@/store/filter.js";
  162. const filtersStore = useFiltersStore();
  163. // const L = lang_zn;
  164. const L = getCurLanguage();
  165. const route = useRoute();
  166. const agreeFlag = ref(false); //同意注册协议标识,默认不同意
  167. const name = ref(""); //用户名
  168. const errorMsg = ref(); //错误提示
  169. const password = ref(""); //密码
  170. const showPwdFlag = ref(false); //密码是否明文显示,默认密文
  171. const imgCode = ref(""); //图形验证码
  172. const router = useRouter();
  173. const { proxy } = getCurrentInstance();
  174. const showCodeImg = ref(""); //图形验证码图片
  175. const imgCodeKey = ref(""); //图形验证码的key
  176. const configInfo = useUserInfo();
  177. const defaultImg = ref("/common_top_logo.png")
  178. const defaultBgImg = ref("/login_bg.png")
  179. const wxEnable = ref("");
  180. const pcAppid = ref("");
  181. const fromurl = ref("");
  182. const activeEmailVal = ref("");
  183. const activeEmailCode = ref("");
  184. const ImgBG = ref('')
  185. useHead({
  186. title: 'Forget Password',
  187. meta: [
  188. {
  189. name: "description",
  190. content: 'Forget Password',
  191. },
  192. {
  193. name: "keywords",
  194. content: 'Forget Password',
  195. },
  196. ],
  197. });
  198. //获取背景图
  199. const getBg = () => {
  200. get('/v3/system/front/setting/getSettings?names=main_user_forget_password_bg').then(res=>{
  201. ImgBG.value = res.data[0]
  202. })
  203. }
  204. getBg()
  205. //密码是否显示
  206. const isShowPwd = () => {
  207. showPwdFlag.value = !showPwdFlag.value;
  208. };
  209. //清空输入框内容
  210. const clearInputVal = (type) => {
  211. if (type == "name") {
  212. name.value = "";
  213. } else if (type == "password") {
  214. password.value = "";
  215. }
  216. };
  217. //获取图形验证码
  218. const getImgCode = () => {
  219. get("v3/captcha/common/getCaptcha", {}).then((res) => {
  220. if (res.state == 200) {
  221. showCodeImg.value = "data:image/png;base64," + res.data.captcha;
  222. imgCodeKey.value = res.data.key;
  223. }
  224. });
  225. };
  226. //是否同意用户注册协议
  227. const agree = () => {
  228. agreeFlag.value = !agreeFlag.value;
  229. };
  230. //通过replace方式跳转页面
  231. const goToPage = (type) => {
  232. router.replace({
  233. path: type,
  234. });
  235. };
  236. watch([name, imgCode, password], () => {
  237. password.value = password.value.substring(0, 20);
  238. imgCode.value = imgCode.value.substring(0, 4);
  239. name.value = name.value.substring(0, 50);
  240. if (password.value || imgCode.value || name.value) {
  241. errorMsg.value = "";
  242. }
  243. });
  244. onMounted(() => {
  245. if (route.query.redirectUrl) {
  246. fromurl.value =
  247. window.location.origin + decodeURIComponent(route.query.redirectUrl);
  248. } else {
  249. fromurl.value = window.location.origin;
  250. }
  251. getImgCode(); //获取图形验证码
  252. document.body.classList.remove("el-popup-parent--hidden");
  253. activeEmailVal.value = route.query.email;
  254. activeEmailCode.value = route.query.code;
  255. });
  256. const activeEmail = () => {
  257. let param = {};
  258. param.nickName = name.value;
  259. param.password = password.value;
  260. param.email = activeEmailVal.value;
  261. param.code = activeEmailCode.value;
  262. param.verifyCode = imgCode.value;
  263. param.verifyKey = imgCodeKey.value;
  264. //用户名验证
  265. if (!param.nickName) {
  266. errorMsg.value = L["请输入用户名"];
  267. return false;
  268. }
  269. //密码验证
  270. if (!param.password) {
  271. errorMsg.value = L["请输入密码"];
  272. return false;
  273. }
  274. //验证码校验
  275. let checkImgCodeVal = checkImgCode(param.verifyCode);
  276. if (checkImgCodeVal !== true) {
  277. errorMsg.value = checkImgCodeVal;
  278. return false;
  279. }
  280. if (!agreeFlag.value) {
  281. errorMsg.value = L["请同意用户注册协议及隐私政策"];
  282. return false;
  283. }
  284. post("v3/member/front/active/email", param).then((res) => {
  285. if (res.state == 200) {
  286. ElMessage.success(L["会员邮箱账户激活成功,请登录"]);
  287. setTimeout(() => {
  288. goToPage("/login");
  289. }, 500);
  290. } else {
  291. //提示错误
  292. getImgCode();
  293. errorMsg.value = res.msg;
  294. }
  295. });
  296. };
  297. </script>
  298. <style lang="scss" scoped>
  299. @import "@/assets/style/register.scss";
  300. .el-popup-parent--hidden {
  301. overflow: visible;
  302. }
  303. </style>