From 2e61c194b816364fe4fbab967fee13dbefe86216 Mon Sep 17 00:00:00 2001
From: zhangwei <1504152376@qq.com>
Date: 星期一, 30 九月 2024 16:35:47 +0800
Subject: [PATCH] -
---
src/pages/mine/index.vue | 172 +++++++++++++++++++++++++++++++++------------------------
1 files changed, 99 insertions(+), 73 deletions(-)
diff --git a/src/pages/mine/index.vue b/src/pages/mine/index.vue
index 9eccc21..06dea60 100644
--- a/src/pages/mine/index.vue
+++ b/src/pages/mine/index.vue
@@ -1,6 +1,6 @@
<template>
<view class="container">
- <view class="header">
+ <view :class="identity=='enterprise'?'header-hide':'header'">
<view class="header-img">
<view class="header-image-left" @click='tologin'>
<up-avatar :src="userInfo.avatar" shape="circle" size='60'></up-avatar>
@@ -12,7 +12,7 @@
<text class='iconfont icon-qiehuan chuany-font28'></text>
</view>
</view>
- <view class="num-box">
+ <view class="num-box" v-if="identity!=='enterprise'">
<view @tap="goWallet" class="num-item" data-ptpid="ef57-17f4-bbea-280f">
<view class="num-bold">{{ balance }}鍏�</view>
<view class="num-text">
@@ -28,13 +28,13 @@
浼佷笟鏈嶅姟
</view>
<view class="tool_content">
- <view class="tool_item" @click="toRelease">
+ <view class="tool_item" @click="toRelease" v-if="isAdmin">
<image src="@/static/image/fabu.png" mode="aspectFit" class="item_img"></image>
<view class="tool_label">
鍙戝竷鑱屼綅
</view>
</view>
- <view class="tool_item" @click="toOrder">
+ <view class="tool_item" @click="toOrder" v-if="isAdmin">
<image src="@/static/image/guanli.png" mode="aspectFit" class="item_img"></image>
<view class="tool_label">
鑱屼綅绠$悊
@@ -46,18 +46,18 @@
鎴戠殑浼佷笟
</view>
</view>
- <view class="tool_item" @click="toWorkerRecord">
+ <view class="tool_item" @click="toWorkerRecord" v-if="isAdmin">
<image src="@/static/image/record.png" mode="aspectFit" class="item_img"></image>
<view class="tool_label">
- 鎵撳崱璁板綍
+ 宸ヨ祫瀹℃牳
</view>
</view>
- <!-- <view class="tool_item" @click="toPage('/otherPages/member/sendCompany/sendCompany')">
- <image src="@/static/image/server.png" mode="aspectFit" class="item_img"></image>
+ <view class="tool_item" @click="toSalary" v-if="isAdmin">
+ <image src="@/static/image/salary.png" mode="aspectFit" class="item_img"></image>
<view class="tool_label">
- 鏈嶅姟涓績
+ 宸ヨ祫鏌ヨ
</view>
- </view> -->
+ </view>
</view>
</view>
</view>
@@ -87,14 +87,14 @@
<view :class="'iconfont ' + item.icon"></view>
{{ item.name }}
</view>
-
+
<view class="nav-icon">
<view v-if="item.num || item.num === 0">{{ item.num }}</view>
<view class="iconfont iconarrow"></view>
</view>
</view>
</view>
-
+
</view>
<view class="nav-box" v-else>
<view @tap="item.cb" class="nav-item" :data-index="index" data-ptpid="58ac-1481-a7d3-b98e"
@@ -116,12 +116,14 @@
</template>
<script>
- var app = getApp();
+ import {
+ mapActions,
+ mapGetters,
+ mapMutations
+ } from 'vuex'
export default {
-
data() {
return {
- identity: '',
navList: [{
icon: 'icon-huabanfuben',
name: '鍛樺伐绠$悊',
@@ -131,7 +133,7 @@
});
}
}, ],
- navList1: [{
+ navList2: [{
icon: 'icon-wanshanxinxi',
name: '瀹屽杽璧勬枡',
cb: function() {
@@ -147,68 +149,75 @@
},
{
icon: 'icon-fuwutuandui',
- name: '宸ヤ綔璁板綍',
+ name: '鎵撳崱璁板綍',
cb: this.toMyRecord
},
],
- isLogin: false,
- userInfo: {},
- balance: '0.00',
- isAdmin: false
+ navList3: [{
+ icon: 'icon-wanshanxinxi',
+ name: '淇敼璧勬枡',
+ cb: function() {
+ uni.navigateTo({
+ url: '/pages/mine/apply'
+ });
+ }
+ },
+ {
+ icon: 'icon-dingdan',
+ name: '鎴戠殑宸ヤ綔',
+ cb: this.toMyWork
+ },
+ {
+ icon: 'icon-fuwutuandui',
+ name: '鎵撳崱璁板綍',
+ cb: this.toMyRecord
+ },
+ ],
+ token: this.$db.get('userToken') || ''
};
},
onLoad: function() {
-
},
onShow: function() {
- let that = this
- this.userInfo = this.$db.get('userInfo') ? JSON.parse(this.$db.get('userInfo')) : {}
- this.token = this.$db.get('userToken') ? this.$db.get('userToken') : ''
- uni.getStorage({
- key: 'identity',
- success: function(res) {
- that.identity = res.data
- if (res.data == 'worker') {
- if (that.userInfo.userWorker) {
- that.balance = that.$common.moneySub(that.userInfo.userWorker.tiXianZonge, that
- .userInfo.userWorker.yiTiXianJine)
- }
- } else {
- if (that.userInfo.userCompany) {
- that.balance = that.userInfo.userCompany.chongZhiYue ? that.userInfo
- .userCompany.chongZhiYue : '0.00'
- }
- }
- }
- });
- // this.userInfo = this.$db.get('userInfo') ? JSON.parse(this.$db.get('userInfo')) : {}
- // this.token = this.$db.get('userToken') ? this.$db.get('userToken') : ''
- this.isLogin = this.token ? true : false;
- this.isAdmin = this.userInfo.userCompany ? this.userInfo.userCompany.isAdmin : false
+ this.getUserInfo()
},
- onPullDownRefresh() {
- this.$api.getUser().then(res => {
- this.$db.set('userInfo', JSON.stringify(res.data))
- this.userInfo = res.data
- this.isAdmin = this.userInfo.userCompany ? this.userInfo.userCompany.isAdmin : false
+ computed: {
+ ...mapGetters(['userInfo', 'identity']),
+ isAdmin() {
+ return this.userInfo.userCompany ? this.userInfo.userCompany.isAdmin : false
+ },
+ navList1() {
+ return this.userInfo.userWorker ? this.navList3 : this.navList2
+ },
+ isLogin() {
+ return this.token ? true : false;
+ },
+ balance() {
if (this.identity == 'worker') {
if (this.userInfo.userWorker) {
- this.balance = this.$common.moneySub(this.userInfo.userWorker.tiXianZonge, this.userInfo
+ return this.$common.moneySub(this.userInfo.userWorker.tiXianZonge, this.userInfo
.userWorker
.yiTiXianJine)
+ } else {
+ return '0.00'
}
} else {
if (this.userInfo.userCompany) {
- this.balance = this.userInfo.userCompany.chongZhiYue ? this.userInfo.userCompany
+ return this.userInfo.userCompany.chongZhiYue ? this.userInfo.userCompany
.chongZhiYue :
'0.00'
+ } else {
+ return '0.00'
}
}
- })
- uni.stopPullDownRefresh();
+ }
},
methods: {
+ ...mapActions([
+ 'getUserInfo'
+ ]),
+ ...mapMutations(['setIdentity']),
tologin() {
if (this.isLogin) {
uni.navigateTo({
@@ -267,6 +276,20 @@
url: '/pages/company/index'
});
},
+ toSalary() {
+ if (!this.userInfo.userCompany) {
+ uni.navigateTo({
+ url: '/pages/enterprise/enterprise'
+ });
+ this.$util.showToast({
+ title: '璇峰厛瀹屽杽浼佷笟璧勬枡锛�'
+ })
+ return
+ }
+ uni.navigateTo({
+ url: '/pages/worker/salary'
+ });
+ },
toMyWork() {
if (!this.userInfo.userWorker) {
uni.navigateTo({
@@ -296,23 +319,25 @@
});
},
changRole() {
- this.identity = this.identity === 'enterprise' ? 'worker' : 'enterprise'
- console.log(this.identity, 'this.identity');
- uni.setStorage({
- key: 'identity',
- data: this.identity,
- });
- if (this.identity == 'worker') {
- if (this.userInfo.userWorker) {
- this.balance = this.$common.moneySub(this.userInfo.userWorker.tiXianZonge, this.userInfo.userWorker
- .yiTiXianJine)
- }
- } else {
- if (this.userInfo.userCompany) {
- this.balance = this.userInfo.userCompany.chongZhiYue ? this.userInfo.userCompany.chongZhiYue :
- '0.00'
- }
- }
+ this.$store.commit('setIdentity', this.identity === 'enterprise' ? 'worker' : 'enterprise')
+ // this.$db.set('identity', this.identity === 'enterprise' ? 'worker' : 'enterprise')
+ // this.identity = this.identity === 'enterprise' ? 'worker' : 'enterprise'
+ console.log(this.identity, this.$db.get('identity'), 'this.identity');
+ // uni.setStorage({
+ // key: 'identity',
+ // data: this.identity,
+ // });
+ // if (this.identity == 'worker') {
+ // if (this.userInfo.userWorker) {
+ // this.balance = this.$common.moneySub(this.userInfo.userWorker.tiXianZonge, this.userInfo.userWorker
+ // .yiTiXianJine)
+ // }
+ // } else {
+ // if (this.userInfo.userCompany) {
+ // this.balance = this.userInfo.userCompany.chongZhiYue ? this.userInfo.userCompany.chongZhiYue :
+ // '0.00'
+ // }
+ // }
},
goWallet() {
uni.navigateTo({
@@ -494,6 +519,7 @@
.tool_content {
display: flex;
+ justify-content: space-between;
padding: 30rpx 0;
.tool_item {
@@ -502,7 +528,7 @@
flex-direction: column;
height: 120rpx;
justify-content: center;
- margin: 0 50rpx 0 0;
+ // margin: 0 50rpx 0 0;
width: 120rpx;
&:nth-child(4n) {
--
Gitblit v1.9.1