wallpaper.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. topImg:
  13. {
  14. // pic: "",
  15. // id: "",
  16. // name: ""
  17. },
  18. imageList: [
  19. ],
  20. selectIndex: 0,
  21. navbarData: {
  22. showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示
  23. title: '壁纸设置', //导航栏 中间的标题
  24. },
  25. showCropImg: false,
  26. },
  27. closePage() {
  28. },
  29. footerTap() {
  30. route_util.jump("../cropper/cropper")
  31. },
  32. imageTap(e) {
  33. // console.log(e)
  34. // wxfile://tmp_d3e57489ead39c698676ff860df9cb8a37f66ee1a4777dbb.jpg
  35. let image = e.currentTarget.dataset.image;
  36. _this.setData({
  37. topImg: image ?? {}
  38. })
  39. }, wallpaperList() {
  40. let _this = this;
  41. deviceWallPaper().then(res => {
  42. console.log("壁纸列表", res);
  43. let data = res.data ?? []
  44. if (data.length == 0) {
  45. _this.setData({
  46. imageList: [],
  47. topImg: {},
  48. })
  49. return;
  50. }
  51. topImg = data[0];
  52. _this.setData({
  53. imageList: data ?? [],
  54. topImg: data[0] ?? {}
  55. })
  56. })
  57. },
  58. hideCut(e) {
  59. const img = arguments[0].detail
  60. if (img && img.path) {
  61. console.log("裁剪图片:", img)
  62. }
  63. this.setData({
  64. showCropImg: true,
  65. topImg: { "pic": img.path }
  66. })
  67. },
  68. /**
  69. * 生命周期函数--监听页面加载
  70. */
  71. onLoad(options) {
  72. let param = JSON.parse(options.param)
  73. console.log(param)
  74. this.wallpaperList();
  75. },
  76. /**
  77. * 生命周期函数--监听页面初次渲染完成
  78. */
  79. onReady() {
  80. },
  81. /**
  82. * 生命周期函数--监听页面显示
  83. */
  84. onShow() {
  85. },
  86. /**
  87. * 生命周期函数--监听页面隐藏
  88. */
  89. onHide() {
  90. },
  91. /**
  92. * 生命周期函数--监听页面卸载
  93. */
  94. onUnload() {
  95. },
  96. /**
  97. * 页面相关事件处理函数--监听用户下拉动作
  98. */
  99. onPullDownRefresh() {
  100. },
  101. /**
  102. * 页面上拉触底事件的处理函数
  103. */
  104. onReachBottom() {
  105. },
  106. /**
  107. * 用户点击右上角分享
  108. */
  109. onShareAppMessage() {
  110. }
  111. })