wallpaper.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. // pages/piano/wallpaper/wallpaper.js
  2. const { deviceWallPaper } = require('../../../request/deviceListRequest')
  3. // const sharp = require('sharp');
  4. // const fs = require('fs');
  5. import route_util from '../../../utils/route_util';
  6. // import EventManager from '../../utils/event_bus'
  7. // applicationType: "[0]"
  8. // createTime: "2025-01-10T09:36:04.000+00:00"
  9. // createTimeStr: null
  10. // id: "1877650605435129856"
  11. // name: null
  12. // note: ""
  13. // pic: "https://music-play.oss-cn-shenzhen.aliyuncs.com/device/20250110173600839933880.png"
  14. // sort: 1
  15. // status: 0
  16. // updateTime: "2025-01-10T09:36:04.000+00:00"
  17. Page({
  18. /**
  19. * 页面的初始数据
  20. */
  21. data: {
  22. topImg:
  23. {
  24. // pic: "",
  25. // id: "",
  26. },
  27. imageList: [
  28. ],
  29. selectIndex: 0,
  30. navbarData: {
  31. showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示
  32. title: '壁纸设置', //导航栏 中间的标题
  33. },
  34. showCropImg: false,
  35. },
  36. closePage() {
  37. },
  38. footerTap() {
  39. route_util.jumpParam("../cropper/cropper", JSON.stringify(this.data.topImg ?? {}))
  40. },
  41. imageTopTap() {
  42. this.setData({
  43. topImg: {}
  44. })
  45. },
  46. imageTap(e) {
  47. console.log(e)
  48. // wxfile://tmp_d3e57489ead39c698676ff860df9cb8a37f66ee1a4777dbb.jpg
  49. let image = e.currentTarget.dataset.image;
  50. let _this = this;
  51. if (image.id == this.data.topImg.id) {
  52. _this.setData({
  53. topImg: {}
  54. })
  55. } else {
  56. _this.setData({
  57. topImg: image ?? {}
  58. })
  59. }
  60. }, wallpaperList() {
  61. let _this = this;
  62. deviceWallPaper().then(res => {
  63. console.log("壁纸列表", res);
  64. let data = res ?? []
  65. if (data.length == 0) {
  66. // _this.setData({
  67. // imageList: [],
  68. // topImg: {},
  69. // })
  70. return;
  71. }
  72. _this.setData({
  73. imageList: data ?? [],
  74. // topImg: data[0] ?? {}
  75. })
  76. })
  77. },
  78. hideCut(e) {
  79. const img = arguments[0].detail
  80. if (img && img.path) {
  81. console.log("裁剪图片:", img)
  82. }
  83. this.setData({
  84. showCropImg: true,
  85. topImg: { "pic": img.path }
  86. })
  87. },
  88. /**
  89. * 生命周期函数--监听页面加载
  90. */
  91. onLoad(options) {
  92. let param = JSON.parse(options.param)
  93. console.log(param)
  94. this.wallpaperList();
  95. },
  96. /**
  97. * 生命周期函数--监听页面初次渲染完成
  98. */
  99. onReady() {
  100. },
  101. /**
  102. * 生命周期函数--监听页面显示
  103. */
  104. onShow() {
  105. },
  106. /**
  107. * 生命周期函数--监听页面隐藏
  108. */
  109. onHide() {
  110. },
  111. /**
  112. * 生命周期函数--监听页面卸载
  113. */
  114. onUnload() {
  115. },
  116. /**
  117. * 页面相关事件处理函数--监听用户下拉动作
  118. */
  119. onPullDownRefresh() {
  120. },
  121. /**
  122. * 页面上拉触底事件的处理函数
  123. */
  124. onReachBottom() {
  125. },
  126. /**
  127. * 用户点击右上角分享
  128. */
  129. onShareAppMessage() {
  130. }
  131. })