111 lines
2.9 KiB
JavaScript
111 lines
2.9 KiB
JavaScript
// var app = getApp();
|
||
Component({
|
||
properties: {
|
||
datas: {
|
||
type: null
|
||
}
|
||
},
|
||
data: {
|
||
Height: 0,
|
||
LastHeight: 0
|
||
}, // 私有数据,可用于模板渲染
|
||
|
||
lifetimes: {
|
||
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名
|
||
attached() {
|
||
console.log('kkkkkk::', this.data.datas);
|
||
},
|
||
moved() {},
|
||
detached() {},
|
||
},
|
||
|
||
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名
|
||
attached() {
|
||
|
||
}, // 此处attached的声明会被lifetimes字段中的声明覆盖
|
||
ready() {
|
||
|
||
},
|
||
|
||
pageLifetimes: {
|
||
// 组件所在页面的生命周期函数
|
||
show() {},
|
||
hide() {},
|
||
resize() {},
|
||
},
|
||
|
||
methods: {
|
||
imgHeight: function(e) {
|
||
var winWid = wx.getSystemInfoSync().windowWidth; //获取当前屏幕的宽度
|
||
var imgh = e.detail.height; //图片高度
|
||
var imgw = e.detail.width; //图片宽度
|
||
var swiperH = winWid * imgh / imgw + "px"; //等比设置swiper的高度。 即 屏幕宽度 / swiper高度 = 图片宽度 / 图片高度 ==》swiper高度 = 屏幕宽度 * 图片高度 / 图片宽度
|
||
if (parseInt(swiperH) > this.data.LastHeight) {
|
||
this.setData({
|
||
Height: swiperH, //设置高度
|
||
});
|
||
this.data.LastHeight = parseInt(swiperH);
|
||
}
|
||
},
|
||
goimgurl(e) {
|
||
let item = e.currentTarget.dataset.item;
|
||
if (item.hrefChoice && item.hrefChoice == 2) {
|
||
if (item.appID) {
|
||
if (item.miniUrl) {
|
||
try {
|
||
wx.navigateToMiniProgram({
|
||
appId: item.appID,
|
||
path: item.miniUrl,
|
||
extraData: {},
|
||
envVersion: 'release',
|
||
success(res) {
|
||
// 打开成功
|
||
},
|
||
fail(res){
|
||
wx.showToast({
|
||
title: '小程序跳转失败',
|
||
icon: 'none',
|
||
duration: 2000
|
||
});
|
||
}
|
||
});
|
||
} catch (e) {
|
||
wx.showToast({
|
||
title: '小程序跳转失败',
|
||
icon: 'none',
|
||
duration: 2000
|
||
});
|
||
}
|
||
} else {
|
||
wx.showToast({
|
||
title: '请设置跳转小程序后的跳转链接',
|
||
icon: 'none',
|
||
duration: 2000
|
||
});
|
||
}
|
||
} else {
|
||
wx.showToast({
|
||
title: '请设置小程序所需跳转appId',
|
||
icon: 'none',
|
||
duration: 2000
|
||
});
|
||
}
|
||
} else {
|
||
let url = item.hrefurl;
|
||
try {
|
||
wx.navigateTo({
|
||
url: url
|
||
});
|
||
} catch (e) {
|
||
wx.showToast({
|
||
title: '链接设置错误',
|
||
icon: 'none',
|
||
duration: 2000
|
||
});
|
||
//TODO handle the exception
|
||
}
|
||
}
|
||
}
|
||
}
|
||
});
|