password.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  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="请输入手机号" 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="mobileCode" 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="password" maxlength="16" class="input" placeholder="请输入新密码,必须为8-16位字母数字的组合" autocomplete="new-password" placeholder-class="placeholder"/>
  53. <input v-show="!isShowEye" type="password" v-model="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="passwordCheck" maxlength="16" class="input" placeholder="请确认密码" autocomplete="new-password" placeholder-class="placeholder"/>
  60. <input v-show="!isShowEyes" type="password" v-model="passwordCheck" :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="email" 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="emailCode" 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="password" maxlength="16" class="input" placeholder="请输入新密码,必须为8-16位字母数字的组合" autocomplete="new-password" placeholder-class="placeholder"/>
  91. <input v-show="!isShowEye" type="password" v-model="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="passwordCheck" maxlength="16" class="input" placeholder="请确认密码" autocomplete="new-password" placeholder-class="placeholder"/>
  98. <input v-show="!isShowEyes" type="password" v-model="passwordCheck" :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 "@/services/use.js"
  111. import { getEmailCode } from "@/services/public.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( error =>{
  157. this.$util.msg(error.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( error =>{
  176. this.$util.msg(error.msg,2000);
  177. })
  178. },
  179. getVerificationCode(){//图形验证
  180. this.PublicService.GetImgVerifyCode().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( error =>{
  214. this.$util.msg(error.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. this.PublicService.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( error =>{
  258. this.$util.msg(error.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: 80rpx;
  289. position: relative;
  290. .nav-item{
  291. display: flex;
  292. flex: 1;
  293. flex-direction: column;
  294. align-items: center;
  295. line-height: 80rpx;
  296. color: #666666;
  297. font-size: $font-size-28;
  298. background: #F7F7F7;
  299. &.current{
  300. color:$color-system;
  301. background: #FFFFFF;
  302. }
  303. }
  304. }
  305. .login-form{
  306. width: 702rpx;
  307. height: auto;
  308. margin: auto;
  309. border-bottom: 2rpx solid #e1e1e1;
  310. .login-input{
  311. width: 100%;
  312. height: 64rpx;
  313. padding: 24rpx 0;
  314. display: flex;
  315. flex-direction: column;
  316. align-items: center;
  317. position: relative;
  318. &.pwd{
  319. .iconfont{
  320. position: absolute;
  321. right: 0;
  322. top: 0;
  323. font-size: 44rpx;
  324. color: #999999;
  325. z-index: 99;
  326. width: 96rpx;
  327. height: 96rpx;
  328. line-height: 96rpx;
  329. text-align: center;
  330. }
  331. }
  332. &.code{
  333. width: 310rpx;
  334. float: left;
  335. margin-right: 20rpx;
  336. }
  337. &.btn{
  338. width: 220rpx;
  339. height: 64rpx;
  340. float: right;
  341. background: $btn-confirm;
  342. padding: 0;
  343. border-radius: 44rpx;
  344. margin-top: 20rpx;
  345. .input{
  346. width: 220rpx;
  347. height: 64rpx;
  348. line-height: 64rpx;
  349. padding: 0;
  350. color: #FFFFFF;
  351. background: $btn-confirm;
  352. text-align: center;
  353. border-radius: 44rpx;
  354. &.none{
  355. background: #F7F7F7;
  356. }
  357. }
  358. &.disabled{
  359. background: #F7F7F7;
  360. .input{
  361. background: #F7F7F7;
  362. color: #999999;
  363. }
  364. }
  365. }
  366. &.img-btn{
  367. width: 290rpx;
  368. height: 64rpx;
  369. padding: 0;
  370. float: right;
  371. background: #FFFFFF;
  372. display: block;
  373. margin-top: 10rpx;
  374. .vscodeimg{
  375. width: 160rpx;
  376. height: 64rpx;
  377. float: left;
  378. display: flex;
  379. flex-direction: column;
  380. align-items: center;
  381. border-radius: 6rpx;
  382. margin-top: 10rpx;
  383. image{
  384. width: 180rpx;
  385. height: 88rpx;
  386. border-radius: 6rpx;
  387. }
  388. }
  389. .vscod-refresh{
  390. width: 100rpx;
  391. float: right;
  392. margin-top: 25rpx;
  393. .icon-shuaxin{
  394. font-size: 36rpx;
  395. color: #999999;
  396. float: left
  397. }
  398. .ref-text{
  399. font-size: 24rpx;
  400. color: #333333;
  401. float: right;
  402. }
  403. }
  404. }
  405. .input{
  406. width: 100%;
  407. height: 100%;
  408. font-size: $font-size-28;
  409. line-height: 40rpx;
  410. color: #333333;
  411. border-radius: 14rpx;
  412. }
  413. }
  414. }
  415. .login-btn{
  416. width: 600rpx;
  417. height: 88rpx;
  418. border-radius: 44rpx;
  419. font-size: $font-size-28;
  420. line-height: 88rpx;
  421. color: #FFFFFF;
  422. margin: 0 auto;
  423. text-align: center;
  424. background: $btn-confirm;
  425. margin-top: 100rpx;
  426. }
  427. .model-authorization{
  428. width: 100%;
  429. height: 100%;
  430. position: fixed;
  431. top: 0;
  432. left: 0;
  433. z-index: 999;
  434. .authorization{
  435. width: 518rpx;
  436. height: 320rpx;
  437. position: absolute;
  438. background: rgba(255,255,255,.7);
  439. left: 0;
  440. right: 0;
  441. bottom: 0;
  442. top: 0;
  443. margin: auto;
  444. .to-btn{
  445. position: absolute;
  446. top: 0;
  447. left: 0;
  448. right: 0;
  449. bottom: 0;
  450. margin: auto;
  451. width: 70%;
  452. height: 88rpx;
  453. font-size: $font-size-28;
  454. line-height: 88rpx;
  455. color: #FFFFFF;
  456. text-align: center;
  457. border-radius: 44rpx;
  458. }
  459. }
  460. }
  461. }
  462. .placeholder{
  463. color: #b2b2b2;
  464. }
  465. </style>