loginByCode.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <div class="container">
  3. <!-- <TopBar :icon="topbarIcon" :title="topbarTitle"></TopBar> -->
  4. <div class="tip font44 fw600" style="padding-top: 50px;">
  5. 验证码登录
  6. </div>
  7. <div class="phone-tip font28 fw400" style="margin-top: 12px;">
  8. 短信验证码已发送至:
  9. </div>
  10. <div class="phone-tip font28 fw400">
  11. {{phone}}
  12. </div>
  13. <div class="input-box flex-between">
  14. <input type="number" maxlength="6" placeholder="请输入验证码" placeholder-style="color:#494667;font-size:14px;" class="input fw500 font32" v-model="code" @input="inputChange" focus="true">
  15. <img src="../../static/input-clear.png" mode="aspectFill" class="clear" v-show="phone!==''" @click="clear"/>
  16. </div>
  17. <div class="btn font32 fw400" :class="timer===null?'primarybg':''" @click="reGetCode">
  18. {{btnStr}}
  19. </div>
  20. </div>
  21. </template>
  22. <script>
  23. import TopBar from '@/components/TopBar/TopBar.vue';
  24. export default {
  25. components:{TopBar},
  26. data() {
  27. return {
  28. topbarIcon:'back',
  29. topbarTitle:'',
  30. phone:'',
  31. code:'',
  32. btnStr:'',
  33. time:0,
  34. timer:'',
  35. verCodeOption:{
  36. scene: "VerCodeLogin",
  37. verCodeLogin:{
  38. phone: "",
  39. verCode: ""
  40. },
  41. androidMarket:'WechatMP',
  42. model:''
  43. },
  44. };
  45. },
  46. mounted() {
  47. this.phone=this.$route.params.phone;
  48. this.reGetCode()
  49. },
  50. methods:{
  51. clear(){
  52. this.code='';
  53. },
  54. inputChange(e){
  55. console.log(this.code)
  56. if(this.code.length===6){
  57. this.verCodeOption.verCodeLogin.phone=this.phone;
  58. this.verCodeOption.verCodeLogin.verCode=this.code;
  59. this.$api.login.login(this.verCodeOption).then(res=>{
  60. if(res.data.frozen){
  61. this.$toast(res.data.msg);
  62. }
  63. else if(res.data.succ){
  64. localStorage.setItem('LL_Ukn',res.data.userToken.ukn);
  65. localStorage.setItem('token',res.data.userToken.token);
  66. localStorage.setItem('userInfo',JSON.stringify(res.data));
  67. localStorage.setItem('user',JSON.stringify(res.data.userToken.user));
  68. this.$api.public.aliossCdn({}).then(cdnRes=>{
  69. this.$store.commit('setImageCdn',cdnRes.data.pictureCdn);
  70. this.$store.commit('setVideoCdn',cdnRes.data.videoCdn);
  71. })
  72. if(res.data.isNew){
  73. this.$router.replace({name:'sex'})
  74. return;
  75. }
  76. this.getMineDetail(res.data.regStepNew);
  77. }
  78. else{
  79. this.$toast(res.data.msg);
  80. }
  81. })
  82. }
  83. },
  84. reGetCode(){
  85. this.time=60;
  86. this.btnStr=`重新获取(${--this.time}s)`
  87. this.timer=setInterval(()=>{
  88. if(this.time<=1){
  89. clearInterval(this.timer);
  90. this.timer=null;
  91. this.btnStr="重新获取"
  92. }
  93. else{
  94. this.btnStr=`重新获取(${--this.time}s)`
  95. }
  96. },1000)
  97. },
  98. getMineDetail(regStepNew){
  99. let user=JSON.parse(localStorage.getItem('user'));
  100. this.$api.public.mineDetail({
  101. getAlbum:true,
  102. completeUser:user
  103. }).then(res=>{
  104. this.$store.commit('setUserInfo',res.data);
  105. localStorage.setItem('userInfo',JSON.stringify(res.data));//正式环境删除
  106. let step=regStepNew||localStorage.getItem('regStep');
  107. switch(step){
  108. case 'Sex':
  109. this.$router.replace({name:'sex'});
  110. break;
  111. case 'SocialImage':
  112. this.$router.replace({name:'figure'});
  113. break;
  114. case 'SocialData':
  115. this.$router.replace({name:'datum'});
  116. break;
  117. case 'CityStay':
  118. this.$router.replace({name:'city'});
  119. break;
  120. case 'WxInfo':
  121. this.$router.replace({name:'wechat'});
  122. break;
  123. case 'Basic':
  124. case 'Index':
  125. this.$router.replace({name:'main'});
  126. break;
  127. }
  128. })
  129. },
  130. }
  131. }
  132. </script>
  133. <style lang="scss" scoped>
  134. @import "../../public.scss";
  135. .container{
  136. background-color: $bgcolor1;
  137. width: 100vw;
  138. height: 100vh;
  139. .tip{
  140. color: $fontcolor5;
  141. padding-left: 30px;
  142. }
  143. .phone-tip{
  144. color: $fontcolor2;
  145. padding-left: 30px;
  146. }
  147. .input-box{
  148. margin: 0px 30px;
  149. margin-top: 80px;
  150. background-color: $bgcolor3;
  151. border-radius: 8px;
  152. height: 56px;
  153. padding: 0px 16px;
  154. .input{
  155. color: $fontcolor5;
  156. background-color: $bgcolor3;
  157. }
  158. .clear{
  159. width: 16px;
  160. height: 16px;
  161. }
  162. }
  163. .btn{
  164. margin: 0px 30px;
  165. margin-top: 60px;
  166. background-color: $fontcolor1;
  167. height: 52px;
  168. border-radius: 26px;
  169. line-height: 52px;
  170. text-align: center;
  171. color: $fontcolor3;
  172. }
  173. .link{
  174. box-sizing: border-box;
  175. margin: 0px 30px;
  176. margin-top: 15px;
  177. background-color: transparent;
  178. height: 52px;
  179. border-radius: 26px;
  180. line-height: 52px;
  181. text-align: center;
  182. color: $fontcolor3;
  183. border: 1px solid $fontcolor1;
  184. }
  185. .primarybg{
  186. background-color: $primary !important;
  187. color: $fontcolor5 !important;
  188. }
  189. }
  190. </style>