#
whycq
2023-10-11 6b6cc4a3b92a9622efe1ad1150c42770b759e127
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
}