// pages/test/index.js const app = getApp() Page({ /** * 页面的初始数据 */ data: { frameStyle: { useTop: true, name: '测试页面', leftArrow: true, useBar: true }, // 主体高度 infoHeight: '', // 图片 img_url: [], // dialog弹框 dialog: { title: '弹框标题', show: false, type: '1' }, // 选项卡 tabs: { active: 'a', list: [ { title: '选项卡一', name: 'a' }, { title: '选项卡二', name: 'b' }, { title: '选项卡三', name: 'c' }, ], }, // 侧导航 sidebar: { active: 0, list: [ { title: '标签一', disabled: false }, { title: '标签二', disabled: false }, { title: '标签三', disabled: false }, ] } }, // 侧导航选择 sidebarChange: function (e) { const that = this; that.setData({ 'sidebar.active': e.detail }) }, // 跳转菜单 tabPath(e) { let { route } = e.detail.detail; if (route) wx.redirectTo({ url: `/${route}` }) }, // 返回上一页 back: function () { wx.navigateBack({ delta: 1 }) }, // 上传图片 imgUpl: function (e) { const that = this; let data = that.data.img_url; data.push(e.detail) that.setData({ img_url: data }) }, // 删除图片 imgDel: function (e) { const that = this; let list = that.data.img_url; let arr = list.filter((i, index) => index != e.detail.index) that.setData({ img_url: arr }) }, // 打开弹框 toDialog: function () { const that = this; that.setData({ dialog: { title: '弹框标题', show: true, type: '1' } }) }, // 关闭弹框 toClose: function () { const that = this; that.setData({ dialog: { title: '弹框标题', show: false, type: '1' } }) }, // 选项卡 tabsChange: function (e) { const that = this; that.setData({ 'tabs.active': e.detail.name }); }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { const that = this; }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })