bfba351b3a4f71f03096c86daf9e9e15fece740f.svn-base 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <template>
  2. <div @mousewheel.prevent>
  3. <div class="registered row center" @click.stop="escRg"></div>
  4. <div class="registered-box">
  5. <div class="registered-box-title pdg20 row item-center allAlignment">
  6. <p style="margin-left:.1rem;">快速注册</p>
  7. <img
  8. style="width:.3rem;height:.3rem;cursor: pointer;"
  9. @click="escRg"
  10. src="@/assets/st-imges/del.png"
  11. >
  12. </div>
  13. <div class="registered-box-center pdg20">
  14. <div>
  15. <p>
  16. 用户名
  17. <span
  18. :style="accountHint?'color:#f76649':''"
  19. >{{accountHint?accountHint:"(6-15位数字下划线或字母,或微信、QQ号组成)"}}</span>
  20. </p>
  21. <input v-model="account" @blur="accountVerify" type="text">
  22. </div>
  23. <div>
  24. <p>
  25. 设置密码
  26. <span
  27. :style="passwordHint?'color:#f76649':''"
  28. >{{passwordHint?passwordHint:"(必须由6-15位数字或字母组成)"}}</span>
  29. </p>
  30. <input v-model="password" @blur="passwordVerify" type="password">
  31. </div>
  32. <div>
  33. <p>
  34. 确认密码
  35. <span
  36. :style="again_passwordHint?'color:#f76649':''"
  37. >{{again_passwordHint?again_passwordHint:"(请再次输入密码)"}}</span>
  38. </p>
  39. <input v-model="again_password" @blur="again_passwordVerify" type="password">
  40. </div>
  41. <div>
  42. <p>
  43. 真实姓名
  44. <span>(与提款银行账户姓名一致)</span>
  45. </p>
  46. <input v-model="name" type="text">
  47. </div>
  48. <div>
  49. <p>
  50. 电话号码
  51. <span :style="phoneHint?'color:#f76649':''">{{phoneHint?phoneHint:'(请确定是您本人电话)'}}</span>
  52. </p>
  53. <input v-model="phone" @blur="PhoneVerify" type="text">
  54. </div>
  55. <div style="position: relative;">
  56. <p>验证码
  57. <span :style="VerificationHint?'color:#f76649':''">{{VerificationHint?"(验证码错误请重新输入)":"(请输入验证码)"}}</span>
  58. </p>
  59. <input v-model="Verification" :style="VerificationActive?'color:lawngreen;':''" @blur="VerificationVerify" type="text">
  60. <p @click="createCode()" class="checkCode row center">{{checkCode}}</p>
  61. </div>
  62. <p>
  63. <input style="width:.22rem;height:.22rem;margin:.1rem 0;" v-model="deal" type="checkbox">我已满18岁并且已阅读及同意
  64. <i>开户协议</i>。
  65. </p>
  66. <button style="cursor: pointer;" @click="submit">创建用户</button>
  67. </div>
  68. </div>
  69. </div>
  70. </template>
  71. <script>
  72. import "@/css/index.css";
  73. export default {
  74. name: "registered",
  75. data() {
  76. return {
  77. account: "",
  78. password: "",
  79. again_password: "",
  80. name: "",
  81. Verification: "",
  82. code: "",
  83. checkCode: "",
  84. phone: "",
  85. phoneHint: "", //电话号码提示
  86. accountHint: "", //账号违法提示
  87. passwordHint: "", //密码违规提示
  88. again_passwordHint: "", //确认密码提示
  89. VerificationHint: "", //验证码输入错误
  90. VerificationActive:false,//验证码输入
  91. deal:true,//协议
  92. timers: true //刷新验证码
  93. };
  94. },
  95. methods: {
  96. // 图片验证码
  97. createCode() {
  98. //先清空验证码的输入
  99. this.code = "";
  100. this.checkCode = "";
  101. this.Verification = "";
  102. //验证码的长度
  103. var codeLength = 4;
  104. //随机数
  105. var random = [0,1,2,3,4,5,6,7,8,9,"A","C","D","E","F","G","H","J","K","L","M","N","P","Q","R","T","U","V","W","X","Y"];
  106. for (var i = 0; i < codeLength; i++) {
  107. //取得随机数的索引(0~30)
  108. var index = Math.floor(Math.random() * 31);
  109. //根据索引取得随机数加到code上
  110. this.code += random[index];
  111. }
  112. //把code值赋给验证码
  113. this.checkCode = this.code;
  114. },
  115. //关闭
  116. escRg() {
  117. this.$store.dispatch("GETRGSHOW", false);
  118. },
  119. //验证电话号码
  120. PhoneVerify() {
  121. let rex = /^(0|86|17951)?(13[0-9]|15[012356789]|17[0-9]|18[0-9]|14[0-9])[0-9]{8}$/;
  122. let result = rex.test(this.phone);
  123. if (result == false) {
  124. this.phoneHint = "(请输入正确的电话号码)";
  125. this.phone = "";
  126. } else {
  127. this.phoneHint = "";
  128. }
  129. },
  130. accountVerify() {
  131. let rex = /^[\da-zA-Z_]{6,15}$/;
  132. let result = rex.test(this.account);
  133. if (result == false) {
  134. this.accountHint = "(请输入6-15位数字下划线或字母,或微信、QQ号)";
  135. this.account = ''
  136. } else {
  137. this.accountHint = "";
  138. }
  139. },
  140. passwordVerify() {
  141. let rex = /^[\da-zA-Z]{6,15}$/;
  142. let result = rex.test(this.password);
  143. if (result == false) {
  144. this.passwordHint = "(请输入6-15位数字或字母)";
  145. this.password = ''
  146. } else if(this.password == this.account){
  147. this.passwordHint = "(账号密码不能一致)";
  148. this.password = ''
  149. }else{
  150. this.passwordHint = "";
  151. }
  152. },
  153. again_passwordVerify() {
  154. if (this.password) {
  155. if (this.password != this.again_password) {
  156. this.again_passwordHint = "(确认密码错误)";
  157. this.again_password = ''
  158. }else{
  159. this.again_passwordHint = "";
  160. }
  161. } else {
  162. this.again_passwordHint = "(请先输入密码再确认密码)";
  163. this.again_password = "";
  164. }
  165. },
  166. VerificationVerify() {
  167. let str=this.Verification.toLocaleUpperCase()
  168. if (str == this.checkCode) {
  169. this.timers = false;
  170. this.VerificationActive = true;
  171. this.VerificationHint = ''
  172. } else {
  173. this.VerificationActive = false;
  174. this.VerificationHint = "(验证码错误)";
  175. this.Verification = '';
  176. }
  177. },
  178. submit(){
  179. if(this.account&&this.password&&this.again_password&&this.name&&this.phone&&this.VerificationActive){
  180. if(this.deal){
  181. this.$http.post(this.$ports.login.reg,{
  182. account:this.account,
  183. name:this.name,
  184. password:this.password,
  185. again_password:this.again_password,
  186. phone:this.phone,
  187. }).then(res=>{
  188. if(res.data.data){
  189. this.$store.dispatch('SET_TOKEN',res.data.data[0].token)
  190. this.$public.setItem('user',res.data.data)
  191. this.$dialog.toast({ mes: '注册成功', timeout: 2000 });
  192. this.$store.dispatch('GETRGSHOW',false)
  193. }else{
  194. this.$dialog.toast({ mes: res.data.msg, timeout: 2000 });
  195. this.account=this.password=this.again_password=this.name=this.phone=this.VerificationActive = this.Verification ='';
  196. this.timers = true;
  197. }
  198. // console.log(res)
  199. })
  200. }else{
  201. this.$dialog.toast({ mes: "请同意我方开户协议", timeout: 2000 });
  202. }
  203. }else{
  204. this.$dialog.toast({ mes: "请将表格填写完毕", timeout: 1000 });
  205. }
  206. }
  207. },
  208. mounted() {
  209. let _this = this
  210. this.$public.ajaxTimerFun(timing => {
  211. if (_this.timers) {
  212. _this.createCode();
  213. } else {
  214. clearInterval(timing);
  215. }
  216. }, 1000 * 16);
  217. },
  218. beforeDestroy() {
  219. this.timers = false;
  220. },
  221. created() {
  222. this.createCode();
  223. }
  224. };
  225. </script>
  226. <style scoped>
  227. .pdg20 {
  228. padding: 0 0.2rem;
  229. color: lawngreen
  230. }
  231. .registered {
  232. width: 100%;
  233. height: 100%;
  234. background-color: rgba(0, 0, 0, 0.6);
  235. position: fixed;
  236. left: 0;
  237. top: 0;
  238. z-index: 10;
  239. }
  240. .registered-box {
  241. position: fixed;
  242. top: 10%;
  243. right: 50%;
  244. bottom: 50%;
  245. left: 38%;
  246. z-index: 11;
  247. width: 5rem;
  248. height: 8rem;
  249. background: #fff;
  250. border-radius: 0.1rem;
  251. }
  252. .registered-box-title {
  253. height: 0.5rem;
  254. background: linear-gradient(
  255. 180deg,
  256. rgba(153, 153, 153, 1) 0%,
  257. rgba(86, 86, 86, 1) 100%
  258. );
  259. border-radius: 0.1rem 0.1rem 0 0;
  260. color: #fff;
  261. font-size: 0.18rem;
  262. position: relative;
  263. }
  264. .registered-box-title::before {
  265. content: "";
  266. display: inline-block;
  267. width: 0.04rem;
  268. height: 0.2rem;
  269. border-radius: 0.02rem;
  270. background: #f76649;
  271. position: absolute;
  272. left: 0.2rem;
  273. top: 0.15rem;
  274. }
  275. .registered-box-center {
  276. font-size: 0.16rem;
  277. color: #666;
  278. }
  279. .registered-box-center span {
  280. font-size: 0.14rem;
  281. color: #999;
  282. }
  283. .registered-box-center input {
  284. background: #eee;
  285. width: 4.6rem;
  286. height: 0.4rem;
  287. border-radius: 0.05rem;
  288. border: 0.01rem solid #ccc;
  289. padding-left: 0.2rem;
  290. color: #666;
  291. }
  292. .registered-box-center div {
  293. height: 1rem;
  294. display: flex;
  295. align-items: center;
  296. flex-wrap: wrap;
  297. }
  298. button {
  299. background: #f76649;
  300. height: 0.5rem;
  301. border-radius: 0.05rem;
  302. font-size: 0.18rem;
  303. color: #fff;
  304. border: none;
  305. width: 100%;
  306. margin-bottom: 0.2rem;
  307. margin-top: 0.2rem;
  308. }
  309. .checkCode {
  310. width: 1rem;
  311. height: 0.38rem;
  312. position: absolute;
  313. right: 0%;
  314. top: 51%;
  315. border-radius: 0 0.05rem 0.05rem 0;
  316. background: #ccc;
  317. cursor: pointer;
  318. }
  319. </style>