forget.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <view class="container">
  3. <view class="container_text">
  4. <!-- <image class="banner-img" src="/static/img/img01.png" mode=" scaleToFill"></image> -->
  5. <image class="banner-img" src="/static/img/shouye1.png" mode="scaleToFill"></image>
  6. <view class="banner-img">
  7. </view>
  8. </view>
  9. <view class="loginTitle"><text>{{$t('login.a0')}}</text></view>
  10. <view class="login_text">
  11. <view class="login_input flex">
  12. <view class="login_img"><image src="/static/icon/img03.png"></image></view>
  13. <view class="login_name"><input class="uni-input" v-model="account" focus :placeholder="$t('login.a1')"/></view>
  14. </view>
  15. <view class="login_input flex">
  16. <view class="login_img"><image src="/static/icon/img06.png"></image></view>
  17. <view class="login_name flex">
  18. <input class="uni-input width" v-model="captcha" focus :placeholder="$t('password.a7')" />
  19. <view class="code" @click="verification">{{ countDown == 0 ? $t('password.a7') : countDown }}</view>
  20. </view>
  21. </view>
  22. <view>
  23. <button type="green" @click="register" class="uni-button uni-button-green">{{$t('login.a4')}}</button>
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import { mapMutations } from 'vuex';
  30. import { verify, loginMobile, getUserInfo } from '@/api/login.js';
  31. export default {
  32. data() {
  33. return {
  34. account: '' ,//用户
  35. captcha: '', //验证码
  36. // phone: '', //用户
  37. // code: '', //验证码
  38. time: '', //保存倒计时对象
  39. countDown: 0 //倒计时
  40. };
  41. },
  42. onLoad() {},
  43. watch: {
  44. // 监听倒计时
  45. countDown(i) {
  46. if (i == 0) {
  47. clearInterval(this.time);
  48. }
  49. }
  50. },
  51. methods: {
  52. ...mapMutations('user', ['setUserInfo', 'login']),
  53. // 手机登录
  54. register() {
  55. let obj = this;
  56. if (obj.account == '') {
  57. obj.$api.msg('请输入电话号码');
  58. return;
  59. }
  60. if (!/(^1[3|4|5|7|8][0-9]{9}$)/.test(this.account)) {
  61. obj.$api.msg('请输入正确的手机号');
  62. return;
  63. }
  64. if (obj.captcha == '') {
  65. obj.$api.msg('请输入验证码');
  66. return;
  67. }
  68. loginMobile({
  69. account: obj.account, //账号
  70. captcha: obj.captcha
  71. }).then(function(e) {
  72. uni.setStorageSync('token', e.data.token);
  73. getUserInfo({}).then(e => {
  74. obj.login();
  75. // 保存返回用户数据
  76. obj.setUserInfo(e.data);
  77. //成功跳转首页
  78. uni.switchTab({
  79. url: '/pages/index/index'
  80. });
  81. });
  82. }).catch((e) => {
  83. console.log(e);
  84. });
  85. },
  86. //发送验证码
  87. verification() {
  88. let obj = this;
  89. if (this.account == '') {
  90. this.$api.msg('请输入电话号码');
  91. return;
  92. }
  93. if (this.account.length < 11) {
  94. this.$api.msg('请输入正确的手机号');
  95. return;
  96. }
  97. // 判断是否在倒计时
  98. if (obj.countDown > 0) {
  99. return false;
  100. } else {
  101. obj.countDown = 60;
  102. obj.time = setInterval(() => {
  103. obj.countDown--;
  104. }, 1000);
  105. //调用验证码接口
  106. verify({
  107. account: obj.account,
  108. type: 'login'
  109. })
  110. .then(({ data }) => {})
  111. .catch(err => {
  112. console.log(err);
  113. });
  114. }
  115. },
  116. login() {
  117. //返回登录
  118. uni.navigateTo({
  119. url: '/pages/public/login'
  120. });
  121. }
  122. }
  123. };
  124. </script>
  125. <style lang="scss">
  126. page {
  127. height: 100%;
  128. }
  129. .container {
  130. width: 100%;
  131. height: 100%;
  132. background-size: 100%;
  133. background-color: #000000;
  134. }
  135. .container_text {
  136. width: 100%;
  137. height: 500rpx;
  138. top: 0rpx;
  139. .banner-img {
  140. width: 144rpx;
  141. height: 144rpx;
  142. margin-top: 100rpx;
  143. margin-left: 302rpx;
  144. }
  145. }
  146. .login_text {
  147. margin: auto 30rpx;
  148. position: relative;
  149. padding: 100rpx 102rpx;
  150. background-color: #000000;
  151. margin-top: -180rpx;
  152. border-radius: 20rpx;
  153. .login_input {
  154. border-bottom: 1px solid #f0f0f0;
  155. margin-bottom: 65rpx;
  156. .login_img image {
  157. height: 35rpx;
  158. width: 29rpx;
  159. margin-right: 20rpx;
  160. }
  161. .uni-input {
  162. text-align: left;
  163. width: 470rpx;
  164. font-size: 28rpx !important;
  165. }
  166. .login_name {
  167. color: #fff;
  168. .width {
  169. width: 325rpx !important;
  170. }
  171. .code {
  172. color: #cbb174;
  173. font-size: 23rpx;
  174. border-left: 1px solid #eeeeee;
  175. width: 150rpx;
  176. flex-shrink: 0;
  177. text-align: center;
  178. }
  179. }
  180. }
  181. .uni-button-green {
  182. color: #2a2421;
  183. background-color: #feb041;
  184. margin: 40rpx 10rpx;
  185. border-radius: 50rpx;
  186. }
  187. .uni-button {
  188. height: 85rpx;
  189. line-height: 85rpx;
  190. }
  191. }
  192. .loginTitle {
  193. position: absolute;
  194. top: 250rpx;
  195. width: 100%;
  196. text-align: center;
  197. color: #cbb174;
  198. font-size: 40rpx;
  199. }
  200. uni-button {
  201. height: 80rpx !important;
  202. line-height: 80rpx !important;
  203. }
  204. </style>