password.vue 13 KB

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