forget.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <view class="container">
  3. <view class="container_text">
  4. <image class="banner-img" src="/static/img/shouye1.png" mode="scaleToFill"></image>
  5. </view>
  6. <view class="loginTitle"><text>{{$t('login.a0')}}</text></view>
  7. <view class="login_text">
  8. <view class="login_input flex_item">
  9. <view class="login_img"><image src="/static/icon/ze.png"></image></view>
  10. <view class="login_name"><input class="uni-input" type="text" v-model="account" focus :placeholder="$t('login.a1')" /></view>
  11. </view>
  12. <view class="login_input flex_item">
  13. <view class="login_img"><image src="/static/icon/ze2.png"></image></view>
  14. <view class="login_name"><input class="uni-input" type="password" v-model="password" focus :placeholder="$t('password.a3')" /></view>
  15. </view>
  16. <view class="login_input flex_item">
  17. <view class="login_img"><image src="/static/icon/ze2.png"></image></view>
  18. <view class="login_name"><input class="uni-input" type="password" v-model="password2" focus :placeholder="$t('password.a5')" /></view>
  19. </view>
  20. <view class="login_input flex">
  21. <view class="login_img"><image class="codeimg" src="/static/icon/ze2.png"></image></view>
  22. <view class="login_name flex">
  23. <input class="uni-input" v-model="captcha" type="number" focus :placeholder="$t('password.a6')" />
  24. <view class="code" @click="verification">{{ countDown == 0 ? $t('login.b5') : countDown }}</view>
  25. </view>
  26. </view>
  27. <view class="uni-button uni-button-green" @click="updatalogin">{{$t('safe.b7')}}</view>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. import { registerReset } from '@/api/set.js';
  33. import { verify } from '@/api/login.js';
  34. export default {
  35. data() {
  36. return {
  37. account: '', //用户
  38. captcha: '', //验证码
  39. password2: '',
  40. password: '',
  41. time: '', //保存倒计时对象
  42. countDown: 0 //倒计时
  43. };
  44. },
  45. onLoad() {},
  46. watch: {
  47. // 监听倒计时
  48. countDown(i) {
  49. if (i == 0) {
  50. clearInterval(this.time);
  51. }
  52. }
  53. },
  54. methods: {
  55. updatalogin() {
  56. let obj = this;
  57. if (obj.account == '') {
  58. obj.$api.msg(obj.$t("login.a1"));
  59. return;
  60. }
  61. if (!/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/.test(obj.account) && !/(^1[3|4|5|6|7|8|9][0-9]{9}$)/.test(this.account)) {
  62. obj.$api.msg(obj.$t("safe.b8"));
  63. return;
  64. }
  65. if (obj.password == '') {
  66. obj.$api.msg(obj.$t("login.a3"));
  67. return;
  68. }
  69. if (obj.password2 == '') {
  70. obj.$api.msg(obj.$t("login.c6"));
  71. return;
  72. }
  73. if (obj.password2 != obj.password) {
  74. obj.$api.msg(obj.$t("login.c7"));
  75. return;
  76. }
  77. if (obj.captcha == '') {
  78. obj.$api.msg(obj.$t("login.b6"));
  79. return;
  80. }
  81. registerReset({
  82. account: obj.account, //账号
  83. password: obj.password,
  84. password2: obj.password2,
  85. type: 1,
  86. captcha: obj.captcha
  87. })
  88. .then(function(e) {
  89. obj.$api.msg(e.msg);
  90. uni.navigateTo({
  91. url: '/pages/public/login'
  92. });
  93. })
  94. .catch(e => {
  95. console.log(e);
  96. });
  97. },
  98. //发送验证码
  99. verification() {
  100. let obj = this;
  101. if (this.account == '') {
  102. this.$api.msg(obj.$t("login.c8"));
  103. return;
  104. }
  105. if (!/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/.test(obj.account) && !/(^1[3|4|5|6|7|8|9][0-9]{9}$)/.test(this.account)) {
  106. obj.$api.msg(obj.$t("login.c9"));
  107. return;
  108. }
  109. // 判断是否在倒计时
  110. if (obj.countDown > 0) {
  111. return false;
  112. } else {
  113. obj.countDown = 60;
  114. obj.time = setInterval(() => {
  115. obj.countDown--;
  116. }, 1000);
  117. //调用验证码接口
  118. verify({
  119. phone: obj.account,
  120. type: 'login'
  121. })
  122. .then(({ data }) => {
  123. uni.showToast({
  124. title: obj.$t("login.c10"),
  125. duration: 2000,
  126. position: 'top',
  127. icon: 'none'
  128. });
  129. })
  130. .catch(err => {
  131. console.log(err);
  132. });
  133. }
  134. }
  135. }
  136. };
  137. </script>
  138. <style lang="scss">
  139. page {
  140. min-height: 100%;
  141. background-color: #000;
  142. .container {
  143. width: 100%;
  144. }
  145. }
  146. .container_text {
  147. position: relative;
  148. width: 100%;
  149. height: 500rpx;
  150. top: 0rpx;
  151. .banner-img {
  152. width: 144rpx;
  153. height: 144rpx;
  154. margin-top: 100rpx;
  155. margin-left: 302rpx;
  156. }
  157. .title-img {
  158. position: absolute;
  159. left: 50%;
  160. top: 100rpx;
  161. margin-left: -130rpx;
  162. width: 260rpx;
  163. height: 156rpx;
  164. .title-image {
  165. width: 260rpx;
  166. height: 156rpx;
  167. }
  168. }
  169. }
  170. .loginTitle {
  171. position: absolute;
  172. top: 250rpx;
  173. width: 100%;
  174. text-align: center;
  175. color: #cbb174;
  176. font-size: 40rpx;
  177. }
  178. .phone {
  179. height: 43rpx !important;
  180. width: 27rpx !important;
  181. }
  182. .codeimg {
  183. height: 39rpx !important;
  184. width: 31rpx !important;
  185. }
  186. .login_text {
  187. margin: -150rpx 0 0;
  188. position: relative;
  189. padding: 100rpx 102rpx;
  190. background-color: #000;
  191. .login_input {
  192. border-bottom: 1px solid #fff;
  193. margin-bottom: 65rpx;
  194. .login_img image {
  195. height: 36rpx;
  196. width: 30rpx;
  197. margin-right: 20rpx;
  198. }
  199. .uni-input {
  200. text-align: left;
  201. font-size: 28rpx !important;
  202. color: #ffffff;
  203. }
  204. .login_name {
  205. color: #333333;
  206. }
  207. }
  208. .uni-button-green {
  209. text-align: center;
  210. color: #ffffff;
  211. background-color: #feb041;
  212. margin: 40rpx 10rpx;
  213. border-radius: 50rpx;
  214. }
  215. .uni-button-green-plain {
  216. border: 1px solid #E6C79D;
  217. margin: 40rpx 10rpx;
  218. border-radius: 50rpx;
  219. color: #E6C79D;
  220. background-color: #feb041;
  221. }
  222. .uni-button {
  223. height: 85rpx;
  224. line-height: 85rpx;
  225. }
  226. }
  227. .code {
  228. color: #E6C79D;
  229. font-size: 23rpx;
  230. border-left: 1px solid #eeeeee;
  231. width: 150rpx;
  232. flex-shrink: 0;
  233. text-align: center;
  234. }
  235. .width {
  236. width: 325rpx !important;
  237. }
  238. .login {
  239. background: #E6C79D;
  240. margin-top: 96rpx;
  241. color: #ffffff;
  242. text-align: center;
  243. padding: 26rpx 0rpx;
  244. border-radius: 20rpx;
  245. }
  246. </style>