邃芒智像相册
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
2.3 KiB

  1. // pages/checkImg/checkImg.ts
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. currentIndex: 0,
  8. swiperList: [
  9. {
  10. id: "1",
  11. src: "https://suimang.oss-accelerate.aliyuncs.com/capi/2023-09-21/4f3cf1dea65142a2945d5412bee85ca2.jpg?x-oss-process=image/resize,w_10000/quality,q_60"
  12. },
  13. {
  14. id: "2",
  15. src: "https://suimang.oss-accelerate.aliyuncs.com/capi/2023-09-21/4f3cf1dea65142a2945d5412bee85ca2.jpg?x-oss-process=image/resize,w_10000/quality,q_60"
  16. },
  17. {
  18. id: "3",
  19. src: "https://suimang.oss-accelerate.aliyuncs.com/capi/2023-09-21/4f3cf1dea65142a2945d5412bee85ca2.jpg?x-oss-process=image/resize,w_10000/quality,q_60"
  20. },
  21. {
  22. id: "4",
  23. src: "https://suimang.oss-accelerate.aliyuncs.com/capi/2023-09-21/4f3cf1dea65142a2945d5412bee85ca2.jpg?x-oss-process=image/resize,w_10000/quality,q_60"
  24. }
  25. ]
  26. },
  27. /**
  28. * 生命周期函数--监听页面加载
  29. */
  30. onLoad(options) {
  31. console.log(options);
  32. },
  33. /**
  34. * 生命周期函数--监听页面显示
  35. */
  36. onShow() {
  37. },
  38. switchImg(e) {
  39. const currentIndex = e.currentTarget.dataset.index
  40. this.setData({
  41. currentIndex
  42. })
  43. },
  44. previewImage() {
  45. const array = []
  46. this.data.swiperList.forEach(item => {
  47. array.push(item.src)
  48. })
  49. wx.previewImage({
  50. urls: array,
  51. showmenu: true,
  52. })
  53. },
  54. swiperChanged(e) {
  55. const currentIndex = e.detail.current
  56. this.setData({
  57. currentIndex
  58. })
  59. },
  60. downloadImage() {
  61. const index = this.data.currentIndex
  62. const list = this.data.swiperList
  63. const filePath = "zhixiangImg.png"
  64. const url = list[index].src
  65. wx.downloadFile({
  66. url,
  67. success: res => {
  68. console.log(res, 'res');
  69. if (res.statusCode === 200) {
  70. wx.saveImageToPhotosAlbum({
  71. filePath: res.tempFilePath,
  72. success: () => {
  73. wx.showToast({
  74. title: '保存成功!',
  75. icon: "success"
  76. })
  77. }
  78. })
  79. }
  80. }
  81. })
  82. },
  83. /**
  84. * 页面相关事件处理函数--监听用户下拉动作
  85. */
  86. onPullDownRefresh() {
  87. },
  88. /**
  89. * 页面上拉触底事件的处理函数
  90. */
  91. onReachBottom() {
  92. },
  93. /**
  94. * 用户点击右上角分享
  95. */
  96. onShareAppMessage() {
  97. }
  98. })