forget.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <view>
  3. <navbar :scroll="scrollNum" :iSimmersive="true" title="" :onBack="onBack"></navbar>
  4. <view class="top">
  5. <view>泰誉凡</view>
  6. <view>找回密码</view>
  7. </view>
  8. <view class="theform">
  9. <form @submit="onSubmit">
  10. <view class="fields-box">
  11. <view class="field-box iconfont">
  12. <input type="number" v-model="phone" class="uni-input" name="phone" placeholder="手机号" />
  13. </view>
  14. <view class="field-box iconfont">
  15. <input type="number" class="uni-input" name="code" placeholder="短信验证码" />
  16. <text class="send-sms" :class="{active: isSendCode}" @click="onSend">{{smsMsg}}</text>
  17. </view>
  18. <view class="field-box iconfont">
  19. <input type="password" class="uni-input" name="password" placeholder="密码" />
  20. </view>
  21. </view>
  22. <view class="btn">
  23. <button :disabled="isSubmit" form-type="submit">提 交</button>
  24. </view>
  25. </form>
  26. <view class="tips-box">
  27. <view><navigator url="login" hover-class="none">已有账号,<text>登录</text></navigator></view>
  28. </view>
  29. </view>
  30. <loading v-if="isSubmit" :layer="true"></loading>
  31. </view>
  32. </template>
  33. <script>
  34. import loading from '../../components/tool/loading'
  35. import { checkPhone } from '../../common/check';
  36. import navbar from "@/components/navbar/navbar";
  37. export default {
  38. components:{
  39. loading,navbar
  40. },
  41. data() {
  42. return {
  43. static: "",
  44. scrollNum: 0,
  45. smsMsg: "发送验证码",
  46. isSendCode: false,
  47. phone: '',
  48. isSubmit: false,
  49. timer: null
  50. }
  51. },
  52. onLoad() {
  53. this.static = this.$static;
  54. },
  55. onPageScroll(obj){
  56. this.scrollNum = obj.scrollTop;
  57. },
  58. methods: {
  59. onBack(){
  60. this.$utils.switchTab("index/index");
  61. },
  62. onSend(){
  63. if(!checkPhone(this.phone)){
  64. this.$utils.msg("您填写的手机号码不正确");
  65. return false;
  66. }
  67. if(this.isSendCode){
  68. return false;
  69. }
  70. this.$http.sendSMS({
  71. username: this.phone,
  72. type: "repassword"
  73. }).then((result)=>{
  74. this.$utils.msg(result.info);
  75. if(result.status){
  76. this.countdown();
  77. }else{
  78. clearInterval(this.timer);
  79. }
  80. }).catch((error)=>{
  81. this.$utils.msg("连接网络错误,请检查网络是否连接!");
  82. });
  83. },
  84. countdown(){
  85. let time = 60;
  86. clearInterval(this.timer);
  87. this.timer = setInterval(() => {
  88. time--;
  89. this.isSendCode=true;
  90. this.smsMsg=time + "秒后重发"
  91. if (time <= 0) {
  92. this.isSendCode=false;
  93. this.smsMsg="重新获取";
  94. clearInterval(this.timer);
  95. }
  96. }, 1000);
  97. },
  98. onSubmit(e){
  99. let formData = e.detail.value;
  100. this.isSubmit = true;
  101. if(formData.phone == ''){
  102. this.isSubmit = false;
  103. this.$utils.msg("请填写手机号码!");
  104. return ;
  105. }else if(!checkPhone(this.phone)){
  106. this.isSubmit = false;
  107. this.$utils.msg("您填写的手机号码不正确!");
  108. return ;
  109. }else if(formData.password == ''){
  110. this.isSubmit = false;
  111. this.$utils.msg("请填写密码!");
  112. return ;
  113. }else if(formData.code == ''){
  114. this.isSubmit = false;
  115. this.$utils.msg("请填写验证码!");
  116. return ;
  117. }
  118. this.$http.sendForget({
  119. username: formData.phone,
  120. password: formData.password,
  121. code: formData.code
  122. }).then((result)=>{
  123. if(result.status){
  124. this.$store.commit("UPDATEUSERS",result.data);
  125. this.$utils.switchTab('ucenter/index');
  126. }else{
  127. this.$utils.msg(result.info);
  128. }
  129. this.isSubmit = false;
  130. }).catch((error)=>{
  131. this.isSubmit = false;
  132. this.$utils.msg("连接网络错误,请检查网络是否连接!");
  133. });
  134. }
  135. }
  136. }
  137. </script>
  138. <style lang="scss" scoped>
  139. .top {
  140. background-color: transparent;
  141. width: 100%;
  142. height: 386rpx;
  143. position: relative;
  144. z-index: 1;
  145. background-image: url(~@/static/images/login-bg.png);
  146. background-repeat: no-repeat;
  147. background-size: 100%;
  148. view {
  149. z-index: 2;
  150. position: absolute;
  151. &:nth-child(1) {
  152. top: 90rpx;
  153. font-size: 72rpx;
  154. color: #fff;
  155. width: 100%;
  156. text-align: center;
  157. &::after {
  158. position: absolute;
  159. content: " ";
  160. background-color: #7a91dc;
  161. height: 1px;
  162. width: 210rpx;
  163. top: 120rpx;
  164. left: 50%;
  165. transform: translateX(-50%);
  166. }
  167. }
  168. &:nth-child(2) {
  169. top: 225rpx;
  170. font-size: 49rpx;
  171. color: #fff000;
  172. text-align: center;
  173. width: 100%;
  174. }
  175. }
  176. image {
  177. width: 100%;
  178. height: 386rpx;
  179. }
  180. }
  181. .theform {
  182. width: 590rpx;
  183. margin: 70rpx auto 0 auto;
  184. .fields-box{
  185. width: 100%;
  186. border: 1px solid #d2cdcd;
  187. overflow: hidden;
  188. border-radius: 10rpx;
  189. .field-box{
  190. width: 100%;
  191. height: 100rpx;
  192. border-bottom:1px solid #d2cdcd;
  193. position: relative;
  194. font-size: 40rpx;
  195. &:last-child {
  196. border-bottom:0px solid #d2cdcd;
  197. }
  198. input {
  199. width: 100%; height: 100rpx; line-height: 100rpx;
  200. text-indent: 100rpx; font-size:29rpx; color: #888;
  201. }
  202. &:nth-child(1):before {
  203. content: "\e61b";
  204. color: #bfbfbf;
  205. position: absolute;
  206. left: 30rpx;
  207. top: 28rpx;
  208. }
  209. &:nth-child(2):before {
  210. content: "\e618";
  211. color: #bfbfbf;
  212. position: absolute;
  213. left: 30rpx;
  214. top: 28rpx;
  215. }
  216. &:nth-child(3):before {
  217. content: "\e61a";
  218. color: #bfbfbf;
  219. position: absolute;
  220. left: 30rpx;
  221. top: 28rpx;
  222. }
  223. .send-sms{
  224. position: absolute;
  225. top: 50%;
  226. transform: translateY(-50%);
  227. font-size: 29rpx;
  228. color: #fff;
  229. background-color: #1b43c4;
  230. display: block;
  231. width: 195rpx;
  232. height: 90rpx;
  233. line-height: 90rpx;
  234. text-align: center;
  235. right: 10rpx;
  236. border-radius: 5rpx;
  237. &.active { color: #333; background-color: #eee; }
  238. }
  239. }
  240. }
  241. .btn{
  242. width: 100%;
  243. margin-top: 48rpx;
  244. button{
  245. color: #fff;
  246. background-color: #1b43c4;
  247. border: 1px solid #1b43c4;
  248. border-radius: 10rpx;
  249. font-size: 33rpx;
  250. height: 100rpx;
  251. line-height: 100rpx;
  252. text-align: center;
  253. }
  254. }
  255. .tips-box{
  256. width: 100%;
  257. font-size: 28rpx;
  258. color: #888;
  259. margin-top: 45rpx;
  260. view {
  261. width: 100%;
  262. float: left;
  263. text-align: center;
  264. text { color: #1b43c4; }
  265. }
  266. }
  267. }
  268. </style>