fix: 修复部分问题

This commit is contained in:
white 2024-09-27 16:14:46 +08:00
parent d596b818e2
commit fc777ef92d
9 changed files with 719 additions and 13 deletions

View File

@ -149,13 +149,13 @@
.xnz{ .xnz{
width: 8rpx; width: 8rpx;
height: 20rpx; height: 20rpx;
background-color: #fff; // background-color: #fff;
border-left: 1rpx solid black; // border-left: 1rpx solid black;
border-right: 1rpx solid black; // border-right: 1rpx solid black;
position: absolute; // position: absolute;
right: 50rpx; // right: 50rpx;
top: 19rpx; // top: 19rpx;
transform: rotate(15deg); // transform: rotate(15deg);
} }
.zzt-body{ .zzt-body{
height: 10rpx; height: 10rpx;

View File

@ -17,7 +17,9 @@
<view style="height: 40rpx;background-color: #fff;"></view> <view style="height: 40rpx;background-color: #fff;"></view>
<!-- 图表 --> <!-- 图表 -->
<l-echart ref="chartRef" @finished="init"></l-echart> <view class="charts">
<l-echart ref="chartRef" @finished="init"></l-echart>
</view>
<overview v-if="dataConfig[pageData.type].overviewData" :overviewData="dataConfig[pageData.type].overviewData"></overview> <overview v-if="dataConfig[pageData.type].overviewData" :overviewData="dataConfig[pageData.type].overviewData"></overview>
<cankao v-if="dataConfig[pageData.type].cankaoData" :cankaoData="dataConfig[pageData.type].cankaoData" ></cankao> <cankao v-if="dataConfig[pageData.type].cankaoData" :cankaoData="dataConfig[pageData.type].cankaoData" ></cankao>
@ -179,7 +181,7 @@ import { mapGetters } from "vuex";
name:'血脂概况', name:'血脂概况',
tb_head:[ tb_head:[
'', '',
'范围', '单日测量范围',
'平均值' '平均值'
], ],
data:[ data:[
@ -248,7 +250,7 @@ import { mapGetters } from "vuex";
0.00, 0.00,
-0.04 -0.04
], ],
max:1.5 max:3
}, },
{ {
name:'低密度脂蛋白', name:'低密度脂蛋白',
@ -1142,4 +1144,11 @@ import { mapGetters } from "vuex";
width: 80%; width: 80%;
padding: 0rpx 20rpx; padding: 0rpx 20rpx;
} }
.charts {
margin: 0rpx 100rpx;
border: 1rpx solid gray;
border-radius: 20px;
padding: 20px 0px;
}
</style> </style>

View File

@ -39,7 +39,7 @@
</audio> </audio>
<div class="status"> <div class="status">
<div class="btn">正在听…</div> <input class="voice-input" type="search" name="voice" id="status-txt" style="pointer-events: none"/>
</div> </div>
<div id="AiButton"> <div id="AiButton">
@ -56,7 +56,7 @@
<!-- 讯飞测试 --> <!-- 讯飞测试 -->
<div class="voice"> <div class="voice">
<div class="voice-box scroll-text"> <div class="voice-box scroll-text">
<input class="voice-input" type="search" name="voice" id="voice-txt" style="pointer-events: none"/> <input class="voice-input" type="search" name="voice" id="voice-txt" style="pointer-events: none" value="我是您的健康助手, 请问您有什么帮助吗?"/>
</div> </div>
</div> </div>
</div> </div>
@ -246,6 +246,7 @@
// 文本输入框 // 文本输入框
const statusTxt = document.querySelector('#status-txt');
const voiceTxt = document.querySelector('#voice-txt'); const voiceTxt = document.querySelector('#voice-txt');
// 防止多次请求 // 防止多次请求
@ -280,8 +281,8 @@
onTextChange: function (text) { onTextChange: function (text) {
// 监听识别结果的变化 // 监听识别结果的变化
console.log(text, '监听')
voiceTxt.value = text; voiceTxt.value = text;
statusTxt.value = '正在听…';
// 3秒钟内没有说话就自动关闭 // 3秒钟内没有说话就自动关闭
if (text) { if (text) {
@ -471,6 +472,8 @@
isCallbackExecuted = true; isCallbackExecuted = true;
return return
} }
statusTxt.value = '';
}, 3000); }, 3000);
} }
} }

View File

@ -1,5 +1,18 @@
<template> <template>
<view> <view>
<view class="skeleton flx" v-if="loading">
<view style="width: 60%">
<x-skeleton type="banner" :loading="loading"></x-skeleton>
<x-skeleton type="banner" :loading="loading"></x-skeleton>
<x-skeleton type="banner" :loading="loading"></x-skeleton>
<x-skeleton type="banner" :loading="loading"></x-skeleton>
<x-skeleton type="banner" :loading="loading"></x-skeleton>
</view>
<view style="width: 40%">
<x-skeleton :loading="loading" :configs="customConfigs" fadeOut></x-skeleton>
</view>
</view>
<view class="content"> <view class="content">
<!-- 首页数据 --> <!-- 首页数据 -->
<view class="content-wrap" v-if="Sindex == 1"> <view class="content-wrap" v-if="Sindex == 1">
@ -83,6 +96,17 @@
pageData: { pageData: {
type: '' type: ''
},
loading: true,
customConfigs: {
padding: '30rpx', //
gridRows: 2, //
gridColumns: 1, //
headShow: true, //head
headWidth: '100%', //head
headHeight: '100vh', //head
headBorderRadius: '12rpx', //head
} }
} }
}, },
@ -161,6 +185,7 @@
this.dataListsNew.bloodLiquidAll.type = 'bloodLiquidAll'; this.dataListsNew.bloodLiquidAll.type = 'bloodLiquidAll';
this.urlLink = `/hybrid/html/ai.html?data=${JSON.stringify(this.dataListsNew)}&user=${JSON.stringify(this.getUserInfo)}&token=${store.getters['api/getApiToken']}&deviceId=${this.getActiceDevice.device_id}`; this.urlLink = `/hybrid/html/ai.html?data=${JSON.stringify(this.dataListsNew)}&user=${JSON.stringify(this.getUserInfo)}&token=${store.getters['api/getApiToken']}&deviceId=${this.getActiceDevice.device_id}`;
this.loading = false;
} }
); );
@ -240,6 +265,16 @@
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.skeleton {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100vh;
overflow: hidden;
background-color: #fff;
z-index: 99;
}
.flex_data{ .flex_data{
display: flex; display: flex;
.f_left{ .f_left{

View File

@ -0,0 +1,11 @@
## 1.0.42023-09-02
1、优化一些显示的细节问题
## 1.0.32023-09-01
1、新增动画、时间、颜色等相关属性
## 1.0.22023-08-31
1、回滚到v1.0.0版本,暂时取消动画时间的修改属性
## 1.0.12023-08-31
1、新增动画持续时间属性
2、新增淡出持续时间属性
## 1.0.02023-08-31
第一个版本

View File

@ -0,0 +1,147 @@
export default {
methods: {
bannerConfigs() {
return {
padding: '30rpx',
gridRows: 1,
gridColumns: 1,
gridRowsGap: '40rpx',
gridColumnsGap: '24rpx',
itemDirection: 'row',
itemGap: '30rpx',
itemAlign: 'center',
headShow: true,
headWidth: '100%',
headHeight: '300rpx',
headBorderRadius: '20rpx',
textShow: false,
textRows: 3,
textRowsGap: '20rpx',
textWidth: '100%',
textHeight: '30rpx',
textBorderRadius: '6rpx',
...this.configs
}
},
infoConfigs() {
return {
padding: '30rpx',
gridRows: 1,
gridColumns: 1,
gridRowsGap: '50rpx',
gridColumnsGap: '24rpx',
itemDirection: 'row',
itemGap: '30rpx',
itemAlign: 'flex-start',
headShow: true,
headWidth: '100rpx',
headHeight: '100rpx',
headBorderRadius: '50%',
textShow: true,
textRows: 4,
textRowsGap: '30rpx',
textWidth: ['50%', '100%', '100%', '80%'],
textHeight: ['40rpx', '24rpx', '24rpx', '24rpx'],
textBorderRadius: '6rpx',
...this.configs
}
},
textConfigs() {
return {
padding: '30rpx',
gridRows: 1,
gridColumns: 1,
gridRowsGap: '50rpx',
gridColumnsGap: '24rpx',
itemDirection: 'row',
itemGap: '30rpx',
itemAlign: 'flex-start',
headShow: false,
headWidth: '100rpx',
headHeight: '100rpx',
headBorderRadius: '50%',
textShow: true,
textRows: 4,
textRowsGap: '30rpx',
textWidth: ['50%', '100%', '100%', '80%'],
textHeight: '30rpx',
textBorderRadius: '6rpx',
...this.configs
}
},
menuConfigs() {
return {
padding: '30rpx',
gridRows: 2,
gridColumns: 5,
gridRowsGap: '40rpx',
gridColumnsGap: '40rpx',
itemDirection: 'column',
itemGap: '16rpx',
itemAlign: 'center',
headShow: true,
headWidth: '100rpx',
headHeight: '100rpx',
headBorderRadius: '50%',
textShow: true,
textRows: 1,
textRowsGap: '0rpx',
textWidth: '100%',
textHeight: '24rpx',
textBorderRadius: '6rpx',
...this.configs
}
},
listConfigs() {
return {
padding: '30rpx',
gridRows: 2,
gridColumns: 1,
gridRowsGap: '50rpx',
gridColumnsGap: '24rpx',
itemDirection: 'row',
itemGap: '30rpx',
itemAlign: 'flex-start',
headShow: true,
headWidth: '200rpx',
headHeight: '200rpx',
headBorderRadius: '16rpx',
textShow: true,
textRows: 4,
textRowsGap: '30rpx',
textWidth: ['50%', '100%', '100%', '80%'],
textHeight: ['38rpx', '24rpx', '24rpx', '24rpx'],
textBorderRadius: '6rpx',
...this.configs
}
},
waterfallConfigs() {
return {
padding: '30rpx',
gridRows: 2,
gridColumns: 2,
gridRowsGap: '40rpx',
gridColumnsGap: '24rpx',
itemDirection: 'column',
itemGap: '16rpx',
itemAlign: 'center',
headShow: true,
headWidth: '100%',
headHeight: '400rpx',
headBorderRadius: '12rpx',
textShow: true,
textRows: 3,
textRowsGap: '12rpx',
textWidth: ['40%', '85%', '60%'],
textHeight: ['30rpx', '20rpx', '20rpx'],
textBorderRadius: '6rpx',
...this.configs
}
},
}
}

View File

@ -0,0 +1,324 @@
<template>
<view class="x-skeleton" :style="variableStr">
<!-- 骨架屏 -->
<view
v-if="skeletonLoading"
class="x-skeleton__wrapper"
:class="[ startFadeOut && 'fade-out' ]"
:style="{ padding: skeletonConfigs.padding }"
>
<view
v-for="(row, rowIndex) in gridRowsArr" :key="rowIndex"
class="x-skeleton__wrapper__rows"
:style="{ marginBottom: rowIndex < gridRowsArr.length - 1 ? skeletonConfigs.gridRowsGap : 0 }"
>
<view
v-for="(column, columnIndex) in gridColumnsArr" :key="columnIndex"
class="x-skeleton__wrapper__columns"
:style="{
flexDirection: skeletonConfigs.itemDirection,
alignItems: skeletonConfigs.itemAlign,
marginRight: columnIndex < gridColumnsArr.length - 1 ? skeletonConfigs.gridColumnsGap : 0,
}"
>
<view
v-if="skeletonConfigs.headShow"
class="x-skeleton__wrapper__head"
:class="[ animate && 'animate' ]"
:style="{
width: skeletonConfigs.headWidth,
height: skeletonConfigs.headHeight,
borderRadius: skeletonConfigs.headBorderRadius,
marginRight: (skeletonConfigs.itemDirection == 'row' && skeletonConfigs.textShow) ? skeletonConfigs.itemGap : 0,
marginBottom: (skeletonConfigs.itemDirection == 'column' && skeletonConfigs.textShow) ? skeletonConfigs.itemGap : 0
}"
></view>
<view v-if="skeletonConfigs.textShow" class="x-skeleton__wrapper__text">
<view
v-for="(text, textIndex) in textRowsArr" :key="textIndex"
class="x-skeleton__wrapper__text__row"
:class="[animate && 'animate']"
:style="{
width: text.width,
height: text.height,
borderRadius: skeletonConfigs.textBorderRadius,
marginBottom: textIndex < textRowsArr.length - 1 ? skeletonConfigs.textRowsGap : 0
}"
></view>
</view>
</view>
</view>
</view>
<!-- 插槽 -->
<view v-else>
<slot></slot>
</view>
</view>
</template>
<script>
import XSkeletonConfigs from './x-skeleton-configs.js'
export default {
name: "x-skeleton",
mixins: [ XSkeletonConfigs ],
props: {
//
type: {
type: String,
default: '' //bannerinfotextmenulistwaterfall
},
//
loading: {
type: Boolean,
default: true
},
//
animate: {
type: Boolean,
default: true
},
//
animateTime: {
type: Number | String,
default: 1.8
},
//
fadeOut: {
type: Boolean,
default: true
},
//
fadeOutTime: {
type: Number | String,
default: 0.5
},
//
bgColor: {
type: String,
default: '#EAEDF5'
},
//
highlightBgColor: {
type: String,
default: '#F9FAFF'
},
//
configs: {
type: Object,
default: () => {
return {
// padding: '30rpx', //
// gridRows: 3, //
// gridColumns: 2, //
// gridRowsGap: '40rpx', //
// gridColumnsGap: '24rpx', //
// itemDirection: 'column', //headtextrowcolumn
// itemGap: '16rpx', //headtext
// itemAlign: 'center', //headtextcenterflex-startflex-endbaseline
// headShow: true, //head
// headWidth: '100%', //head
// headHeight: '400rpx', //head
// headBorderRadius: '12rpx', //head
// textShow: true, //
// textRows: 3, //
// textRowsGap: '12rpx', //
// textWidth: ['40%', '85%', '60%'], //
// textHeight: ['30rpx', '20rpx', '20rpx'], //
// textBorderRadius: '6rpx', //
}
}
}
},
computed: {
gridRowsArr() {
return new Array(Number(this.skeletonConfigs?.gridRows || []));
},
gridColumnsArr() {
return new Array(Number(this.skeletonConfigs?.gridColumns || []));
},
textRowsArr() {
if (!this.skeletonConfigs?.textShow) return [];
if (/%$/.test(this.skeletonConfigs.textHeight)) {
console.error('x-skeleton: textHeight参数不支持百分比单位');
}
const rows = []
for (let i = 0; i < this.skeletonConfigs.textRows; i++) {
const { gridRows, textWidth, textHeight } = this.skeletonConfigs;
let item = {},
//
rowWidth = this.isArray(textWidth) ? (textWidth[i] || (i === gridRows - 1 ? '70%' : '100%')) : i === gridRows - 1 ? '70%' : textWidth,
rowHeight = this.isArray(textHeight) ? (textHeight[i] || '30rpx') : textHeight
//
if (/%$/.test(rowWidth)) {
item.width = rowWidth;
} else {
item.width = this.addUnit(rowWidth)
}
item.height = this.addUnit(rowHeight)
rows.push(item)
}
return rows
},
variableStr() {
let keys = ['animateTime', 'fadeOutTime', 'bgColor', 'highlightBgColor'];
let str = keys.map(item => {
if (item.indexOf('Time') > -1) {
return `--${item}:${this[item]}s`
} else {
return `--${item}:${this[item]}`
}
}).join(";");
return str;
}
},
watch: {
loading: {
immediate: true,
handler(value) {
if (value) {
this.skeletonLoading = true;
} else {
if (this.fadeOut) {
this.startFadeOut = true;
setTimeout(() => {
this.skeletonLoading = false;
this.startFadeOut = false;
}, this.fadeOutTime * 1000);
} else {
this.skeletonLoading = false;
}
}
}
},
type: {
immediate: true,
handler(value) {
if (value === 'banner') {
this.skeletonConfigs = this.bannerConfigs();
} else if (value === 'info') {
this.skeletonConfigs = this.infoConfigs();
} else if (value === 'text') {
this.skeletonConfigs = this.textConfigs();
} else if (value === 'menu') {
this.skeletonConfigs = this.menuConfigs();
} else if (value === 'list') {
this.skeletonConfigs = this.listConfigs();
} else if (value === 'waterfall') {
this.skeletonConfigs = this.waterfallConfigs();
} else {
this.skeletonConfigs = this.configs || {};
}
}
}
},
data() {
return {
skeletonConfigs: this.configs || {},
skeletonLoading: this.loading,
startFadeOut: false,
width: 0
};
},
mounted() {
},
methods: {
/**
* @description 是否为数组
* @param {object} value 需要判断的对象
*/
isArray(value) {
if (typeof Array.isArray === 'function') {
return Array.isArray(value)
}
return Object.prototype.toString.call(value) === '[object Array]'
},
/**
* @description 添加单位如果有rpxupx%px等单位结尾或者值为auto直接返回否则加上px单位结尾
* @param {string|number} value 需要添加单位的值
* @param {string} unit 添加的单位名 比如px
*/
addUnit(value = 'auto', unit = 'px') {
value = String(value);
// uViewnumber
return /^[\+-]?(\d+\.?\d*|\.\d+|\d\.\d+e\+\d+)$/.test(value) ? `${value}${unit}` : value;
}
}
}
</script>
<style lang="scss" scoped>
@mixin background {
background: linear-gradient(90deg, var(--bgColor) 25%, var(--highlightBgColor) 37%, var(--bgColor) 50%);
background-size: 400% 100%;
}
.x-skeleton {
width: 100%;
box-sizing: border-box;
.x-skeleton__wrapper {
display: flex;
flex-direction: column;
&__rows {
display: flex;
align-items: center;
justify-content: space-between;
}
&__columns {
display: flex;
align-items: center;
flex: 1;
}
&__head {
width: 100%;
@include background;
}
&__text {
flex: 1;
width: 100%;
&__row {
@include background;
}
}
}
.fade-out {
opacity: 0;
animation: fadeOutAnim var(--fadeOutTime);
}
@keyframes fadeOutAnim {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
.animate {
animation: skeletonAnim var(--animateTime) ease infinite;
}
@keyframes skeletonAnim {
0% {
background-position: 100% 50%;
}
100% {
background-position: 0 50%;
}
}
}
</style>

View File

@ -0,0 +1,84 @@
{
"id": "x-skeleton",
"displayName": "skeleton骨架屏可任意配置-易用-灵活-动画)",
"version": "1.0.4",
"description": "x-skeleton骨架屏可随意配置内容扩展性强简单易用内含常用的骨架类型",
"keywords": [
"skeleton",
"骨架屏",
"加载效果",
"vue",
"微信小程序"
],
"repository": "",
"engines": {
},
"dcloudext": {
"type": "component-vue",
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "插件不采集任何数据",
"permissions": "无"
},
"npmurl": ""
},
"uni_modules": {
"dependencies": [],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y"
},
"client": {
"Vue": {
"vue2": "y",
"vue3": "u"
},
"App": {
"app-vue": "u",
"app-nvue": "u"
},
"H5-mobile": {
"Safari": "u",
"Android Browser": "u",
"微信浏览器(Android)": "u",
"QQ浏览器(Android)": "u"
},
"H5-pc": {
"Chrome": "y",
"IE": "y",
"Edge": "y",
"Firefox": "y",
"Safari": "u"
},
"小程序": {
"微信": "y",
"阿里": "u",
"百度": "u",
"字节跳动": "u",
"QQ": "u",
"钉钉": "u",
"快手": "u",
"飞书": "u",
"京东": "u"
},
"快应用": {
"华为": "u",
"联盟": "u"
}
}
}
}
}

View File

@ -0,0 +1,93 @@
# x-skeleton
# 功能介绍
- 支持 H5、微信小程序其他端未测试过
- 使用简单、灵活,高度自定义
- 加载时支持动画
- 消失时加了动画,不再生硬切换页面
- 支持绝大部分常用场景:
1、轮播图
2、个人信息
3、段落
4、菜单
5、列表
6、瀑布流
7、自定义...
# 属性说明
| 参数 | 说明 | 类型 | 默认值 | 可选值 |
| ------- | --------------------------------------------------- | ------- | ------ | --- |
| type | 骨架类型,为空时是完全自定义 | String | - |banner轮播图、info个人信息、text段落、menu菜单、list列表、waterfall瀑布流|
| loading | 是否显示骨架占位图设置为false将会展示子组件内容 | Boolean | true |true、false|
| animate | 是否开启动画效果 | Boolean | true |true、false|
| animateTime | 动画效果持续时间,单位秒 | Number \| String | 1.8 |-|
| fadeOut | 是否开启淡出动画 | Boolean | true |true、false|
| fadeOutTime | 淡出效果持续时间,单位秒 | Number \| String | 0.5 |-|
| bgColor | 骨架的背景色 | String | #EAEDF5 |-|
| highlightBgColor | 骨架的动画高亮背景色 | String | #F9FAFF |-|
| configs | 自定义配置,具体看下方 | Object | {} |-|
## configs参数说明
| 参数 | 说明 | 类型 |
| ------- | --------------------------------------------------- | ------- |
| padding | 骨架内边距,同 css 的 padding | String |
| gridRows | 行数 | Number |
| gridColumns | 列数 | Number |
| gridRowsGap | 行间隔 | String |
| gridColumnsGap | 竖间距 | String |
| itemDirection | head与text之间的排列方向row、column | String |
| itemGap | head与text之间的间隔 | String |
| itemAlign | head与text之间的纵轴对齐方式同 flex 的align-itemscenter、flex-start、flex-end等 | String |
| headShow | head是否展示 | Boolean |
| headWidth | head宽度支持百分比 | String |
| headHeight | head高度 | String |
| headBorderRadius | head圆角支持百分比 | String |
| textShow | text是否展示 | Boolean |
| textRows | text的行数 | Number |
| textRowsGap | text间距 | String |
| textWidth | text的宽度可以为百分比数值带单位字符串等可通过数组传入指定每个段落行的宽度 | String \| Array \| Number |
| textHeight | text的高度可以为数值带单位字符串等可通过数组传入指定每个段落行的高度 | String \| Array \| Number |
| textBorderRadius | text的圆角支持百分比 | String |
大部分情况下,直接指定相应的 type 已经够用了,如果大家想进行样式的微调、完全自定义可通过设置 configs 来实现。
简单解释一下这些参数(右边有结构布局图示):
布局总共分成 4 块,分别是 grid、item、head、text。
1、grid包含 item指定每一行有多少个 item每一列有多少个 item
2、item包含 head、text可设置他们之间的排列方式、间距
3、head一个 item 只有一个 head可设置宽高、圆角
4、text一个 item 可以有多行 text可分别设置宽高、圆角、间距
# 使用示例
```html
<x-skeleton type="banner" :loading="loading">
<view>我是轮播图</view>
</x-skeleton>
```
```js
export default {
data() {
return {
loading: true,
}
},
onLoad() {
setTimeout(() => {
this.loading = false;
}, 2000);
},
}
```
更多用法请下载查看示例代码,有问题可以留言