Browse Source

修改轮播图卡顿的问题

master
Gao xiaosong 4 years ago
parent
commit
e7dccf1572
  1. 2
      manifest.json
  2. 36
      pages/home/components/Banner.vue

2
manifest.json

@ -2,7 +2,7 @@
"name" : "yshopmall",
"appid" : "__UNI__C7A519E",
"description" : "",
"versionName" : "1.0.0",
"versionName" : "1.0.1",
"versionCode" : 1,
"transformPx" : false,
/* 5+App */

36
pages/home/components/Banner.vue

@ -41,46 +41,14 @@
let item = this.detail[this.swiperCurrent];
//
let bgcolor = item.bgcolor;
// #ifdef APP-PLUS
that.$set(item, 'bgcolor', '#c40414');
that.$emit('getbgcolor', '#c40414');
// #endif
// #ifndef APP-PLUS
//
if (bgcolor === '') {
let ctx = uni.createCanvasContext('colorThief', that);
if (0 === that.webviewId || ctx.webviewId === that.webviewId) {
that.webviewId = ctx.webviewId;
uni.getImageInfo({
src: item.pic,
success: function (image) {
ctx.drawImage(image.path, 0, 0, image.width, image.height);
ctx.draw(true, function (e) {
uni.canvasGetImageData({
canvasId: 'colorThief',
x: 0,
y: 0,
width: parseInt(image.width),
height: parseInt(image.height),
success(res) {
let bgcolor = colorThief(res.data)
.color()
.getHex();
that.$set(item, 'bgcolor', bgcolor);
that.$emit('getbgcolor', bgcolor);
}
},
that
);
});
}
});
}
that.$set(item, 'bgcolor', '#c40414');
that.$emit('getbgcolor', '#c40414');
} else {
that.$set(item, 'bgcolor', bgcolor);
that.$emit('getbgcolor', bgcolor);
}
// #endif
},
swiperChange(e) {

Loading…
Cancel
Save