From 6b6cc4a3b92a9622efe1ad1150c42770b759e127 Mon Sep 17 00:00:00 2001
From: whycq <10027870+whycq@user.noreply.gitee.com>
Date: 星期三, 11 十月 2023 17:34:48 +0800
Subject: [PATCH] #
---
static/js/common.js | 5 ++
pages/api/index.js | 51 +++++++++++++++++++------
pages/index/index.vue | 38 +++++++++++++++---
3 files changed, 75 insertions(+), 19 deletions(-)
diff --git a/pages/api/index.js b/pages/api/index.js
index a8498ff..1c5d683 100644
--- a/pages/api/index.js
+++ b/pages/api/index.js
@@ -1,26 +1,52 @@
-function isEmpty(obj) {
- if (JSON.stringify(obj) === '{}') {
- return true
- }
- return obj == "undefined" || obj == null || obj === "" || obj == {};
-}
-
-const baseUrl = 'http://127.0.0.1:9528'
+import common from '@/static/js/common.js'
async function getCompanyData() {
let _this = this,item = [];
- var ress = await uni.request({
- url: `${baseUrl}/dashboard/companyData/auth`,
+ let ress = await uni.request({
+ url: `${common.baseUrl}/dashboard/companyData/auth`,
header:{'token':uni.getStorageSync('token')},
}).then((res)=> {
+ res = res[1].data
+ if (res.code === 200) {
+ item = {
+ code: res.code,
+ data: [
+ {name: '骞村害閿�鍞洰鏍�',content: res.data.yearTarget,unit: '涓囧厓'},
+ {name: '宸插畬鎴愰攢鍞换鍔�',content: res.data.successMoney,unit: '涓囧厓'},
+ {name: '鏈畬鎴愰攢鍞换鍔�',content: res.data.progressMoney,unit: '涓囧厓'},
+ {name: '瀹屾垚鐜�',content: res.data.yearTransactionRate,unit: '%'}
+ ]
+ }
+ } else if(res.code === 403){
+ item = {code: 403,msg: '璇烽噸鏂扮櫥褰�'}
+ }
+ },(result)=>{
+ // console.log(res);
+ })
+ return item
+}
+
+async function getPersonData() {
+ let item = [];
+ let ress = await uni.request({
+ url: `${common.baseUrl}/dashboard/personData/auth`,
+ header:{'token':uni.getStorageSync('token')},
+ }).then((res)=> {
+ console.log(res);
res = res[1].data
if (res.code === 200) {
item = [
{name: '骞村害閿�鍞洰鏍�',content: res.data.yearTarget,unit: '涓囧厓'},
{name: '宸插畬鎴愰攢鍞换鍔�',content: res.data.successMoney,unit: '涓囧厓'},
{name: '鏈畬鎴愰攢鍞换鍔�',content: res.data.progressMoney,unit: '涓囧厓'},
- {name: '瀹屾垚鐜�',content: res.data.yearTransactionRate,unit: '%'}
+ {name: '瀹屾垚鐜�',content: res.data.yearTransactionRate,unit: '%'},
+ {name: '璺熻釜椤圭洰鏁伴噺',content: res.data.progressCount,unit: '椤�'},
+ {name: '璺熻釜椤圭洰閲戦',content: res.data.successCount,unit: '涓囧厓'},
+ {name: '鎴愪氦椤圭洰鏁伴噺',content: res.data.progressMoney2,unit: '椤�'},
+ {name: '鎴愪氦椤圭洰閲戦',content: res.data.successMoney,unit: '涓囧厓'}
]
+ } else if(res.code === 403){
+ item = {code: 403,msg: '璇烽噸鏂扮櫥褰�'}
}
},(result)=>{
// console.log(res);
@@ -29,5 +55,6 @@
}
module.exports = {
- getCompanyData: getCompanyData
+ getCompanyData,
+ getPersonData
}
\ No newline at end of file
diff --git a/pages/index/index.vue b/pages/index/index.vue
index 8d56aff..74881ed 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -70,10 +70,10 @@
{name: '宸插畬鎴愰攢鍞换鍔�',content: 0,unit: '涓囧厓'},
{name: '鏈畬鎴愰攢鍞换鍔�',content: 0,unit: '涓囧厓'},
{name: '瀹屾垚鐜�',content: '0.00',unit: '%'},
- {name: '璺熻釜椤圭洰鏁伴噺',content: 0,unit: '涓囧厓'},
+ {name: '璺熻釜椤圭洰鏁伴噺',content: 0,unit: '椤�'},
{name: '璺熻釜椤圭洰閲戦',content: 0,unit: '涓囧厓'},
- {name: '鎴愪氦椤圭洰鏁伴噺',content: 0,unit: '涓囧厓'},
- {name: '鎴愪氦椤圭洰閲戦',content: '0.00',unit: '%'}
+ {name: '鎴愪氦椤圭洰鏁伴噺',content: 0,unit: '椤�'},
+ {name: '鎴愪氦椤圭洰閲戦',content: '0.00',unit: '涓囧厓'}
]
}
],
@@ -109,6 +109,7 @@
//妯℃嫙浠庢湇鍔″櫒鑾峰彇鏁版嵁
this.getServerData()
this.getCompanyData()
+ this.getPersonData()
},
mounted() {
@@ -135,11 +136,34 @@
// console.log(this.mainItem);
},
async getCompanyData() {
- let companyDatas = await getCompanyData.getCompanyData()
- this.mainItem[0].title = '鍥㈤槦娲诲姩瀹炴椂浜ゆ槗鎯呭喌'
- this.mainItem[0].subTitle = '鍥㈤槦鏁版嵁'
- this.mainItem[0].items = companyDatas
+ let res = await getCompanyData.getCompanyData()
+ if (res.code === 200) {
+ this.mainItem[0].title = '鍥㈤槦娲诲姩瀹炴椂浜ゆ槗鎯呭喌'
+ this.mainItem[0].subTitle = '鍥㈤槦鏁版嵁'
+ this.mainItem[0].items = res
+ } else if (res.code === 403) {
+ this.backLogin(res)
+ }
},
+ async getPersonData() {
+ let res = await getCompanyData.getPersonData()
+ if (res.code === 200) {
+ this.mainItem[1].title = '瀹炴椂閿�鍞儏鍐�'
+ this.mainItem[1].subTitle = '涓汉鏁版嵁'
+ this.mainItem[1].items = res
+ } else if (res.code === 403) {
+ this.backLogin(res)
+ }
+ },
+ backLogin(res) {
+ uni.showToast({title: res.msg, icon: "none", position: 'top'})
+ setTimeout(() => {
+ uni.reLaunch({
+ url: '../login/login'
+ });
+ }, 1000);
+ }
+
}
}
</script>
diff --git a/static/js/common.js b/static/js/common.js
new file mode 100644
index 0000000..017ba0b
--- /dev/null
+++ b/static/js/common.js
@@ -0,0 +1,5 @@
+const baseUrl = 'http://127.0.0.1:9528'
+
+export default {
+ baseUrl
+}
\ No newline at end of file
--
Gitblit v1.9.1