| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- <template>
- <view>
- <view class="bg-white padding-left-40 padding-right-40">
- <u-form ref="uForm" >
- <u-form-item label="旧密码" :label-width="labelWidth">
- <u-input maxlength="8" placeholder="请输入旧密码" v-model="password" type="password"></u-input>
- </u-form-item>
- <u-form-item label="新密码" :label-width="labelWidth">
- <u-input maxlength="8" placeholder="请输入新密码" v-model="newPass" type="password"></u-input>
- </u-form-item>
- <u-form-item label="确认新密码" :label-width="labelWidth">
- <u-input maxlength="8" placeholder="再次输入新密码" v-model="confirmPass" type="password"></u-input>
- </u-form-item>
- </u-form>
- </view>
- <view @click="submit" class="footer-fixed cu-btn bg-blue flex" style="padding: 45rpx;">
- 确认修改
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- loginType:'',
-
- dataDetail:{},
-
- labelWidth:180,
- password:'',
- newPass:'',
- confirmPass:''
- }
- },
- onShow() {
- let dataDetail=getApp().globalData.userInfo
- this.loginType=this.$cache.get('loginType')
- if (this.$isEmpty(dataDetail)) {
- if (this.$loginType.AGENCY==this.loginType) {
- //加载园区信息
- this.fetchAgencyInfo()
- }else if(this.$loginType.ENTERPRISE==this.loginType){
- //加载企业信息
- this.fetchEnterpriseInfo()
- }
- }else{
- this.dataDetail=dataDetail
- }
- },
- methods: {
- /**
- * 加载园区信息
- */
- fetchAgencyInfo(){
- let agencyId=this.$cache.get('agencyId')
- this.$api.agency.page({id:agencyId}).then(res=>{
- this.dataDetail=res.data[0]
- })
- },
- /**
- * 加载企业信息
- */
- fetchEnterpriseInfo(){
- let creditCode=this.$cache.get('creditCode')
- this.$api.enterprise.detail({creditCode:creditCode}).then(res=>{
- this.dataDetail=res.data
- })
- },
- /**
- * 修改密码
- */
- submit(){
- if (this.$isEmpty(this.password)) {
- this.$u.toast("请输入旧密码")
- return
- }
- if (this.password!=this.dataDetail.password) {
- this.$u.toast("旧密码错误")
- return
- }
- if (this.$isEmpty(this.newPass)) {
- this.$u.toast('请输入新密码')
- return
- }
- if (this.newPass.length<6) {
- this.$u.toast('新密码不能少于6位')
- return
- }
- if (this.$isEmpty(this.confirmPass)) {
- this.$u.toast('请再次输入新密码')
- return
- }
- if (this.newPass!=this.confirmPass) {
- this.$u.toast('两次密码输入不一致')
- return
- }
- this.dataDetail.password=this.newPass
-
- if (this.loginType==this.$loginType.AGENCY) {
- //修改园区密码
- this.$api.agency.submit(this.dataDetail).then(res=>{
- if (res.success) {
- this.$showModel('修改成功,请重新登陆!',false).then(res=>{
- this.$cache.clear()
- this.$Router.push('login')
- })
- }
- })
-
- }else if (this.loginType==this.$loginType.ENTERPRISE) {
- //修改企业密码
- this.$api.enterprise.submit(this.dataDetail).then(res=>{
- if (res.success) {
- this.$showModel('修改成功,请重新登陆!',false).then(res=>{
- this.$cache.clear()
- this.$Router.push('login')
- })
- }
- })
- }
- }
- }
- }
- </script>
- <style>
- </style>
|