wallpaper.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. // pages/piano/wallpaper/wallpaper.js
  2. const { deviceWallPaper } = require('../../../request/deviceListRequest')
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. topImg: {
  9. pic: "wxfile://tmp_d3e57489ead39c698676ff860df9cb8a37f66ee1a4777dbb.jpg",
  10. id: "",
  11. name: ""
  12. },
  13. imageList: [
  14. {
  15. pic: "https://inews.gtimg.com/om_bt/OAVMydtx9BsJxf5i_thi4Oll9sR1px-Esmtv6UHSxoisEAA/641",
  16. id: "",
  17. name: ""
  18. },
  19. {
  20. pic: "https://inews.gtimg.com/om_bt/OAVMydtx9BsJxf5i_thi4Oll9sR1px-Esmtv6UHSxoisEAA/641",
  21. id: "",
  22. name: ""
  23. },
  24. {
  25. pic: "https://inews.gtimg.com/om_bt/OAVMydtx9BsJxf5i_thi4Oll9sR1px-Esmtv6UHSxoisEAA/641",
  26. id: "",
  27. name: ""
  28. },
  29. {
  30. pic: "https://inews.gtimg.com/om_bt/OAVMydtx9BsJxf5i_thi4Oll9sR1px-Esmtv6UHSxoisEAA/641",
  31. id: "",
  32. name: ""
  33. },
  34. {
  35. pic: "https://inews.gtimg.com/om_bt/OAVMydtx9BsJxf5i_thi4Oll9sR1px-Esmtv6UHSxoisEAA/641",
  36. id: "",
  37. name: ""
  38. }
  39. ],
  40. selectIndex: 0,
  41. nvabarData: {
  42. showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示
  43. title: '壁纸设置', //导航栏 中间的标题
  44. },
  45. }, footerTap() {
  46. const that = this;
  47. wx.chooseImage({
  48. count: 1, // 最多可以选择的图片张数
  49. sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
  50. sourceType: ['album'], // 从相册选择
  51. success: function (res) {
  52. const tempFilePaths = res.tempFilePaths;
  53. console.log('获取图片信息成功', res);
  54. wx.getImageInfo({
  55. src: tempFilePaths[0],
  56. success: function (imageInfo) {
  57. console.log(imageInfo);
  58. wx.navigateTo({
  59. url: `/pages/crop/crop?path=${tempFilePaths[0]}&width=${imageInfo.width}&height=${imageInfo.height}`
  60. });
  61. },
  62. fail: function (err) {
  63. console.error('获取图片信息失败', err);
  64. }
  65. });
  66. },
  67. fail: function (err) {
  68. console.error('选择图片失败', err);
  69. }
  70. });
  71. }, imageTap(e) {
  72. console.log(e)
  73. // wxfile://tmp_d3e57489ead39c698676ff860df9cb8a37f66ee1a4777dbb.jpg
  74. let image = e.currentTarget.dataset.image;
  75. _this.setData({
  76. topImg: image ?? {}
  77. })
  78. }, wallpaperList() {
  79. let _this = this;
  80. deviceWallPaper().then(res => {
  81. console.log("壁纸列表", res);
  82. topImg = res.data[0];
  83. _this.setData({
  84. imageList: res.data ?? [],
  85. topImg: res.data[0] ?? {}
  86. })
  87. })
  88. },
  89. /**
  90. * 生命周期函数--监听页面加载
  91. */
  92. onLoad(options) {
  93. },
  94. /**
  95. * 生命周期函数--监听页面初次渲染完成
  96. */
  97. onReady() {
  98. },
  99. /**
  100. * 生命周期函数--监听页面显示
  101. */
  102. onShow() {
  103. },
  104. /**
  105. * 生命周期函数--监听页面隐藏
  106. */
  107. onHide() {
  108. },
  109. /**
  110. * 生命周期函数--监听页面卸载
  111. */
  112. onUnload() {
  113. },
  114. /**
  115. * 页面相关事件处理函数--监听用户下拉动作
  116. */
  117. onPullDownRefresh() {
  118. },
  119. /**
  120. * 页面上拉触底事件的处理函数
  121. */
  122. onReachBottom() {
  123. },
  124. /**
  125. * 用户点击右上角分享
  126. */
  127. onShareAppMessage() {
  128. }
  129. })