forget.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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. uni.showToast({
  72. title: "请输入电话号码",
  73. icon:'none'
  74. });
  75. return;
  76. }
  77. if (this.phone.length != 11) {
  78. uni.showToast({
  79. title: "请输入正确的手机号",
  80. icon:'none'
  81. });
  82. return;
  83. }
  84. if (obj.password == '') {
  85. uni.showToast({
  86. title: "请输入密码",
  87. icon:'none'
  88. });
  89. return;
  90. }
  91. registerReset({
  92. account: obj.phone, //账号
  93. captcha: obj.code, //验证码
  94. password: obj.password, //密码
  95. }).then(function(e) {
  96. uni.showToast({
  97. title: '修改成功',
  98. duration: 2000,
  99. position: 'top'
  100. });
  101. setTimeout(function() {
  102. uni.navigateTo({
  103. url: '/pages/public/login'
  104. });
  105. }, 1000)
  106. });
  107. //调用注册接口,成功跳转登录页
  108. },
  109. //发送验证码
  110. verification() {
  111. let obj = this;
  112. if (this.phone == '') {
  113. uni.showToast({
  114. title: "请输入电话号码",
  115. icon:'none'
  116. });
  117. return;
  118. }
  119. if (this.phone.length < 11) {
  120. uni.showToast({
  121. title: "请输入正确的手机号",
  122. icon:'none'
  123. });
  124. return;
  125. }
  126. // 判断是否在倒计时
  127. if (obj.countDown > 0) {
  128. return false;
  129. } else {
  130. obj.countDown = 60;
  131. obj.time = setInterval(() => {
  132. obj.countDown--;
  133. }, 1000);
  134. //调用验证码接口
  135. verify({
  136. phone: obj.phone,
  137. type: ''
  138. })
  139. .then(({
  140. data
  141. }) => {})
  142. .catch(err => {
  143. console.log(err);
  144. });
  145. }
  146. },
  147. login() {
  148. //返回登录
  149. uni.navigateTo({
  150. url: '/pages/public/login'
  151. });
  152. }
  153. }
  154. };
  155. </script>
  156. <style lang="scss">
  157. page {
  158. height: 100%;
  159. }
  160. .container {
  161. width: 100%;
  162. height: 100%;
  163. background-size: 100%;
  164. background-color: #FFFFFF;
  165. }
  166. .container_text {
  167. width: 100%;
  168. height: 500rpx;
  169. top: 0rpx;
  170. .banner-img {
  171. width: 100%;
  172. height: 100%;
  173. }
  174. }
  175. .login_text {
  176. margin: auto 50rpx;
  177. position: relative;
  178. background-color: #ffffff;
  179. border-radius: 20rpx;
  180. .login_input {
  181. border-bottom: 1px solid #f0f0f0;
  182. margin-bottom: 30rpx;
  183. padding: 30rpx 0;
  184. line-height: 1;
  185. .login_img {
  186. height: 35rpx;
  187. width: 150rpx;
  188. flex-shrink: 0;
  189. font-size: 30rpx;
  190. text-align: center;
  191. margin-right: 20rpx;
  192. color: $font-base;
  193. }
  194. .uni-input {
  195. text-align: left;
  196. width: 100%;
  197. font-size: 28rpx !important;
  198. }
  199. .login_name {
  200. color: #333333;
  201. flex-grow: 1;
  202. .code {
  203. color: #5dbc7c;
  204. font-size: 23rpx;
  205. border-left: 1px solid #eeeeee;
  206. width: 150rpx;
  207. flex-shrink: 0;
  208. text-align: center;
  209. }
  210. }
  211. }
  212. .other {
  213. margin-top: 60rpx;
  214. .fenge {
  215. width: 30%;
  216. height: 2rpx;
  217. background-color: #eeeeee;
  218. }
  219. .qita {
  220. font-size: 28rpx;
  221. color: #999999;
  222. }
  223. }
  224. .weixin {
  225. width: 75rpx;
  226. height: 75rpx;
  227. margin: 25rpx auto;
  228. }
  229. .weixin image {
  230. width: 100%;
  231. height: 100%;
  232. }
  233. .weixin_text {
  234. text-align: center;
  235. font-size: 28rpx;
  236. color: #999999;
  237. }
  238. .forget {
  239. font-size: 28rpx;
  240. width: 100%;
  241. text-align: right;
  242. color: #999999;
  243. }
  244. .uni-button-green {
  245. color: #ffffff;
  246. background-color: #5dbc7c;
  247. margin: 40rpx 10rpx;
  248. border-radius: 50rpx;
  249. box-shadow: 0px 8px 10px 0px rgba(166, 203, 184, 0.75);
  250. }
  251. .uni-button-green-plain {
  252. margin: 40rpx 10rpx;
  253. border-radius: 50rpx;
  254. color: $font-base;
  255. background-color: $page-color-base;
  256. border: none;
  257. }
  258. .uni-button {
  259. height: 80rpx;
  260. line-height: 80rpx;
  261. font-size: 28rpx;
  262. width: 100%;
  263. }
  264. }
  265. .loginTitle {
  266. padding: 150rpx 0;
  267. width: 100%;
  268. text-align: left;
  269. color: $font-base;
  270. font-size: 48rpx;
  271. margin: 0 50rpx;
  272. }
  273. .forget {
  274. width: 100rpx;
  275. font-size: 24rpx;
  276. color: #ffffff;
  277. margin: 0px auto;
  278. border-bottom: 1px solid #ffffff;
  279. }
  280. .width {
  281. width: 325rpx !important;
  282. }
  283. .code {
  284. color: #5dbc7c;
  285. font-size: 23rpx;
  286. border-left: 1px solid #eeeeee;
  287. width: 150rpx;
  288. flex-shrink: 0;
  289. text-align: center;
  290. }
  291. uni-button {
  292. height: 80rpx !important;
  293. line-height: 80rpx !important;
  294. }
  295. </style>