// pages/mp/mp.ts import ActionSheet, { ActionSheetTheme, ActionSheetShowOption } from 'tdesign-miniprogram/action-sheet/index'; Page({ /** * 页面的初始数据 */ data: { pageImage: 'https://4dkk.4dage.com/miniapp-source/daikan/about_us.png', pageQRcode: 'https://4dkk.4dage.com/miniapp-source/daikan/about_qrcode.png', handler: null, }, handleActionShow() { const basicListOption: ActionSheetShowOption = { theme: ActionSheetTheme.List, selector: '#t-action-sheet', items: [ { label: '下载图片', }, ], }; const handler = ActionSheet.show(basicListOption); this.setData({ handler: handler }) }, handleSelected(event: WechatMiniprogram.TouchEvent) { const { index } = event.detail console.log('event', index) if (index === 0) { wx.downloadFile({ url: this.data.pageQRcode, success (res) { wx.saveImageToPhotosAlbum({ filePath: res.tempFilePath, success(res) { wx.showModal({ title: '图片保存成功', content: '图片成功保存到相册了,通过扫一扫就可以哒!', showCancel: false, confirmText: '好哒', confirmColor: '#72B9C3', success: (res) => { if (res.confirm) { } } }) } }) } }) } }, handleCancel() { const { handler } = this.data if (handler) { (handler as any).close() } }, /** * 生命周期函数--监听页面加载 */ onLoad() { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })