第一次提交:小程序前端最新版本

This commit is contained in:
XingQue
2026-06-14 02:38:05 +08:00
commit 5e90f7c87c
677 changed files with 153758 additions and 0 deletions

View File

@@ -0,0 +1,73 @@
// components/chenghao-tag/chenghao-tag.js
const app = getApp();
Component({
properties: {
mingcheng: { type: String, value: '' },
texiaoJson: { type: Object, value: {} }
},
data: {
// 默认值宽152高52六边形无背景图无动画白色字
width: 152,
height: 52,
shapeClass: 'liubianxing', // 保证至少不是矩形
animationClass: '',
bgStyle: '',
textColor: '#FFFFFF',
textSize: 22,
imageUrl: ''
},
lifetimes: {
attached() {
const cfg = this.properties.texiaoJson || {};
// 1. 尺寸稍大一些一行能放3~4个
const width = cfg.width || 152;
const height = cfg.height || 52;
// 2. 背景处理:优先背景图,否则用渐变/纯色
let bgStyle = '';
let imageUrl = '';
if (cfg.image_url) {
const ossImageUrl = app.globalData.ossImageUrl || '';
imageUrl = cfg.image_url.startsWith('http')
? cfg.image_url
: ossImageUrl + cfg.image_url;
} else if (cfg.bg_gradient) {
bgStyle = `background: ${cfg.bg_gradient};`;
} else if (cfg.bg_color) {
bgStyle = `background: ${cfg.bg_color};`;
} else {
// 默认金橙渐变
bgStyle = `background: linear-gradient(135deg, #FFD700, #FF8C00);`;
}
// 3. 形状(后端传入 shape 字段,默认 liubianxing
const shapeClass = cfg.shape || 'liubianxing';
// 4. 动画
const animationClass = cfg.animation || '';
// 5. 文字
const textColor = cfg.text_color || '#FFFFFF';
const textSize = cfg.text_size || 22;
this.setData({
width, height,
bgStyle, imageUrl,
shapeClass, animationClass,
textColor, textSize
});
}
},
methods: {
// 背景图加载失败时回退为纯色背景
onImageError() {
this.setData({ imageUrl: '' });
// 如果 bgStyle 为空,给个默认背景
if (!this.data.bgStyle) {
this.setData({ bgStyle: 'background: linear-gradient(135deg, #FFD700, #FF8C00);' });
}
}
}
});

View File

@@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}

View File

@@ -0,0 +1,20 @@
<!-- components/chenghao-tag/chenghao-tag.wxml -->
<view
class="tag-root {{shapeClass}} {{animationClass}}"
style="width: {{width}}rpx; height: {{height}}rpx; {{bgStyle}}"
>
<!-- 背景图(如果有) -->
<image
wx:if="{{imageUrl}}"
class="tag-bg-image"
src="{{imageUrl}}"
mode="aspectFill"
binderror="onImageError"
></image>
<!-- 文字层 -->
<text
class="tag-text"
style="color: {{textColor}}; font-size: {{textSize}}rpx;"
>{{mingcheng}}</text>
</view>

View File

@@ -0,0 +1,90 @@
/* components/chenghao-tag/chenghao-tag.wxss */
/* ========== 根容器 ========== */
.tag-root {
display: inline-flex;
align-items: center;
justify-content: center;
position: relative;
border-radius: 4rpx;
overflow: hidden;
flex-shrink: 0;
margin: 4rpx;
box-sizing: border-box;
}
/* ========== 背景图 ========== */
.tag-bg-image {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 0;
border-radius: inherit;
}
/* ========== 文字层 ========== */
.tag-text {
position: relative;
z-index: 2;
font-weight: bold;
white-space: nowrap;
text-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.5);
padding: 0 10rpx;
}
/* ========== 多边形形状 ========== */
.tag-root.liubianxing {
clip-path: polygon(12% 0%, 88% 0%, 100% 50%, 88% 100%, 12% 100%, 0% 50%);
}
.tag-root.lingxing {
clip-path: polygon(50% 0%, 85% 12%, 100% 50%, 85% 88%, 50% 100%, 15% 88%, 0% 50%, 15% 12%);
}
.tag-root.wujiaoxing {
clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
.tag-root.dunpai {
clip-path: polygon(18% 0%, 82% 0%, 100% 18%, 95% 50%, 100% 82%, 82% 100%, 18% 100%, 0% 82%, 5% 50%, 0% 18%);
}
.tag-root.jiantou {
clip-path: polygon(0% 0%, 85% 0%, 100% 50%, 85% 100%, 0% 100%, 12% 50%);
}
/* ========== 动画 ========== */
/* 流光扫描 */
.tag-root.shine::after {
content: '';
position: absolute;
top: 0;
left: -100%;
width: 60%;
height: 100%;
background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
transform: skewX(-20deg);
animation: shine-anim 2s infinite;
z-index: 1;
pointer-events: none;
}
@keyframes shine-anim {
0% { left: -100%; }
100% { left: 200%; }
}
/* 呼吸光晕 */
.tag-root.pulse {
animation: pulse-anim 1.5s ease-in-out infinite;
}
@keyframes pulse-anim {
0%, 100% { filter: brightness(1); transform: scale(1); }
50% { filter: brightness(1.2); transform: scale(1.04); }
}
/* 外发光闪烁 */
.tag-root.glow {
animation: glow-anim 2s ease-in-out infinite;
}
@keyframes glow-anim {
0%, 100% { box-shadow: 0 0 8rpx rgba(255, 215, 0, 0.4); }
50% { box-shadow: 0 0 20rpx rgba(255, 215, 0, 0.8), 0 0 40rpx rgba(255, 215, 0, 0.4); }
}