forget.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <view class="container">
  3. <view class="container_box"></view>
  4. <view class="loginTitle"><text>找回密码。</text></view>
  5. <view class="login_text">
  6. <view class="login_input flex">
  7. <!-- <view class="login_img"><image src="/static/icon/img03.png"></image></view> -->
  8. <view class="login_name"><input class="uni-input" v-model="phone" focus placeholder="请输入用户名" /></view>
  9. </view>
  10. <view class="login_input flex">
  11. <!-- <view class="login_img"><image src="/static/icon/img04.png"></image></view> -->
  12. <view class="login_name"><input class="uni-input" type="password" v-model="password" focus placeholder="请输入密码" /></view>
  13. </view>
  14. <view class="login_input flex">
  15. <!-- <view class="login_img"><image src="/static/icon/img04.png"></image></view> -->
  16. <view class="login_name"><input class="uni-input" type="password" v-model="repassword" focus placeholder="请重复输入密码" /></view>
  17. </view>
  18. <!-- <view class="login_input flex">
  19. <view class="login_img"><image src="/static/icon/img07.png"></image></view>
  20. <view class="login_name"><input class="uni-input" type="text" v-model="invitation" focus placeholder="请输入邀请码" /></view>
  21. </view> -->
  22. <view class="login_input flex">
  23. <!-- <view class="login_img"><image src="/static/icon/img06.png"></image></view> -->
  24. <view class="login_name flex">
  25. <input class="uni-input width" v-model="code" focus placeholder="请输入验证码" />
  26. <view class="code" @click="verification">{{ countDown == 0 ? '获取验证码' : countDown }}</view>
  27. </view>
  28. </view>
  29. <view><button type="green" @click="register" class="uni-button uni-button-red">找回密码</button></view>
  30. <view class="forget" @click="login">已找回密码?返回登录</view>
  31. <!-- <view class="forget" @click="login">已有账号?立即登录。</view> -->
  32. <!-- <view><button class="uni-button uni-button-green uni-button-green-plain" type="green" plain="true" hover-class="none" @click="login">返回登录</button></view> -->
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. import { register, verify } from '@/api/login.js';
  38. import { registerReset } from '@/api/set.js';
  39. export default {
  40. data() {
  41. return {
  42. phone: '', //用户
  43. password: '', //密码
  44. repassword: '',
  45. invitation: '', //邀请码
  46. code: '', //验证码
  47. time: '', //保存倒计时对象
  48. countDown: 0 //倒计时
  49. };
  50. },
  51. onLoad() {},
  52. watch: {
  53. // 监听倒计时
  54. countDown(i) {
  55. if (i == 0) {
  56. clearInterval(this.time);
  57. }
  58. }
  59. },
  60. methods: {
  61. // 注册
  62. register() {
  63. let obj = this;
  64. if (obj.phone == '') {
  65. obj.$api.msg('请输入电话号码');
  66. return;
  67. }
  68. if (!/(^1[3|4|5|7|8][0-9]{9}$)/.test(obj.phone)) {
  69. obj.$api.msg('请输入正确的手机号');
  70. return;
  71. }
  72. if (obj.password == '') {
  73. obj.$api.msg('请输入密码');
  74. return;
  75. }
  76. if (obj.repassword == '') {
  77. obj.$api.msg('请再次输入密码');
  78. return;
  79. }
  80. if (obj.repassword != obj.password) {
  81. obj.$api.msg('两次密码不正确');
  82. return;
  83. }
  84. if ((obj.invitation = '')) {
  85. obj.$api.msg('请输入邀请码');
  86. return;
  87. }
  88. if (obj.code == '') {
  89. obj.$api.msg('请输入验证码');
  90. return;
  91. }
  92. registerReset({
  93. account: obj.phone, //账号
  94. captcha: obj.code, //验证码
  95. password: obj.password //密码
  96. }).then(function(e) {
  97. uni.showToast({
  98. title:'修改成功',
  99. duration:2000,
  100. position:'top'
  101. });
  102. setTimeout(function () {
  103. uni.navigateTo({
  104. url: '/pages/public/login'
  105. });
  106. },1000)
  107. });
  108. //调用注册接口,成功跳转登录页
  109. },
  110. //发送验证码
  111. verification() {
  112. let obj = this;
  113. if (this.phone == '') {
  114. this.$api.msg('请输入电话号码');
  115. return;
  116. }
  117. if (this.phone.length < 11) {
  118. this.$api.msg('请输入正确的手机号');
  119. return;
  120. }
  121. // 判断是否在倒计时
  122. if (obj.countDown > 0) {
  123. return false;
  124. } else {
  125. obj.countDown = 60;
  126. obj.time = setInterval(() => {
  127. obj.countDown--;
  128. }, 1000);
  129. //调用验证码接口
  130. verify({
  131. phone: obj.phone,
  132. type:'RETRIEV_CODE'
  133. })
  134. .then(({ data }) => {})
  135. .catch(err => {
  136. console.log(err);
  137. });
  138. }
  139. },
  140. login() {
  141. //返回登录
  142. uni.navigateTo({
  143. url: '/pages/public/login'
  144. });
  145. }
  146. }
  147. };
  148. </script>
  149. <style>
  150. page {
  151. height: 100%;
  152. background-color: #FFFFFF;
  153. }
  154. .container {
  155. width: 100%;
  156. height: 100%;
  157. background-size: 100%;
  158. }
  159. .container_box {
  160. width: 100%;
  161. height: 200rpx;
  162. }
  163. .login_text {
  164. margin: auto 30rpx;
  165. position: relative;
  166. margin-top: 150rpx !important;
  167. }
  168. .login_input {
  169. border: 1px solid #f0f0f0;
  170. padding: 35rpx 25rpx;
  171. margin-bottom: 35rpx;
  172. border-radius: 15rpx;
  173. }
  174. .login_img image {
  175. height: 35rpx;
  176. width: 29rpx;
  177. }
  178. .uni-input {
  179. text-align: left;
  180. width: 100%;
  181. flex-shrink: 1;
  182. font-size: 28rpx !important;
  183. }
  184. .login_name {
  185. color: #333333;
  186. flex-grow: 1;
  187. padding-left: 20rpx;
  188. }
  189. .forget {
  190. width: 100rpx;
  191. font-size: 24rpx;
  192. color: #ffffff;
  193. margin: 0px auto;
  194. border-bottom: 1px solid #ffffff;
  195. }
  196. .width {
  197. width: 325rpx !important;
  198. }
  199. .code {
  200. color: #1B1B1B;
  201. font-size: 23rpx;
  202. border-left: 1px solid #1B1B1B;
  203. width: 180rpx;
  204. flex-shrink: 0;
  205. text-align: center;
  206. }
  207. uni-button {
  208. height: 80rpx !important;
  209. line-height: 80rpx !important;
  210. }
  211. .loginTitle {
  212. position: absolute;
  213. width: 100%;
  214. text-align: left;
  215. color: #333333;
  216. font-size: 56rpx;
  217. padding-left: 25rpx;
  218. font-weight: bold;
  219. }
  220. .uni-button-red {
  221. color: #FFFFFF;
  222. background-color: #BC253A;
  223. margin: 40rpx 10rpx;
  224. border-radius: 15rpx;
  225. }
  226. .uni-button-green-plain {
  227. border: 1px solid #5dbc7c;
  228. margin: 40rpx 10rpx;
  229. border-radius: 50rpx;
  230. color: #5dbc7c;
  231. background-color: #ffffff;
  232. }
  233. .uni-button {
  234. height: 100rpx !important;
  235. line-height: 100rpx !important;
  236. }
  237. .forget {
  238. font-size: 28rpx;
  239. width: 100%;
  240. text-align: left;
  241. color: #313131;
  242. margin-bottom: 25rpx;
  243. }
  244. .forget:hover{
  245. cursor: pointer;
  246. }
  247. </style>