forget.vue 4.6 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/ze.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/ze2.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. obj.$api.msg(obj.$t("login.a1"));
  59. return;
  60. }
  61. if (!/(^1[3|4|5|7|8][0-9]{9}$)/.test(this.account)) {
  62. obj.$api.msg(obj.$t("safe.b8"));
  63. return;
  64. }
  65. if (obj.captcha == '') {
  66. obj.$api.msg(obj.$t("login.b6"));
  67. return;
  68. }
  69. loginMobile({
  70. account: obj.account, //账号
  71. captcha: obj.captcha
  72. }).then(function(e) {
  73. uni.setStorageSync('token', e.data.token);
  74. getUserInfo({}).then(e => {
  75. obj.login();
  76. // 保存返回用户数据
  77. obj.setUserInfo(e.data);
  78. //成功跳转首页
  79. uni.switchTab({
  80. url: '/pages/index/index'
  81. });
  82. });
  83. }).catch((e) => {
  84. console.log(e);
  85. });
  86. },
  87. //发送验证码
  88. verification() {
  89. let obj = this;
  90. if (this.account == '') {
  91. this.$api.msg(obj.$t("login.a1"));
  92. return;
  93. }
  94. if (this.account.length < 11) {
  95. this.$api.msg(obj.$t("safe.b8"));
  96. return;
  97. }
  98. // 判断是否在倒计时
  99. if (obj.countDown > 0) {
  100. return false;
  101. } else {
  102. obj.countDown = 60;
  103. obj.time = setInterval(() => {
  104. obj.countDown--;
  105. }, 1000);
  106. //调用验证码接口
  107. verify({
  108. account: obj.account,
  109. type: 'login'
  110. })
  111. .then(({ data }) => {})
  112. .catch(err => {
  113. console.log(err);
  114. });
  115. }
  116. },
  117. login() {
  118. //返回登录
  119. uni.navigateTo({
  120. url: '/pages/public/login'
  121. });
  122. }
  123. }
  124. };
  125. </script>
  126. <style lang="scss">
  127. page {
  128. height: 100%;
  129. }
  130. .container {
  131. width: 100%;
  132. height: 100%;
  133. background-size: 100%;
  134. background-color: #000000;
  135. }
  136. .container_text {
  137. width: 100%;
  138. height: 500rpx;
  139. top: 0rpx;
  140. .banner-img {
  141. width: 144rpx;
  142. height: 144rpx;
  143. margin-top: 100rpx;
  144. margin-left: 302rpx;
  145. }
  146. }
  147. .login_text {
  148. margin: auto 10rpx;
  149. position: relative;
  150. padding: 100rpx 102rpx;
  151. background-color: #000000;
  152. margin-top: -180rpx;
  153. border-radius: 20rpx;
  154. .login_input {
  155. border-bottom: 1px solid #f0f0f0;
  156. margin-bottom: 65rpx;
  157. .login_img image {
  158. height: 35rpx;
  159. width: 29rpx;
  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>