password.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. <template>
  2. <view class="container login">
  3. <view class="login-main">
  4. <!-- <view class="line"></view> -->
  5. <view class="nav-item"
  6. :class="{ current: tabCurrentIndex === 1 }"
  7. @click="tabClick(1)">
  8. 使用手机修改
  9. </view>
  10. <view class="nav-item"
  11. :class="{ current: tabCurrentIndex === 2 }"
  12. @click="tabClick(2)">
  13. 使用邮箱修改
  14. </view>
  15. </view>
  16. <!-- 手机修改 -->
  17. <view class="content" v-if="tabCurrentIndex === 1">
  18. <view class="login-form clearfix">
  19. <view class="login-input">
  20. <input type="number" v-model="phoneParams.mobileOrEmail" maxlength="11" class="input" placeholder="请输入手机号" placeholder-class="placeholder"/>
  21. </view>
  22. </view>
  23. <view class="login-form clearfix">
  24. <view class="login-input code">
  25. <input type="text" v-model="imageCode" maxlength="4" class="input" placeholder="请输入右侧图形验证码" placeholder-class="placeholder"/>
  26. </view>
  27. <view class="login-input img-btn">
  28. <view class="vscodeimg">
  29. <image :src="imageCodeUrl" mode=""></image>
  30. </view>
  31. <view class="vscod-refresh" @click.stop="getVerificationCode">
  32. <text class="iconfont icon-shuaxin"></text>
  33. <text class="ref-text">刷新</text>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="login-form clearfix">
  38. <view class="login-input code">
  39. <input type="number" v-model="phoneParams.smsCode" maxlength="6" class="input" placeholder="请输入短信验证码" placeholder-class="placeholder"/>
  40. </view>
  41. <view class="login-input btn" :class="[isMobileDisabled ? 'disabled' : '']" >
  42. <button type="button"
  43. @click.stop="getMobileCodeFn"
  44. :disabled="isMobileDisabled"
  45. class="input" >
  46. {{ mobileCodeText }}
  47. </button>
  48. </view>
  49. </view>
  50. <view class="login-form clearfix">
  51. <view class="login-input pwd">
  52. <input v-show="isShowEye" type="text" v-model="phoneParams.password" maxlength="16" class="input" placeholder="请输入新密码,必须为8-16位字母数字的组合" autocomplete="new-password" placeholder-class="placeholder"/>
  53. <input v-show="!isShowEye" type="password" v-model="phoneParams.password" :password="true" maxlength="16" class="input" placeholder="请输入新密码,必须为8-16位字母数字的组合" autocomplete="new-password" placeholder-class="placeholder"/>
  54. <view class="iconfont" :class="isShowEye ? 'icon-kejian1' : 'icon-bukejian'" @click="passwordEye"></view>
  55. </view>
  56. </view>
  57. <view class="login-form clearfix">
  58. <view class="login-input pwd">
  59. <input v-show="isShowEyes" type="text" v-model="phoneParams.passwordConfirm" maxlength="16" class="input" placeholder="请确认密码" autocomplete="new-password" placeholder-class="placeholder"/>
  60. <input v-show="!isShowEyes" type="password" v-model="phoneParams.passwordConfirm" :password="true" maxlength="16" class="input" placeholder="请确认密码" autocomplete="new-password" placeholder-class="placeholder"/>
  61. <view class="iconfont" :class="isShowEyes ? 'icon-kejian1' : 'icon-bukejian'" @click="passwordEyes"></view>
  62. </view>
  63. </view>
  64. <view class="login-form clearfix" style="border: 0;">
  65. <view class="login-btn" @click="confirmMobilePassword">修改密码</view>
  66. </view>
  67. </view>
  68. <!-- 邮箱修改 -->
  69. <view class="content" v-else>
  70. <view class="login-form clearfix">
  71. <view class="login-input">
  72. <input class="input" type="text" v-model="emailParams.mobileOrEmail" maxlength="30" placeholder="请输入邮箱地址" placeholder-class="placeholder"/>
  73. </view>
  74. </view>
  75. <view class="login-form clearfix">
  76. <view class="login-input code">
  77. <input class="input" type="number" v-model="emailParams.smsCode" maxlength="6" placeholder="请输入邮箱验证码" placeholder-class="placeholder"/>
  78. </view>
  79. <view class="login-input btn" :class="[isEmialDisabled ? 'disabled' : '']">
  80. <button class="input"
  81. type="button"
  82. @click.stop="getEmailCodeFn"
  83. :disabled="isEmialDisabled">
  84. {{ emailCodeText }}
  85. </button>
  86. </view>
  87. </view>
  88. <view class="login-form clearfix">
  89. <view class="login-input pwd">
  90. <input v-show="isShowEye" type="text" v-model="emailParams.password" maxlength="16" class="input" placeholder="请输入新密码,必须为8-16位字母数字的组合" autocomplete="new-password" placeholder-class="placeholder"/>
  91. <input v-show="!isShowEye" type="password" v-model="emailParams.password" :password="true" maxlength="16" class="input" placeholder="请输入新密码,必须为8-16位字母数字的组合" autocomplete="new-password" placeholder-class="placeholder"/>
  92. <view class="iconfont" :class="isShowEye ? 'icon-kejian1' : 'icon-bukejian'" @click="passwordEye"></view>
  93. </view>
  94. </view>
  95. <view class="login-form clearfix">
  96. <view class="login-input pwd">
  97. <input v-show="isShowEyes" type="text" v-model="emailParams.passwordConfirm" maxlength="16" class="input" placeholder="请确认密码" autocomplete="new-password" placeholder-class="placeholder"/>
  98. <input v-show="!isShowEyes" type="password" v-model="emailParams.passwordConfirm" :password="true" maxlength="16" class="input" placeholder="请确认密码" autocomplete="new-password" placeholder-class="placeholder"/>
  99. <view class="iconfont" :class="isShowEyes ? 'icon-kejian1' : 'icon-bukejian'" @click="passwordEyes"></view>
  100. </view>
  101. </view>
  102. <view class="login-form clearfix" style="border: 0;">
  103. <view class="login-btn" @click="confirmEmailPassword">修改密码</view>
  104. </view>
  105. </view>
  106. </view>
  107. </template>
  108. <script>
  109. import authorize from '@/common/config/authorize.js'
  110. export default{
  111. data() {
  112. return{
  113. tabCurrentIndex: 1,
  114. isShowEye:false, //控显
  115. isShowEyes:false, //控显
  116. iconEyes:'icon-yanjing_yincang_o',
  117. iconEyen:'icon-yanjing_xianshi_o',
  118. isEmialDisabled:false,//获取邮箱验证码按钮
  119. isMobileDisabled:false,//获取手机短信按钮
  120. imageCode:'', //图形验证码
  121. imageCodeUrl:'', //图形验证码地址
  122. imageCodetoken:'', //图形校验token
  123. count: '', //倒计时
  124. emailCodeText: '获取验证码',
  125. mobileCodeText: '获取验证码',
  126. codeTime: null,
  127. phoneParams: {
  128. mobileOrEmail :'',
  129. smsCode : '',
  130. password : '',
  131. passwordConfirm : '',
  132. status:1
  133. },
  134. emailParams: {
  135. mobileOrEmail :'',
  136. smsCode : '',
  137. password : '',
  138. passwordConfirm : '',
  139. status:2
  140. },
  141. }
  142. },
  143. onLoad(option) {
  144. this.getVerificationCode()
  145. },
  146. methods:{
  147. confirmMobilePassword(){//手机号修改
  148. if( this.phoneParams.mobileOrEmail == ''){
  149. this.$util.msg('请输入手机号',2000);
  150. return
  151. }
  152. if(!this.$reg.isMobile(this.phoneParams.mobileOrEmail)){
  153. this.$util.msg('手机格式不正确',2000);
  154. return
  155. }
  156. if( this.phoneParams.smsCode == ''){
  157. this.$util.msg('请输入手机验证码',2000);
  158. return
  159. }
  160. if(!this.$reg.isMobileCode(this.phoneParams.smsCode)){
  161. this.$util.msg('验证码格式不正确',2000);
  162. return
  163. }
  164. if( this.phoneParams.password == ''){
  165. this.$util.msg('请输入密码',2000);
  166. return
  167. }
  168. if(!this.$reg.checkPwd(this.phoneParams.password)){
  169. this.$util.msg('密码必须为8-16位字母数字的组合',2000);
  170. return
  171. }
  172. if( this.phoneParams.passwordConfirm == ''){
  173. this.$util.msg('请再次确认密码',2000);
  174. return
  175. }
  176. if( this.phoneParams.passwordConfirm !== this.phoneParams.password){
  177. this.$util.msg('两次输入的密码不一致',2000);
  178. return
  179. }
  180. this.UserService.ModifyMobilePassword(this.phoneParams).then(res =>{
  181. this.$util.msg(res.msg,2000,true,'success')
  182. setTimeout(()=>{
  183. uni.navigateBack({
  184. delta: 1
  185. });
  186. },2000)
  187. }).catch( error =>{
  188. this.$util.msg(error.msg,2000);
  189. })
  190. },
  191. confirmEmailPassword(){//邮箱修改密码
  192. if( this.emailParams.mobileOrEmail == ''){
  193. this.$util.msg('请输入邮箱',2000);
  194. return
  195. }
  196. if(!this.$reg.isEmail(this.emailParams.mobileOrEmail)){
  197. this.$util.msg('请输入正确的邮箱地址',2000);
  198. return
  199. }
  200. if( this.emailParams.smsCode == ''){
  201. this.$util.msg('请输入邮箱验证码',2000);
  202. return
  203. }
  204. if(!this.$reg.isMobileCode(this.emailParams.smsCode)){
  205. this.$util.msg('验证码格式不正确',2000);
  206. return
  207. }
  208. if( this.emailParams.password == ''){
  209. this.$util.msg('请输入密码',2000);
  210. return
  211. }
  212. if(!this.$reg.checkPwd(this.emailParams.password)){
  213. this.$util.msg('密码必须为8-16位字母数字的组合',2000);
  214. return
  215. }
  216. if( this.emailParams.passwordConfirm == ''){
  217. this.$util.msg('请再次确认密码',2000);
  218. return
  219. }
  220. if( this.emailParams.passwordConfirm !== this.emailParams.password){
  221. this.$util.msg('两次输入的密码不一致',2000);
  222. return
  223. }
  224. this.UserService.ModifyMobilePassword(this.emailParams).then(res =>{
  225. this.$util.msg(res.msg,2000,true,'success')
  226. setTimeout(()=>{
  227. uni.navigateBack({
  228. delta: 1
  229. });
  230. },2000)
  231. }).catch( error =>{
  232. this.$util.msg(error.msg,2000);
  233. })
  234. },
  235. getVerificationCode(){//图形验证
  236. this.PublicService.GetImgVerifyCode().then(res => {
  237. this.imageCodeUrl = res.data.baseImage
  238. this.imageCodetoken = res.data.token
  239. })
  240. },
  241. getEmailCodeFn(){//获取邮箱验证码
  242. if( this.emailParams.mobileOrEmail == ''){
  243. this.$util.msg('请输入邮箱地址',2000);
  244. return
  245. }
  246. if(!this.$reg.isEmail(this.emailParams.mobileOrEmail)){
  247. this.$util.msg('请输入正确的邮箱地址',2000);
  248. return
  249. }
  250. this.isEmialDisabled = true;
  251. this.PublicService.GetUserEmailCode({email:this.emailParams.mobileOrEmail,status:3}).then(res =>{
  252. this.$util.msg('邮箱验证码已发送',2000);
  253. const TIME_COUNT = 60;
  254. if (!this.codeTime) {
  255. this.count = TIME_COUNT;
  256. this.isEmialDisabled = true;
  257. this.codeTime = setInterval(() => {
  258. if (this.count > 1 && this.count <= TIME_COUNT) {
  259. this.count--
  260. this.emailCodeText = this.count +'s重新发送'
  261. } else {
  262. this.isEmialDisabled = false;
  263. clearInterval(this.codeTime)
  264. this.codeTime = null
  265. this.emailCodeText = '获取验证码'
  266. }
  267. },1000)
  268. }
  269. }).catch( error =>{
  270. this.$util.msg(error.msg,2000);
  271. this.isEmialDisabled = false;
  272. })
  273. },
  274. getMobileCodeFn(){//获取手机验证码
  275. if( this.phoneParams.mobileOrEmail == ''){
  276. this.$util.msg('请输入手机号',2000);
  277. return
  278. }
  279. if(!this.$reg.isMobile(this.phoneParams.mobileOrEmail)){
  280. this.$util.msg('请输入正确的手机号',2000);
  281. return
  282. }
  283. if( this.imageCode == ''){
  284. this.$util.msg('请输入图形验证码',2000);
  285. return
  286. }
  287. let params = {
  288. mobile:this.phoneParams.mobileOrEmail,
  289. activateCodeType:1,
  290. platformType:2,
  291. imgCode:this.imageCode,
  292. token:this.imageCodetoken,
  293. }
  294. this.isMobileDisabled = true;
  295. this.PublicService.GetRegisterMobileCode(params).then(res =>{
  296. this.$util.msg('验证短信已发送',2000);
  297. const TIME_COUNT = 60;
  298. if (!this.codeTime) {
  299. this.count = TIME_COUNT;
  300. this.isMobileDisabled = true;
  301. this.codeTime = setInterval(() => {
  302. if (this.count > 1 && this.count <= TIME_COUNT) {
  303. this.count--
  304. this.mobileCodeText = this.count +'s重新发送'
  305. } else {
  306. this.isMobileDisabled = false;
  307. clearInterval(this.codeTime)
  308. this.codeTime = null
  309. this.mobileCodeText = '获取验证码'
  310. }
  311. },1000)
  312. }
  313. }).catch( error =>{
  314. this.$util.msg(error.msg,2000);
  315. this.isMobileDisabled = false;
  316. })
  317. },
  318. tabClick(index) {//tab切换
  319. this.tabCurrentIndex = index;
  320. this.password = ''
  321. this.passwordCheck = ''
  322. if(this.tabCurrentIndex == 1){
  323. this.getVerificationCode()
  324. }
  325. },
  326. passwordEye() {//密码显隐操作
  327. this.isShowEye = !this.isShowEye;
  328. },
  329. passwordEyes() {//密码显隐操作
  330. this.isShowEyes = !this.isShowEyes;
  331. }
  332. }
  333. }
  334. </script>
  335. <style lang="scss">
  336. .login{
  337. width: 100%;
  338. height: auto;
  339. .login-main{
  340. width: 100%;
  341. display: flex;
  342. height: 80rpx;
  343. border-top: 1px solid #F7F7F7;
  344. margin-bottom: 80rpx;
  345. position: relative;
  346. .nav-item{
  347. display: flex;
  348. flex: 1;
  349. flex-direction: column;
  350. align-items: center;
  351. line-height: 80rpx;
  352. color: #666666;
  353. font-size: $font-size-28;
  354. background: #F7F7F7;
  355. &.current{
  356. color:$color-system;
  357. background: #FFFFFF;
  358. }
  359. }
  360. }
  361. .login-form{
  362. width: 702rpx;
  363. height: auto;
  364. margin: auto;
  365. border-bottom: 2rpx solid #e1e1e1;
  366. .login-input{
  367. width: 100%;
  368. height: 64rpx;
  369. padding: 24rpx 0;
  370. display: flex;
  371. flex-direction: column;
  372. align-items: center;
  373. position: relative;
  374. &.pwd{
  375. .iconfont{
  376. position: absolute;
  377. right: 0;
  378. top: 0;
  379. font-size: 44rpx;
  380. color: #999999;
  381. z-index: 99;
  382. width: 96rpx;
  383. height: 96rpx;
  384. line-height: 96rpx;
  385. text-align: center;
  386. }
  387. }
  388. &.code{
  389. width: 310rpx;
  390. float: left;
  391. margin-right: 20rpx;
  392. }
  393. &.btn{
  394. width: 220rpx;
  395. height: 64rpx;
  396. float: right;
  397. background: $btn-confirm;
  398. padding: 0;
  399. border-radius: 44rpx;
  400. margin-top: 20rpx;
  401. .input{
  402. width: 220rpx;
  403. height: 64rpx;
  404. line-height: 64rpx;
  405. padding: 0;
  406. color: #FFFFFF;
  407. background: $btn-confirm;
  408. text-align: center;
  409. border-radius: 44rpx;
  410. &.none{
  411. background: #F7F7F7;
  412. }
  413. }
  414. &.disabled{
  415. background: #F7F7F7;
  416. .input{
  417. background: #F7F7F7;
  418. color: #999999;
  419. }
  420. }
  421. }
  422. &.img-btn{
  423. width: 290rpx;
  424. height: 64rpx;
  425. padding: 0;
  426. float: right;
  427. background: #FFFFFF;
  428. display: block;
  429. margin-top: 10rpx;
  430. .vscodeimg{
  431. width: 160rpx;
  432. height: 64rpx;
  433. float: left;
  434. display: flex;
  435. flex-direction: column;
  436. align-items: center;
  437. border-radius: 6rpx;
  438. margin-top: 10rpx;
  439. image{
  440. width: 180rpx;
  441. height: 88rpx;
  442. border-radius: 6rpx;
  443. }
  444. }
  445. .vscod-refresh{
  446. width: 100rpx;
  447. float: right;
  448. margin-top: 25rpx;
  449. .icon-shuaxin{
  450. font-size: 36rpx;
  451. color: #999999;
  452. float: left
  453. }
  454. .ref-text{
  455. font-size: 24rpx;
  456. color: #333333;
  457. float: right;
  458. }
  459. }
  460. }
  461. .input{
  462. width: 100%;
  463. height: 100%;
  464. font-size: $font-size-28;
  465. line-height: 40rpx;
  466. color: #333333;
  467. border-radius: 14rpx;
  468. }
  469. }
  470. }
  471. .login-btn{
  472. width: 600rpx;
  473. height: 88rpx;
  474. border-radius: 44rpx;
  475. font-size: $font-size-28;
  476. line-height: 88rpx;
  477. color: #FFFFFF;
  478. margin: 0 auto;
  479. text-align: center;
  480. background: $btn-confirm;
  481. margin-top: 100rpx;
  482. }
  483. .model-authorization{
  484. width: 100%;
  485. height: 100%;
  486. position: fixed;
  487. top: 0;
  488. left: 0;
  489. z-index: 999;
  490. .authorization{
  491. width: 518rpx;
  492. height: 320rpx;
  493. position: absolute;
  494. background: rgba(255,255,255,.7);
  495. left: 0;
  496. right: 0;
  497. bottom: 0;
  498. top: 0;
  499. margin: auto;
  500. .to-btn{
  501. position: absolute;
  502. top: 0;
  503. left: 0;
  504. right: 0;
  505. bottom: 0;
  506. margin: auto;
  507. width: 70%;
  508. height: 88rpx;
  509. font-size: $font-size-28;
  510. line-height: 88rpx;
  511. color: #FFFFFF;
  512. text-align: center;
  513. border-radius: 44rpx;
  514. }
  515. }
  516. }
  517. }
  518. .placeholder{
  519. color: #b2b2b2;
  520. }
  521. </style>