forget.vue 5.4 KB

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