// pages/piano/wallpaper/wallpaper.js const { deviceWallPaper } = require('../../../request/deviceListRequest') Page({ /** * 页面的初始数据 */ data: { topImg: { pic: "wxfile://tmp_d3e57489ead39c698676ff860df9cb8a37f66ee1a4777dbb.jpg", id: "", name: "" }, imageList: [ { pic: "https://inews.gtimg.com/om_bt/OAVMydtx9BsJxf5i_thi4Oll9sR1px-Esmtv6UHSxoisEAA/641", id: "", name: "" }, { pic: "https://inews.gtimg.com/om_bt/OAVMydtx9BsJxf5i_thi4Oll9sR1px-Esmtv6UHSxoisEAA/641", id: "", name: "" }, { pic: "https://inews.gtimg.com/om_bt/OAVMydtx9BsJxf5i_thi4Oll9sR1px-Esmtv6UHSxoisEAA/641", id: "", name: "" }, { pic: "https://inews.gtimg.com/om_bt/OAVMydtx9BsJxf5i_thi4Oll9sR1px-Esmtv6UHSxoisEAA/641", id: "", name: "" }, { pic: "https://inews.gtimg.com/om_bt/OAVMydtx9BsJxf5i_thi4Oll9sR1px-Esmtv6UHSxoisEAA/641", id: "", name: "" } ], selectIndex: 0, nvabarData: { showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示 title: '壁纸设置', //导航栏 中间的标题 }, }, footerTap() { const that = this; wx.chooseImage({ count: 1, // 最多可以选择的图片张数 sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有 sourceType: ['album'], // 从相册选择 success: function (res) { const tempFilePaths = res.tempFilePaths; console.log('获取图片信息成功', res); wx.getImageInfo({ src: tempFilePaths[0], success: function (imageInfo) { console.log(imageInfo); wx.navigateTo({ url: `/pages/crop/crop?path=${tempFilePaths[0]}&width=${imageInfo.width}&height=${imageInfo.height}` }); }, fail: function (err) { console.error('获取图片信息失败', err); } }); }, fail: function (err) { console.error('选择图片失败', err); } }); }, imageTap(e) { console.log(e) // wxfile://tmp_d3e57489ead39c698676ff860df9cb8a37f66ee1a4777dbb.jpg let image = e.currentTarget.dataset.image; _this.setData({ topImg: image ?? {} }) }, wallpaperList() { let _this = this; deviceWallPaper().then(res => { console.log("壁纸列表", res); topImg = res.data[0]; _this.setData({ imageList: res.data ?? [], topImg: res.data[0] ?? {} }) }) }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })