对接大部分接口

This commit is contained in:
aixianling
2023-10-23 10:48:30 +08:00
parent 189e7621ad
commit 8c07c9a6cb
5 changed files with 232 additions and 139 deletions

View File

@@ -1,7 +1,7 @@
<template>
<section class="AppBIBoard" :class="{fullscreen}">
<ai-fit-view @scale="v=>scale=v">
<ai-dv-wrapper ref="fddv" title="丰收号-家庭互助" :instance="instance" :mask="false">
<ai-dv-wrapper ref="fddv" title="丰收号-家庭互助" :instance="instance" :mask="false" @pick="getData()">
<template v-slot:head="head">
<fengdu-head v-model="areaId" v-bind="head" @fullscreen="handleFullScreen" @setting="handleSetting"/>
</template>
@@ -53,9 +53,10 @@
</fd-card>
</div>
<div class="center fill relative">
<fd-map class="w100 h100"/>
<fd-map class="w100 h100" v-model="map"/>
<fd-card class="centerBottom pad-b8" label="实时动态">
<dv-scroll-board class="mar-t14" :config="realtimeEvents" style="height: 228px"/>
<dv-scroll-board class="mar-t14" :config="realtimeEvents" style="height: 228px"
@click="handleRealtimeEventDialog"/>
</fd-card>
</div>
<div class="right">
@@ -67,11 +68,11 @@
<div class="boxSta flex">
<div class="flex text">
<div>获取总积分</div>
<p v-text="12000"/>
<p v-text="GongdeBank.total"/>
</div>
</div>
<div class="staPanel simple right flex mar-t14">
<div class="fill" v-for="(v,k) in volunteers" :key="k">
<div class="fill" v-for="(v,k) in GongdeBank.users" :key="k">
<div v-text="k"/>
<b v-text="v"/>
</div>
@@ -79,17 +80,17 @@
<div class="boxSta flex">
<div class="flex text">
<div>兑换总积分</div>
<p v-text="9500"/>
<p v-text="GongdeBank.useTotal"/>
</div>
</div>
<div class="staPanel simple right flex mar-t14">
<div class="fill" v-for="(v,k) in volunteers" :key="k">
<div class="fill" v-for="(v,k) in GongdeBank.stores" :key="k">
<div v-text="k"/>
<b v-text="v"/>
</div>
</div>
<div class="grid c-3 pad-t14 pad-b20">
<div class="staPanel" v-for="(v,k) in volunteers">
<div class="staPanel" v-for="(v,k) in GongdeBank.tasks">
<div v-text="k"/>
<b v-text="v"/>
</div>
@@ -228,13 +229,13 @@ export default {
columnWidth: [250],
align: ['left', 'right', 'right'],
data: [
['渝快办', 178, 266],
['公交乘车码', 178, 266],
['警快办', 178, 266],
['医保电子凭证', 178, 266],
['居民上报', 178, 266],
['医保电子凭证', 178, 266],
['居民上报', 178, 266],
// ['渝快办', 178, 266],
// ['公交乘车码', 178, 266],
// ['警快办', 178, 266],
// ['医保电子凭证', 178, 266],
// ['居民上报', 178, 266],
// ['医保电子凭证', 178, 266],
// ['居民上报', 178, 266],
]
},
current: 1,
@@ -245,24 +246,31 @@ export default {
columnWidth: [226],
align: ['center', 'left'],
data: [
['<div class="timeRow">2023-10-19 14:55:32</div>', '汇南社区-张三 创建了新的居民群'],
['<div class="timeRow">2023-10-19 14:55:32</div>', '汇南社区-张三 邀请居民"蓝天白云"加入居民群“书院社区2群”'],
['<div class="timeRow">2023-10-19 14:55:32</div>', '汇南社区-张三 将居民"蓝天白云"踢出居民群 “书院社区2群”'],
['<div class="timeRow">2023-10-19 14:55:32</div>', '滨江东路社区居民-陈思宇在丰收号小程序中进行了打卡签到'],
['<div class="timeRow">2023-10-19 14:55:32</div>', '滨江东路社区居民-陈思宇在丰收号小程序中进行了积分申请'],
['<div class="timeRow">2023-10-19 14:55:32</div>', '滨滨江东路社区居民-陈思宇在丰收号小程序中进行了物品兑换'],
['<div class="timeRow">2023-10-18 14:55:32</div>', '三角路社区居民-陈思宇在丰收号小程序中进行了物品兑换'],
['<div class="timeRow">2023-10-18 14:55:32</div>', '三角路社区居民-陈思宇在丰收号小程序中进行了物品兑换'],
['<div class="timeRow">2023-10-18 14:55:32</div>', '三角路社区居民-陈思宇在丰收号小程序中进行了物品兑换'],
// ['<div class="timeRow">2023-10-19 14:55:32</div>', '汇南社区-张三 创建了新的居民群'],
// ['<div class="timeRow">2023-10-19 14:55:32</div>', '汇南社区-张三 邀请居民"蓝天白云"加入居民群“书院社区2群”'],
// ['<div class="timeRow">2023-10-19 14:55:32</div>', '汇南社区-张三 将居民"蓝天白云"踢出居民群 “书院社区2群”'],
// ['<div class="timeRow">2023-10-19 14:55:32</div>', '滨江东路社区居民-陈思宇在丰收号小程序中进行了打卡签到'],
// ['<div class="timeRow">2023-10-19 14:55:32</div>', '滨江东路社区居民-陈思宇在丰收号小程序中进行了积分申请'],
// ['<div class="timeRow">2023-10-19 14:55:32</div>', '滨滨江东路社区居民-陈思宇在丰收号小程序中进行了物品兑换'],
// ['<div class="timeRow">2023-10-18 14:55:32</div>', '三角路社区居民-陈思宇在丰收号小程序中进行了物品兑换'],
// ['<div class="timeRow">2023-10-18 14:55:32</div>', '三角路社区居民-陈思宇在丰收号小程序中进行了物品兑换'],
// ['<div class="timeRow">2023-10-18 14:55:32</div>', '三角路社区居民-陈思宇在丰收号小程序中进行了物品兑换'],
]
},
shortcut: 0
shortcut: 0,
GongdeBank: {},
map: null
}
},
computed: {
tablePages: v => Math.ceil(v.volunteerConfig.data.length / v.volunteerConfig.rowNum) || 0,
shortcuts: () => Object.assign({0: '昨日', 1: '近七天', 2: '近30天', 3: '近一年'})
},
watch: {
shortcut() {
this.getGdyh(this.areaId)
}
},
methods: {
handleFullScreen() {
this.fullscreen = this.$refs.fddv.handleFullScreen()
@@ -283,13 +291,86 @@ export default {
setTimeout(() => this.watchTablePageChange(++c), 500)
}
},
getData() {
getData(c = 0) {
const {areaId} = this.$data
if (areaId) {
this.getMiniAppInfo()
this.getRealTimeDynamic(areaId)
this.getWxGroupOverview(areaId)
this.getGdyh(areaId)
} else if (c < 10) setTimeout(() => this.getData(++c), 500)
else console.error(`尝试${c}次加载数据,无法过去数据`)
},
getMiniAppInfo() {
this.instance.post("/app/fdDiy/miniAppInfo").then(res => {
if (res?.data) {
const data = res.data.map(e => [e.name || "应用", e.lastDayClick, e.totalClick])
this.appSta = {...this.appSta, data}
}
})
},
getRealTimeDynamic(areaId) {
this.instance.post("/app/fdDiy/realTimeDynamic", null, {params: {areaId}}).then(res => {
if (res?.data) {
const data = res.data.map(e => [`<div class="timeRow">${e.eventTime}</div>`, `<div class="flex">${e.bizId ? e.description.replace(e.type, `<div class="blue">${e.type}</div>`) : e.description}</div>`])
this.realtimeEvents = {...this.realtimeEvents, data, meta: res.data}
}
})
},
getWxGroupOverview(areaId) {
this.instance.post("/app/fdDiy/wxGroupOverview", null, {params: {areaId}}).then(res => {
if (res?.data) {
}
})
},
getGdyh(areaId) {
this.instance.post("/app/fdDiy/gdyh", null, {params: {areaId, type: this.shortcut}}).then(res => {
if (res?.data) {
const {
宣发发布任务数,
宣发未审核数,
宣发审核通过数,
店铺总数,
店品库存量 = 0,
兑换物品数量,
获取积分总数: total = 0,
居民签到人次: 签到人数 = 0,
积分申请次数: 申请人数 = 0,
兑换总积分: useTotal = 0
} = res.data
this.GongdeBank = {
total, useTotal,
users: {
参与人数: 签到人数 + 申请人数,
申请人数,
签到人数
},
stores: {店铺总数, 店品库存量, 兑换物品数量},
tasks: {
宣发发布任务数,
审核通过率: (宣发审核通过数 / 宣发发布任务数 * 100 || 0).toFixed(2) + "%",
宣发未审核数,
}
}
}
})
},
handleRealtimeEventDialog({rowIndex}) {
const row = this.realtimeEvents.meta[rowIndex]
if (row.bizId) {
const action = {
积分申请: "",
物品兑换: "",
精选动态: "",
}[row.type]
this.instance.post(action, null, {params: {id: row.bizId}}).then(res => {
if (res?.data) {
}
})
}
console.log(row)
}
},
created() {
@@ -444,6 +525,11 @@ export default {
background-position: 20px center;
text-indent: 24px;
}
.blue {
color: #02FEFF;
cursor: pointer;
}
}
.dots {
@@ -498,7 +584,7 @@ export default {
.boxSta {
margin-top: 16px;
padding-right: 70px;
padding-right: 40px;
justify-content: flex-end;
background: url("./assets/box.png") no-repeat 80px center;
height: 82px;
@@ -506,7 +592,7 @@ export default {
.text {
color: #FFFFFF;
width: 156px;
width: 200px;
justify-content: space-between;
& > p {

View File

@@ -8,6 +8,13 @@ import fdEdge from "../assets/fdEdge.json"
export default {
name: "fdMap",
model: {
prop: "ins",
event: "input"
},
props: {
ins: {default: null}
},
data() {
return {
map: null
@@ -54,6 +61,7 @@ export default {
},
]
})
this.$emit("input", this.map)
} else if (c < 5) setTimeout(() => this.init(++c), 500)
}
},

View File

@@ -1,7 +1,7 @@
<template>
<section class="fengduHead">
<div class="content flex">
<ai-area class="fill" v-model="current" :mask="false" :root="currentRoot">
<ai-area class="fill" v-model="current" :mask="false" :root="currentRoot" @area="v=>$emit('pick',v)">
<template slot-scope="{areaname}">
<el-input class="areaPicker" :value="areaname" readonly suffix-icon="el-icon-arrow-down"/>
</template>
@@ -45,11 +45,11 @@ export default {
active: {
immediate: true,
handler(v) {
if (v != this.current) this.current = this.$copy(this.active)
if (v && v != this.current) this.current = this.$copy(this.active)
}
},
current(v) {
this.$emit("change", v)
v != this.active && this.$emit("change", v)
}
},
created() {

View File

@@ -2,113 +2,113 @@
* Area类用于处理地区相关信息
*/
export default class Area {
/**
* 构造函数
* @param {string} code 地区编码
* @param {Object} hash 哈希表
*/
constructor(code, hash = {}) {
this.id = code
this.level = Area.getLevelByAreaId(code)
this.areaMap = Object.values(this.getAreaInfo(code))
if (Object.keys(hash).length > 0) {
this.getName(this.areaMap.map(id => hash[id]))
/**
* 构造函数
* @param {string} code 地区编码
* @param {Object} hash 哈希表
*/
constructor(code, hash = {}) {
this.id = code
this.level = Area.getLevelByAreaId(code)
this.areaMap = Object.values(this.getAreaInfo(code))
if (Object.keys(hash).length > 0) {
this.getName(this.areaMap.map(id => hash[id]))
}
}
}
/**
* 获取地区的行政等级
* @param {string} code 地区编码
* @returns {number}
*/
static getLevelByAreaId(code) {
if (code) {
if (code.length === 2 || /0{10}$/.test(code)) return 0;
else if (/0{8}$/.test(code)) return 1;
else if (/0{6}$/.test(code)) return 2;
else if (/0{3}$/.test(code)) return 3;
else return 4
} else return -1
}
/**
* 根据地区编码获取指定等级的地区编码
* @param {string} value 地区编码
* @param {number} level 指定等级
* @returns {string|null|*}
*/
static getAreaCodeByLevel(value, level) {
if (value) {
const areaNumber = value.toString();
switch (level) {
case 0:
return areaNumber.substring(0, 2) + '0000000000';
case 1:
return areaNumber.substring(0, 4) + '00000000';
case 2:
return areaNumber.substring(0, 6) + '000000';
case 3:
return areaNumber.substring(0, 9) + '000';
case 4:
return areaNumber
}
} else return null
}
/**
* 根据地区id获取所有父级地区id
* @param {string} areaId 地区id
* @param {Object} ins 请求实例
* @param {string} action 请求地址
* @returns {Promise<Array>} 所有父级地区id
*/
static createByAction(areaId, ins = request, action = "/admin/area/getAllParentAreaId") {
return ins.post(action, null, {params: {areaId}, withoutToken: 1}).then(res => res?.data?.reverse() || [])
}
/**
* 获取地区信息
* @param {string} id 地区id
* @returns {Object} 地区信息
*/
getAreaInfo(id) {
let info = {}
const currentLevel = Area.getLevelByAreaId(id);
for (let i = 0; i <= currentLevel; i++) {
info[i] = Area.getAreaCodeByLevel(id, i);
/**
* 获取地区的行政等级
* @param {string} code 地区编码
* @returns {number}
*/
static getLevelByAreaId(code) {
if (code) {
if (code.length === 2 || /0{10}$/.test(code)) return 0;
else if (/0{8}$/.test(code)) return 1;
else if (/0{6}$/.test(code)) return 2;
else if (/0{3}$/.test(code)) return 3;
else return 4
} else return -1
}
return info
}
/**
* 异步获取地区名称
* @returns {Promise<void>}
*/
async getAreaName() {
const names = await Area.createByAction(this.id);
this.getName(names)
}
/**
* 根据地区编码获取指定等级的地区编码
* @param {string} value 地区编码
* @param {number} level 指定等级
* @returns {string|null|*}
*/
static getAreaCodeByLevel(value, level) {
if (value) {
const areaNumber = value.toString();
switch (level) {
case 0:
return areaNumber.substring(0, 2) + '0000000000';
case 1:
return areaNumber.substring(0, 4) + '00000000';
case 2:
return areaNumber.substring(0, 6) + '000000';
case 3:
return areaNumber.substring(0, 9) + '000';
case 4:
return areaNumber
}
} else return null
}
/**
* 获取地区名称
* @param {Array} names 地区名称数组
*/
getName(names) {
this.meta = names
this.nameMap = names?.map(e => e?.name) || []
this.name = names?.slice(-1)?.[0]?.name
this.fullname = this.nameMap.join('')
}
/**
* 根据地区id获取所有父级地区id
* @param {string} areaId 地区id
* @param {Object} ins 请求实例
* @param {string} action 请求地址
* @returns {Promise<Array>} 所有父级地区id
*/
static createByAction(areaId, ins = request, action = "/admin/area/getAllParentAreaId") {
return ins.post(action, null, {params: {areaId}, withoutToken: 1}).then(res => res?.data?.reverse() || [])
}
/**
* 异步从数据库中获取地区信息
* @param {string} code 地区编码
* @returns {Promise<Area>} Area实例
*/
static async init(code) {
const names = await Area.createByAction(code),
area = new Area(code)
area.getName(names)
return area
}
/**
* 获取地区信息
* @param {string} id 地区id
* @returns {Object} 地区信息
*/
getAreaInfo(id) {
let info = {}
const currentLevel = Area.getLevelByAreaId(id);
for (let i = 0; i <= currentLevel; i++) {
info[i] = Area.getAreaCodeByLevel(id, i);
}
return info
}
/**
* 异步获取地区名称
* @returns {Promise<void>}
*/
async getAreaName() {
const names = await Area.createByAction(this.id);
this.getName(names)
}
/**
* 获取地区名称
* @param {Array} names 地区名称数组
*/
getName(names) {
this.meta = names
this.nameMap = names?.map(e => e?.name) || []
this.name = names?.slice(-1)?.[0]?.name || "无"
this.fullname = this.nameMap.join('')
}
/**
* 异步从数据库中获取地区信息
* @param {string} code 地区编码
* @returns {Promise<Area>} Area实例
*/
static async init(code) {
const names = await Area.createByAction(code),
area = new Area(code)
area.getName(names)
return area
}
}

View File

@@ -12,14 +12,14 @@
</div>
<el-button v-else-if="!customClicker&&!$scopedSlots.default" class="area-btn" type="primary" size="mini"
@click="chooseArea">
{{ btnShowArea ? selectedName : "切换地区" }}
{{ btnShowArea ? selectedArea.name : "切换地区" }}
</el-button>
<a class="custom-clicker" v-else @click="chooseArea">
<slot :areaname="selectedName" :fullname="fullName" :id="selected"/>
<slot :areaname="selectedArea.name" :fullname="fullName" :id="selected"/>
</a>
<ai-dialog :visible.sync="dialog" title="选择地区" width="60%" @onConfirm="confirmArea" :modal="mask"
@open="selected=(value||'')">
<ai-highlight content="您当前选择&nbsp;@v" :value="selectedName" color="#333" bold/>
<ai-highlight content="您当前选择&nbsp;@v" :value="selectedArea.name" color="#333" bold/>
<div class="area_edge">
<div class="area-box" v-for="ops in showOps">
<h2 v-text="ops.header"/>
@@ -85,7 +85,6 @@ export default {
startLevel: v => Math.max(Number(v.hideLevel), 0, v.rootArea.level),//地区最高可选行政地区等级
endLevel: v => Number(v.areaLevel) || 0,//地区最低可选行政地区等级
selectedArea: v => new Area(v.currentArea, v.hashMap),
selectedName: v => v.selectedArea.name || "无",
selectedMap: v => v.selectedArea.areaMap,
validateState: v => ['', 'success'].includes(v.elFormItem?.validateState),
hashMap() {
@@ -230,7 +229,7 @@ export default {
Area.createByAction(this.currentArea, this.instance).then(names => {
this.selectedArea.getName(names)
this.fullName = this.selectedArea.nameMap.join(this.separator)
this.$emit("update:name", this.selectedName)
this.$emit("update:name", this.selectedArea.name)
this.$emit("fullname", this.fullName)
})
}