wallpaper.js 2.9 KB

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