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>
<template>
<web-view :src="url" @message="handleChildMessage" :update-title="false" />
<web-view :src="url" :update-title="false" />
</template>
<script setup lang="ts">
@ -20,23 +20,19 @@ const userStore = useUserStore()
//chatv2.ycymedu.com
const url = ref(``)
const handleChildMessage = (event) => {
console.log('子应用传递的消息', event)
}
onLoad((options) => {
getAssistant().then((res) => {
if (res.code === 200) {
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()}`
}
if (options.id) {
if (options?.id) {
url.value += `&reportId=${options.id}`
}
if (options.type) {
if (options?.type) {
url.value += `&reportType=${options.type}`
}
if (options.fileId) {
if (options?.fileId) {
url.value += `&fileId=${options.fileId}`
}
})

View File

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

View File

@ -19,7 +19,7 @@ export const useCityInfo = () => {
const li = groupByFirstLetter(list)
cityStore.setCities(li)
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)
}
}
@ -48,12 +48,12 @@ const groupByFirstLetter = (lis: Province[]): { letter: string; provinces: Provi
.map((key) => ({ letter: key, provinces: grouped[key] }))
}
export const newsList = ref([])
export const newsList = ref<News[]>([])
export const useCityNewTop = () => {
const fetchNewTopFun = (provinceCode) => {
const fetchNewTopFun = (provinceCode: string) => {
getNewsTop({ Top: 4, CategoryId: 1, provinceCode }).then((res) => {
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
}
export const useRegionInfo = () => {
const regionList = ref([])
const regionList = ref<any[]>([])
getRegionInfo().then((res) => {
if (res.code === 200) {
regionList.value = res.result as Region[]
@ -19,7 +19,7 @@ export const useRegionInfo = () => {
}
export const useUniversityType = () => {
const typeList = ref([])
const typeList = ref<any[]>([])
getUniversityType().then((res) => {
if (res.code === 200) {
typeList.value = res.result as { id: number; name: string }[]
@ -30,7 +30,7 @@ export const useUniversityType = () => {
}
export const useNatureList = () => {
const natureList = ref([])
const natureList = ref<any[]>([])
getNature().then((res) => {
if (res.code === 200) {
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 }[]
export const useUnSortType = () => {
let unSortTypeList = ref([])
let unSortTypeList = ref<any[]>([])
getUnSortType().then((res) => {
unSortTypeList.value = res.result as UnSortType
})
@ -23,7 +23,7 @@ export const useUniversityRank = ({
PageSize: number
PageIndex: number
}) => {
let universityRankList = ref([])
let universityRankList = ref<any[]>([])
getUniversityRank({ Year, Type, PageSize, PageIndex }).then((res) => {
if (res.code === 200) {
const _res = res.result as { rows: any[] }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -9,7 +9,7 @@
<script lang="ts" setup>
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 echart = ref(null)
const echart = ref<any>(null)
const props = defineProps({
picData: {
type: Object,

View File

@ -13,7 +13,7 @@
<script lang="ts" setup>
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 echart = ref(null)
const echart = ref<any>(null)
const props = defineProps({
echartData: {

View File

@ -9,7 +9,7 @@
<script lang="ts" setup>
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 echart = ref(null)
const echart = ref<any>(null)
interface IndicatorItem {
name: string

View File

@ -9,7 +9,7 @@
<script lang="ts" setup>
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 echart = ref(null)
const echart = ref<any>(null)
</script>
<script lang="scss" scoped></script>

View File

@ -32,7 +32,7 @@
<script lang="ts" setup>
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 echart = ref(null)
const echart = ref<any>(null)
const props = defineProps({
picData: {
@ -45,7 +45,7 @@ const props = defineProps({
},
})
const innerParsing = ref([])
const innerParsing = ref<any[]>([])
const policy = ref({ items: [] })
watch(

View File

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

View File

@ -60,9 +60,9 @@ const studyRecord = ref({
suggestions: '',
})
const chartData = ref([])
const chartData = ref<any[]>([])
const parsing = ref('')
const suggestions = ref([])
const suggestions = ref<any[]>([])
onLoad((options) => {
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
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
pageId.value = options.id

View File

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

View File

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

View File

@ -150,13 +150,13 @@ const handleConfirm = () => {
getScoreSectionData()
}
const checkYearList = ref([])
const checkYearList = ref<any[]>([])
const dropMenuRef = ref()
const handleYearChange = (val) => {
const handleYearChange = (val: any) => {
let _yearList = []
if (val.length > 1 && val.some((item) => item === '')) {
_yearList = val.filter((item) => item !== '')
if (val.length > 1 && val.some((item: any) => item === '')) {
_yearList = val.filter((item: any) => item !== '')
} else {
_yearList = val
}
@ -224,7 +224,7 @@ const getScoreSectionData = () => {
})
}
const echart = ref(null)
const echart = ref<any>(null)
onLoad(() => {
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>
> 一个基于 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 |
| --- | ---------- | ------------ | ---------- | ---------- | --------- | ---- |
| --- | ---------- | ------------ | ---------- | ---------- | --------- | --- |
| √ | √ | √ | √ | √ | √ | √ |
## 安装
- 第一步:在市场导入 [百度图表](https://ext.dcloud.net.cn/plugin?id=4899)
- 第二步:选择插件依赖:<br>
1、可以选插件内的`echarts`包或自定义包,自定义包[下载地址](https://echarts.apache.org/zh/builder.html)<br>
2、或者使用`npm`安装`echarts`
**注意**
* 🔔 echarts 5.3.0及以上
* 🔔 如果是 `cli` 项目请下载插件到`src`目录下的`uni_modules`,没有这个目录就创建一个
- 🔔 echarts 5.3.0及以上
- 🔔 如果是 `cli` 项目请下载插件到`src`目录下的`uni_modules`,没有这个目录就创建一个
## 代码演示
### Vue2
- 引入依赖,可以是插件内提供或自己下载的[自定义包](https://echarts.apache.org/zh/builder.html),也可以是`npm`包
```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
@ -47,32 +50,32 @@ export default {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
type: 'shadow',
},
confine: true
confine: true,
},
legend: {
data: ['热度', '正面', '负面']
data: ['热度', '正面', '负面'],
},
grid: {
left: 20,
right: 20,
bottom: 15,
top: 40,
containLabel: true
containLabel: true,
},
xAxis: [
{
type: 'value',
axisLine: {
lineStyle: {
color: '#999999'
}
color: '#999999',
},
},
axisLabel: {
color: '#666666'
}
}
color: '#666666',
},
},
],
yAxis: [
{
@ -81,13 +84,13 @@ export default {
data: ['汽车之家', '今日头条', '百度贴吧', '一点资讯', '微信', '微博', '知乎'],
axisLine: {
lineStyle: {
color: '#999999'
}
color: '#999999',
},
},
axisLabel: {
color: '#666666'
}
}
color: '#666666',
},
},
],
series: [
{
@ -96,8 +99,8 @@ export default {
label: {
normal: {
show: true,
position: 'inside'
}
position: 'inside',
},
},
data: [300, 270, 340, 344, 300, 320, 310],
},
@ -107,10 +110,10 @@ export default {
stack: '总量',
label: {
normal: {
show: true
}
show: true,
},
data: [120, 102, 141, 174, 190, 250, 220]
},
data: [120, 102, 141, 174, 190, 250, 220],
},
{
name: '负面',
@ -119,32 +122,32 @@ export default {
label: {
normal: {
show: true,
position: 'left'
}
position: 'left',
},
data: [-20, -32, -21, -34, -90, -130, -110]
}
]
},
};
data: [-20, -32, -21, -34, -90, -130, -110],
},
],
},
}
},
// 组件能被调用必须是组件的节点已经被渲染到页面上
methods: {
async init() {
// chart 图表实例不能存在data里
const chart = await this.$refs.chartRef.init(echarts);
const chart = await this.$refs.chartRef.init(echarts)
chart.setOption(this.option)
}
}
},
},
}
```
### Vue3
- 小程序可以使用`require`引入插件内提供或自己下载的[自定义包](https://echarts.apache.org/zh/builder.html)
- `require`仅支持相对路径,不支持路径别名
- 非小程序使用 `npm`
```html
<view style="width:750rpx; height:750rpx"><l-echart ref="chartRef"></l-echart></view>
```
@ -152,9 +155,9 @@ export default {
```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')
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// 非小程序
@ -163,38 +166,37 @@ import * as echarts from 'echarts'
```
```js
const chartRef = ref(null)
const chartRef = ref < any > null
const option = {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
type: 'shadow',
},
confine: true
confine: true,
},
legend: {
data: ['热度', '正面', '负面']
data: ['热度', '正面', '负面'],
},
grid: {
left: 20,
right: 20,
bottom: 15,
top: 40,
containLabel: true
containLabel: true,
},
xAxis: [
{
type: 'value',
axisLine: {
lineStyle: {
color: '#999999'
}
color: '#999999',
},
},
axisLabel: {
color: '#666666'
}
}
color: '#666666',
},
},
],
yAxis: [
{
@ -203,13 +205,13 @@ const option = {
data: ['汽车之家', '今日头条', '百度贴吧', '一点资讯', '微信', '微博', '知乎'],
axisLine: {
lineStyle: {
color: '#999999'
}
color: '#999999',
},
},
axisLabel: {
color: '#666666'
}
}
color: '#666666',
},
},
],
series: [
{
@ -218,8 +220,8 @@ const option = {
label: {
normal: {
show: true,
position: 'inside'
}
position: 'inside',
},
},
data: [300, 270, 340, 344, 300, 320, 310],
},
@ -229,10 +231,10 @@ const option = {
stack: '总量',
label: {
normal: {
show: true
}
show: true,
},
data: [120, 102, 141, 174, 190, 250, 220]
},
data: [120, 102, 141, 174, 190, 250, 220],
},
{
name: '负面',
@ -241,14 +243,13 @@ const option = {
label: {
normal: {
show: true,
position: 'left'
}
position: 'left',
},
data: [-20, -32, -21, -34, -90, -130, -110]
},
data: [-20, -32, -21, -34, -90, -130, -110],
},
],
}
]
};
onMounted(() => {
// 组件能被调用必须是组件的节点已经被渲染到页面上
@ -258,11 +259,10 @@ onMounted( ()=>{
myChart.setOption(option)
}, 300)
})
```
### Uvue
- Uvue和Nvue不需要引入`echarts`,因为它们的实现方式是`webview`
- uniapp x需要HBX 4.13以上
@ -290,8 +290,8 @@ const init = async () => {
}
```
## 数据更新
- 1、使用 `ref` 可获取`setOption`设置更新
- 2、也可以拿到图表实例`chart`设置`myChart.setOption(data)`
@ -304,6 +304,7 @@ myChart.setOption(data)
```
## 图表大小
- 在有些场景下,我们希望当容器大小改变时,图表的大小也相应地改变。
```js
@ -314,23 +315,26 @@ this.$refs.chart.resize({width: 375, height: 375})
```
## 自定义Tooltips
- uvue\nvue 不支持
由于除H5之外都不存在dom但又有tooltips个性化的需求代码就不贴了看示例吧
```
代码位于/uni_modules/lime-echart/component/lime-echart
```
## 插件标签
- 默认 l-echart 为 component
- 默认 lime-echart 为 demo
```html
// 在任意地方使用可查看domo, 代码位于/uni_modules/lime-echart/component/lime-echart
<lime-echart></lime-echart>
```
## 常见问题
- 钉钉小程序 由于没有`measureText`,模拟的`measureText`又无法得到当前字体的`fontWeight`,故可能存在估计不精细的问题
- 微信小程序 `2d` 只支持 真机调试2.0
- 微信开发工具会出现 `canvas` 不跟随页面的情况,真机不影响
@ -340,6 +344,7 @@ this.$refs.chart.resize({width: 375, height: 375})
- dataZoom H5不要设置 `showDetail`
- 如果微信小程序的`tooltip`文字有阴影,可能是微信的锅,临时解决方法是`tooltip.shadowBlur = 0`
- 如果钉钉小程序上传时报安全问题`Uint8Clamped`,可以向钉钉反馈是安全代码扫描把Uint8Clamped数组错误识别了也可以在 echarts 文件修改`Uint8Clamped`
```js
// 找到这段代码把代码中`Uint8Clamped`改成`Uint8_Clamped`,再把下划线去掉,不过直接去掉`Uint8Clamped`也是可行的
// ["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
如果您是使用 **vite + vue3** 非微信小程序可能会遇到`echarts`文件缺少`wx`判断导致无法使用或缺少`tooltip`<br>
方式一:可以在`echarts.min.js`文件开头增加以下内容参考插件内的echart.min.js的做法
@ -362,25 +368,24 @@ let wx = uni
```js
// 或者在`vite.config.js`的`define`设置环境
import { defineConfig } from 'vite';
import uni from '@dcloudio/vite-plugin-uni';
import { defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
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['wx'] = 'uni'
}
export default defineConfig({
plugins: [uni()],
define
});
define,
})
```
## Props
| 参数 | 说明 | 类型 | 默认值 | 版本 |
| --------------- | -------- | ------- | ------------ | ----- |
| ----------------- | -------------------------- | --------- | ------- | ---- |
| custom-style | 自定义样式 | `string` | - | - |
| type | 指定 canvas 类型 | `string` | `2d` | |
| is-disable-scroll | 触摸图表时是否禁止页面滚动 | `boolean` | `false` | |
@ -391,7 +396,7 @@ export default defineConfig({
## 事件
| 参数 | 说明 |
| --------------- | --------------- |
| --------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
| init(echarts, chart => {}) | 初始化调用函数,第一个参数是传入`echarts`,第二个参数是回调函数,回调函数的参数是 `chart` 实例 |
| setChart(chart => {}) | 已经初始化后,请使用这个方法,是个回调函数,参数是 `chart` 实例 |
| setOption(data) | [图表配置项](https://echarts.apache.org/zh/option.html#title),用于更新 ,传递是数据 `option` |
@ -401,8 +406,8 @@ export default defineConfig({
| hideLoading() | 隐藏加载 |
| [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/wpay.png)

View File

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

View File

@ -4,7 +4,7 @@
</view>
</template>
<script setup>
<script setup lang="ts">
import { ref, computed, watch, provide, onMounted, nextTick } from 'vue'
const props = defineProps({
@ -26,8 +26,8 @@ const props = defineProps({
const emit = defineEmits(['change', 'activeItem', 'input', 'update:modelValue'])
//
const childrens = ref([])
const names = ref([])
const childrens = ref<any[]>([])
const names = ref<any[]>([])
// 使 vue2 vue3
const dataValue = computed(() => {
@ -38,25 +38,25 @@ const dataValue = computed(() => {
return props.value
})
//
const emitValue = (val) => {
const emitValue = (val: any) => {
emit('input', val)
emit('update:modelValue', val)
}
//
const register = (childInstance) => {
const register = (childInstance: any) => {
childrens.value.push(childInstance)
}
//
const unregister = (childInstance) => {
const unregister = (childInstance: any) => {
const index = childrens.value.findIndex((child) => child.nameSync === childInstance.nameSync)
if (index !== -1) {
childrens.value.splice(index, 1)
}
}
// -
const setOpen = (val) => {
const setOpen = (val: any) => {
//
const isString = typeof val === 'string' || typeof val === 'number'
const isArray = Array.isArray(val)
@ -110,7 +110,7 @@ watch(
)
// -
const setAccordion = (self) => {
const setAccordion = (self: any) => {
if (!props.accordion) return
childrens.value.forEach((vm) => {
@ -143,7 +143,7 @@ const resize = () => {
}
//
const onChange = (isOpen, self) => {
const onChange = (isOpen: any, self: any) => {
let activeItem = ''
if (props.accordion) {
@ -151,7 +151,7 @@ const onChange = (isOpen, self) => {
activeItem = isOpen ? self.nameSync : ''
} else {
//
const activeItems = []
const activeItems: any = []
childrens.value.forEach((vm) => {
if (vm.isOpen) {
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
const elId = ref(`Uni_${Math.ceil(Math.random() * 10e5).toString(36)}`)
const isOpen = ref(false)
const isheight = ref(null)
const isheight = ref < any > null
const height = ref(0)
const nameSync = ref('0')
const collapseHook = ref(null)
const collapseHook = ref < any > null
const proxy = getCurrentInstance()
//

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -66,8 +66,8 @@ const navigatorBack = () => {
const userStore = useUserStore()
const newsList = ref([])
const paging = ref(null)
const newsList = ref<any[]>([])
const paging = ref<any>(null)
const virtualListChange = (_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 }[]
let unSortTypeList = ref([])
let unSortTypeList = ref<any[]>([])
getUnSortType().then((res) => {
unSortTypeList.value = res.result as UnSortType
})
@ -113,9 +113,9 @@ const navigatorBack = () => {
}
const tabIndex = ref<number>(0)
const tabsRef = ref(null)
const tabsRef = ref<any>(null)
const itemClick = (item) => {
const itemClick = (item: any) => {
console.log('点击了', item)
}
@ -124,8 +124,8 @@ onLoad((option) => {
tabsRef.value?.setActiveTab(tabIndex.value)
})
const schoolList = ref([])
const paging = ref(null)
const schoolList = ref<any[]>([])
const paging = ref<any>(null)
const queryList = (page: number, pageSize: number) => {
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
}

View File

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

View File

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

View File

@ -168,23 +168,23 @@ const navigatorBack = () => {
uni.navigateBack()
}
const schoolList = ref([])
const paging = ref(null)
const filterMenuRef = ref(null)
const filterMajorRef = ref(null)
const schoolList = ref<any[]>([])
const paging = ref<any>(null)
const filterMenuRef = ref<any>(null)
const filterMajorRef = ref<any>(null)
const location = ref(userStore.userInfo.estimatedAchievement.provinceCode)
const showCollegeItem = ref(null)
const showCollegeItem = ref<any>(null)
const collegeShow = ref(false)
const handleShowAction = (item) => {
const handleShowAction = (item: any) => {
showCollegeItem.value = item
collegeShow.value = true
}
const total = ref(0)
const typeModelList = ref([])
const handleTypeModelChange = ({ item }) => {
const typeModelList = ref<any[]>([])
const handleTypeModelChange = ({ item }: { item: any }) => {
collegeSearch.value.tModelValue = item.value
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
}
const itemClick = (item) => {
const itemClick = (item: any) => {
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: [],
feature: [],
majors: [], //
@ -260,7 +268,7 @@ const handleConfirm = () => {
let _cur = filterMajorRef.value.getSearchParam()
let temSet = new Set()
collegeSearch.value.majors = []
_cur.forEach((item) => {
_cur.forEach((item: any) => {
temSet.add(item.pName)
collegeSearch.value.majors.push(item.zymc)
})
@ -288,12 +296,12 @@ const handleChange = (value: string) => {
paging.value.reload()
}
const province = ref([])
const province = ref<any[]>([])
const handleRegionName = (val: string[]) => {
province.value = val
}
const handleSliderChange = (val) => {
const handleSliderChange = (val: any) => {
collegeSearch.value.tModelValue = '-1'
paging.value.reload()
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -23,7 +23,7 @@
<script lang="ts" setup>
import { getADBanner } from '@/service/index/api'
const bannerList = ref([])
const bannerList = ref<any[]>([])
getADBanner().then((resp) => {
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)
}
const deleteWishListMajor = ({ uId, planId }: { uId: string; planId: string }) => {
userInfo.value.wishList = userInfo.value.wishList
.map((item) => {
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
})
.filter((item) => item.vItems.length > 0)
}
const setWishListMajorWithUn = (val) => {
const setWishListMajorWithUn = (val: any) => {
userInfo.value.wishList.push({ ...val, sort: userInfo.value.wishList.length + 1 })
}
// 排序专业

View File

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

View File

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