123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- // 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() {
- }
- })
|