// pages/piano/wallpaper/wallpaper.js const { deviceWallPaper } = require('../../../request/deviceListRequest') // const sharp = require('sharp'); // const fs = require('fs'); import route_util from '../../../utils/route_util'; // import EventManager from '../../utils/event_bus' Page({ /** * 页面的初始数据 */ data: { topImg: { // pic: "", // id: "", // name: "" }, imageList: [ ], selectIndex: 0, navbarData: { showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示 title: '壁纸设置', //导航栏 中间的标题 }, showCropImg: false, }, closePage() { }, footerTap() { route_util.jump("../cropper/cropper") return; const that = this; wx.chooseMedia({ count: 1, mediaType: ['image'], sourceType: ['album'], // camera: 'back', success(res) { // console.log(res.tempFiles[0].tempFilePath) // console.log(res.tempFiles[0].size) //重置图片角度、缩放、位置 // wx.getImageInfo({ // src: res.tempFiles[0].tempFilePath, // success(res) { // console.log(res) // wx.cropImage({ // src: res.path,// 图片路径 // cropScale: '1:1', // 裁剪比例 // success(res) { // console.log("裁剪后的图片", res) // that.setData({ // showCropImg: true, // topImg: { "pic": res.tempFilePath } // }) // that.convertImageToRGB565(res.tempFilePath) // }, // }) // } // }) } }) }, 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); let data = res.data ?? [] if (data.length == 0) { _this.setData({ imageList: [], topImg: {}, }) return; } topImg = data[0]; _this.setData({ imageList: data ?? [], topImg: data[0] ?? {} }) }) }, hideCut(e) { const img = arguments[0].detail if (img && img.path) { console.log("裁剪图片:", img) } this.setData({ showCropImg: true, topImg: { "pic": img.path } }) }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { let param = JSON.parse(options.param) console.log(param) this.wallpaperList(); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })