| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232 |
- <template>
- <u-popup :show="popShow" @close="cancel" mode="center" :is-mask-click="false">
- <view class="popup-wrapper">
- <view class="title">服务器设置</view>
- <u-form labelPosition="left" labelAlign="right" :model="formData" :rules="rules" ref="formRef"
- label-width="150">
- <u-form-item label="旧密码" prop="oldPassword" class="form-required">
- <u-input v-model="formData.oldPassword" placeholder="输入" type="password">
- </u-input>
- </u-form-item>
- <u-form-item label="新密码" prop="newPassword" class="form-required">
- <u-input v-model="formData.newPassword" placeholder="输入" type="password">
- </u-input>
- </u-form-item>
- <u-form-item label="确认密码" prop="newPassword1" class="form-required">
- <u-input v-model="formData.newPassword1" placeholder="输入" type="password">
- </u-input>
- </u-form-item>
- </u-form>
- <view class="footer">
- <u-button size="small" @click="cancel">取消</u-button>
- <u-button size="small" type="success" @click="confirm">确定</u-button>
- </view>
- </view>
- </u-popup>
- </template>
- <script>
- import {
- updatePassword
- } from '@/api/common.js'
- export default {
- data() {
- return {
- popShow: false,
- formData: {
- oldPassword: '',
- newPassword: '',
- newPassword1: ''
- },
- rules: {
- oldPassword: {
- type: 'string',
- required: true,
- message: '请输入旧密码',
- trigger: ['blur']
- },
- newPassword: {
- type: 'string',
- required: true,
- message: '请输入新密码',
- trigger: ['blur']
- },
- newPassword1: [{
- required: true,
- type: 'string',
- trigger: ['blur'],
- validator: (_rule, value, callback) => {
- if (!value) {
- return callback(new Error('请再次输入新密码'));
- }
- if (value !== this.formData.newPassword) {
- return callback(new Error('两次输入密码不一致'));
- }
- callback();
- }
- }]
- }
- }
- },
- created() {
- },
- methods: {
- open() {
- this.popShow = true
- },
- cancel() {
- this.popShow = false
- },
- loginOut() {
- uni.showModal({
- title: '提示',
- content: '确认退出登录',
- success: res => {
- console.log(res, res.confirm, '-----确认退出登录');
- if (res.confirm) {
- console.log('-----确认退出登录9999999');
- try {
- postJ(this.apiUrl + '/main/user/logout')
- .then(res => {
- uni.showToast({
- title: '退出成功',
- icon: 'success',
- duration: 500
- })
- setTimeout(() => {
- uni.clearStorage()
- uni.removeStorageSync('token')
- uni.removeStorageSync('userInfo')
- uni.removeStorageSync('treeList')
- uni.reLaunch({
- url: '/pages/login/login'
- })
- }, 500)
- })
- .catch(err => {
- console.log(err);
- uni.showToast({
- title: '退出失败',
- icon: 'none'
- })
- })
- } catch (error) {
- console.log(error, 'error----')
- uni.reLaunch({
- url: '/pages/login/login'
- })
- }
- } else if (res.cancel) {
- console.log('用户点击取消')
- }
- }
- })
- },
- confirm() {
- const userInfo = uni.getStorageSync("userInfo");
- this.$refs.formRef
- .validate()
- .then(res => {
- // Vue.prototype.apiWebUrl =
- // `${this.formData.protocal}${this.formData.hostname}:${this.formData.port}/web`
- // Vue.prototype.apiUrl =
- // `${this.formData.protocal}${this.formData.hostname}:${this.formData.port}/api`
- // Vue.prototype.webviewUrl =
- // `${this.formData.protocal}${this.formData.hostname}:${this.formData.port}`
- // uni.setStorageSync('apiInfo', this.formData)
- // this.$emit('setServerStatus', true)
- // this.cancel()
- this.formData.id = userInfo.userId
- updatePassword(this.formData).then(res => {
- if (res == 1) {
- uni.$u.toast('密码修改成功')
- setTimeout(() => {
- uni.removeStorageSync('token')
- uni.removeStorageSync('userInfo')
- uni.removeStorageSync('treeList')
- uni.reLaunch({
- url: '/pages/login/login'
- })
- }, 500)
- }
- })
- })
- .catch(errors => {
- uni.$u.toast('校验失败')
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .popup-wrapper {
- padding: 0 20rpx;
- .title {
- text-align: center;
- font-weight: bold;
- padding: 20rpx;
- }
- /deep/.u-form {
- .u-input__content__field-wrapper__field,
- .u-form-item__body__left__content__label {
- font-size: 28rpx !important;
- }
- .u-form-item__body__right__content__slot {}
- }
- /deep/.uni-stat__select {
- // height: 76rpx !important;
- width: 150rpx;
- flex: 0;
- .uni-select {
- width: 150rpx;
- font-size: 28rpx !important;
- }
- .uni-stat-box,
- .uni-select__input-box {
- // height: 76rpx !important;
- }
- }
- /deep/.u-input {
- flex: 1;
- padding: 12rpx 18rpx !important;
- border: 1px solid #e5e5e5;
- }
- .footer {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 20rpx 0;
- .u-button+.u-button {
- margin-left: 20rpx;
- }
- }
- }
- </style>
|