refactor: 由于valor升级导致ts类型提示错误,不影响使用但是影响观看

master
xjs 2026-04-20 13:43:51 +08:00
parent 5cff6fb924
commit acc7396a9b
65 changed files with 491 additions and 462 deletions

View File

@ -7,7 +7,7 @@
} }
</route> </route>
<template> <template>
<web-view :src="url" @message="handleChildMessage" :update-title="false" /> <web-view :src="url" :update-title="false" />
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@ -20,23 +20,19 @@ const userStore = useUserStore()
//chatv2.ycymedu.com //chatv2.ycymedu.com
const url = ref(``) const url = ref(``)
const handleChildMessage = (event) => {
console.log('子应用传递的消息', event)
}
onLoad((options) => { onLoad((options) => {
getAssistant().then((res) => { getAssistant().then((res) => {
if (res.code === 200) { if (res.code === 200) {
const data = res.result as unknown as string const data = res.result as unknown as string
url.value = `${data}?userId=${userStore.userInfo.estimatedAchievement.wxId}&subjectGroup=${userStore.userInfo.estimatedAchievement.subjectGroup}&expectedScore=${userStore.userInfo.estimatedAchievement.expectedScore}&provinceName=${userStore.userInfo.estimatedAchievement.provinceName}&locationCode=${userStore.userInfo.estimatedAchievement.provinceCode}&token=${userStore.userInfo.token}&timestamp=${new Date().getTime()}` url.value = `${data}?userId=${userStore.userInfo.estimatedAchievement.wxId}&subjectGroup=${userStore.userInfo.estimatedAchievement.subjectGroup}&expectedScore=${userStore.userInfo.estimatedAchievement.expectedScore}&provinceName=${userStore.userInfo.estimatedAchievement.provinceName}&locationCode=${userStore.userInfo.estimatedAchievement.provinceCode}&token=${userStore.userInfo.token}&timestamp=${new Date().getTime()}`
} }
if (options.id) { if (options?.id) {
url.value += `&reportId=${options.id}` url.value += `&reportId=${options.id}`
} }
if (options.type) { if (options?.type) {
url.value += `&reportType=${options.type}` url.value += `&reportType=${options.type}`
} }
if (options.fileId) { if (options?.fileId) {
url.value += `&fileId=${options.fileId}` url.value += `&fileId=${options.fileId}`
} }
}) })

View File

@ -91,7 +91,7 @@ const toSchool = (id: string) => {
} }
const { unSortTypeList } = useUnSortType() const { unSortTypeList } = useUnSortType()
let universityTypeRankList = ref([]) let universityTypeRankList = ref<any[]>([])
const isLoading = ref(true) const isLoading = ref(true)
// //

View File

@ -19,7 +19,7 @@ export const useCityInfo = () => {
const li = groupByFirstLetter(list) const li = groupByFirstLetter(list)
cityStore.setCities(li) cityStore.setCities(li)
const defaultCity = list.filter((item) => item.provincename === '山东省')[0] as City const defaultCity = list.filter((item) => item.provincename === '山东省')[0] as City
if (userStore.userInfo.city.code === '0') { if (userStore.userInfo.city?.code === '0') {
userStore.setUserCity(defaultCity) userStore.setUserCity(defaultCity)
} }
} }
@ -48,12 +48,12 @@ const groupByFirstLetter = (lis: Province[]): { letter: string; provinces: Provi
.map((key) => ({ letter: key, provinces: grouped[key] })) .map((key) => ({ letter: key, provinces: grouped[key] }))
} }
export const newsList = ref([]) export const newsList = ref<News[]>([])
export const useCityNewTop = () => { export const useCityNewTop = () => {
const fetchNewTopFun = (provinceCode) => { const fetchNewTopFun = (provinceCode: string) => {
getNewsTop({ Top: 4, CategoryId: 1, provinceCode }).then((res) => { getNewsTop({ Top: 4, CategoryId: 1, provinceCode }).then((res) => {
if (res.code === 200) { if (res.code === 200) {
newsList.value = res.result as { title: string }[] newsList.value = res.result as News[]
} }
}) })
} }

View File

@ -8,7 +8,7 @@ interface Region {
pinyin: string pinyin: string
} }
export const useRegionInfo = () => { export const useRegionInfo = () => {
const regionList = ref([]) const regionList = ref<any[]>([])
getRegionInfo().then((res) => { getRegionInfo().then((res) => {
if (res.code === 200) { if (res.code === 200) {
regionList.value = res.result as Region[] regionList.value = res.result as Region[]
@ -19,7 +19,7 @@ export const useRegionInfo = () => {
} }
export const useUniversityType = () => { export const useUniversityType = () => {
const typeList = ref([]) const typeList = ref<any[]>([])
getUniversityType().then((res) => { getUniversityType().then((res) => {
if (res.code === 200) { if (res.code === 200) {
typeList.value = res.result as { id: number; name: string }[] typeList.value = res.result as { id: number; name: string }[]
@ -30,7 +30,7 @@ export const useUniversityType = () => {
} }
export const useNatureList = () => { export const useNatureList = () => {
const natureList = ref([]) const natureList = ref<any[]>([])
getNature().then((res) => { getNature().then((res) => {
if (res.code === 200) { if (res.code === 200) {
natureList.value = res.result as { id: number; name: string }[] natureList.value = res.result as { id: number; name: string }[]

View File

@ -4,7 +4,7 @@ import { getUnSortType, getUniversityRank } from '@/service/index/api'
type UnSortType = { type: number; name: string }[] type UnSortType = { type: number; name: string }[]
export const useUnSortType = () => { export const useUnSortType = () => {
let unSortTypeList = ref([]) let unSortTypeList = ref<any[]>([])
getUnSortType().then((res) => { getUnSortType().then((res) => {
unSortTypeList.value = res.result as UnSortType unSortTypeList.value = res.result as UnSortType
}) })
@ -23,7 +23,7 @@ export const useUniversityRank = ({
PageSize: number PageSize: number
PageIndex: number PageIndex: number
}) => { }) => {
let universityRankList = ref([]) let universityRankList = ref<any[]>([])
getUniversityRank({ Year, Type, PageSize, PageIndex }).then((res) => { getUniversityRank({ Year, Type, PageSize, PageIndex }).then((res) => {
if (res.code === 200) { if (res.code === 200) {
const _res = res.result as { rows: any[] } const _res = res.result as { rows: any[] }

View File

@ -83,8 +83,8 @@ const handleClose = () => {
} }
const phone = ref(true) // const phone = ref(true) //
const checked = ref([]) // const checked = ref<any[]>([]) //
const getPhoneInfo = ref(null) const getPhoneInfo = ref<any | null>(null)
const handleClickUserAgreement = () => { const handleClickUserAgreement = () => {
uni.navigateTo({ uni.navigateTo({
@ -165,7 +165,7 @@ const getUserInfo = async (_code: string) => {
getVolunteerInitialization().then((res) => { getVolunteerInitialization().then((res) => {
let list = res.result as any[] let list = res.result as any[]
let code = infoData.userExtend ? infoData.userExtend.provinceCode : '' let code = infoData.userExtend ? infoData.userExtend.provinceCode : ''
let addressItem: City let addressItem: City | null = null
if (code !== '') { if (code !== '') {
for (let i = 0; i < list.length; i++) { for (let i = 0; i < list.length; i++) {
if (list[i].code == code) { if (list[i].code == code) {
@ -173,7 +173,9 @@ const getUserInfo = async (_code: string) => {
} }
} }
} }
userStore.setUserCity(addressItem) if (addressItem) {
userStore.setUserCity(addressItem)
}
handleClose() handleClose()
emits('authReady') emits('authReady')
}) })

View File

@ -78,8 +78,8 @@ import { useLogin } from '@/login-sub/hooks/useUserInfo'
const show = ref(false) const show = ref(false)
const checked = ref([]) // const checked = ref<any[]>([]) //
const getPhoneInfo = ref(null) const getPhoneInfo = ref<any>(null)
const scene = ref('') const scene = ref('')

View File

@ -1,20 +1,28 @@
export const renderEchart = ({ echart, echarts, pieChartData }) => { export const renderEchart = ({
const typeColorMap = { echart,
echarts,
pieChartData,
}: {
echart: any
echarts: any
pieChartData: any
}) => {
const typeColorMap: { [key: string]: any } = {
: { color: '#EB5241', simpleName: '冲' }, : { color: '#EB5241', simpleName: '冲' },
: { color: '#F0BA16', simpleName: '稳' }, : { color: '#F0BA16', simpleName: '稳' },
: { color: '#15C496', simpleName: '保' }, : { color: '#15C496', simpleName: '保' },
} }
const formattedData = pieChartData.value.map((item) => ({ const formattedData = pieChartData.value.map((item: any) => ({
...item, ...item,
itemStyle: { itemStyle: {
color: typeColorMap[item.name]?.color, color: typeColorMap[item.name]?.color,
}, },
label: { label: {
formatter: (params) => typeColorMap[params.name]?.simpleName || params.name, formatter: (params: any) => typeColorMap[params.name]?.simpleName || params.name,
}, },
})) }))
echart.value.init(echarts, (chart) => { echart.value.init(echarts, (chart: any) => {
let option = { let option = {
tooltip: { tooltip: {
trigger: 'item', trigger: 'item',
@ -42,7 +50,7 @@ export const renderEchart = ({ echart, echarts, pieChartData }) => {
}, },
}, },
label: { label: {
formatter: (params) => typeColorMap[params.name]?.simpleName || params.name, formatter: (params: any) => typeColorMap[params.name]?.simpleName || params.name,
}, },
}, },
], ],
@ -66,7 +74,7 @@ export const renderEchart = ({ echart, echarts, pieChartData }) => {
left: 'center', left: 'center',
top: '50%', top: '50%',
style: { style: {
text: formattedData.reduce((acc, curr) => acc + curr.value, 0), text: formattedData.reduce((acc: any, curr: any) => acc + curr.value, 0),
fontSize: 24, fontSize: 24,
fill: '#1F2329', fill: '#1F2329',
textAlign: 'center', textAlign: 'center',

View File

@ -72,10 +72,10 @@ const userStore = useUserStore()
const userInfo = computed(() => userStore.userInfo) const userInfo = computed(() => userStore.userInfo)
const echart = ref(null) const echart = ref<any>(null)
const pieChartData = ref([]) const pieChartData = ref<any[]>([])
const universities = ref([]) const universities = ref<any[]>([])
onLoad(() => { onLoad(() => {
aiPreview({ aiPreview({
location: userInfo.value.estimatedAchievement.provinceCode, location: userInfo.value.estimatedAchievement.provinceCode,

View File

@ -45,7 +45,7 @@ const props = defineProps({
}, },
}) })
const personList = ref([]) const personList = ref<any[]>([])
watch( watch(
() => props.tag, () => props.tag,

View File

@ -34,7 +34,7 @@ const props = defineProps({
}, },
}) })
const majorList = ref([]) const majorList = ref<any[]>([])
watch( watch(
() => props.tag, () => props.tag,

View File

@ -85,7 +85,7 @@ const transformData = (names: string[], values: number[]) => {
return result return result
} }
const characterData = ref([]) const characterData = ref<any[]>([])
watch( watch(
() => props.linChart, () => props.linChart,
(newV) => { (newV) => {

View File

@ -30,7 +30,7 @@
import LEchart from '@/pages-evaluation-sub/uni_modules/lime-echart/components/l-echart/l-echart.vue' import LEchart from '@/pages-evaluation-sub/uni_modules/lime-echart/components/l-echart/l-echart.vue'
import TitleBar from '../TitleBar.vue' import TitleBar from '../TitleBar.vue'
const echarts = require('../../../uni_modules/lime-echart/static/echarts.min') const echarts = require('../../../uni_modules/lime-echart/static/echarts.min')
const echart = ref(null) const echart = ref<any>(null)
const props = defineProps({ const props = defineProps({
mainDomain: { mainDomain: {
@ -57,7 +57,7 @@ const styleConfig = [
{ bg: '#FDF0F0', text: '#F58C8C', size: 45, x: 166, y: 118 }, { bg: '#FDF0F0', text: '#F58C8C', size: 45, x: 166, y: 118 },
] ]
const chartData = ref([]) const chartData = ref<any[]>([])
// //
const selectStylesByLength = (items: string[]) => { const selectStylesByLength = (items: string[]) => {

View File

@ -9,7 +9,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import LEchart from '@/pages-evaluation-sub/uni_modules/lime-echart/components/l-echart/l-echart.vue' import LEchart from '@/pages-evaluation-sub/uni_modules/lime-echart/components/l-echart/l-echart.vue'
const echarts = require('../../../uni_modules/lime-echart/static/echarts.min') const echarts = require('../../../uni_modules/lime-echart/static/echarts.min')
const echart = ref(null) const echart = ref<any>(null)
const props = defineProps({ const props = defineProps({
picData: { picData: {
type: Object, type: Object,

View File

@ -13,7 +13,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import LEchart from '@/pages-evaluation-sub/uni_modules/lime-echart/components/l-echart/l-echart.vue' import LEchart from '@/pages-evaluation-sub/uni_modules/lime-echart/components/l-echart/l-echart.vue'
const echarts = require('../../../uni_modules/lime-echart/static/echarts.min') const echarts = require('../../../uni_modules/lime-echart/static/echarts.min')
const echart = ref(null) const echart = ref<any>(null)
const props = defineProps({ const props = defineProps({
echartData: { echartData: {

View File

@ -9,7 +9,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import LEchart from '@/pages-evaluation-sub/uni_modules/lime-echart/components/l-echart/l-echart.vue' import LEchart from '@/pages-evaluation-sub/uni_modules/lime-echart/components/l-echart/l-echart.vue'
const echarts = require('../../../uni_modules/lime-echart/static/echarts.min') const echarts = require('../../../uni_modules/lime-echart/static/echarts.min')
const echart = ref(null) const echart = ref<any>(null)
interface IndicatorItem { interface IndicatorItem {
name: string name: string

View File

@ -9,7 +9,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import LEchart from '@/pages-evaluation-sub/uni_modules/lime-echart/components/l-echart/l-echart.vue' import LEchart from '@/pages-evaluation-sub/uni_modules/lime-echart/components/l-echart/l-echart.vue'
const echarts = require('../../../uni_modules/lime-echart/static/echarts.min') const echarts = require('../../../uni_modules/lime-echart/static/echarts.min')
const echart = ref(null) const echart = ref<any>(null)
</script> </script>
<script lang="scss" scoped></script> <script lang="scss" scoped></script>

View File

@ -32,7 +32,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import LEchart from '@/pages-evaluation-sub/uni_modules/lime-echart/components/l-echart/l-echart.vue' import LEchart from '@/pages-evaluation-sub/uni_modules/lime-echart/components/l-echart/l-echart.vue'
const echarts = require('../../../uni_modules/lime-echart/static/echarts.min') const echarts = require('../../../uni_modules/lime-echart/static/echarts.min')
const echart = ref(null) const echart = ref<any>(null)
const props = defineProps({ const props = defineProps({
picData: { picData: {
@ -45,7 +45,7 @@ const props = defineProps({
}, },
}) })
const innerParsing = ref([]) const innerParsing = ref<any[]>([])
const policy = ref({ items: [] }) const policy = ref({ items: [] })
watch( watch(

View File

@ -99,7 +99,7 @@ const calcLevel = (val: string) => {
} }
} }
onLoad((options) => { onLoad((options: any) => {
pageType.value = +options.type pageType.value = +options.type
pageId.value = options.id pageId.value = options.id

View File

@ -112,9 +112,9 @@ const calcLevel = (val: string) => {
} }
} }
const suggestions = ref([]) const suggestions = ref<any[]>([])
onLoad((options) => { onLoad((options: any) => {
pageType.value = +options.type pageType.value = +options.type
pageId.value = options.id pageId.value = options.id

View File

@ -60,9 +60,9 @@ const studyRecord = ref({
suggestions: '', suggestions: '',
}) })
const chartData = ref([]) const chartData = ref<any[]>([])
const parsing = ref('') const parsing = ref('')
const suggestions = ref([]) const suggestions = ref<any[]>([])
onLoad((options) => { onLoad((options) => {
pageType.value = +options.type pageType.value = +options.type

View File

@ -97,9 +97,9 @@ const calcLevel = (val: string) => {
} }
} }
const suggestions = ref([]) const suggestions = ref<any[]>([])
onLoad((options) => { onLoad((options: any) => {
pageType.value = +options.type pageType.value = +options.type
pageId.value = options.id pageId.value = options.id

View File

@ -112,9 +112,9 @@ const calcLevel = (val: string) => {
} }
} }
const suggestions = ref([]) const suggestions = ref<any[]>([])
onLoad((options) => { onLoad((options: any) => {
pageType.value = +options.type pageType.value = +options.type
pageId.value = options.id pageId.value = options.id

View File

@ -60,9 +60,9 @@ const studyRecord = ref({
suggestions: '', suggestions: '',
}) })
const chartData = ref([]) const chartData = ref<any[]>([])
const parsing = ref('') const parsing = ref('')
const suggestions = ref([]) const suggestions = ref<any[]>([])
onLoad((options) => { onLoad((options) => {
pageType.value = +options.type pageType.value = +options.type

View File

@ -18,7 +18,7 @@ interface Region {
simplename: string simplename: string
pinyin: string pinyin: string
} }
const regionList = ref([]) const regionList = ref<any[]>([])
getRegionInfo().then((res) => { getRegionInfo().then((res) => {
if (res.code === 200) { if (res.code === 200) {
regionList.value = res.result as Region[] regionList.value = res.result as Region[]

View File

@ -150,13 +150,13 @@ const handleConfirm = () => {
getScoreSectionData() getScoreSectionData()
} }
const checkYearList = ref([]) const checkYearList = ref<any[]>([])
const dropMenuRef = ref() const dropMenuRef = ref()
const handleYearChange = (val) => { const handleYearChange = (val: any) => {
let _yearList = [] let _yearList = []
if (val.length > 1 && val.some((item) => item === '')) { if (val.length > 1 && val.some((item: any) => item === '')) {
_yearList = val.filter((item) => item !== '') _yearList = val.filter((item: any) => item !== '')
} else { } else {
_yearList = val _yearList = val
} }
@ -224,7 +224,7 @@ const getScoreSectionData = () => {
}) })
} }
const echart = ref(null) const echart = ref<any>(null)
onLoad(() => { onLoad(() => {
getScoreSectionData() getScoreSectionData()

View File

@ -1,33 +1,36 @@
# echarts 图表 <span style="font-size:16px;">👑👑👑👑👑 <span style="background:#ff9d00;padding:2px 4px;color:#fff;font-size:10px;border-radius: 3px;">全端</span></span> # echarts 图表 <span style="font-size:16px;">👑👑👑👑👑 <span style="background:#ff9d00;padding:2px 4px;color:#fff;font-size:10px;border-radius: 3px;">全端</span></span>
> 一个基于 JavaScript 的开源可视化图表库 [查看更多](https://limeui.qcoon.cn/#/echart) <br>
> 基于 echarts 做了兼容处理,更多示例请访问 [uni示例](https://limeui.qcoon.cn/#/echart-example) | [官方示例](https://echarts.apache.org/examples/zh/index.html) <br>
> 一个基于 JavaScript 的开源可视化图表库 [查看更多](https://limeui.qcoon.cn/#/echart) <br>
> 基于 echarts 做了兼容处理,更多示例请访问 [uni示例](https://limeui.qcoon.cn/#/echart-example) | [官方示例](https://echarts.apache.org/examples/zh/index.html) <br>
## 平台兼容 ## 平台兼容
| H5 | 微信小程序 | 支付宝小程序 | 百度小程序 | 头条小程序 | QQ 小程序 | App | | H5 | 微信小程序 | 支付宝小程序 | 百度小程序 | 头条小程序 | QQ 小程序 | App |
| --- | ---------- | ------------ | ---------- | ---------- | --------- | ---- | | --- | ---------- | ------------ | ---------- | ---------- | --------- | --- |
| √ | √ | √ | √ | √ | √ | √ | | √ | √ | √ | √ | √ | √ | √ |
## 安装 ## 安装
- 第一步:在市场导入 [百度图表](https://ext.dcloud.net.cn/plugin?id=4899)
- 第一步:在市场导入 [百度图表](https://ext.dcloud.net.cn/plugin?id=4899)
- 第二步:选择插件依赖:<br> - 第二步:选择插件依赖:<br>
1、可以选插件内的`echarts`包或自定义包,自定义包[下载地址](https://echarts.apache.org/zh/builder.html)<br> 1、可以选插件内的`echarts`包或自定义包,自定义包[下载地址](https://echarts.apache.org/zh/builder.html)<br>
2、或者使用`npm`安装`echarts` 2、或者使用`npm`安装`echarts`
**注意** **注意**
* 🔔 echarts 5.3.0及以上
* 🔔 如果是 `cli` 项目请下载插件到`src`目录下的`uni_modules`,没有这个目录就创建一个
- 🔔 echarts 5.3.0及以上
- 🔔 如果是 `cli` 项目请下载插件到`src`目录下的`uni_modules`,没有这个目录就创建一个
## 代码演示 ## 代码演示
### Vue2 ### Vue2
- 引入依赖,可以是插件内提供或自己下载的[自定义包](https://echarts.apache.org/zh/builder.html),也可以是`npm`包 - 引入依赖,可以是插件内提供或自己下载的[自定义包](https://echarts.apache.org/zh/builder.html),也可以是`npm`包
```html ```html
<view style="width:750rpx; height:750rpx"><l-echart ref="chartRef" @finished="init"></l-echart></view> <view style="width:750rpx; height:750rpx">
<l-echart ref="chartRef" @finished="init"></l-echart>
</view>
``` ```
```js ```js
@ -41,234 +44,231 @@ import * as echarts from 'echarts'
```js ```js
export default { export default {
data() { data() {
return { return {
option: { option: {
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
axisPointer: { axisPointer: {
type: 'shadow' type: 'shadow',
}, },
confine: true confine: true,
}, },
legend: { legend: {
data: ['热度', '正面', '负面'] data: ['热度', '正面', '负面'],
}, },
grid: { grid: {
left: 20, left: 20,
right: 20, right: 20,
bottom: 15, bottom: 15,
top: 40, top: 40,
containLabel: true containLabel: true,
}, },
xAxis: [ xAxis: [
{ {
type: 'value', type: 'value',
axisLine: { axisLine: {
lineStyle: { lineStyle: {
color: '#999999' color: '#999999',
} },
}, },
axisLabel: { axisLabel: {
color: '#666666' color: '#666666',
} },
} },
], ],
yAxis: [ yAxis: [
{ {
type: 'category', type: 'category',
axisTick: { show: false }, axisTick: { show: false },
data: ['汽车之家', '今日头条', '百度贴吧', '一点资讯', '微信', '微博', '知乎'], data: ['汽车之家', '今日头条', '百度贴吧', '一点资讯', '微信', '微博', '知乎'],
axisLine: { axisLine: {
lineStyle: { lineStyle: {
color: '#999999' color: '#999999',
} },
}, },
axisLabel: { axisLabel: {
color: '#666666' color: '#666666',
} },
} },
], ],
series: [ series: [
{ {
name: '热度', name: '热度',
type: 'bar', type: 'bar',
label: { label: {
normal: { normal: {
show: true, show: true,
position: 'inside' position: 'inside',
} },
}, },
data: [300, 270, 340, 344, 300, 320, 310], data: [300, 270, 340, 344, 300, 320, 310],
}, },
{ {
name: '正面', name: '正面',
type: 'bar', type: 'bar',
stack: '总量', stack: '总量',
label: { label: {
normal: { normal: {
show: true show: true,
} },
}, },
data: [120, 102, 141, 174, 190, 250, 220] data: [120, 102, 141, 174, 190, 250, 220],
}, },
{ {
name: '负面', name: '负面',
type: 'bar', type: 'bar',
stack: '总量', stack: '总量',
label: { label: {
normal: { normal: {
show: true, show: true,
position: 'left' position: 'left',
} },
}, },
data: [-20, -32, -21, -34, -90, -130, -110] data: [-20, -32, -21, -34, -90, -130, -110],
} },
] ],
}, },
}; }
}, },
// 组件能被调用必须是组件的节点已经被渲染到页面上 // 组件能被调用必须是组件的节点已经被渲染到页面上
methods: { methods: {
async init() { async init() {
// chart 图表实例不能存在data里 // chart 图表实例不能存在data里
const chart = await this.$refs.chartRef.init(echarts); const chart = await this.$refs.chartRef.init(echarts)
chart.setOption(this.option) chart.setOption(this.option)
} },
} },
} }
``` ```
### Vue3 ### Vue3
- 小程序可以使用`require`引入插件内提供或自己下载的[自定义包](https://echarts.apache.org/zh/builder.html) - 小程序可以使用`require`引入插件内提供或自己下载的[自定义包](https://echarts.apache.org/zh/builder.html)
- `require`仅支持相对路径,不支持路径别名 - `require`仅支持相对路径,不支持路径别名
- 非小程序使用 `npm` - 非小程序使用 `npm`
```html ```html
<view style="width:750rpx; height:750rpx"><l-echart ref="chartRef"></l-echart></view> <view style="width:750rpx; height:750rpx"><l-echart ref="chartRef"></l-echart></view>
``` ```
```js ```js
// 小程序 二选一 // 小程序 二选一
// 插件内的 二选一 // 插件内的 二选一
const echarts = require('../../uni_modules/lime-echart/static/echarts.min'); const echarts = require('../../uni_modules/lime-echart/static/echarts.min')
// 自定义的 二选一 下载后放入项目的路径 // 自定义的 二选一 下载后放入项目的路径
const echarts = require('xxx/xxx/echarts'); const echarts = require('xxx/xxx/echarts')
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// 非小程序 // 非小程序
// 需要在控制台 输入命令npm install echarts // 需要在控制台 输入命令npm install echarts
import * as echarts from 'echarts' import * as echarts from 'echarts'
``` ```
```js ```js
const chartRef = ref < any > null
const chartRef = ref(null)
const option = { const option = {
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
axisPointer: { axisPointer: {
type: 'shadow' type: 'shadow',
}, },
confine: true confine: true,
}, },
legend: { legend: {
data: ['热度', '正面', '负面'] data: ['热度', '正面', '负面'],
}, },
grid: { grid: {
left: 20, left: 20,
right: 20, right: 20,
bottom: 15, bottom: 15,
top: 40, top: 40,
containLabel: true containLabel: true,
}, },
xAxis: [ xAxis: [
{ {
type: 'value', type: 'value',
axisLine: { axisLine: {
lineStyle: { lineStyle: {
color: '#999999' color: '#999999',
} },
}, },
axisLabel: { axisLabel: {
color: '#666666' color: '#666666',
} },
} },
], ],
yAxis: [ yAxis: [
{ {
type: 'category', type: 'category',
axisTick: { show: false }, axisTick: { show: false },
data: ['汽车之家', '今日头条', '百度贴吧', '一点资讯', '微信', '微博', '知乎'], data: ['汽车之家', '今日头条', '百度贴吧', '一点资讯', '微信', '微博', '知乎'],
axisLine: { axisLine: {
lineStyle: { lineStyle: {
color: '#999999' color: '#999999',
} },
}, },
axisLabel: { axisLabel: {
color: '#666666' color: '#666666',
} },
} },
], ],
series: [ series: [
{ {
name: '热度', name: '热度',
type: 'bar', type: 'bar',
label: { label: {
normal: { normal: {
show: true, show: true,
position: 'inside' position: 'inside',
} },
}, },
data: [300, 270, 340, 344, 300, 320, 310], data: [300, 270, 340, 344, 300, 320, 310],
}, },
{ {
name: '正面', name: '正面',
type: 'bar', type: 'bar',
stack: '总量', stack: '总量',
label: { label: {
normal: { normal: {
show: true show: true,
} },
}, },
data: [120, 102, 141, 174, 190, 250, 220] data: [120, 102, 141, 174, 190, 250, 220],
}, },
{ {
name: '负面', name: '负面',
type: 'bar', type: 'bar',
stack: '总量', stack: '总量',
label: { label: {
normal: { normal: {
show: true, show: true,
position: 'left' position: 'left',
} },
}, },
data: [-20, -32, -21, -34, -90, -130, -110] data: [-20, -32, -21, -34, -90, -130, -110],
} },
] ],
}; }
onMounted(() => {
onMounted( ()=>{ // 组件能被调用必须是组件的节点已经被渲染到页面上
// 组件能被调用必须是组件的节点已经被渲染到页面上 setTimeout(async () => {
setTimeout(async()=>{ if (!chartRef.value) return
if(!chartRef.value) return const myChart = await chartRef.value.init(echarts)
const myChart = await chartRef.value.init(echarts) myChart.setOption(option)
myChart.setOption(option) }, 300)
},300)
}) })
``` ```
### Uvue ### Uvue
- Uvue和Nvue不需要引入`echarts`,因为它们的实现方式是`webview` - Uvue和Nvue不需要引入`echarts`,因为它们的实现方式是`webview`
- uniapp x需要HBX 4.13以上 - uniapp x需要HBX 4.13以上
```html ```html
<view style="width: 100%; height: 408px;"> <view style="width: 100%; height: 408px;">
<l-echart ref="chartRef" @finished="init"></l-echart> <l-echart ref="chartRef" @finished="init"></l-echart>
</view> </view>
``` ```
@ -290,8 +290,8 @@ const init = async () => {
} }
``` ```
## 数据更新 ## 数据更新
- 1、使用 `ref` 可获取`setOption`设置更新 - 1、使用 `ref` 可获取`setOption`设置更新
- 2、也可以拿到图表实例`chart`设置`myChart.setOption(data)` - 2、也可以拿到图表实例`chart`设置`myChart.setOption(data)`
@ -304,42 +304,47 @@ myChart.setOption(data)
``` ```
## 图表大小 ## 图表大小
- 在有些场景下,我们希望当容器大小改变时,图表的大小也相应地改变。 - 在有些场景下,我们希望当容器大小改变时,图表的大小也相应地改变。
```js ```js
// 默认获取容器尺寸 // 默认获取容器尺寸
this.$refs.chart.resize() this.$refs.chart.resize()
// 指定尺寸 // 指定尺寸
this.$refs.chart.resize({width: 375, height: 375}) this.$refs.chart.resize({ width: 375, height: 375 })
``` ```
## 自定义Tooltips ## 自定义Tooltips
- uvue\nvue 不支持 - uvue\nvue 不支持
由于除H5之外都不存在dom但又有tooltips个性化的需求代码就不贴了看示例吧 由于除H5之外都不存在dom但又有tooltips个性化的需求代码就不贴了看示例吧
``` ```
代码位于/uni_modules/lime-echart/component/lime-echart 代码位于/uni_modules/lime-echart/component/lime-echart
``` ```
## 插件标签 ## 插件标签
- 默认 l-echart 为 component - 默认 l-echart 为 component
- 默认 lime-echart 为 demo - 默认 lime-echart 为 demo
```html ```html
// 在任意地方使用可查看domo, 代码位于/uni_modules/lime-echart/component/lime-echart // 在任意地方使用可查看domo, 代码位于/uni_modules/lime-echart/component/lime-echart
<lime-echart></lime-echart> <lime-echart></lime-echart>
``` ```
## 常见问题 ## 常见问题
- 钉钉小程序 由于没有`measureText`,模拟的`measureText`又无法得到当前字体的`fontWeight`,故可能存在估计不精细的问题 - 钉钉小程序 由于没有`measureText`,模拟的`measureText`又无法得到当前字体的`fontWeight`,故可能存在估计不精细的问题
- 微信小程序 `2d` 只支持 真机调试2.0 - 微信小程序 `2d` 只支持 真机调试2.0
- 微信开发工具会出现 `canvas` 不跟随页面的情况,真机不影响 - 微信开发工具会出现 `canvas` 不跟随页面的情况,真机不影响
- 微信开发工具会出现 `canvas` 层级过高的问题,真机一般不受影响,可以先测只有两个元素的页面看是否会有层级问题。 - 微信开发工具会出现 `canvas` 层级过高的问题,真机一般不受影响,可以先测只有两个元素的页面看是否会有层级问题。
- toolbox 不支持 `saveImage` - toolbox 不支持 `saveImage`
- echarts 5.3.0 的 lines 不支持 trailLength故需设置为 `0` - echarts 5.3.0 的 lines 不支持 trailLength故需设置为 `0`
- dataZoom H5不要设置 `showDetail` - dataZoom H5不要设置 `showDetail`
- 如果微信小程序的`tooltip`文字有阴影,可能是微信的锅,临时解决方法是`tooltip.shadowBlur = 0` - 如果微信小程序的`tooltip`文字有阴影,可能是微信的锅,临时解决方法是`tooltip.shadowBlur = 0`
- 如果钉钉小程序上传时报安全问题`Uint8Clamped`,可以向钉钉反馈是安全代码扫描把Uint8Clamped数组错误识别了也可以在 echarts 文件修改`Uint8Clamped` - 如果钉钉小程序上传时报安全问题`Uint8Clamped`,可以向钉钉反馈是安全代码扫描把Uint8Clamped数组错误识别了也可以在 echarts 文件修改`Uint8Clamped`
```js ```js
// 找到这段代码把代码中`Uint8Clamped`改成`Uint8_Clamped`,再把下划线去掉,不过直接去掉`Uint8Clamped`也是可行的 // 找到这段代码把代码中`Uint8Clamped`改成`Uint8_Clamped`,再把下划线去掉,不过直接去掉`Uint8Clamped`也是可行的
// ["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64"],(function(t,e){return t["[object "+e+"Array]"] // ["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64"],(function(t,e){return t["[object "+e+"Array]"]
@ -348,6 +353,7 @@ this.$refs.chart.resize({width: 375, height: 375})
``` ```
### vue3 ### vue3
如果您是使用 **vite + vue3** 非微信小程序可能会遇到`echarts`文件缺少`wx`判断导致无法使用或缺少`tooltip`<br> 如果您是使用 **vite + vue3** 非微信小程序可能会遇到`echarts`文件缺少`wx`判断导致无法使用或缺少`tooltip`<br>
方式一:可以在`echarts.min.js`文件开头增加以下内容参考插件内的echart.min.js的做法 方式一:可以在`echarts.min.js`文件开头增加以下内容参考插件内的echart.min.js的做法
@ -362,47 +368,46 @@ let wx = uni
```js ```js
// 或者在`vite.config.js`的`define`设置环境 // 或者在`vite.config.js`的`define`设置环境
import { defineConfig } from 'vite'; import { defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'; import uni from '@dcloudio/vite-plugin-uni'
const define = {} const define = {}
if(!["mp-weixin", "h5", "web"].includes(process.env.UNI_PLATFORM)) { if (!['mp-weixin', 'h5', 'web'].includes(process.env.UNI_PLATFORM)) {
define['global'] = null define['global'] = null
define['wx'] = 'uni' define['wx'] = 'uni'
} }
export default defineConfig({ export default defineConfig({
plugins: [uni()], plugins: [uni()],
define define,
}); })
``` ```
## Props ## Props
| 参数 | 说明 | 类型 | 默认值 | 版本 | | 参数 | 说明 | 类型 | 默认值 | 版本 |
| --------------- | -------- | ------- | ------------ | ----- | | ----------------- | -------------------------- | --------- | ------- | ---- |
| custom-style | 自定义样式 | `string` | - | - | | custom-style | 自定义样式 | `string` | - | - |
| type | 指定 canvas 类型 | `string` | `2d` | | | type | 指定 canvas 类型 | `string` | `2d` | |
| is-disable-scroll | 触摸图表时是否禁止页面滚动 | `boolean` | `false` | | | is-disable-scroll | 触摸图表时是否禁止页面滚动 | `boolean` | `false` | |
| beforeDelay | 延迟初始化 (毫秒) | `number` | `30` | | | beforeDelay | 延迟初始化 (毫秒) | `number` | `30` | |
| enableHover | PC端使用鼠标悬浮 | `boolean` | `false` | | | enableHover | PC端使用鼠标悬浮 | `boolean` | `false` | |
| landscape | 是否旋转90deg,模拟横屏效果 | `boolean` | `false` | | | landscape | 是否旋转90deg,模拟横屏效果 | `boolean` | `false` | |
## 事件 ## 事件
| 参数 | 说明 | | 参数 | 说明 |
| --------------- | --------------- | | --------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
| init(echarts, chart => {}) | 初始化调用函数,第一个参数是传入`echarts`,第二个参数是回调函数,回调函数的参数是 `chart` 实例 | | init(echarts, chart => {}) | 初始化调用函数,第一个参数是传入`echarts`,第二个参数是回调函数,回调函数的参数是 `chart` 实例 |
| setChart(chart => {}) | 已经初始化后,请使用这个方法,是个回调函数,参数是 `chart` 实例 | | setChart(chart => {}) | 已经初始化后,请使用这个方法,是个回调函数,参数是 `chart` 实例 |
| setOption(data) | [图表配置项](https://echarts.apache.org/zh/option.html#title),用于更新 ,传递是数据 `option` | | setOption(data) | [图表配置项](https://echarts.apache.org/zh/option.html#title),用于更新 ,传递是数据 `option` |
| clear() | 清空当前实例,会移除实例中所有的组件和图表。 | | clear() | 清空当前实例,会移除实例中所有的组件和图表。 |
| dispose() | 销毁实例 | | dispose() | 销毁实例 |
| showLoading() | 显示加载 | | showLoading() | 显示加载 |
| hideLoading() | 隐藏加载 | | hideLoading() | 隐藏加载 |
| [canvasToTempFilePath](https://uniapp.dcloud.io/api/canvas/canvasToTempFilePath.html#canvastotempfilepath)(opt) | 用于生成图片,与官方使用方法一致,但不需要传`canvasId` | | [canvasToTempFilePath](https://uniapp.dcloud.io/api/canvas/canvasToTempFilePath.html#canvastotempfilepath)(opt) | 用于生成图片,与官方使用方法一致,但不需要传`canvasId` |
## 打赏 ## 打赏
如果你觉得本插件,解决了你的问题,赠人玫瑰,手留余香。 如果你觉得本插件,解决了你的问题,赠人玫瑰,手留余香。
![](https://testingcf.jsdelivr.net/gh/liangei/image@1.9/alipay.png) ![](https://testingcf.jsdelivr.net/gh/liangei/image@1.9/alipay.png)
![](https://testingcf.jsdelivr.net/gh/liangei/image@1.9/wpay.png) ![](https://testingcf.jsdelivr.net/gh/liangei/image@1.9/wpay.png)

View File

@ -25,7 +25,7 @@ import Checkbox from './Checkbox.vue'
import CheckboxGroup from './CheckboxGroup.vue' import CheckboxGroup from './CheckboxGroup.vue'
const props = defineProps({ const props = defineProps({
list: { list: {
type: Array, type: Array<any>,
default: () => [], default: () => [],
}, },
labelKey: { labelKey: {

View File

@ -4,7 +4,7 @@
</view> </view>
</template> </template>
<script setup> <script setup lang="ts">
import { ref, computed, watch, provide, onMounted, nextTick } from 'vue' import { ref, computed, watch, provide, onMounted, nextTick } from 'vue'
const props = defineProps({ const props = defineProps({
@ -26,8 +26,8 @@ const props = defineProps({
const emit = defineEmits(['change', 'activeItem', 'input', 'update:modelValue']) const emit = defineEmits(['change', 'activeItem', 'input', 'update:modelValue'])
// //
const childrens = ref([]) const childrens = ref<any[]>([])
const names = ref([]) const names = ref<any[]>([])
// 使 vue2 vue3 // 使 vue2 vue3
const dataValue = computed(() => { const dataValue = computed(() => {
@ -38,25 +38,25 @@ const dataValue = computed(() => {
return props.value return props.value
}) })
// //
const emitValue = (val) => { const emitValue = (val: any) => {
emit('input', val) emit('input', val)
emit('update:modelValue', val) emit('update:modelValue', val)
} }
// //
const register = (childInstance) => { const register = (childInstance: any) => {
childrens.value.push(childInstance) childrens.value.push(childInstance)
} }
// //
const unregister = (childInstance) => { const unregister = (childInstance: any) => {
const index = childrens.value.findIndex((child) => child.nameSync === childInstance.nameSync) const index = childrens.value.findIndex((child) => child.nameSync === childInstance.nameSync)
if (index !== -1) { if (index !== -1) {
childrens.value.splice(index, 1) childrens.value.splice(index, 1)
} }
} }
// - // -
const setOpen = (val) => { const setOpen = (val: any) => {
// //
const isString = typeof val === 'string' || typeof val === 'number' const isString = typeof val === 'string' || typeof val === 'number'
const isArray = Array.isArray(val) const isArray = Array.isArray(val)
@ -110,7 +110,7 @@ watch(
) )
// - // -
const setAccordion = (self) => { const setAccordion = (self: any) => {
if (!props.accordion) return if (!props.accordion) return
childrens.value.forEach((vm) => { childrens.value.forEach((vm) => {
@ -143,7 +143,7 @@ const resize = () => {
} }
// //
const onChange = (isOpen, self) => { const onChange = (isOpen: any, self: any) => {
let activeItem = '' let activeItem = ''
if (props.accordion) { if (props.accordion) {
@ -151,7 +151,7 @@ const onChange = (isOpen, self) => {
activeItem = isOpen ? self.nameSync : '' activeItem = isOpen ? self.nameSync : ''
} else { } else {
// //
const activeItems = [] const activeItems: any = []
childrens.value.forEach((vm) => { childrens.value.forEach((vm) => {
if (vm.isOpen) { if (vm.isOpen) {
activeItems.push(vm.nameSync) activeItems.push(vm.nameSync)
@ -181,7 +181,7 @@ provide('uniCollapseContext', {
: [] : []
} }
// //
return Array.isArray(dataValue.value) ? dataValue.value.map((v) => v.toString()) : [] return Array.isArray(dataValue.value) ? dataValue.value.map((v: any) => v.toString()) : []
}, },
}) })

View File

@ -132,10 +132,10 @@ const props = defineProps({
// IDbug // IDbug
const elId = ref(`Uni_${Math.ceil(Math.random() * 10e5).toString(36)}`) const elId = ref(`Uni_${Math.ceil(Math.random() * 10e5).toString(36)}`)
const isOpen = ref(false) const isOpen = ref(false)
const isheight = ref(null) const isheight = ref < any > null
const height = ref(0) const height = ref(0)
const nameSync = ref('0') const nameSync = ref('0')
const collapseHook = ref(null) const collapseHook = ref < any > null
const proxy = getCurrentInstance() const proxy = getCurrentInstance()
// //

View File

@ -114,7 +114,7 @@ const handleBack = () => {
uni.navigateBack() uni.navigateBack()
} }
const checkedList = ref([]) const checkedList = ref<any[]>([])
const answerMap = new Map() const answerMap = new Map()
const disableBtn = ref(true) const disableBtn = ref(true)
const handleCheckChange = (value: any[]) => { const handleCheckChange = (value: any[]) => {
@ -155,7 +155,7 @@ const calcScore = () => {
// //
const currentIndex = ref(0) const currentIndex = ref(0)
const questions = ref([]) const questions = ref<any[]>([])
const questionType = ref(-1) const questionType = ref(-1)
const questionName = ref('') const questionName = ref('')

View File

@ -71,7 +71,7 @@ const badgeValue = ref(1)
const filterMenuRef = ref() const filterMenuRef = ref()
const handleChange = (params) => { const handleChange = (params: any) => {
badgeValue.value = params.length badgeValue.value = params.length
} }
@ -96,7 +96,7 @@ const handleResult = () => {
let _major = { let _major = {
...item, ...item,
name: item.universityName, name: item.universityName,
vItems: item.majorItems.map((majorItem) => ({ vItems: item.majorItems.map((majorItem: any) => ({
...majorItem, ...majorItem,
name: majorItem.majorName, name: majorItem.majorName,
items: majorItem.planItems, items: majorItem.planItems,

View File

@ -30,8 +30,8 @@ const props = defineProps({
}, },
}) })
const menus = ref([]) const menus = ref<any[]>([])
const currentMenuObj = ref(null) const currentMenuObj = ref<any>(null)
const changeMenu = (item: any) => { const changeMenu = (item: any) => {
currentMenuObj.value = item currentMenuObj.value = item

View File

@ -161,7 +161,7 @@ const professionInfo = ref<ProfessionInfo>({
const professionId = ref('') const professionId = ref('')
onLoad((options) => { onLoad((options) => {
professionId.value = options.id professionId.value = options?.id
getProfessionInfo({ id: professionId.value }).then((resp) => { getProfessionInfo({ id: professionId.value }).then((resp) => {
if (resp.code === 200) { if (resp.code === 200) {
professionInfo.value = resp.result as ProfessionInfo professionInfo.value = resp.result as ProfessionInfo

View File

@ -62,7 +62,7 @@ watch(
}, },
) )
const tableData = ref([]) const tableData = ref<any[]>([])
const show = ref(false) const show = ref(false)
let originTableData = [] let originTableData = []

View File

@ -54,13 +54,13 @@ const batche = ref(batchList[0])
const batches = ref(batchList) const batches = ref(batchList)
const year = ref('') const year = ref('')
const yearList = ref([]) const yearList = ref<any[]>([])
const pickList = ref([]) const pickList = ref<any[]>([])
const pickValue = ref('') const pickValue = ref('')
let pickType = 1 let pickType = 1
const tableData = ref([]) const tableData = ref<any[]>([])
let isFirst = true let isFirst = true
watch( watch(

View File

@ -79,13 +79,13 @@ const batches = ref(batchList)
const provinceName = userStore.userInfo.estimatedAchievement.provinceName const provinceName = userStore.userInfo.estimatedAchievement.provinceName
const year = ref('') const year = ref('')
const yearList = ref([]) const yearList = ref<any[]>([])
const pickList = ref([]) const pickList = ref<any[]>([])
const pickValue = ref('') const pickValue = ref('')
let pickType = 1 let pickType = 1
const tableData = ref([]) const tableData = ref<any[]>([])
let isFirst = true let isFirst = true
watch( watch(

View File

@ -162,9 +162,9 @@
import { getSubjectIntroduceList } from '@/service/index/api' import { getSubjectIntroduceList } from '@/service/index/api'
import ActionSheet from '@/pages-sub/components/ActionSheet.vue' import ActionSheet from '@/pages-sub/components/ActionSheet.vue'
const subjectIntroduceList = ref([]) const subjectIntroduceList = ref<any[]>([])
const assessmentSubjectList = ref([]) const assessmentSubjectList = ref<any[]>([])
const featureSubjectList = ref([]) const featureSubjectList = ref<any[]>([])
const props = defineProps({ const props = defineProps({
id: { id: {
type: Number, type: Number,

View File

@ -85,9 +85,9 @@ const provinceCode = ref([userStore.userInfo.city.code])
const year = ref(0) const year = ref(0)
const pickList = ref([]) const pickList = ref<any[]>([])
const tableData = ref([]) const tableData = ref<any[]>([])
watch( watch(
() => props.id, () => props.id,

View File

@ -137,21 +137,21 @@ const subMenu = ref([
const dropMenuRef = ref() const dropMenuRef = ref()
const regionInfo = ref([]) // const regionInfo = ref<any[]>([]) //
const uniTypeInfo = ref([]) // const uniTypeInfo = ref<any[]>([]) //
const natureInfo = ref([]) // const natureInfo = ref<any[]>([]) //
const regionKeyInfo = ref([]) // const regionKeyInfo = ref<any[]>([]) //
const uniTypeKeyInfo = ref([]) // const uniTypeKeyInfo = ref<any[]>([]) //
const natureKeyInfo = ref([]) // const natureKeyInfo = ref<any[]>([]) //
const currentMenu = ref(1) const currentMenu = ref(1)
const handleOpenSubMenu = (id: number) => { const handleOpenSubMenu = (id: number) => {
currentMenu.value = id currentMenu.value = id
} }
const schoolList = ref([]) const schoolList = ref<any[]>([])
const paging = ref(null) const paging = ref<any>(null)
const queryList = (page: number, pageSize: number) => { const queryList = (page: number, pageSize: number) => {
getUniversityList({ getUniversityList({

View File

@ -109,18 +109,18 @@ const changeMenu = (item: { id: number; name: string }) => {
currentMenu.value = item.id currentMenu.value = item.id
} }
const defaultRegion = ref([]) const defaultRegion = ref<any[]>([])
const defaultNature = ref([]) const defaultNature = ref<any[]>([])
const defaultUniType = ref([]) const defaultUniType = ref<any[]>([])
const defaultCollegeFeature = ref([]) const defaultCollegeFeature = ref<any[]>([])
const defaultPhase = ref('') const defaultPhase = ref('')
const filterParams = ref([]) const filterParams = ref<any[]>([])
const chooseRegion = ref([]) const chooseRegion = ref<any[]>([])
const chooseNature = ref([]) const chooseNature = ref<any[]>([])
const chooseUniType = ref([]) const chooseUniType = ref<any[]>([])
const chooseCollegeFeature = ref([]) const chooseCollegeFeature = ref<any[]>([])
const choosePhase = ref('') const choosePhase = ref('')
const handleRegionChangeObj = (val: any[]) => { const handleRegionChangeObj = (val: any[]) => {

View File

@ -30,7 +30,7 @@ import { useRules } from '@/pages-sub/home/inputScore/useRules'
const userStore = useUserStore() const userStore = useUserStore()
const phaseList = ref([]) const phaseList = ref<any[]>([])
const choosePhase = ref('') const choosePhase = ref('')

View File

@ -19,7 +19,7 @@ interface Region {
simplename: string simplename: string
pinyin: string pinyin: string
} }
const regionList = ref([]) const regionList = ref<any[]>([])
getRegionInfo().then((res) => { getRegionInfo().then((res) => {
if (res.code === 200) { if (res.code === 200) {
regionList.value = res.result as Region[] regionList.value = res.result as Region[]

View File

@ -125,10 +125,10 @@ const handleShow = () => {
show.value = true show.value = true
} }
const handleRegionChangeName = (val) => { const handleRegionChangeName = (val: any) => {
searchParams.value.locationName = val.join(',') searchParams.value.locationName = val.join(',')
} }
const handleRegionChangeCode = (val) => { const handleRegionChangeCode = (val: any) => {
if (val.length > 0) { if (val.length > 0) {
show.value = false show.value = false
} }
@ -140,7 +140,7 @@ const navigatorBack = () => {
uni.navigateBack() uni.navigateBack()
} }
const tableData = ref([]) const tableData = ref<any[]>([])
const getUniversityList = () => { const getUniversityList = () => {
verifyUniversity({ verifyUniversity({
keyword: searchParams.value.collegeName, keyword: searchParams.value.collegeName,

View File

@ -166,35 +166,35 @@ const navigatorBack = () => {
uni.navigateBack() uni.navigateBack()
} }
const handleNatureChangeCode = (val) => { const handleNatureChangeCode = (val: any) => {
natureKeyInfo.value = val natureKeyInfo.value = val
} }
const handleUniTypeChangeCode = (val) => { const handleUniTypeChangeCode = (val: any) => {
uniTypeKeyInfo.value = val uniTypeKeyInfo.value = val
} }
const handleRegionChangeCode = (val) => { const handleRegionChangeCode = (val: any) => {
regionKeyInfo.value = val regionKeyInfo.value = val
} }
const handleRegionChange = (val) => { const handleRegionChange = (val: any) => {
searchParams.value.locationName = val searchParams.value.locationName = val
subMenu.value[0].activation = val.length !== 0 subMenu.value[0].activation = val.length !== 0
} }
const handleNatureChange = (val) => { const handleNatureChange = (val: any) => {
searchParams.value.searchNature = val searchParams.value.searchNature = val
subMenu.value[1].activation = val.length !== 0 subMenu.value[1].activation = val.length !== 0
} }
const handleUniTypeChange = (val) => { const handleUniTypeChange = (val: any) => {
searchParams.value.type = val searchParams.value.type = val
subMenu.value[2].activation = val.length !== 0 subMenu.value[2].activation = val.length !== 0
} }
const lineList = ref([]) const lineList = ref<any[]>([])
const tModel = ref({ year: 0 }) const tModel = ref({ year: 0 })
const paging = ref(null) const paging = ref<any>(null)
const queryList = (page: number, pageSize: number) => { const queryList = (page: number, pageSize: number) => {
getAdmissionTrends({ getAdmissionTrends({
pageIndex: page, pageIndex: page,
@ -213,7 +213,7 @@ const queryList = (page: number, pageSize: number) => {
} }
}) })
} }
const virtualListChange = (_vList) => { const virtualListChange = (_vList: any) => {
lineList.value = _vList lineList.value = _vList
} }
@ -224,9 +224,9 @@ const subMenu = ref([
]) ])
const dropMenuRef = ref() const dropMenuRef = ref()
const regionKeyInfo = ref([]) // const regionKeyInfo = ref<any[]>([]) //
const uniTypeKeyInfo = ref([]) // const uniTypeKeyInfo = ref<any[]>([]) //
const natureKeyInfo = ref([]) // const natureKeyInfo = ref<any[]>([]) //
const handleClear = (index: number) => { const handleClear = (index: number) => {
if (subMenu.value[index].id === 1) { if (subMenu.value[index].id === 1) {

View File

@ -5,12 +5,12 @@ import { RuleResult } from '@/types/app-type'
const userStore = useUserStore() const userStore = useUserStore()
export const requireSubjectList = ref([]) export const requireSubjectList = ref<any[]>([])
export const optionalSubjectList = ref([]) export const optionalSubjectList = ref<any[]>([])
// 单选 必选学科 // 单选 必选学科
export const requireSubject = ref('') export const requireSubject = ref('')
// 任意选择科目 // 任意选择科目
export const optionalSubject = ref([]) export const optionalSubject = ref<any[]>([])
export const useRules = (callback?: any) => { export const useRules = (callback?: any) => {
getCountryRules().then((res) => { getCountryRules().then((res) => {

View File

@ -83,7 +83,7 @@ const searchParams = ref({
type: '', type: '',
}) })
const checkYearList = ref([]) const checkYearList = ref<any[]>([])
const dropMenuRef = ref() const dropMenuRef = ref()
@ -91,10 +91,10 @@ const navigatorBack = () => {
uni.navigateBack() uni.navigateBack()
} }
const handleRegionChange = (val) => { const handleRegionChange = (val: any) => {
searchParams.value.locationName = val.join(',') searchParams.value.locationName = val.join(',')
} }
const handleRegionChangeCode = (val) => { const handleRegionChangeCode = (val: any) => {
searchParams.value.locationCode = val[0] searchParams.value.locationCode = val[0]
getBatchListData() getBatchListData()
if (val.length !== 0) { if (val.length !== 0) {
@ -102,11 +102,11 @@ const handleRegionChangeCode = (val) => {
} }
} }
const handleYearChange = (val) => { const handleYearChange = (val: any) => {
let _yearList = [] let _yearList = []
if (val.length > 1 && val.some((item) => item === '')) { if (val.length > 1 && val.some((item: any) => item === '')) {
_yearList = val.filter((item) => item !== '') _yearList = val.filter((item: any) => item !== '')
} else { } else {
_yearList = val _yearList = val
} }

View File

@ -34,8 +34,8 @@ const props = defineProps({
}, },
}) })
const menus = ref([]) const menus = ref<any[]>([])
const currentMenuObj = ref(null) const currentMenuObj = ref<any>(null)
const changeMenu = (item: any) => { const changeMenu = (item: any) => {
currentMenuObj.value = item currentMenuObj.value = item

View File

@ -105,14 +105,14 @@ watch(
) )
const provinceName = ref('') const provinceName = ref('')
const provinceList = ref([]) const provinceList = ref<any[]>([])
const provinceTotal = ref(0) const provinceTotal = ref(0)
const provinceCode = ref('') const provinceCode = ref('')
const show = ref(false) const show = ref(false)
const universityList = ref([]) const universityList = ref<any[]>([])
const subUniversityList = ref([]) const subUniversityList = ref<any[]>([])
const handleShow = () => { const handleShow = () => {
show.value = true show.value = true

View File

@ -127,7 +127,7 @@ const majorDetail = ref<CollegeInfo>({
}) })
const specId = ref('') const specId = ref('')
onLoad((options) => { onLoad((options: any) => {
specId.value = options.specId || '0' specId.value = options.specId || '0'
getMajorDetail({ SpecId: specId.value }).then((resp) => { getMajorDetail({ SpecId: specId.value }).then((resp) => {
if (resp.code === 200) { if (resp.code === 200) {

View File

@ -43,7 +43,7 @@ const navigatorBack = () => {
uni.navigateBack() uni.navigateBack()
} }
onLoad((option) => { onLoad((option: any) => {
let newsId = option.newsId let newsId = option.newsId
useCityNewDetail(newsId) useCityNewDetail(newsId)
}) })

View File

@ -66,8 +66,8 @@ const navigatorBack = () => {
const userStore = useUserStore() const userStore = useUserStore()
const newsList = ref([]) const newsList = ref<any[]>([])
const paging = ref(null) const paging = ref<any>(null)
const virtualListChange = (_vList) => { const virtualListChange = (_vList) => {
newsList.value = _vList newsList.value = _vList

View File

@ -103,7 +103,7 @@ import Navbar from '@/pages-sub/components/navbar/Navbar.vue'
type UnSortType = { type: number; name: string }[] type UnSortType = { type: number; name: string }[]
let unSortTypeList = ref([]) let unSortTypeList = ref<any[]>([])
getUnSortType().then((res) => { getUnSortType().then((res) => {
unSortTypeList.value = res.result as UnSortType unSortTypeList.value = res.result as UnSortType
}) })
@ -113,9 +113,9 @@ const navigatorBack = () => {
} }
const tabIndex = ref<number>(0) const tabIndex = ref<number>(0)
const tabsRef = ref(null) const tabsRef = ref<any>(null)
const itemClick = (item) => { const itemClick = (item: any) => {
console.log('点击了', item) console.log('点击了', item)
} }
@ -124,8 +124,8 @@ onLoad((option) => {
tabsRef.value?.setActiveTab(tabIndex.value) tabsRef.value?.setActiveTab(tabIndex.value)
}) })
const schoolList = ref([]) const schoolList = ref<any[]>([])
const paging = ref(null) const paging = ref<any>(null)
const queryList = (page: number, pageSize: number) => { const queryList = (page: number, pageSize: number) => {
getUniversityRank({ Type: tabIndex.value, PageIndex: page, PageSize: pageSize, Year: 2023 }).then( getUniversityRank({ Type: tabIndex.value, PageIndex: page, PageSize: pageSize, Year: 2023 }).then(
@ -134,7 +134,7 @@ const queryList = (page: number, pageSize: number) => {
}, },
) )
} }
const virtualListChange = (_vList) => { const virtualListChange = (_vList: any) => {
schoolList.value = _vList schoolList.value = _vList
} }

View File

@ -57,7 +57,7 @@ const props = defineProps({
}, },
}) })
const filterParams = ref([]) const filterParams = ref<any[]>([])
const handleRemove = (item, index) => { const handleRemove = (item, index) => {
filterParams.value.splice(index, 1) filterParams.value.splice(index, 1)
@ -71,8 +71,8 @@ const handleClear = () => {
filterParams.value = [] filterParams.value = []
} }
const menus = ref([]) const menus = ref<any[]>([])
const currentMenuObj = ref(null) const currentMenuObj = ref<any>(null)
const changeMenu = (item: any) => { const changeMenu = (item: any) => {
currentMenuObj.value = item currentMenuObj.value = item

View File

@ -1,26 +1,38 @@
import { getBatchDynamicData } from '@/service/index/api' import { getBatchDynamicData } from '@/service/index/api'
const TYPE_LABELS = {
c: '冲',
w: '稳',
b: '保',
} as const
type WishTypeKey = keyof typeof TYPE_LABELS
const TYPE_STYLE_MAP = {
2: {
text: '冲',
color: '#EB5241',
bgColor: 'rgba(235,82,65,0.15)',
roundedBgColor: '#E75859',
},
1: {
text: '稳',
color: '#FA8E23',
bgColor: 'rgba(250,142,35,0.15)',
roundedBgColor: '#FF8800',
},
0: {
text: '保',
color: '#15C496',
bgColor: 'rgba(21,196,150,0.15)',
roundedBgColor: '#34C724',
},
} as const
const DEFAULT_TYPE_STYLE = TYPE_STYLE_MAP[0]
export const calcTypeName = (type: number) => { export const calcTypeName = (type: number) => {
const style = { const style = TYPE_STYLE_MAP[type as keyof typeof TYPE_STYLE_MAP] ?? DEFAULT_TYPE_STYLE
2: {
text: '冲',
color: '#EB5241',
bgColor: 'rgba(235,82,65,0.15)',
roundedBgColor: '#E75859',
},
1: {
text: '稳',
color: '#FA8E23',
bgColor: 'rgba(250,142,35,0.15)',
roundedBgColor: '#FF8800',
},
0: {
text: '保',
color: '#15C496',
bgColor: 'rgba(21,196,150,0.15)',
roundedBgColor: '#34C724',
},
}[type] || { text: '保', color: '#15C496', bgColor: 'rgba(21,196,150,0.15)' }
return { return {
text: style.text, text: style.text,
@ -31,17 +43,12 @@ export const calcTypeName = (type: number) => {
roundedBgColor: style.roundedBgColor, roundedBgColor: style.roundedBgColor,
} }
} }
export const coverTypeModel = (tModel: Record<keyof typeof TYPE_LABELS, number>, total: number) => { export const coverTypeModel = (tModel: Record<WishTypeKey, number>, total: number) => {
const TYPE_LABELS = { const _result = (Object.keys(TYPE_LABELS) as WishTypeKey[]).map((key) => ({
c: '冲', name: `${TYPE_LABELS[key]}(${tModel[key]})`,
w: '稳',
b: '保',
} as const
let _result = Object.entries(TYPE_LABELS).map(([key, label]) => ({
name: `${label}(${tModel[key]})`,
value: key === 'b' ? '0' : key === 'w' ? '1' : '2', value: key === 'b' ? '0' : key === 'w' ? '1' : '2',
})) }))
_result.unshift({ _result.unshift({
name: `全部${total}`, name: `全部${total}`,
value: '-1', value: '-1',
@ -57,7 +64,7 @@ export const countModel = (list: any[]) => {
]) ])
list.forEach((item) => { list.forEach((item) => {
item.vItems.forEach((vItem) => { item.vItems.forEach((vItem: any) => {
const target = tModel.value.find((t) => t.type === vItem.type) const target = tModel.value.find((t) => t.type === vItem.type)
if (target) target.count++ if (target) target.count++
}) })
@ -66,7 +73,12 @@ export const countModel = (list: any[]) => {
return { tModel } return { tModel }
} }
export const useScore = (provinceCode, batchName, requireSubject, expectedScore) => { export const useScore = (
provinceCode: string,
batchName: string,
requireSubject: any[],
expectedScore: number,
) => {
const score = ref(0) const score = ref(0)
const minScore = ref(0) const minScore = ref(0)
const maxScore = ref(0) const maxScore = ref(0)

View File

@ -168,23 +168,23 @@ const navigatorBack = () => {
uni.navigateBack() uni.navigateBack()
} }
const schoolList = ref([]) const schoolList = ref<any[]>([])
const paging = ref(null) const paging = ref<any>(null)
const filterMenuRef = ref(null) const filterMenuRef = ref<any>(null)
const filterMajorRef = ref(null) const filterMajorRef = ref<any>(null)
const location = ref(userStore.userInfo.estimatedAchievement.provinceCode) const location = ref(userStore.userInfo.estimatedAchievement.provinceCode)
const showCollegeItem = ref(null) const showCollegeItem = ref<any>(null)
const collegeShow = ref(false) const collegeShow = ref(false)
const handleShowAction = (item) => { const handleShowAction = (item: any) => {
showCollegeItem.value = item showCollegeItem.value = item
collegeShow.value = true collegeShow.value = true
} }
const total = ref(0) const total = ref(0)
const typeModelList = ref([]) const typeModelList = ref<any[]>([])
const handleTypeModelChange = ({ item }) => { const handleTypeModelChange = ({ item }: { item: any }) => {
collegeSearch.value.tModelValue = item.value collegeSearch.value.tModelValue = item.value
collegeSearch.value.tModel = item.name collegeSearch.value.tModel = item.name
} }
@ -228,15 +228,23 @@ const queryList = (page: number, pageSize: number) => {
}) })
} }
const virtualListChange = (_vList) => { const virtualListChange = (_vList: any) => {
schoolList.value = _vList schoolList.value = _vList
} }
const itemClick = (item) => { const itemClick = (item: any) => {
uni.navigateTo({ url: `/pages-sub/home/college/info?collegeId=${item.uId}` }) uni.navigateTo({ url: `/pages-sub/home/college/info?collegeId=${item.uId}` })
} }
const collegeSearch = ref({ const collegeSearch = ref<{
nature: any[]
feature: any[]
majors: any[]
tModel: string
utype: any[]
tModelValue: string
secondmajor: any[]
}>({
nature: [], nature: [],
feature: [], feature: [],
majors: [], // majors: [], //
@ -260,7 +268,7 @@ const handleConfirm = () => {
let _cur = filterMajorRef.value.getSearchParam() let _cur = filterMajorRef.value.getSearchParam()
let temSet = new Set() let temSet = new Set()
collegeSearch.value.majors = [] collegeSearch.value.majors = []
_cur.forEach((item) => { _cur.forEach((item: any) => {
temSet.add(item.pName) temSet.add(item.pName)
collegeSearch.value.majors.push(item.zymc) collegeSearch.value.majors.push(item.zymc)
}) })
@ -288,12 +296,12 @@ const handleChange = (value: string) => {
paging.value.reload() paging.value.reload()
} }
const province = ref([]) const province = ref<any[]>([])
const handleRegionName = (val: string[]) => { const handleRegionName = (val: string[]) => {
province.value = val province.value = val
} }
const handleSliderChange = (val) => { const handleSliderChange = (val: any) => {
collegeSearch.value.tModelValue = '-1' collegeSearch.value.tModelValue = '-1'
paging.value.reload() paging.value.reload()
} }

View File

@ -48,7 +48,7 @@ import { useUserStore } from '@/store'
const userStore = useUserStore() const userStore = useUserStore()
const appointList = ref([]) const appointList = ref<any[]>([])
onLoad(() => { onLoad(() => {
getMySpecialList({ openId: userStore.userInfo?.estimatedAchievement.wxId.toString() }).then( getMySpecialList({ openId: userStore.userInfo?.estimatedAchievement.wxId.toString() }).then(
@ -60,7 +60,7 @@ onLoad(() => {
) )
}) })
const handleDelete = (item, index) => { const handleDelete = (item: any, index: number) => {
deleteMyAppointment({ deleteMyAppointment({
id: item.id, id: item.id,
}).then((res) => { }).then((res) => {

View File

@ -41,7 +41,7 @@ import { useRouterDetail } from '@/pages-sub/composables/useRouterDetail'
const userStore = useUserStore() const userStore = useUserStore()
const list = ref([]) const list = ref<any[]>([])
onShow(() => { onShow(() => {
getMyBusReports({ CustomId: userStore.userInfo?.estimatedAchievement.wxId }).then((res) => { getMyBusReports({ CustomId: userStore.userInfo?.estimatedAchievement.wxId }).then((res) => {

View File

@ -86,8 +86,8 @@ const currentTab = ref(0)
// currentTab.value = index // currentTab.value = index
// } // }
const starList = ref([]) const starList = ref<any[]>([])
const paging = ref(null) const paging = ref<any>(null)
const queryList = (page: number, pageSize: number) => { const queryList = (page: number, pageSize: number) => {
getUnCollectionList({ getUnCollectionList({

View File

@ -54,7 +54,7 @@ import { downloadPDF } from '@/service/index/api'
const userStore = useUserStore() const userStore = useUserStore()
const wishList = ref([]) const wishList = ref<any[]>([])
onShow(() => { onShow(() => {
getWishList({ locationCode: userStore.userInfo.estimatedAchievement.provinceCode }).then( getWishList({ locationCode: userStore.userInfo.estimatedAchievement.provinceCode }).then(

View File

@ -74,11 +74,11 @@ const tabs = [
const currentIndex = ref(0) const currentIndex = ref(0)
const academicList = ref([]) const academicList = ref<any[]>([])
const healthList = ref([]) const healthList = ref<any[]>([])
const learningList = ref([]) const learningList = ref<any[]>([])
const handleSwiperChange = (val) => { const handleSwiperChange = (val: any) => {
currentIndex.value = val.detail.current currentIndex.value = val.detail.current
} }

View File

@ -23,7 +23,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { getADBanner } from '@/service/index/api' import { getADBanner } from '@/service/index/api'
const bannerList = ref([]) const bannerList = ref<any[]>([])
getADBanner().then((resp) => { getADBanner().then((resp) => {
if (resp.code === 200) { if (resp.code === 200) {

View File

@ -155,21 +155,21 @@ export const useUserStore = defineStore(
} }
} }
const deleteWishListCollege = ({ uId }) => { const deleteWishListCollege = ({ uId }: { uId: string }) => {
userInfo.value.wishList = userInfo.value.wishList.filter((item) => item.uId !== uId) userInfo.value.wishList = userInfo.value.wishList.filter((item) => item.uId !== uId)
} }
const deleteWishListMajor = ({ uId, planId }: { uId: string; planId: string }) => { const deleteWishListMajor = ({ uId, planId }: { uId: string; planId: string }) => {
userInfo.value.wishList = userInfo.value.wishList userInfo.value.wishList = userInfo.value.wishList
.map((item) => { .map((item) => {
if (item.uId === uId) { if (item.uId === uId) {
item.vItems = item.vItems.filter((vItem) => vItem.planId !== planId) item.vItems = item.vItems.filter((vItem: any) => vItem.planId !== planId)
return item return item
} }
return item return item
}) })
.filter((item) => item.vItems.length > 0) .filter((item) => item.vItems.length > 0)
} }
const setWishListMajorWithUn = (val) => { const setWishListMajorWithUn = (val: any) => {
userInfo.value.wishList.push({ ...val, sort: userInfo.value.wishList.length + 1 }) userInfo.value.wishList.push({ ...val, sort: userInfo.value.wishList.length + 1 })
} }
// 排序专业 // 排序专业

View File

@ -25,7 +25,7 @@ export type IUserCity = {
} }
export type ExtraUserInfo = { export type ExtraUserInfo = {
city?: City city: City
estimatedAchievement: { estimatedAchievement: {
year: number year: number
expectedScore: number | string expectedScore: number | string

View File

@ -3,13 +3,11 @@
"composite": true, "composite": true,
"skipLibCheck": true, "skipLibCheck": true,
"module": "ESNext", "module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true, "resolveJsonModule": true,
"noImplicitThis": true, "noImplicitThis": true,
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,
"allowJs": true, "allowJs": true,
"sourceMap": true, "sourceMap": true,
"baseUrl": ".",
"paths": { "paths": {
"@/*": ["./src/*"] "@/*": ["./src/*"]
}, },