diff --git a/apis/commonApi.js b/apis/commonApi.js index df55430..51ab891 100644 --- a/apis/commonApi.js +++ b/apis/commonApi.js @@ -80,11 +80,19 @@ export function getBaseInfo(data = {}, refresh = false) { http.get({ url: '/yyt-uec/get/base-info', data }, { hideLoading: true }).then((res) => { if (res) { // 排除供应商角色 - if (res.enterpriseList && res.enterpriseList.length > 0 && res.enterpriseList[0].enterpriseType == enterpriseType.SUPPLIER) { - uni.showToast({ - title: '您是供应商角色,请登陆纸掌柜app进行操作', - icon: 'error' - }) + var factory = null + var organizationList = res.organizationList + if(res.organizationList && res.organizationList.length > 0){ + for (var i = 0; i < res.organizationList.length; i++) { + if(!res.organizationList[i].factoryList || !res.organizationList[i].factoryList.length){ + continue + } + factory = res.organizationList[i].factoryList[0] + break + } + } + if (!factory) { + uni.showToast({ title: '没有您的工厂信息,请联系管理员处理', icon: 'error'}) resolve(null) } else { baseInfo = res diff --git a/pages/device-production-info/index.vue b/pages/device-production-info/index.vue index d00e358..ff35219 100644 --- a/pages/device-production-info/index.vue +++ b/pages/device-production-info/index.vue @@ -189,7 +189,6 @@ export default { this.info = res } }) - uni.setStorageSync('factoryId', this.factoryId) getOrderListByMachine(this.id, {status: 1}).then((res) => { if (res && res.productionTaskList && res.productionTaskList.length) { this.orderList = res.productionTaskList diff --git a/pages/digital-workshops/index.vue b/pages/digital-workshops/index.vue index 599ccc2..94a3855 100644 --- a/pages/digital-workshops/index.vue +++ b/pages/digital-workshops/index.vue @@ -184,6 +184,10 @@ export default { watch: { factoryId(val, oldVal) { uni.setStorageSync('factoryId', this.factoryId) + var organization = this.findOrgByFactoryId(this.factoryId) + if(organization){ + uni.setStorageSync('organizationId', organization.organizationId) + } if(this.factoryId){ this.getCameraList() this.getList() @@ -218,6 +222,20 @@ export default { this.current = e.currentIndex; } }, + findOrgByFactoryId(factoryId){ + var organizationList = this.$store.state.userInfo.organizationList + for (var i = 0; i < organizationList.length; i++) { + if(!organizationList[i].factoryList || !organizationList[i].factoryList.length){ + continue + } + for (var k = 0; k < organizationList[i].factoryList.length; k++) { + if(organizationList[i].factoryList[k].id == factoryId){ + return organizationList[i] + } + } + } + return null + }, getList() { getMachinList({ factoryId: this.factoryId, pageSize: 1000 }).then((res) => { let list = res.records diff --git a/pages/employee-manage/index.vue b/pages/employee-manage/index.vue index 12ae121..2604334 100644 --- a/pages/employee-manage/index.vue +++ b/pages/employee-manage/index.vue @@ -92,7 +92,6 @@ export default { }, findOrgByFactoryId(factoryId){ var organizationList = this.$store.state.userInfo.organizationList - console.log(organizationList) for (var i = 0; i < organizationList.length; i++) { if(!organizationList[i].factoryList || !organizationList[i].factoryList.length){ continue @@ -119,7 +118,7 @@ export default { provider: 'weixin', scene: "WXSceneSession", type: 5, - imageUrl: 'https://qncloud.oss-cn-shenzhen.aliyuncs.com/common/45309546072860651.webp', + imageUrl: 'https://qncloud.oss-cn-shenzhen.aliyuncs.com/common/46359753264412852.webp', title: '欢迎加入普瑞特', miniProgram: { id: 'gh_ddfcf0fe593d', diff --git a/pages/enterprise-info-edit/index.vue b/pages/enterprise-info-edit/index.vue index 54c30f1..eb37b2e 100644 --- a/pages/enterprise-info-edit/index.vue +++ b/pages/enterprise-info-edit/index.vue @@ -220,22 +220,37 @@ export default { } }) }, - created() { - const enterpriseId = this.$store.state.companyInfo.id - if (enterpriseId) { - getCompanyInfoById(enterpriseId).then((res) => { - if (res) { - this.form = res - this.form.id = enterpriseId - } - }) - } + onLoad() { + var factoryId = uni.getStorageSync('factoryId') + var organization = this.findOrgByFactoryId(factoryId) + if(organization){ + getCompanyInfoById(organization.enterpriseId).then((res) => { + if (res) { + this.form = res + this.form.id = organization.enterpriseId + } + }) + } }, methods: { back, cancel() { back() }, + findOrgByFactoryId(factoryId){ + var organizationList = this.$store.state.userInfo.organizationList + for (var i = 0; i < organizationList.length; i++) { + if(!organizationList[i].factoryList || !organizationList[i].factoryList.length){ + continue + } + for (var k = 0; k < organizationList[i].factoryList.length; k++) { + if(organizationList[i].factoryList[k].id == factoryId){ + return organizationList[i] + } + } + } + return null + }, showLocationList() { if (!this.form.name || !this.form.name.trim()) { uni.showToast({ diff --git a/pages/mine/index.vue b/pages/mine/index.vue index 902a7b9..c7adc99 100644 --- a/pages/mine/index.vue +++ b/pages/mine/index.vue @@ -19,7 +19,7 @@ - + {{ hasCompany ? userInfo.companyName : '点击完善企业信息' }} @@ -131,6 +131,7 @@ export default { workingNum: 0, freeNum: 0 }, + hasLogin: false, fsAuditStatus: Object.freeze(fsAuditStatus), orderStatusEnum: Object.freeze(orderStatusEnum) } @@ -207,13 +208,25 @@ export default { } }) }, + findOrgByFactoryId(factoryId){ + var organizationList = this.$store.state.userInfo.organizationList + for (var i = 0; i < organizationList.length; i++) { + if(!organizationList[i].factoryList || !organizationList[i].factoryList.length){ + continue + } + for (var k = 0; k < organizationList[i].factoryList.length; k++) { + if(organizationList[i].factoryList[k].id == factoryId){ + return organizationList[i] + } + } + } + return null + }, jumpEnterpriseEdit() { if (!this.hasCompany) { loginGo2('enterprise-info') } else { - if (this.$store.state.companyInfo.enterpriseType === enterpriseType.PRINT_PACKAGE_FACTORY) { - loginGo2('enterprise-info-edit') - } + loginGo2('enterprise-info-edit') } } }, @@ -227,9 +240,6 @@ export default { isVip() { return this.$store.state.companyInfo.isVip }, - hasLogin() { - return this.$store.state.qnToken != '' - }, curAvatar() { if (!this.hasLogin) { return '/static/imgs/mine/user-avatar.png' @@ -239,36 +249,36 @@ export default { } else { return '/static/imgs/mine/default-avatar.png' } - }, - userInfo() { - return { - avatar: this.$store.state.userInfo.avatar || '', - name: this.$store.state.userInfo.name || this.$store.state.userInfo.mobile || '', - companyName: this.$store.state.companyInfo.name || '', - fddEnterpriseStatus: this.$store.state.companyInfo.fddEnterpriseStatus || 1 - } - }, - hasCompany() { - return this.$store.state.companyInfo.id != null } }, onShow() { - this.hasLogin && - getFsCredit({ - enterpriseId: this.$store.state.companyInfo.id - }).then((res) => { - if (res) { - this.fsInfo = res + this.factoryId = uni.getStorageSync('factoryId') + this.organization = this.findOrgByFactoryId(this.factoryId) + var companyName = '' + if(this.organization){ + companyName = this.organization.organizationName + this.hasLogin = true + this.hasCompany = true + this.userInfo = { + avatar: this.$store.state.userInfo.avatar || '', + name: this.$store.state.userInfo.name || this.$store.state.userInfo.mobile || '', + companyName, + fddEnterpriseStatus: this.$store.state.companyInfo.fddEnterpriseStatus || 1 } - }) - this.hasLogin && getBaseInfo({}, true) - !this.hasLogin && (this.fsInfo.status = -1) - this.hasCompany && - getDeviceStatistics().then((res) => { - if (res) { - this.deviceInfo = res - } - }) + + getFsCredit({ + enterpriseId: this.organization.enterpriseId + }).then((res) => { + if (res) { + this.fsInfo = res + } + }) + getDeviceStatistics().then((res) => { + if (res) { + this.deviceInfo = res + } + }) + } } } diff --git a/store/index.js b/store/index.js index 2c36797..d1681dd 100644 --- a/store/index.js +++ b/store/index.js @@ -177,12 +177,12 @@ if (!store) { console.warn('companyInfo必须是对象') return } - for (let param of companyInfoParams) { - if (companyInfo[param] === undefined) { - console.warn(`companyInfo必须包含${param}`) - return - } - } + // for (let param of companyInfoParams) { + // if (companyInfo[param] === undefined) { + // console.warn(`companyInfo必须包含${param}`) + // return + // } + // } try { uni.setStorageSync('companyInfo', JSON.stringify(companyInfo)) state.companyInfo = companyInfo