Skip to content

Commit 30d4f71

Browse files
committed
update: 修复 popup 样式问题,修改 echarts 传值方式。
1 parent 830ef3d commit 30d4f71

6 files changed

Lines changed: 218 additions & 199 deletions

File tree

Lines changed: 134 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -1,135 +1,135 @@
1-
<template>
2-
<canvas
3-
v-if="canvasId"
4-
class="ec-canvas"
5-
:id="canvasId"
6-
:canvasId="canvasId"
7-
@touchstart="touchStart"
8-
@touchmove="touchMove"
9-
@touchend="touchEnd"
10-
@error="error">
11-
</canvas>
12-
</template>
13-
14-
<script>
15-
import WxCanvas from './wx-canvas';
16-
17-
export default {
18-
props: {
19-
onInit: {
20-
required: true,
21-
type: Function,
22-
default: null,
23-
},
24-
canvasId: {
25-
type: String,
26-
default: 'ec-canvas',
27-
},
28-
lazyLoad: {
29-
type: Boolean,
30-
default: false,
31-
},
32-
disableTouch: {
33-
type: Boolean,
34-
default: false,
35-
},
36-
throttleTouch: {
37-
type: Boolean,
38-
default: false,
39-
},
40-
},
41-
// #ifdef H5
42-
mounted() {
43-
if (!this.lazyLoad) this.init();
44-
},
45-
// #endif
46-
// #ifndef H5
47-
onReady() {
48-
if (!this.lazyLoad) this.init();
49-
},
50-
// #endif
51-
methods: {
52-
init() {
53-
if (!this.onInit) {
54-
console.warn('请传入 onInit 函数进行初始化');
55-
return;
56-
}
57-
58-
const { canvasId } = this;
59-
this.ctx = wx.createCanvasContext(canvasId, this);
60-
61-
const canvas = new WxCanvas(this.ctx, canvasId);
62-
63-
const query = wx.createSelectorQuery().in(this);
64-
query.select(`#${canvasId}`).boundingClientRect((res) => {
65-
if (!res) {
66-
setTimeout(() => this.init(), 50);
67-
return;
68-
}
69-
this.chart = this.onInit(canvas, res.width, res.height);
70-
}).exec();
71-
},
72-
canvasToTempFilePath(opt) {
73-
const { canvasId } = this;
74-
this.ctx.draw(true, () => {
75-
wx.canvasToTempFilePath({
76-
canvasId,
77-
...opt,
78-
});
79-
});
80-
},
81-
touchStart(e) {
82-
const { disableTouch, chart } = this;
83-
if (disableTouch || !chart || !e.mp.touches.length) return;
84-
const touch = e.mp.touches[0];
85-
chart._zr.handler.dispatch('mousedown', {
86-
zrX: touch.x,
87-
zrY: touch.y,
88-
});
89-
chart._zr.handler.dispatch('mousemove', {
90-
zrX: touch.x,
91-
zrY: touch.y,
92-
});
93-
},
94-
touchMove(e) {
95-
const {
96-
disableTouch, throttleTouch, chart, lastMoveTime,
97-
} = this;
98-
if (disableTouch || !chart || !e.mp.touches.length) return;
99-
100-
if (throttleTouch) {
101-
const currMoveTime = Date.now();
102-
if (currMoveTime - lastMoveTime < 240) return;
103-
this.lastMoveTime = currMoveTime;
104-
}
105-
106-
const touch = e.mp.touches[0];
107-
chart._zr.handler.dispatch('mousemove', {
108-
zrX: touch.x,
109-
zrY: touch.y,
110-
});
111-
},
112-
touchEnd(e) {
113-
const { disableTouch, chart } = this;
114-
if (disableTouch || !chart) return;
115-
const touch = e.mp.changedTouches ? e.mp.changedTouches[0] : {};
116-
chart._zr.handler.dispatch('mouseup', {
117-
zrX: touch.x,
118-
zrY: touch.y,
119-
});
120-
chart._zr.handler.dispatch('click', {
121-
zrX: touch.x,
122-
zrY: touch.y,
123-
});
124-
},
125-
},
126-
};
127-
</script>
128-
129-
<style scoped>
130-
.ec-canvas {
131-
width: 100%;
132-
height: 100%;
133-
flex: 1;
134-
}
1+
<template>
2+
<canvas v-if="canvasId" class="ec-canvas" :id="canvasId" :canvasId="canvasId" @touchstart="touchStart" @touchmove="touchMove" @touchend="touchEnd" @error="error"></canvas>
3+
</template>
4+
5+
<script>
6+
import WxCanvas from './wx-canvas';
7+
8+
export default {
9+
props: {
10+
// onInit: {
11+
// required: true,
12+
// type: Function,
13+
// default: null,
14+
// },
15+
canvasId: {
16+
type: String,
17+
default: 'ec-canvas'
18+
},
19+
lazyLoad: {
20+
type: Boolean,
21+
default: false
22+
},
23+
disableTouch: {
24+
type: Boolean,
25+
default: false
26+
},
27+
throttleTouch: {
28+
type: Boolean,
29+
default: false
30+
}
31+
},
32+
// #ifdef H5
33+
mounted() {
34+
if (!this.lazyLoad) this.init();
35+
},
36+
// #endif
37+
// #ifndef H5
38+
onReady() {
39+
if (!this.lazyLoad) this.init();
40+
},
41+
// #endif
42+
methods: {
43+
init() {
44+
// if (!this.onInit) {
45+
// console.warn('请传入 onInit 函数进行初始化');
46+
// return;
47+
// }
48+
const { canvasId } = this;
49+
this.ctx = wx.createCanvasContext(canvasId, this);
50+
51+
const canvas = new WxCanvas(this.ctx, canvasId);
52+
53+
const query = wx.createSelectorQuery().in(this);
54+
query
55+
.select(`#${canvasId}`)
56+
.boundingClientRect(res => {
57+
if (!res) {
58+
setTimeout(() => this.init(), 50);
59+
return;
60+
}
61+
this.$emit('onInit', {
62+
canvas,
63+
width: res.width,
64+
height: res.height,
65+
fire: chart => {
66+
console.log(chart);
67+
this.chart = chart;
68+
}
69+
});
70+
// this.chart = this.onInit(canvas, res.width, res.height);
71+
})
72+
.exec();
73+
},
74+
canvasToTempFilePath(opt) {
75+
const { canvasId } = this;
76+
this.ctx.draw(true, () => {
77+
wx.canvasToTempFilePath({
78+
canvasId,
79+
...opt
80+
});
81+
});
82+
},
83+
touchStart(e) {
84+
const { disableTouch, chart } = this;
85+
if (disableTouch || !chart || !e.mp.touches.length) return;
86+
const touch = e.mp.touches[0];
87+
chart._zr.handler.dispatch('mousedown', {
88+
zrX: touch.x,
89+
zrY: touch.y
90+
});
91+
chart._zr.handler.dispatch('mousemove', {
92+
zrX: touch.x,
93+
zrY: touch.y
94+
});
95+
},
96+
touchMove(e) {
97+
const { disableTouch, throttleTouch, chart, lastMoveTime } = this;
98+
if (disableTouch || !chart || !e.mp.touches.length) return;
99+
100+
if (throttleTouch) {
101+
const currMoveTime = Date.now();
102+
if (currMoveTime - lastMoveTime < 240) return;
103+
this.lastMoveTime = currMoveTime;
104+
}
105+
106+
const touch = e.mp.touches[0];
107+
chart._zr.handler.dispatch('mousemove', {
108+
zrX: touch.x,
109+
zrY: touch.y
110+
});
111+
},
112+
touchEnd(e) {
113+
const { disableTouch, chart } = this;
114+
if (disableTouch || !chart) return;
115+
const touch = e.mp.changedTouches ? e.mp.changedTouches[0] : {};
116+
chart._zr.handler.dispatch('mouseup', {
117+
zrX: touch.x,
118+
zrY: touch.y
119+
});
120+
chart._zr.handler.dispatch('click', {
121+
zrX: touch.x,
122+
zrY: touch.y
123+
});
124+
}
125+
}
126+
};
127+
</script>
128+
129+
<style scoped>
130+
.ec-canvas {
131+
width: 100%;
132+
height: 100%;
133+
flex: 1;
134+
}
135135
</style>

‎components/uLink.vue‎

Lines changed: 58 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,59 @@
1-
<template>
2-
<view style="text-decoration:underline" :href="href" @click="openURL" :inWhiteList="inWhiteList">{{text}}</view>
3-
</template>
4-
5-
<script>
6-
export default {
7-
name: 'u-link',
8-
props: {
9-
href: {
10-
type: String,
11-
default: ''
12-
},
13-
text: {
14-
type: String,
15-
default: ''
16-
},
17-
inWhiteList: {
18-
type: Boolean,
19-
default: false
20-
}
21-
},
22-
methods: {
23-
openURL() {
24-
// #ifdef APP-PLUS
25-
plus.runtime.openURL(this.href) //这里默认使用外部浏览器打开而不是内部web-view组件打开
26-
// #endif
27-
// #ifdef H5
28-
window.open(this.href)
29-
// #endif
30-
// #ifdef MP
31-
if (this.inWhiteList) { //如果在小程序的网址白名单中,会走内置webview打开,否则会复制网址提示在外部浏览器打开
32-
uni.navigateTo({
33-
url: '/pages/component/web-view/web-view?url=' + this.href
34-
});
35-
} else {
36-
uni.setClipboardData({
37-
data: this.href
38-
});
39-
uni.showModal({
40-
content: '本网址无法直接在小程序内打开。已自动复制网址,请在手机浏览器里粘贴该网址',
41-
showCancel: false
42-
});
43-
}
44-
// #endif
45-
}
46-
}
47-
}
48-
</script>
49-
50-
<style>
51-
1+
<template>
2+
<view style="text-decoration:underline" :href="href" @click="openURL" :inWhiteList="inWhiteList">{{text}}</view>
3+
</template>
4+
5+
<script>
6+
/**
7+
* @description u-link是一个外部网页超链接组件,在小程序内打开内部web-view组件或复制url,在app内打开外部浏览器,在h5端打开新网页
8+
* @property {String} href 点击后打开的外部网页url,小程序中必须以https://开头
9+
* @property {String} text 显示的文字
10+
* @property {Boolean} inWhiteList 是否在小程序白名单中,如果在的话,在小程序端会直接打开内置web-view,否则会只会复制url,提示在外部打开
11+
* @example * <u-link href="https://ext.dcloud.net.cn" text="https://ext.dcloud.net.cn" :inWhiteList="true"></u-link>
12+
*/
13+
export default {
14+
name: 'u-link',
15+
props: {
16+
href: {
17+
type: String,
18+
default: ''
19+
},
20+
text: {
21+
type: String,
22+
default: ''
23+
},
24+
inWhiteList: {
25+
type: Boolean,
26+
default: false
27+
}
28+
},
29+
methods: {
30+
openURL() {
31+
// #ifdef APP-PLUS
32+
plus.runtime.openURL(this.href) //这里默认使用外部浏览器打开而不是内部web-view组件打开
33+
// #endif
34+
// #ifdef H5
35+
window.open(this.href)
36+
// #endif
37+
// #ifdef MP
38+
if (this.inWhiteList) { //如果在小程序的网址白名单中,会走内置webview打开,否则会复制网址提示在外部浏览器打开
39+
uni.navigateTo({
40+
url: '/pages/component/web-view/web-view?url=' + this.href
41+
});
42+
} else {
43+
uni.setClipboardData({
44+
data: this.href
45+
});
46+
uni.showModal({
47+
content: '本网址无法直接在小程序内打开。已自动复制网址,请在手机浏览器里粘贴该网址',
48+
showCancel: false
49+
});
50+
}
51+
// #endif
52+
}
53+
}
54+
}
55+
</script>
56+
57+
<style>
58+
5259
</style>

‎components/uni-popup/uni-popup.vue‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,12 @@
151151
z-index: -1;
152152
}
153153
154+
.uni-close-bottom {
155+
margin: auto;
156+
left: 0;
157+
right: 0;
158+
}
159+
154160
.uni-close-right {
155161
right: -60upx;
156162
top: -80upx;

0 commit comments

Comments
 (0)