password.vue 13 KB

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