const app = getApp() Page({ onShareAppMessage() { return { title: 'swiper', path: 'page/component/pages/swiper/swiper' } }, /** * 页面的初始数据 */ data: { frameStyle: { useTop: true, name: '练习', leftArrow: true, useBar: false}, // 主体高度 infoHeight: '', latitude: 23.099994, longitude: 113.324520, x: 0, y: 0, scale: 2, background: ['demo-text-1', 'demo-text-2', 'demo-text-3'], indicatorDots: true, vertical: false, autoplay: false, interval: 2000, duration: 500, iconSize: [20, 30, 40, 50, 60, 70], iconColor: [ 'red', 'orange', 'yellow', 'green', 'rgb(0,255,255)', 'blue', 'purple' ], iconType: [ 'success', 'success_no_circle', 'info', 'warn', 'waiting', 'cancel', 'download', 'search', 'clear' ], chosen: '', focus: false, inputValue: '', checkboxItems: [ {name: 'USA', value: '美国'}, {name: 'CHN', value: '中国', checked: 'true'} ], radioItems: [ {name: 'USA', value: '美国'}, {name: 'CHN', value: '中国', checked: 'true'} ], hidden: false, height: 20, focus: false }, bindButtonTap: function() { this.setData({ focus: true }) }, bindTextAreaBlur: function(e) { console.log(e.detail.value) }, bindFormSubmit: function(e) { console.log(e.detail.value.textarea) }, radioChange(e) { const checked = e.detail.value const changed = {} for (let i = 0; i < this.data.radioItems.length; i++) { if (checked.indexOf(this.data.radioItems[i].name) !== -1) { changed['radioItems[' + i + '].checked'] = true } else { changed['radioItems[' + i + '].checked'] = false } } this.setData(changed) }, bindKeyInput: function (e) { this.setData({ inputValue: e.detail.value }) }, changeIndicatorDots() { this.setData({ indicatorDots: !this.data.indicatorDots }) }, formReset(e) { console.log('form发生了reset事件,携带数据为:', e.detail.value) this.setData({ chosen: '' }) }, changeAutoplay() { this.setData({ autoplay: !this.data.autoplay }) }, intervalChange(e) { this.setData({ interval: e.detail.value }) }, durationChange(e) { this.setData({ duration: e.detail.value }) }, tap() { this.setData({ x: 30, y: 30 }) }, tap2() { this.setData({ scale: 3 }) }, onChange(e) { console.log(e.detail) }, onScale(e) { console.log(e.detail) }, back: function () { wx.navigateBack({ url: '/pages/home/index' }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function () { // 计算高度 this.searchHeight() }, // 计算高度 searchHeight: function () { let frameStyle = this.data.frameStyle; let client = app.globalData.client; // 减去状态栏 let infoHeight = client.windowHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2); // 是否减去底部菜单 if (frameStyle.useBar) infoHeight = infoHeight - 50; if (infoHeight) this.setData({ infoHeight: infoHeight }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })