password.vue 11 KB

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