password.vue 13 KB

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