7.10 增加登录页面,事件详情接口对接,我的点赞,关注收藏页面搭建,接口对接

This commit is contained in:
尚政杰
2025-07-10 18:08:16 +08:00
parent c4267a0e27
commit 58b3414bdd
356 changed files with 7710 additions and 978 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,129 @@
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title></title>
<style type="text/css">
html,
body,
.canvas {
padding: 0;
margin: 0;
overflow-y: hidden;
background-color: transparent;
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div class="canvas" id="limeChart"></div>
<script type="text/javascript" src="./uni.webview.1.5.3.js"></script>
<script type="text/javascript" src="./echarts.min.js"></script>
<script type="text/javascript" src="./ecStat.min.js"></script>
<!-- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts-liquidfill@latest/dist/echarts-liquidfill.min.js"></script> -->
<script>
let chart = null;
let cache = [];
console.log = function(...agrs) {
postMessage(agrs)
}
function emit(event, data) {
let dataStr = JSON.stringify(data, stringify)
postMessage({
event,
data: dataStr
})
cache = []
}
function postMessage(data) {
uni.postMessage({
data
});
}
function stringify(key, value) {
if (typeof value === 'object' && value !== null) {
if (cache.indexOf(value) !== -1) {
return;
}
cache.push(value);
}
return value;
}
function parse(name, callback, options) {
const optionNameReg = /[\w]+\.setOption\(([\w]+\.)?([\w]+)\)/
if (optionNameReg.test(callback)) {
const optionNames = callback.match(optionNameReg)
if(optionNames[1]) {
const _this = optionNames[1].split('.')[0]
window[_this] = {}
window[_this][optionNames[2]] = options
return optionNames[2]
} else {
return null
}
}
return null
}
function init(callback, options, opts = {}, theme = null) {
if(!chart) {
chart = echarts.init(document.getElementById('limeChart'), theme, opts)
if(options) {
chart.setOption(options)
}
// const name = parse('a', callback, options)
// console.log('options::', callback)
// if(name) this[name] = options
// eval(`a = ${callback};`)
// if(a) {a(chart)}
}
}
function setChart(callback, options) {
if(!callback) return
if(chart && callback && options) {
var r = null
const name = parse('r', callback, options)
if(name) this[name] = options
eval(`r = ${callback};`)
if(r) {r(chart)}
}
}
function setOption(data) {
if (chart) chart.setOption(data[0], data[1])
}
function showLoading(data) {
if (chart) chart.showLoading(data[0], data[1])
}
function hideLoading() {
if (chart) chart.hideLoading()
}
function clear() {
if (chart) chart.clear()
}
function dispose() {
if (chart) chart.dispose()
}
function resize(size) {
if (chart) chart.resize(size)
}
function canvasToTempFilePath(opt = {}) {
if (chart) {
const src = chart.getDataURL(opt)
postMessage({
file: true,
data: src
})
}
}
</script>
</body>
</html>

View File

@@ -0,0 +1,177 @@
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title></title>
<style type="text/css">
html,
body,
.canvas {
padding: 0;
margin: 0;
overflow-y: hidden;
background-color: transparent;
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div class="canvas" id="limeChart"></div>
<script type="text/javascript" src="./uni.webview.1.5.3.js"></script>
<script type="text/javascript" src="./echarts.min.js"></script>
<script type="text/javascript" src="./ecStat.min.js"></script>
<!-- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts-liquidfill@latest/dist/echarts-liquidfill.min.js"></script> -->
<script>
let chart = null;
let cache = [];
console.log = function(...agrs) {
postMessage(agrs)
}
function emit(event, data) {
let dataStr = JSON.stringify(data, stringify)
postMessage({
event,
data: dataStr
})
cache = []
}
function postMessage(data) {
uni.postMessage({
data
});
}
function stringify(key, value) {
if (typeof value === 'object' && value !== null) {
if (cache.indexOf(value) !== -1) {
return;
}
cache.push(value);
}
return value;
}
function parse(name, callback, options) {
const optionNameReg = /[\w]+\.setOption\(([\w]+\.)?([\w]+)\)/
if (optionNameReg.test(callback)) {
const optionNames = callback.match(optionNameReg)
if (optionNames[1]) {
const _this = optionNames[1].split('.')[0]
window[_this] = {}
window[_this][optionNames[2]] = options
return optionNames[2]
} else {
return null
}
}
return null
}
function init(callback, options, opts = {}, theme = null) {
if (!chart) {
chart = echarts.init(document.getElementById('limeChart'), theme, opts)
if (options) {
chart.setOption(options)
}
// const name = parse('a', callback, options)
// console.log('options::', callback)
// if(name) this[name] = options
// eval(`a = ${callback};`)
// if(a) {a(chart)}
}
}
function setChart(callback, options) {
if (!callback) return
if (chart && callback && options) {
var r = null
const name = parse('r', callback, options)
if (name) this[name] = options
eval(`r = ${callback};`)
if (r) {
r(chart)
}
}
}
function setOption(data) {
if (chart) chart.setOption(data[0], data[1])
}
function showLoading(data) {
if (chart) chart.showLoading(data[0], data[1])
}
function hideLoading() {
if (chart) chart.hideLoading()
}
function clear() {
if (chart) chart.clear()
}
function dispose() {
if (chart) chart.dispose()
}
function resize(size) {
if (chart) chart.resize(size)
}
function canvasToTempFilePath(opt = {}) {
if (chart) {
const src = chart.getDataURL(opt)
postMessage({
file: true,
data: src
})
}
}
function on(data) {
if (chart && data.length > 0) {
const [type, query] = data
const useQuery = query && typeof query != 'function'
const key = `${type}${useQuery ? JSON.stringify(query): '' }`
if (query) {
chart.on(type, query, (options) => {
const obj = {}
Object.keys(options).forEach(key => {
if (key != 'event') {
obj[key] = options[key]
}
})
emit(`@${key}`, {
event: key,
options: obj
})
})
} else {
chart.on(type, (options) => {
const obj = {}
Object.keys(options).forEach(key => {
if (key != 'event') {
obj[key] = options[key]
}
})
emit(`@${key}`, {
event: key,
options: obj
})
})
}
}
}
</script>
</body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,184 @@
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title></title>
<style type="text/css">
html,
body {
overflow: hidden;
/* 隐藏滚动条 */
overscroll-behavior: none;
/* 禁止橡皮筋效果 */
}
html,
body,
.canvas {
padding: 0;
margin: 0;
overflow-y: hidden;
background-color: transparent;
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div class="canvas" id="limeChart"></div>
<script type="text/javascript" src="./uni.webview.1.5.5.js"></script>
<script type="text/javascript" src="./echarts.min.js"></script>
<script type="text/javascript" src="./ecStat.min.js"></script>
<!-- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts-liquidfill@latest/dist/echarts-liquidfill.min.js"></script> -->
<script>
let chart = null;
let cache = [];
console.log = function() {
emit('log', {
log: arguments,
})
}
function emit(event, data) {
postMessage({
event,
data
})
cache = []
}
function postMessage(data) {
uni.webView.postMessage({
data
})
// window.__uniapp_x_.postMessage(JSON.stringify(data))
};
function stringify(key, value) {
if (typeof value === 'object' && value !== null) {
if (cache.indexOf(value) !== -1) {
return;
}
cache.push(value);
}
return value;
}
function parse(name, callback, options) {
const optionNameReg = /[\w]+\.setOption\(([\w]+\.)?([\w]+)\)/
if (optionNameReg.test(callback)) {
const optionNames = callback.match(optionNameReg)
if (optionNames[1]) {
const _this = optionNames[1].split('.')[0]
window[_this] = {}
window[_this][optionNames[2]] = options
return optionNames[2]
} else {
return null
}
}
return null
}
function init(callback, options, opts, theme) {
if (!chart) {
chart = echarts.init(document.getElementById('limeChart'), theme, opts)
if (options) {
chart.setOption(options)
}
}
}
function on(data) {
if (chart && data.length > 0) {
const [type, query] = data
const key = `${type}${JSON.stringify(query||'')}`
if (query) {
chart.on(type, query, function(options) {
var obj = {};
Object.keys(options).forEach(function(key) {
if (key != 'event') {
obj[key] = options[key];
}
});
emit(key, {
event: key,
options: obj,
});
});
} else {
chart.on(type, function(options) {
var obj = {};
Object.keys(options).forEach(function(key) {
if (key != 'event') {
obj[key] = options[key];
}
});
emit(key, {
event: key,
options: obj,
});
});
}
}
}
function setChart(callback, options) {
if (!callback) return
if (chart && callback && options) {
var r = null
const name = parse('r', callback, options)
if (name) this[name] = options
eval(`r = ${callback};`)
if (r) {
r(chart)
}
}
}
function setOption(data) {
if (chart) chart.setOption(data[0], data[1])
}
function showLoading(data) {
if (chart) chart.showLoading(data[0], data[1])
}
function hideLoading() {
if (chart) chart.hideLoading()
}
function clear() {
if (chart) chart.clear()
}
function dispose() {
if (chart) chart.dispose()
}
function resize(size) {
if (chart) chart.resize(size)
}
function canvasToTempFilePath(opt) {
if (chart) {
delete opt.success
const src = chart.getDataURL(opt)
postMessage({
// event: 'file',
file: src
})
}
}
document.addEventListener('touchmove', () => {
})
</script>
</body>
</html>

View File

@@ -0,0 +1 @@
"use strict";const t=require("../../../../common/vendor.js"),s={name:"uniPopup",components:{},emits:["change","maskClick"],props:{animation:{type:Boolean,default:!0},type:{type:String,default:"center"},isMaskClick:{type:Boolean,default:null},maskClick:{type:Boolean,default:null},backgroundColor:{type:String,default:"none"},safeArea:{type:Boolean,default:!0},maskBackgroundColor:{type:String,default:"rgba(0, 0, 0, 0.4)"},borderRadius:{type:String}},watch:{type:{handler:function(t){this.config[t]&&this[this.config[t]](!0)},immediate:!0},isDesktop:{handler:function(t){this.config[t]&&this[this.config[this.type]](!0)},immediate:!0},maskClick:{handler:function(t){this.mkclick=t},immediate:!0},isMaskClick:{handler:function(t){this.mkclick=t},immediate:!0},showPopup(t){}},data(){return{duration:300,ani:[],showPopup:!1,showTrans:!1,popupWidth:0,popupHeight:0,config:{top:"top",bottom:"bottom",center:"center",left:"left",right:"right",message:"top",dialog:"center",share:"bottom"},maskClass:{position:"fixed",bottom:0,top:0,left:0,right:0,backgroundColor:"rgba(0, 0, 0, 0.4)"},transClass:{backgroundColor:"transparent",borderRadius:this.borderRadius||"0",position:"fixed",left:0,right:0},maskShow:!0,mkclick:!0,popupstyle:"top"}},computed:{getStyles(){let t={backgroundColor:this.bg};return this.borderRadius,t=Object.assign(t,{borderRadius:this.borderRadius}),t},isDesktop(){return this.popupWidth>=500&&this.popupHeight>=500},bg(){return""===this.backgroundColor||"none"===this.backgroundColor?"transparent":this.backgroundColor}},mounted(){(()=>{const{windowWidth:s,windowHeight:i,windowTop:o,safeArea:e,screenHeight:a,safeAreaInsets:r}=t.index.getWindowInfo();this.popupWidth=s,this.popupHeight=i+(o||0),e&&this.safeArea?this.safeAreaInsets=a-e.bottom:this.safeAreaInsets=0})()},unmounted(){this.setH5Visible()},activated(){this.setH5Visible(!this.showPopup)},deactivated(){this.setH5Visible(!0)},created(){null===this.isMaskClick&&null===this.maskClick?this.mkclick=!0:this.mkclick=null!==this.isMaskClick?this.isMaskClick:this.maskClick,this.animation?this.duration=300:this.duration=0,this.messageChild=null,this.clearPropagation=!1,this.maskClass.backgroundColor=this.maskBackgroundColor},methods:{setH5Visible(t=!0){},closeMask(){this.maskShow=!1},disableMask(){this.mkclick=!1},clear(t){t.stopPropagation(),this.clearPropagation=!0},open(t){if(this.showPopup)return;t&&-1!==["top","center","bottom","left","right","message","dialog","share"].indexOf(t)||(t=this.type),this.config[t]?(this[this.config[t]](),this.$emit("change",{show:!0,type:t})):console.error("缺少类型:",t)},close(t){this.showTrans=!1,this.$emit("change",{show:!1,type:this.type}),clearTimeout(this.timer),this.timer=setTimeout((()=>{this.showPopup=!1}),300)},touchstart(){this.clearPropagation=!1},onTap(){this.clearPropagation?this.clearPropagation=!1:(this.$emit("maskClick"),this.mkclick&&this.close())},top(t){this.popupstyle=this.isDesktop?"fixforpc-top":"top",this.ani=["slide-top"],this.transClass={position:"fixed",left:0,right:0,backgroundColor:this.bg,borderRadius:this.borderRadius||"0"},t||(this.showPopup=!0,this.showTrans=!0,this.$nextTick((()=>{this.showPoptrans(),this.messageChild&&"message"===this.type&&this.messageChild.timerClose()})))},bottom(t){this.popupstyle="bottom",this.ani=["slide-bottom"],this.transClass={position:"fixed",left:0,right:0,bottom:0,paddingBottom:this.safeAreaInsets+"px",backgroundColor:this.bg,borderRadius:this.borderRadius||"0"},t||this.showPoptrans()},center(t){this.popupstyle="center",this.ani=["fade"],this.transClass={position:"fixed",display:"flex",flexDirection:"column",bottom:0,left:0,right:0,top:0,justifyContent:"center",alignItems:"center",borderRadius:this.borderRadius||"0"},t||this.showPoptrans()},left(t){this.popupstyle="left",this.ani=["slide-left"],this.transClass={position:"fixed",left:0,bottom:0,top:0,backgroundColor:this.bg,borderRadius:this.borderRadius||"0",display:"flex",flexDirection:"column"},t||this.showPoptrans()},right(t){this.popupstyle="right",this.ani=["slide-right"],this.transClass={position:"fixed",bottom:0,right:0,top:0,backgroundColor:this.bg,borderRadius:this.borderRadius||"0",display:"flex",flexDirection:"column"},t||this.showPoptrans()},showPoptrans(){this.$nextTick((()=>{this.showPopup=!0,this.showTrans=!0}))}}};if(!Array){t.resolveComponent("uni-transition")()}Math;const i=t._export_sfc(s,[["render",function(s,i,o,e,a,r){return t.e({a:a.showPopup},a.showPopup?t.e({b:a.maskShow},a.maskShow?{c:t.o(r.onTap),d:t.p({name:"mask","mode-class":"fade",styles:a.maskClass,duration:a.duration,show:a.showTrans})}:{},{e:t.s(r.getStyles),f:t.n(a.popupstyle),g:t.o(((...t)=>r.clear&&r.clear(...t))),h:t.o(r.onTap),i:t.p({"mode-class":a.ani,name:"content",styles:a.transClass,duration:a.duration,show:a.showTrans}),j:t.o(((...t)=>r.touchstart&&r.touchstart(...t))),k:t.n(a.popupstyle),l:t.n(r.isDesktop?"fixforpc-z-index":"")}):{})}]]);wx.createComponent(i);

View File

@@ -0,0 +1,6 @@
{
"component": true,
"usingComponents": {
"uni-transition": "../../../uni-transition/components/uni-transition/uni-transition"
}
}

View File

@@ -0,0 +1 @@
<view wx:if="{{a}}" class="{{['uni-popup', k, l]}}"><view bindtouchstart="{{j}}"><uni-transition wx:if="{{b}}" key="1" bindclick="{{c}}" u-i="10ea031a-0" bind:__l="__l" u-p="{{d}}"/><uni-transition wx:if="{{i}}" u-s="{{['d']}}" key="2" bindclick="{{h}}" u-i="10ea031a-1" bind:__l="__l" u-p="{{i}}"><view style="{{e}}" class="{{['uni-popup__wrapper', f]}}" bindtap="{{g}}"><slot/></view></uni-transition></view></view>

View File

@@ -0,0 +1 @@
.uni-popup{position:fixed;z-index:10000}.uni-popup.top,.uni-popup.left,.uni-popup.right{top:0}.uni-popup .uni-popup__wrapper{display:block;position:relative}.uni-popup .uni-popup__wrapper.left,.uni-popup .uni-popup__wrapper.right{padding-top:0;flex:1}.fixforpc-z-index{z-index:999}.fixforpc-top{top:0}

View File

@@ -0,0 +1 @@
"use strict";const t=require("../../../../common/vendor.js");class e{constructor(e,i){this.options=e,this.animation=t.index.createAnimation({...e}),this.currentStepAnimates={},this.next=0,this.$=i}_nvuePushAnimates(t,e){let n=this.currentStepAnimates[this.next],s={};if(s=n||{styles:{},config:{}},i.includes(t)){s.styles.transform||(s.styles.transform="");let i="";"rotate"===t&&(i="deg"),s.styles.transform+=`${t}(${e+i}) `}else s.styles[t]=`${e}`;this.currentStepAnimates[this.next]=s}_animateRun(t={},e={}){let i=this.$.$refs.ani.ref;if(i)return new Promise(((n,s)=>{nvueAnimation.transition(i,{styles:t,...e},(t=>{n()}))}))}_nvueNextAnimate(t,e=0,i){let n=t[e];if(n){let{styles:s,config:a}=n;this._animateRun(s,a).then((()=>{e+=1,this._nvueNextAnimate(t,e,i)}))}else this.currentStepAnimates={},"function"==typeof i&&i(),this.isEnd=!0}step(t={}){return this.animation.step(t),this}run(t){this.$.animationData=this.animation.export(),this.$.timer=setTimeout((()=>{"function"==typeof t&&t()}),this.$.durationTime)}}const i=["matrix","matrix3d","rotate","rotate3d","rotateX","rotateY","rotateZ","scale","scale3d","scaleX","scaleY","scaleZ","skew","skewX","skewY","translate","translate3d","translateX","translateY","translateZ"];i.concat(["opacity","backgroundColor"],["width","height","left","right","top","bottom"]).forEach((t=>{e.prototype[t]=function(...e){return this.animation[t](...e),this}})),exports.createAnimation=function(t,i){if(i)return clearTimeout(i.timer),new e(t,i)};

View File

@@ -0,0 +1 @@
"use strict";const t=require("./createAnimation.js"),i=require("../../../../common/vendor.js"),s={name:"uniTransition",emits:["click","change"],props:{show:{type:Boolean,default:!1},modeClass:{type:[Array,String],default:()=>"fade"},duration:{type:Number,default:300},styles:{type:Object,default:()=>({})},customClass:{type:String,default:""},onceRender:{type:Boolean,default:!1}},data:()=>({isShow:!1,transform:"",opacity:0,animationData:{},durationTime:300,config:{}}),watch:{show:{handler(t){t?this.open():this.isShow&&this.close()},immediate:!0}},computed:{stylesObject(){let t={...this.styles,"transition-duration":this.duration/1e3+"s"},i="";for(let s in t){i+=this.toLine(s)+":"+t[s]+";"}return i},transformStyles(){return"transform:"+this.transform+";opacity:"+this.opacity+";"+this.stylesObject}},created(){this.config={duration:this.duration,timingFunction:"ease",transformOrigin:"50% 50%",delay:0},this.durationTime=this.duration},methods:{init(i={}){i.duration&&(this.durationTime=i.duration),this.animation=t.createAnimation(Object.assign(this.config,i),this)},onClick(){this.$emit("click",{detail:this.isShow})},step(t,i={}){return this.animation?(Object.keys(t).forEach((i=>{const s=t[i];"function"==typeof this.animation[i]&&(Array.isArray(s)?this.animation[i](...s):this.animation[i](s))})),this.animation.step(i),this):this},run(t){this.animation&&this.animation.run(t)},open(){clearTimeout(this.timer),this.isShow=!0,this.transform=this.styleInit(!1).transform||"",this.opacity=this.styleInit(!1).opacity||0,this.$nextTick((()=>{this.timer=setTimeout((()=>{this.animation=t.createAnimation(this.config,this),this.tranfromInit(!1).step(),this.animation.run((()=>{this.transform="",this.opacity=this.styleInit(!1).opacity||1,this.$emit("change",{detail:this.isShow})}))}),80)}))},close(t){this.animation&&this.tranfromInit(!0).step().run((()=>{this.isShow=!1,this.animationData=null,this.animation=null;let{opacity:t,transform:i}=this.styleInit(!1);this.opacity=t||1,this.transform=i,this.$emit("change",{detail:this.isShow})}))},styleInit(t){let i={transform:"",opacity:1};const s=(t,s)=>{const a=this.animationType(t)[s];s.startsWith("fade")?i.opacity=a:i.transform+=a+" "};return"string"==typeof this.modeClass?s(t,this.modeClass):this.modeClass.forEach((i=>s(t,i))),i},tranfromInit(t){let i=(t,i)=>{let s=null;"fade"===i?s=t?0:1:(s=t?"-100%":"0","zoom-in"===i&&(s=t?.8:1),"zoom-out"===i&&(s=t?1.2:1),"slide-right"===i&&(s=t?"100%":"0"),"slide-bottom"===i&&(s=t?"100%":"0")),this.animation[this.animationMode()[i]](s)};return"string"==typeof this.modeClass?i(t,this.modeClass):this.modeClass.forEach((s=>{i(t,s)})),this.animation},animationType:t=>({fade:t?1:0,"slide-top":`translateY(${t?"0":"-100%"})`,"slide-right":`translateX(${t?"0":"100%"})`,"slide-bottom":`translateY(${t?"0":"100%"})`,"slide-left":`translateX(${t?"0":"-100%"})`,"zoom-in":`scaleX(${t?1:.8}) scaleY(${t?1:.8})`,"zoom-out":`scaleX(${t?1:1.2}) scaleY(${t?1:1.2})`}),animationMode:()=>({fade:"opacity","slide-top":"translateY","slide-right":"translateX","slide-bottom":"translateY","slide-left":"translateX","zoom-in":"scale","zoom-out":"scale"}),toLine:t=>t.replace(/([A-Z])/g,"-$1").toLowerCase()}};const a=i._export_sfc(s,[["render",function(t,s,a,n,e,o){return{a:e.isShow,b:e.animationData,c:i.n(a.customClass),d:i.s(o.transformStyles),e:i.o(((...t)=>o.onClick&&o.onClick(...t)))}}]]);wx.createComponent(a);

View File

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

View File

@@ -0,0 +1 @@
<view hidden="{{!a}}" ref="ani" animation="{{b}}" class="{{c}}" style="{{d}}" bindtap="{{e}}"><slot></slot></view>

View File

@@ -0,0 +1 @@
"use strict";const t=require("../../../../common/vendor.js"),e="counterclockwise",r="clockwise",i={name:"zui-progress-circle",components:{},props:{size:{type:Number,default:180},position:{type:Number,default:0},range:{type:[Array],default:()=>[0,360]},direction:{type:String,default:r,validator:t=>[e,r].includes(t)},ringWidth:{type:Number,default:8},linecap:{type:String,default:"round"},texture:{type:[String,Array],default:()=>["#1BB507","#E2D8D8"]},pointer:String,pointerOffset:Number,fixOverlay:Boolean,debug:Boolean},data:()=>({}),computed:{preset(){const t={};return t.start=this.range[0],t.end=this.range[0]>this.range[1]?this.range[1]+360:this.range[1],t.ringRadius=(this.size-this.ringWidth)/2,t.ringCenter=this.size/2,t.ringPerimeter=2*Math.PI*t.ringRadius,t.ringLength=(t.end-t.start)*Math.PI*t.ringRadius/180,t.ringStart=t.start*Math.PI*t.ringRadius/180,t.ringEnd=t.end*Math.PI*t.ringRadius/180,/^(ccw|counterclockwise)$/i.test(this.direction)?t.direction=e:t.direction=r,t},textureFG(){const t=this.size;return"string"==typeof this.texture?this.parseTexture(this.texture,t):"[object Array]"===Object.prototype.toString.call(this.texture)?"number"==typeof this.texture[0]?this.parseTexture(this.texture,t):this.parseTexture(this.texture[0],t):this.parseTexture("#1BB507",t)},textureBG(){const t=this.size;return"string"==typeof this.texture?this.parseTexture(void 0,t):"[object Array]"===Object.prototype.toString.call(this.texture)?"number"==typeof this.texture[0]?this.parseTexture(void 0,t):this.parseTexture(this.texture[1],t):this.parseTexture("#E2D8D8",t)},hasBackground(){return!!this.textureBG},svgDataUrl(){let t=this.createSVG();return t=`data:image/svg+xml,${encodeURIComponent(t.replace(/ +/g," "))}`,t},style(){const t={width:`${this.size}px`,height:`${this.size}px`,"--zui-progress-circle-ring-size":`${this.size}px`,"--zui-progress-circle-ring-width":`${this.ringWidth}px`};return Object.keys(t).map((e=>`${e}:${t[e]}`)).join(";")},pointerStyle(){const t={},{start:e,end:r,ringRadius:i}=this.preset;let n=(r-e)*this.position+e;"round"!==this.linecap&&"butt"!==this.linecap||(n+=this.ringWidth/3*180/(Math.PI*i));const s=this.pointerOffset||0;return t["--zui-progress-circle-pointer-rotate"]=`translate(-${s}px, -50%) rotate(${n}deg)`,t["--zui-progress-circle-pointer-center"]=`${s}px 50%`,Object.keys(t).map((e=>`${e}:${t[e]}`)).join(";")}},methods:{parseTexture(t,e){if(!t)return;if(/^#[0-9a-f]+/i.test(t))return{type:"color",value:t};const r=(()=>{const t=999999*Math.random();return Math.round(t)+1e5})();return/Gradient>/i.test(t)?{type:"gradient",value:`url(#def_${r})`,def:t=/id="[^"]+"/.test(t)?t.replace(/id="[^"]+"/,`id="def_${r}"`):t.replace(/<(\w+Gradient) /,`<$1 id="def_${r}" `)}:"[object Array]"===Object.prototype.toString.call(t)?{type:"gradient",value:`url(#def_${r})`,def:t=this.createGradient(r,t.slice(1),t[0])}:{type:"pattern",value:`url(#def_${r})`,def:t=/<pattern /.test(t)?/id="[^"]+"/.test(t)?t.replace(/id="[^"]+"/,`id="def_${r}"`):t.replace(/<pattern /,`<$1 id="def_${r}" `):this.createPattern(`def_${r}`,t,e)}},createGradient(t,e,r){const i=100/(e.length-1);return`<linearGradient id="def_${t}" x1="0%" y1="0%" x2="100%" y2="64.9%" gradientTransform="rotate(${r})">\n ${new Array(e.length).fill(null).map(((t,r)=>`<stop offset="${i*r*100}%" stop-color="${e[r]}" />`)).join("")}\n </linearGradient>`},createPattern:(t,e,r)=>`<pattern id="${t}" patternUnits="userSpaceOnUse" width="100%" height="100%">\n <image xlink:href="${e}" x="0" y="0" width="100%" height="100%"/>\n </pattern>`,createCircle(t,e,r){const{ringCenter:i,ringRadius:n,fixOverlay:s}=this.preset,a={cx:i,cy:i,r:n,"stroke-width":this.ringWidth,stroke:t&&t.value,"stroke-linecap":this.linecap,"stroke-dasharray":e.join(",")};if(s){const t="fg"===r?this.ringWidth:this.ringWidth-1;a["stroke-width"]=t>8?t:8}return`<circle fill="none" stroke-dashoffset="1" ${Object.keys(a).map((t=>a[t]?`${t}="${a[t]}"`:"")).join(" ")}></circle>`},generateDashArray(t){const{direction:r,ringStart:i,ringPerimeter:n,ringLength:s}=this.preset;let a=r===e?i+(1-t)*s:i,o=0,h=0,d=0;h=1+a,d=t*s;const c=a+t*s;return c>n?(o=c-n,h=a-o):o=0,[o,h,d,n]},createSVG(){const t=this.hasBackground?this.createCircle(this.textureBG,this.generateDashArray(1)):"",e=this.createCircle(this.textureFG,this.generateDashArray(this.position),"fg"),r=[this.textureFG.def||"",this.textureBG&&this.textureBG.def||""];return`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="${this.size}" height="${this.size}">\n <defs>\n ${r.join("\n")}\n </defs>\n <g>\n ${t}\n ${e}\n </g>\n</svg>`}}};const n=t._export_sfc(i,[["render",function(e,r,i,n,s,a){return t.e({a:i.pointer},i.pointer?{b:i.pointer,c:t.s(a.pointerStyle)}:{},{d:a.svgDataUrl,e:i.debug},(i.debug,{}),{f:t.n(i.debug?"debug":""),g:t.s(a.style)})}],["__scopeId","data-v-429415b9"]]);wx.createComponent(n);

View File

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

View File

@@ -0,0 +1 @@
<view ref="eleMeter" class="{{['data-v-429415b9', 'zui-progress-circle', f]}}" style="{{g}}"><view class="zui-progress-circle-wrapper data-v-429415b9"><image wx:if="{{a}}" class="zui-progress-circle-pointer data-v-429415b9" mode="aspectFit" src="{{b}}" style="{{c}}"/><image class="zui-progress-circle-ring data-v-429415b9" mode="aspectFit" src="{{d}}"/></view><view class="zui-progress-circle-slot data-v-429415b9"><slot/></view><view wx:if="{{e}}" class="debug-frame data-v-429415b9"><view class="cross-v data-v-429415b9"></view><view class="cross-h data-v-429415b9"></view><view class="half-size data-v-429415b9"></view></view></view>

View File

@@ -0,0 +1 @@
.zui-progress-circle.data-v-429415b9{--zui-progress-circle-debug-color: #f00;position:relative}.zui-progress-circle-wrapper.data-v-429415b9{width:100%;height:100%}.zui-progress-circle-ring.data-v-429415b9{width:var(--zui-progress-circle-ring-size);height:var(--zui-progress-circle-ring-size)}.zui-progress-circle-slot.data-v-429415b9{position:absolute;top:0;left:0;width:100%;height:100%;padding:var(--zui-progress-circle-ring-width);box-sizing:border-box}.zui-progress-circle-pointer.data-v-429415b9{position:absolute;z-index:10;top:50%;left:50%;transform:var(--zui-progress-circle-pointer-rotate);transform-origin:var(--zui-progress-circle-pointer-center);width:50%;height:50%;transition:transform .1s linear}.debug-frame.data-v-429415b9,.cross-v.data-v-429415b9,.cross-h.data-v-429415b9,.half-size.data-v-429415b9{position:absolute}.debug-frame.data-v-429415b9{position:absolute;z-index:99;top:0;left:0;width:100%;height:100%;border:1px solid var(--zui-progress-circle-debug-color);border-radius:50%}.cross-h.data-v-429415b9,.cross-v.data-v-429415b9,.half-size.data-v-429415b9{top:50%;left:50%;transform:translate(-50%,-50%);background-color:var(--zui-progress-circle-debug-color);mix-blend-mode:difference}.cross-v.data-v-429415b9{width:1px;height:100%}.cross-h.data-v-429415b9{width:100%;height:1px}.half-size.data-v-429415b9{width:50%;height:50%;border:1px solid var(--zui-progress-circle-debug-color);background-color:transparent;border-radius:50%}