Mr.Shi
2023-09-04 682182cf67a5aa9fed34335fea22d4673f30f10c
小程序
已修改9个文件
216 ■■■■ 文件已修改
minipro_standard/pages/changePassword/changePassword.vue 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
minipro_standard/pages/login/login.vue 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
minipro_standard/pages/mine/mine.vue 71 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
minipro_standard/pages/personal/personal.vue 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
minipro_standard/pages/updatePhone/updatePhone.vue 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
minipro_standard/pages/workbench/workbench.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
minipro_standard/store/index.js 34 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
minipro_standard/util/api/index.js 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
minipro_standard/util/request/requestInterceptors.js 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
minipro_standard/pages/changePassword/changePassword.vue
@@ -25,7 +25,7 @@
            </view>
        </view>
        <view class="password_footer">
            <button v-preventReClick class="password_footer_submit">
            <button class="password_footer_submit" @click="submit">
                <text>完成</text>
            </button>
        </view>
@@ -33,6 +33,7 @@
</template>
<script>
    import { updatePwd } from '@/util/api/PersonalAPI'
    export default {
        data() {
            return {
@@ -42,6 +43,38 @@
                    confirmPassword: ''
                }
            };
        },
        methods: {
            // 忘记密码
            forgotPassword() {
            },
            // 提交修改
            submit() {
                if (!this.form.originalPassword) {
                    uni.showToast({ title: '原密码不能为空', icon: 'none', duration: 2000 });
                } else if (!this.form.newPassword) {
                    uni.showToast({ title: '新密码不能为空', icon: 'none', duration: 2000 });
                } else if (!/^(?=.*[A-Za-z])(?=.*\d)(?=.*[$@$!%*#?&])[A-Za-z\d$@$!%*#?&]{6,}$/.test(this.form.newPassword)) {
                    uni.showToast({ title: '密码格式不正确', icon: 'none', duration: 2000 });
                } else if (!this.form.confirmPassword) {
                    uni.showToast({ title: '确认密码不能为空', icon: 'none', duration: 2000 });
                } else if (this.form.newPassword !== this.form.confirmPassword) {
                    uni.showToast({ title: '两次输入的密码不一致', icon: 'none', duration: 2000 });
                } else {
                    updatePwd({
                        newPwd: this.form.newPassword,
                        oldPwd: this.form.originalPassword
                    }).then(res => {
                        if (res.code === 200) {
                            uni.showToast({ title: '修改成功', icon: 'success', duration: 2000, mask: true });
                            setTimeout(() => {
                                uni.navigateBack({ delta: 1 });
                            }, 2000)
                        }
                    })
                }
            }
        }
    }
</script>
minipro_standard/pages/login/login.vue
@@ -49,7 +49,7 @@
                                    let info = await getUserInfo()
                                    if (info.code === 200) {
                                        await that.$store.commit('setEntrance', 'WX')
                                        await that.$store.commit('setUserInfo', info.data)
                                        await that.$store.commit('SETUSERINFO', info.data)
                                        await that.$store.dispatch('getMenuList', 2)
                                        uni.switchTab({
                                            url: '/pages/workbench/workbench'
@@ -71,6 +71,7 @@
                if (!this.from.password) return uni.showToast({ title: '密码不能为空', icon:"error", duration: 2000 });
                let res = await wxAccountLogin(this.from)
                if (res.code === 200) {
                    await this.$store.commit('SETSESSION', res.data)
                    let user = await getUserInfo({})
                    if (user.code === 200) {
                        await this.$store.commit('SETUSERINFO', user.data)
minipro_standard/pages/mine/mine.vue
@@ -2,11 +2,11 @@
<view>
    <div class="box">
        <div class="box_info" :style="{background: 'url(' + img + ')'}">
            <image src="@/static/2@2x.png" mode="widthFix" />
            <image :src="userInfo.avatar ? userInfo.avatar : avatar" mode="widthFix" />
            <div class="box_info_box">
                <text>张三</text>
                <div class="box_info_box_x" @click="show = true">
                    <text>豆米科技</text>
                <text>{{userInfo.realname}}</text>
                <div class="box_info_box_x" @click="switchOrganization">
                    <text>{{userInfo.curComDepartment ? userInfo.curComDepartment.name : ''}}</text>
                    <image src="@/static/mine_ic_change@2x.png" alt="" />
                </div>
            </div>
@@ -22,20 +22,26 @@
                </div>
            </div>
        </div>
        <div class="box_out"><text>退出登录</text></div>
        <div class="box_out" @click="loginOut"><text>退出登录</text></div>
    </div>
    <!-- 部门选择器 -->
    <u-picker :show="show" :columns="columns" @confirm="confirm"></u-picker>
    <u-picker :show="show" :columns="columns" @confirm="onConfirm" @cancel="show = false"></u-picker>
    <myTabbar :index="2" />
</view>
</template>
<script>
    import { changeCom, getDepartmentListByConditon } from '@/util/api/PersonalAPI'
    import myTabbar from "@/components/myTabber.vue"
    import { wxLoginOut } from '@/util/api'
    import { mapState } from 'vuex'
    export default {
        components: {
            myTabbar
        },
        computed: mapState([
            'userInfo'
        ]),
        data() {
            return {
                MENU: [
@@ -47,22 +53,61 @@
                    { name: '修改密码', url: '/pages/changePassword/changePassword', icon: require('@/static/mine_ic_xiugaimima@2x.png') },
                ],
                img: require('@/static/mine_bg@2x.png'),
                avatar: require('@/static/2@2x.png'),
                show: false,
                columns: [
                    ['中国', '美国', '日本']
                ]
                columns: []
            }
        },
        onLoad() {
            uni.hideTabBar()
        },
        methods: {
            jump(url) {
                uni.navigateTo({ url })
            // 退出登录
            loginOut() {
                wxLoginOut({
                    companyUserId: this.userInfo.companyUser.id
                }).then(res => {
                    if (res.code === 200) {
                        this.$store.commit('clearCache')
                        uni.reLaunch({
                            url: '/pages/login/login'
                        });
                    }
                })
            },
            confirm(val) {
                console.log(val)
            // 确认切换组织
            onConfirm(e) {
                changeCom(e.value[0].id).then(res => {
                    if (res.code === 200) {
                this.show = false
                        uni.showToast({ title: '更新组织成功', icon: 'success', duration: 2000 });
                        this.$store.dispatch('getUserInfos')
                    }
                })
            },
            // 获取组织
            switchOrganization() {
                getDepartmentListByConditon({
                    type: 0
                }).then(res => {
                    if (res.code === 200) {
                        this.columns = []
                        let arr = []
                        res.data.forEach((item) => {
                            let obj = {
                                text: item.name, id: item.id
                            }
                            arr.push(obj)
                        })
                        this.columns.push(arr)
                        this.show = true
                    }
                })
            },
            // 跳转页面
            jump(url) {
                if (!url) return
                uni.navigateTo({ url })
            }
        }
    }
minipro_standard/pages/personal/personal.vue
@@ -1,41 +1,45 @@
<template>
    <view class="info">
        <view class="info_portrait">
            <image src="@/static/2@2x.png" mode="widthFix" />
            <image :src="userInfo.avatar ? userInfo.avatar : avatar" mode="widthFix" />
            <text>用户名</text>
        </view>
        <view class="info_list">
            <view class="info_list_item">
                <text>昵称</text>
                <text>暂无昵称</text>
                <text>{{userInfo.realname ? userInfo.realname : '暂无昵称'}}</text>
            </view>
            <view class="info_list_item">
                <text>手机号</text>
                <text>暂无手机号</text>
                <text>{{userInfo.companyUser.phone ? userInfo.companyUser.phone : '暂无手机号'}}</text>
            </view>
            <view class="info_list_item">
                <text>所属部门</text>
                <text>暂无所属部门</text>
                <text>{{userInfo.department.name ? userInfo.department.name : '暂无所属部门'}}</text>
            </view>
            <view class="info_list_item">
                <text>岗位</text>
                <text>暂无岗位</text>
                <text>{{userInfo.companyUser.positionName ? userInfo.companyUser.positionName : '暂无岗位'}}</text>
            </view>
            <view class="info_list_item">
                <text>当前组织</text>
                <text>暂无组织</text>
                <text>{{userInfo.rootDepartment.name ? userInfo.rootDepartment.name : '暂无组织'}}</text>
            </view>
        </view>
    </view>
</template>
<script>
    import { mapState } from 'vuex'
    export default {
        data() {
            return {
                avatar: require('@/static/2@2x.png'),
            };
        }
        },
        computed: mapState([
            'userInfo'
        ])
    }
</script>
minipro_standard/pages/updatePhone/updatePhone.vue
@@ -8,7 +8,7 @@
            <view class="password_list_item">
                <text>当前绑定</text>
                <view class="password_list_item_box">
                    <input type="number" disabled v-model="form.currentPhone" maxlength="11">
                    <input type="number" disabled v-model="userInfo.companyUser.phone" maxlength="11">
                </view>
            </view>
            <view class="password_list_item">
@@ -22,7 +22,7 @@
                <view class="password_list_item_box">
                    <input type="text" v-model="form.verificationCode" maxlength="4" placeholder="请输入手机验证码">
                    <p @click="getVerificationCode" v-if="!code.isOpen">获取验证码</p>
                    <p @click="getVerificationCode" v-else>{{code.num}}</p>
                    <p v-else>{{code.num}}</p>
                </view>
            </view>
        </view>
@@ -35,15 +35,50 @@
</template>
<script>
    import { mapState } from 'vuex'
    import { phoneRegular } from '@/common/config.js'
    export default {
        data() {
            return {
                form: {
                    currentPhone: '',
                    newPhone: '',
                    verificationCode: ''
                },
                code: {
                    num: 60,
                    isOpen: false,
                    timer: 0
                }
            };
        },
        computed: mapState([
            'userInfo'
        ]),
        methods: {
            // 获取验证码
            getVerificationCode() {
                this.code.isOpen = true
                this.code.timer = setInterval(() => {
                    if (this.code.num === 0) {
                        clearInterval(this.code.timer)
                        this.code.isOpen = false
                        this.code.num = 60
                    }
                    this.code.num = this.code.num - 1
                }, 1000)
            },
            // 提交修改
            submit() {
                if (!this.form.newPhone) {
                    uni.showToast({ title: '新手机号不能为空', icon: 'none', duration: 2000 });
                } else if (!phoneRegular.test(this.form.newPhone)) {
                    uni.showToast({ title: '手机号不合法', icon: 'none', duration: 2000 });
                } else if (!this.form.verificationCode) {
                    uni.showToast({ title: '验证码不能为空', icon: 'none', duration: 2000 });
                } else {
                    console.log('可以提交')
                }
            }
        }
    }
</script>
minipro_standard/pages/workbench/workbench.vue
@@ -1,7 +1,7 @@
<template>
    <view class="index">
        <view class="menu">
            <!-- <view class="menu_list" v-for="(row, i) in Menu" :key="i">
            <view class="menu_list" v-for="(row, i) in Menu" :key="i">
                <view class="menu_list_head">
                    <span>{{row.label}}</span>
                </view>
@@ -14,7 +14,7 @@
                    <view class="menu_list_zw"></view>
                    <view class="menu_list_zw"></view>
                </div>
            </view> -->
            </view>
        </view>
        <myTabbar :index="1" />
    </view>
minipro_standard/store/index.js
@@ -1,6 +1,10 @@
import Vue from 'vue'
import Vuex from 'vuex'
import { pageCount, getTreeList } from '@/util/api/index.js'
import {
    pageCount,
    getTreeList,
    getUserInfo
} from '@/util/api/index.js'
Vue.use(Vuex) // vue的插件机制
@@ -25,7 +29,7 @@
        navHeight: navHeight || '0',
        session: session ? session : '',
        // 菜单权限
        Menu: Menu ? Menu : [],
        Menu: Menu ? JSON.parse(Menu) : [],
        // 待办数量
        upcomingNum: {
            d: 0,
@@ -60,12 +64,23 @@
        SETSESSION (state, data) {
            state.session = data;
            uni.setStorageSync('session', data);
        },
        clearCache(state) {
            state.userInfo = ''
            state.token = ''
            state.session = ''
            state.Menu = []
            state.upcomingNum.d = 0
            state.upcomingNum.y = 0
            uni.clearStorageSync()
        }
    },
    actions: {
        // 向后端获取菜单栏权限
        async getMenuList (content, type) {
            let res = await getTreeList({ type: type })
            let res = await getTreeList({
                type: type
            })
            if (res.code === 200) {
                content.commit('SETMENU', res.data)
            }
@@ -88,7 +103,18 @@
        async getUpcomingNum() {
            let res = await pageCount({})
            if (res.code === 200) {
                content.commit('SETNUM', { d: res.data.startNum, y: res.data.endNum })
                content.commit('SETNUM', {
                    d: res.data.startNum,
                    y: res.data.endNum
                })
            }
        },
        // 向后端获取个人信息
        async getUserInfos(content) {
            let res = await getUserInfo()
            if (res.code === 200) {
                content.commit('SETUSERINFO', res.data)
                return true;
            }
        }
    }
minipro_standard/util/api/index.js
@@ -43,3 +43,8 @@
export function wxProgramLogin(params) {
    return http.get('/system/wxProgramLogin', {params})
}
// 微信退出登录
export function wxLoginOut(data) {
    return http.post('/system/wxLoginOut', data)
}
minipro_standard/util/request/requestInterceptors.js
@@ -4,8 +4,9 @@
 */
module.exports = (vm) => {
    uni.$u.http.interceptors.request.use((config) => { // 可使用async await 做异步操作
        console.log(config)
        if (vm.$store.state.session) {
        config.header['Cookie'] = 'eva-auth-token=' + vm.$store.state.session
        }
        uni.showLoading({ title: '请求中' });
        config.data = config.data || {}
        return config