froget.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. <template>
  2. <view class="content">
  3. <view class="login-bg">
  4. <view class="locked-head">
  5. <uni-icons type='locked' style="font-size: 42px; color: #fff;"></uni-icons>
  6. </view>
  7. <view class="login-card">
  8. <block v-if="step==0">
  9. <label class="uni-list-cell uni-list-cell-pd" >
  10. <label class="label-2-text" style="width: 15%;" >
  11. <text>用户名</text>
  12. </label>
  13. <view style="width: 85%;">
  14. <input class="uni-input" placeholder="输入用户名或者ID" v-model="form.username" />
  15. </view>
  16. </label>
  17. </block>
  18. <block v-if="step==1">
  19. <label class="uni-list-cell uni-list-cell-pd" >
  20. <label class="label-2-text" style="width: 25%;" >
  21. <text>手机号</text>
  22. </label>
  23. <view style="float: left;text-align: left;width: 75%;">
  24. {{mobileshow}}
  25. </view>
  26. </label>
  27. <label class="uni-list-cell uni-list-cell-pd" >
  28. <label class="label-2-text" >
  29. <text>验证码</text>
  30. </label>
  31. <view style="float: left;">
  32. <input class="uni-input captch" style="width:300upx;" placeholder="请输入验证码" v-model="form.captch" />
  33. <button class="captchtext" v-if="issend" style="font-size: 24rpx;">{{getCodeTime}}秒获取</button>
  34. <button class="captchtext" v-else @tap="send_sms" >获取验证码</button>
  35. </view>
  36. </label>
  37. </block>
  38. <block v-if="step==2">
  39. <label class="uni-list-cell uni-list-cell-pd" >
  40. <label class="label-2-text" >
  41. <text>新登录密码</text>
  42. </label>
  43. <view style="float: left;text-align: left;width: 70%;">
  44. <input class="uni-input pass" style="width: 100%;" placeholder="输入新登录密码(6-16位)" maxlength="16" password="password" v-model="form.password"/>
  45. </view>
  46. </label>
  47. <label class="uni-list-cell uni-list-cell-pd" >
  48. <label class="label-2-text" >
  49. <text>确认登录密码</text>
  50. </label>
  51. <view style="float: left;text-align: left;width: 70%;">
  52. <input class="uni-input pass" style="width: 100%;" placeholder="再次输入登录密码(6-16位)" maxlength="16" password="password" v-model="form.password2"/>
  53. </view>
  54. </label>
  55. </block>
  56. </view>
  57. </view>
  58. <view class="login-btn">
  59. <button
  60. :disabled="checkIn ? false : true" type="primary" @tap="subReg">下一步</button>
  61. </view>
  62. </view>
  63. </template>
  64. <script>
  65. import store from "../../store";
  66. import cache from '../../library/cache.js'
  67. import api from "../../library/index.js"
  68. import http from '../../library/http.js'
  69. import uniIcons from '../../components/uni-icons/uni-icons.vue'
  70. export default {
  71. components: {
  72. uniIcons
  73. },
  74. data() {
  75. return {
  76. showPassword: true,
  77. form: {
  78. username:'',
  79. captch: '',
  80. mobile: '',
  81. password: '',
  82. password2:'',
  83. },
  84. userid:0,
  85. mobileshow:'',
  86. mobile:'',
  87. disabled:true,
  88. getCodeTime:60,
  89. issend:0,
  90. timer1:'',
  91. isok:0,
  92. step:0,
  93. checkIn:true
  94. }
  95. },
  96. onLoad() {
  97. },
  98. onShow(){
  99. if(uni.getStorageSync('access_token')){
  100. this.disabled=true;
  101. var userinfo=uni.getStorageSync('userinfo');
  102. console.log(userinfo);
  103. this.form.mobile=userinfo.name;
  104. }
  105. },
  106. methods: {
  107. changePassword() {
  108. this.showPassword = !this.showPassword;
  109. },
  110. delInputUEmailText(){
  111. this.form.mobile = ''
  112. },
  113. delInputCaptchText(){
  114. this.form.captch = ''
  115. },
  116. delInputPasswordText(){
  117. this.form.password = ''
  118. },
  119. send_sms(){
  120. var reg =/^0?1[3|4|5|6|7|8|9][0-9]\d{8}$/;
  121. if(reg.test(this.mobile)){
  122. this.issend=1;
  123. this.timer1= setInterval(() => {
  124. this.getCodeTime--
  125. if (this.getCodeTime == 0){
  126. this.getCodeTime = 60;
  127. clearInterval(this.timer1);
  128. this.issend=0;
  129. }
  130. }, 1000)
  131. api.sendCode({mobile:this.mobile,type:'pwd'}).then(res=>{
  132. var data=res.data;
  133. if(data.method=='login') this.isok=1;
  134. else {
  135. uni.showToast({
  136. title: '手机号尚未注册',
  137. duration: 1000,
  138. icon:'none'
  139. });
  140. this.isok=0;
  141. this.getCodeTime = 60;
  142. clearInterval(this.timer1);
  143. this.issend=0;
  144. }
  145. })
  146. }
  147. else{
  148. uni.showToast({
  149. title: '手机格式错误',
  150. duration: 1000,
  151. icon:'none'
  152. });
  153. return false;
  154. }
  155. //console.log(,this.form.captch);
  156. },
  157. subReg(){
  158. let _this = this;
  159. if(this.step==0){
  160. if(this.form.username==''){
  161. uni.showToast({
  162. icon:'none',
  163. title:'请输入用户名',
  164. duration:1000
  165. })
  166. return false;
  167. }
  168. http.setWait(false).post('user.php?act=findpwd0',{username:this.form.username}).then(res=>{
  169. var data=res.data;
  170. if(res.code==200){
  171. this.step=1;
  172. this.mobile=data.mobile;
  173. this.userid=data.id;
  174. this.mobileshow=this.mobile.substr(0,3)+'****'+this.mobile.substr(this.mobile.length-3,3);
  175. }else{
  176. }
  177. })
  178. }
  179. else if(this.step==1){
  180. if(this.form.captch==''){
  181. uni.showToast({
  182. icon:'none',
  183. title:'请输入验证码',
  184. duration:1000
  185. })
  186. return false;
  187. }
  188. if(this.form.captch.length!=6){
  189. uni.showToast({
  190. icon:'none',
  191. title:'验证码长度不正确',
  192. duration:1000
  193. })
  194. return false;
  195. }
  196. http.setWait(false).post('user.php?act=findpwd1',{mobile:this.mobile,randcode:this.form.captch}).then(res=>{
  197. var data=res.data;
  198. if(res.code==200){
  199. this.step=2;
  200. }else{
  201. }
  202. })
  203. }
  204. else if(this.step==2){
  205. if(this.form.password.length<6){
  206. uni.showToast({
  207. icon:'none',
  208. title:'密码长度不能小于6位',
  209. duration:1000
  210. })
  211. return false;
  212. }
  213. if(this.form.password!=this.form.password2){
  214. uni.showToast({
  215. icon:'none',
  216. title:'两次密码输入不一致',
  217. duration:1000
  218. })
  219. return false;
  220. }
  221. if(!(/^\w{1,18}$/.test(_this.form.password))){
  222. uni.showModal({
  223. content: '密码只能包括下划线、数字、字母,长度6-18位',
  224. });
  225. return;
  226. }
  227. http.setWait(false).post('user.php?act=findpwd2',{id:this.userid,pwd:this.form.password}).then(res=>{
  228. var data=res.data;
  229. if(res.code==200){
  230. uni.showToast({
  231. icon:'none',
  232. title:'密码重置成功',
  233. duration:1000
  234. })
  235. setTimeout(function(){
  236. uni.reLaunch({
  237. url: '../login/index'
  238. })
  239. },800)
  240. }else{
  241. }
  242. })
  243. }
  244. }
  245. }
  246. }
  247. </script>
  248. <style>
  249. @import '../../static/css/uni.css';
  250. .landing {
  251. height: 84upx;
  252. line-height: 84upx;
  253. color: #FFFFFF;
  254. font-size: 32upx;
  255. bordor: none;
  256. border-radius: 10upx;
  257. }
  258. .landing_true {
  259. }
  260. .landing_false {
  261. background-color: #d8d8d8;
  262. }
  263. .uni-button[type=primary] {
  264. }
  265. .placeholdertext{
  266. /* #ifdef H5 */
  267. width: 48upx;
  268. /* #endif */
  269. /*#ifdef APP-PLUS */
  270. width: 10upx;
  271. /* #endif */
  272. height:24upx;
  273. }
  274. .captch {
  275. /* #ifdef H5 */
  276. width: 180upx;
  277. /* #endif */
  278. /* #ifdef APP-PLUS */
  279. width: 165upx;
  280. /* #endif */
  281. }
  282. .login-btn{
  283. padding: 10upx 20upx;
  284. margin-top: 40upx;
  285. text-align: center;
  286. }
  287. .login-btn button{
  288. border-radius: 25px;
  289. background: -webkit-linear-gradient(left top, #3388ff , #2319dc);
  290. background: -o-linear-gradient(bottom right, #3388ff, #2319dc);
  291. background: -moz-linear-gradient(bottom right, #3388ff, #2319dc);
  292. background: linear-gradient(to bottom right, #3388ff , #2319dc);
  293. }
  294. .uni-input{float: left;}
  295. .captchtext{font-size: 28upx; padding: 5upx 8upx;}
  296. .login-input input{
  297. background: #F2F5F6;
  298. font-size: 28upx;
  299. padding: 10upx 25upx;
  300. height: 62upx;
  301. line-height: 62upx;
  302. border-radius: 8upx;
  303. }
  304. .login-margin-b{
  305. margin-bottom: 25upx;
  306. }
  307. .pass .email {
  308. /* #ifdef H5 */
  309. width: 320upx;
  310. /* #endif */
  311. /* #ifdef APP-PLUS */
  312. width: 420upx;
  313. /* #endif */
  314. }
  315. .login-input{
  316. padding: 20upx 20upx;
  317. }
  318. .locked {font-size: 100upx;
  319. font-weight: 1000;
  320. color:#ffffff;
  321. }
  322. .locked-head{
  323. background: #dcdcdc;
  324. text-align: center;
  325. border-radius: 50%;
  326. width:100px;
  327. height:100px;line-height: 100px;;
  328. margin: auto;
  329. margin-top: 30px;
  330. }
  331. .login-card{
  332. background: #fff;
  333. border-radius: 12upx;
  334. padding: 10upx 25upx;
  335. /* box-shadow: 0 6upx 18upx rgba(0,0,0,0.12); */
  336. position: relative;
  337. margin-top: 70upx;
  338. }
  339. .login-bg {
  340. /* height: 260upx;
  341. padding: 25upx;
  342. background: linear-gradient(#FF978D, #FFBB69); */
  343. }
  344. page {
  345. background-color: #FFFFFF;
  346. }
  347. </style>