password.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  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="mobile" maxlength="11" class="input" 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="请输入右侧图形验证码" />
  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="mobileCode" maxlength="4" class="input" 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="password" maxlength="18" class="input" placeholder="请输入新密码,必须为8-16位字母数字的组合" autocomplete="new-password"/>
  53. <input v-show="!isShowEye" type="password" v-model="password" :password="true" maxlength="18" class="input" placeholder="请输入新密码,必须为8-16位字母数字的组合" autocomplete="new-password"/>
  54. <view class="iconfont" :class="isShowEye ? iconEyen : iconEyes" @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="passwordCheck" maxlength="18" class="input" placeholder="请确认密码" autocomplete="new-password"/>
  60. <input v-show="!isShowEyes" type="password" v-model="passwordCheck" :password="true" maxlength="18" class="input" placeholder="请确认密码" autocomplete="new-password"/>
  61. <view class="iconfont" :class="isShowEyes ? iconEyen : iconEyes" @click="passwordEyes"></view>
  62. </view>
  63. </view>
  64. <view class="login-form clearfix">
  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="email" maxlength="30" 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="emailCode" maxlength="6" 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="password" maxlength="18" class="input" placeholder="请输入新密码,必须为8-16位字母数字的组合" autocomplete="new-password"/>
  91. <input v-show="!isShowEye" type="password" v-model="password" :password="true" maxlength="18" class="input" placeholder="请输入新密码,必须为8-16位字母数字的组合" autocomplete="new-password"/>
  92. <view class="iconfont" :class="isShowEye ? iconEyen : iconEyes" @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="passwordCheck" maxlength="18" class="input" placeholder="请确认密码" autocomplete="new-password"/>
  98. <input v-show="!isShowEyes" type="password" v-model="passwordCheck" :password="true" maxlength="18" class="input" placeholder="请确认密码" autocomplete="new-password"/>
  99. <view class="iconfont" :class="isShowEyes ? iconEyen : iconEyes" @click="passwordEyes"></view>
  100. </view>
  101. </view>
  102. <view class="login-form clearfix">
  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. import { mobilePassword , emailPassword } from "@/api/use.js"
  111. import { getImageCode, getEmailCode, getMobileCode } from "@/api/utils.js"
  112. export default{
  113. data() {
  114. return{
  115. tabCurrentIndex: 1,
  116. mobile:'', //用户手机号
  117. email:'', //邮箱地址
  118. emailCode:'', //油箱验证码
  119. mobileCode:'', //手机验证码
  120. password:'', //新密码
  121. passwordCheck:'', //二次校验新密码
  122. isShowEye:false, //控显
  123. isShowEyes:false, //控显
  124. iconEyes:'icon-yanjing_yincang_o',
  125. iconEyen:'icon-yanjing_xianshi_o',
  126. isEmialDisabled:false,//获取邮箱验证码按钮
  127. isMobileDisabled:false,//获取手机短信按钮
  128. imageCode:'', //图形验证码
  129. imageCodeUrl:'', //图形验证码地址
  130. imageCodetoken:'', //图形校验token
  131. count: '', //倒计时
  132. emailCodeText: '获取验证码',
  133. mobileCodeText: '获取验证码',
  134. codeTime: null,
  135. }
  136. },
  137. onLoad(option) {
  138. console.log(option)
  139. this.getVerificationCode()
  140. },
  141. methods:{
  142. confirmMobilePassword(){//手机号修改
  143. let params = {
  144. mobileOrEmail : this.mobile,
  145. activateCode : this.mobileCode,
  146. passWord : this.password,
  147. confirmPwd : this.passwordCheck,
  148. status:1
  149. }
  150. mobilePassword(params).then(res =>{
  151. this.$util.msg(res.msg,2000);
  152. }).catch( res =>{
  153. this.$util.msg(res.msg,2000);
  154. this.getVerificationCode()
  155. })
  156. },
  157. confirmEmailPassword(){//邮箱修改密码
  158. let params = {
  159. mobileOrEmail : this.email,
  160. activateCode : this.emailCode,
  161. passWord : this.password,
  162. confirmPwd : this.passwordCheck,
  163. status:2
  164. }
  165. emailPassword(params).then(res =>{
  166. this.$util.msg(res.msg,2000);
  167. }).catch( res =>{
  168. this.$util.msg(res.msg,2000);
  169. })
  170. },
  171. getVerificationCode(){//图形验证
  172. getImageCode().then(res => {
  173. this.imageCodeUrl = res.data.baseImage
  174. this.imageCodetoken = res.data.token
  175. })
  176. },
  177. getEmailCodeFn(){//获取邮箱验证码
  178. if( this.email == ''){
  179. this.$util.msg('请输入邮箱地址',2000);
  180. return
  181. }
  182. if(!this.$reg.isEmail(this.email)){
  183. this.$util.msg('请输入正确的邮箱地址',2000);
  184. return
  185. }
  186. this.isEmialDisabled = true;
  187. getEmailCode({email:this.email,status:3}).then(res =>{
  188. this.$util.msg('验证邮件已发送至邮箱,请登录邮箱查收',2000);
  189. const TIME_COUNT = 60;
  190.       if (!this.codeTime) {
  191.         this.count = TIME_COUNT;
  192.         this.isEmialDisabled = true;
  193.         this.codeTime = setInterval(() => {
  194.         if (this.count > 1 && this.count <= TIME_COUNT) {
  195.           this.count--
  196.           this.emailCodeText = this.count +'s重新发送'
  197.          } else {
  198.           this.isEmialDisabled = false;
  199.           clearInterval(this.codeTime)
  200.           this.codeTime = null
  201. this.emailCodeText = '获取验证码'
  202.          }
  203.         },1000)
  204.        }
  205. }).catch( res =>{
  206. this.$util.msg(res.msg,2000);
  207. this.isEmialDisabled = false;
  208. })
  209. },
  210. getMobileCodeFn(){//获取手机验证码
  211. if( this.mobile == ''){
  212. this.$util.msg('请输入手机号',2000);
  213. return
  214. }
  215. if(!this.$reg.isMobile(this.mobile)){
  216. this.$util.msg('请输入正确的手机号',2000);
  217. return
  218. }
  219. if( this.imageCode == ''){
  220. this.$util.msg('请输入图形验证码',2000);
  221. return
  222. }
  223. let params = {
  224. mobile:this.mobile,
  225. activateCodeType:1,
  226. platformType:2,
  227. imgCode:this.imageCode,
  228. token:this.imageCodetoken,
  229. }
  230. this.isMobileDisabled = true;
  231. getMobileCode(params).then(res =>{
  232. this.$util.msg('验证短信已发送',2000);
  233. const TIME_COUNT = 60;
  234.       if (!this.codeTime) {
  235.         this.count = TIME_COUNT;
  236.         this.isMobileDisabled = true;
  237.         this.codeTime = setInterval(() => {
  238.         if (this.count > 1 && this.count <= TIME_COUNT) {
  239.           this.count--
  240.           this.mobileCodeText = this.count +'s重新发送'
  241.          } else {
  242.           this.isMobileDisabled = false;
  243.           clearInterval(this.codeTime)
  244.           this.codeTime = null
  245. this.mobileCodeText = '获取验证码'
  246.          }
  247.         },1000)
  248.        }
  249. }).catch( res =>{
  250. this.$util.msg(res.msg,2000);
  251. this.isMobileDisabled = false;
  252. this.getVerificationCode()
  253. })
  254. },
  255. tabClick(index) {//tab切换
  256. this.tabCurrentIndex = index;
  257. this.password = ''
  258. this.passwordCheck = ''
  259. if(this.tabCurrentIndex == 1){
  260. this.getVerificationCode()
  261. }
  262. },
  263. passwordEye() {//密码显隐操作
  264. this.isShowEye = !this.isShowEye;
  265. },
  266. passwordEyes() {//密码显隐操作
  267. this.isShowEyes = !this.isShowEyes;
  268. }
  269. }
  270. }
  271. </script>
  272. <style lang="scss">
  273. .login{
  274. width: 100%;
  275. height: auto;
  276. .login-main{
  277. width: 100%;
  278. display: flex;
  279. height: 80rpx;
  280. border-top: 1px solid #F7F7F7;
  281. margin-bottom: 112rpx;
  282. position: relative;
  283. .line{
  284. position: absolute;
  285. top: 0;
  286. left: 50%;
  287. margin-left: -80rpx;
  288. width: 0;
  289. height: 0;
  290. border-left: 80rpx solid transparent;
  291. border-right: 80rpx solid transparent;
  292. border-bottom: 160rpx solid #FFFFFF;
  293. }
  294. .nav-item{
  295. display: flex;
  296. flex: 1;
  297. flex-direction: column;
  298. align-items: center;
  299. line-height: 80rpx;
  300. color: $text-color;
  301. font-size: $font-size-28;
  302. background: #F7F7F7;
  303. &.current{
  304. color:$color-system;
  305. background: #FFFFFF;
  306. }
  307. }
  308. }
  309. .login-form{
  310. width: 702rpx;
  311. height: auto;
  312. padding: 0 24rpx;
  313. .login-input{
  314. width: 654rpx;
  315. height: 40rpx;
  316. padding: 24rpx;
  317. margin-bottom: 20rpx;
  318. background: #F7F7F7;
  319. border-radius: 14rpx;
  320. display: flex;
  321. flex-direction: column;
  322. align-items: center;
  323. position: relative;
  324. &.pwd{
  325. .iconfont{
  326. position: absolute;
  327. right: 0;
  328. top: 0;
  329. font-size: 44rpx;
  330. color: #999999;
  331. font-weight: bold;
  332. z-index: 99;
  333. width: 96rpx;
  334. height: 96rpx;
  335. line-height: 96rpx;
  336. text-align: center;
  337. }
  338. }
  339. &.code{
  340. width: 370rpx;
  341. float: left;
  342. margin-right: 20rpx;
  343. }
  344. &.btn{
  345. width: 263rpx;
  346. height: 88rpx;
  347. float: left;
  348. background: $btn-confirm;
  349. padding: 0;
  350. .input{
  351. width: 263rpx;
  352. height: 88rpx;
  353. line-height: 88rpx;
  354. padding: 0;
  355. color: #FFFFFF;
  356. background: $btn-confirm;
  357. text-align: center;
  358. border-radius: 14rpx;
  359. &.none{
  360. background: #F7F7F7;
  361. }
  362. }
  363. &.disabled{
  364. background: #F7F7F7;
  365. .input{
  366. background: #F7F7F7;
  367. color: #999999;
  368. }
  369. }
  370. }
  371. &.img-btn{
  372. width: 250rpx;
  373. height: 88rpx;
  374. padding: 0;
  375. float: left;
  376. background: #FFFFFF;
  377. display: block;
  378. .vscodeimg{
  379. width: 180rpx;
  380. height: 88rpx;
  381. float: left;
  382. display: flex;
  383. flex-direction: column;
  384. align-items: center;
  385. border-radius: 14rpx;
  386. image{
  387. width: 180rpx;
  388. height: 88rpx;
  389. border-radius: 14rpx;
  390. }
  391. }
  392. .vscod-refresh{
  393. width: 70rpx;
  394. float: right;
  395. display: flex;
  396. flex-direction: column;
  397. align-items: center;
  398. .icon-shuaxin{
  399. font-size: 48rpx;
  400. color: #333333;
  401. }
  402. .ref-text{
  403. font-size: 24rpx;
  404. color: #333333;
  405. }
  406. }
  407. }
  408. .input{
  409. width: 100%;
  410. height: 100%;
  411. background: #F7F7F7;
  412. font-size: $font-size-28;
  413. line-height: 40rpx;
  414. color: #333333;
  415. border-radius: 14rpx;
  416. }
  417. }
  418. }
  419. .login-btn{
  420. width: 702rpx;
  421. height: 88rpx;
  422. border-radius: 14rpx;
  423. font-size: $font-size-28;
  424. line-height: 88rpx;
  425. color: #FFFFFF;
  426. margin: 0 auto;
  427. text-align: center;
  428. background: $btn-confirm;
  429. margin-top: 100rpx;
  430. }
  431. .model-authorization{
  432. width: 100%;
  433. height: 100%;
  434. position: fixed;
  435. top: 0;
  436. left: 0;
  437. z-index: 999;
  438. .authorization{
  439. width: 518rpx;
  440. height: 320rpx;
  441. position: absolute;
  442. background: rgba(255,255,255,.7);
  443. left: 0;
  444. right: 0;
  445. bottom: 0;
  446. top: 0;
  447. margin: auto;
  448. .to-btn{
  449. position: absolute;
  450. top: 0;
  451. left: 0;
  452. right: 0;
  453. bottom: 0;
  454. margin: auto;
  455. width: 70%;
  456. height: 88rpx;
  457. font-size: $font-size-28;
  458. line-height: 88rpx;
  459. color: #FFFFFF;
  460. text-align: center;
  461. border-radius: 44rpx;
  462. }
  463. }
  464. }
  465. }
  466. </style>