forget.vue 5.7 KB

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