password.vue 13 KB

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