password.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  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="6" 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. })
  155. },
  156. confirmEmailPassword(){//邮箱修改密码
  157. let params = {
  158. mobileOrEmail : this.email,
  159. activateCode : this.emailCode,
  160. passWord : this.password,
  161. confirmPwd : this.passwordCheck,
  162. status:2
  163. }
  164. emailPassword(params).then(res =>{
  165. this.$util.msg(res.msg,2000);
  166. }).catch( res =>{
  167. this.$util.msg(res.msg,2000);
  168. })
  169. },
  170. getVerificationCode(){//图形验证
  171. getImageCode().then(res => {
  172. this.imageCodeUrl = res.data.baseImage
  173. this.imageCodetoken = res.data.token
  174. })
  175. },
  176. getEmailCodeFn(){//获取邮箱验证码
  177. this.isEmialDisabled = true;
  178. getEmailCode({email:this.email,status:3}).then(res =>{
  179. this.$util.msg('验证邮件已发送至邮箱,请登录邮箱查收',2000);
  180. const TIME_COUNT = 60;
  181.       if (!this.codeTime) {
  182.         this.count = TIME_COUNT;
  183.         this.isEmialDisabled = true;
  184.         this.codeTime = setInterval(() => {
  185.         if (this.count > 1 && this.count <= TIME_COUNT) {
  186.           this.count--
  187.           this.emailCodeText = this.count +'s重新发送'
  188.          } else {
  189.           this.isEmialDisabled = false;
  190.           clearInterval(this.codeTime)
  191.           this.codeTime = null
  192. this.emailCodeText = '获取验证码'
  193.          }
  194.         },1000)
  195.        }
  196. }).catch( res =>{
  197. this.$util.msg(res.msg,2000);
  198. this.isEmialDisabled = false;
  199. })
  200. },
  201. getMobileCodeFn(){//获取手机验证码
  202. if( this.mobile == ''){
  203. this.$util.msg('请输入手机号',2000);
  204. return
  205. }
  206. if(!this.$reg.isMobile(this.mobile)){
  207. this.$util.msg('请输入正确的手机号',2000);
  208. return
  209. }
  210. if( this.imageCode == ''){
  211. this.$util.msg('请输入图形验证码',2000);
  212. return
  213. }
  214. let params = {
  215. mobile:this.mobile,
  216. activateCodeType:1,
  217. platformType:2,
  218. imgCode:this.imageCode,
  219. token:this.imageCodetoken,
  220. }
  221. this.isMobileDisabled = true;
  222. getMobileCode(params).then(res =>{
  223. this.$util.msg('验证短信已发送',2000);
  224. const TIME_COUNT = 60;
  225.       if (!this.codeTime) {
  226.         this.count = TIME_COUNT;
  227.         this.isMobileDisabled = true;
  228.         this.codeTime = setInterval(() => {
  229.         if (this.count > 1 && this.count <= TIME_COUNT) {
  230.           this.count--
  231.           this.mobileCodeText = this.count +'s重新发送'
  232.          } else {
  233.           this.isMobileDisabled = false;
  234.           clearInterval(this.codeTime)
  235.           this.codeTime = null
  236. this.mobileCodeText = '获取验证码'
  237.          }
  238.         },1000)
  239.        }
  240. }).catch( res =>{
  241. this.$util.msg(res.msg,2000);
  242. this.isMobileDisabled = false;
  243. })
  244. },
  245. tabClick(index) {//tab切换
  246. this.tabCurrentIndex = index;
  247. this.password = ''
  248. this.passwordCheck = ''
  249. if(this.tabCurrentIndex == 1){
  250. this.getVerificationCode()
  251. }
  252. },
  253. passwordEye() {//密码显隐操作
  254. this.isShowEye = !this.isShowEye;
  255. },
  256. passwordEyes() {//密码显隐操作
  257. this.isShowEyes = !this.isShowEyes;
  258. }
  259. }
  260. }
  261. </script>
  262. <style lang="scss">
  263. .login{
  264. width: 100%;
  265. height: auto;
  266. .login-main{
  267. width: 100%;
  268. display: flex;
  269. height: 80rpx;
  270. border-top: 1px solid #F7F7F7;
  271. margin-bottom: 112rpx;
  272. position: relative;
  273. .line{
  274. position: absolute;
  275. top: 0;
  276. left: 50%;
  277. margin-left: -80rpx;
  278. width: 0;
  279. height: 0;
  280. border-left: 80rpx solid transparent;
  281. border-right: 80rpx solid transparent;
  282. border-bottom: 160rpx solid #FFFFFF;
  283. }
  284. .nav-item{
  285. display: flex;
  286. flex: 1;
  287. flex-direction: column;
  288. align-items: center;
  289. line-height: 80rpx;
  290. color: $text-color;
  291. font-size: $font-size-28;
  292. background: #F7F7F7;
  293. &.current{
  294. color:$color-system;
  295. background: #FFFFFF;
  296. }
  297. }
  298. }
  299. .login-form{
  300. width: 702rpx;
  301. height: auto;
  302. padding: 0 24rpx;
  303. .login-input{
  304. width: 654rpx;
  305. height: 40rpx;
  306. padding: 24rpx;
  307. margin-bottom: 20rpx;
  308. background: #F7F7F7;
  309. border-radius: 14rpx;
  310. display: flex;
  311. flex-direction: column;
  312. align-items: center;
  313. position: relative;
  314. &.pwd{
  315. .iconfont{
  316. position: absolute;
  317. right: 0;
  318. top: 0;
  319. font-size: 46rpx;
  320. color: $color-system;
  321. font-weight: bold;
  322. z-index: 99;
  323. width: 96rpx;
  324. height: 96rpx;
  325. line-height: 96rpx;
  326. text-align: center;
  327. }
  328. }
  329. &.code{
  330. width: 370rpx;
  331. float: left;
  332. margin-right: 20rpx;
  333. }
  334. &.btn{
  335. width: 263rpx;
  336. height: 88rpx;
  337. float: left;
  338. background: $btn-confirm;
  339. padding: 0;
  340. .input{
  341. width: 263rpx;
  342. height: 88rpx;
  343. line-height: 88rpx;
  344. padding: 0;
  345. color: #FFFFFF;
  346. background: $btn-confirm;
  347. text-align: center;
  348. border-radius: 14rpx;
  349. &.none{
  350. background: #F7F7F7;
  351. }
  352. }
  353. &.disabled{
  354. background: #F7F7F7;
  355. .input{
  356. background: #F7F7F7;
  357. color: #999999;
  358. }
  359. }
  360. }
  361. &.img-btn{
  362. width: 250rpx;
  363. height: 88rpx;
  364. padding: 0;
  365. float: left;
  366. background: #FFFFFF;
  367. display: block;
  368. .vscodeimg{
  369. width: 180rpx;
  370. height: 88rpx;
  371. float: left;
  372. display: flex;
  373. flex-direction: column;
  374. align-items: center;
  375. border-radius: 14rpx;
  376. image{
  377. width: 180rpx;
  378. height: 88rpx;
  379. border-radius: 14rpx;
  380. }
  381. }
  382. .vscod-refresh{
  383. width: 70rpx;
  384. float: right;
  385. display: flex;
  386. flex-direction: column;
  387. align-items: center;
  388. .icon-shuaxin{
  389. font-size: 48rpx;
  390. color: #333333;
  391. }
  392. .ref-text{
  393. font-size: 24rpx;
  394. color: #333333;
  395. }
  396. }
  397. }
  398. .input{
  399. width: 100%;
  400. height: 100%;
  401. background: #F7F7F7;
  402. font-size: $font-size-28;
  403. line-height: 40rpx;
  404. color: #333333;
  405. border-radius: 14rpx;
  406. }
  407. }
  408. }
  409. .login-btn{
  410. width: 702rpx;
  411. height: 88rpx;
  412. border-radius: 14rpx;
  413. font-size: $font-size-28;
  414. line-height: 88rpx;
  415. color: #FFFFFF;
  416. margin: 0 auto;
  417. text-align: center;
  418. background: $btn-confirm;
  419. margin-top: 100rpx;
  420. }
  421. .model-authorization{
  422. width: 100%;
  423. height: 100%;
  424. position: fixed;
  425. top: 0;
  426. left: 0;
  427. z-index: 999;
  428. .authorization{
  429. width: 518rpx;
  430. height: 320rpx;
  431. position: absolute;
  432. background: rgba(255,255,255,.7);
  433. left: 0;
  434. right: 0;
  435. bottom: 0;
  436. top: 0;
  437. margin: auto;
  438. .to-btn{
  439. position: absolute;
  440. top: 0;
  441. left: 0;
  442. right: 0;
  443. bottom: 0;
  444. margin: auto;
  445. width: 70%;
  446. height: 88rpx;
  447. font-size: $font-size-28;
  448. line-height: 88rpx;
  449. color: #FFFFFF;
  450. text-align: center;
  451. border-radius: 44rpx;
  452. }
  453. }
  454. }
  455. }
  456. </style>