password.vue 14 KB

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