import PageContainerBehavior from "../../../../core/behavior/page-container.behavior";
import tickleBehavior, { getTickleContext } from "../../../../core/behavior/tickle.behavior";
import { getDietMethod } from "../../request";
// module/diet/pages/delivery-address/delivery-address.ts
Component({
  behaviors: [
    PageContainerBehavior,
    tickleBehavior,
  ],
  lifetimes: {
    attached() {
    }
  },
  properties: {
  },
  data: {
    goodsList: [
      {
        id: 1,
        img: 'https://pic.nximg.cn/file/20190718/28170468_214109363000_2.jpg',
        name: '元气茶',
        count: 3,
        expressNo: '00385322232830'
      },
      {
        id: 2,
        img: 'https://pic.nximg.cn/file/20190718/28170468_214109363000_2.jpg',
        name: '芡实米仁燕麦粥',
        count: 21,
        expressNo: '00385322290821'
      },
      {
        id: 3,
        img: 'https://pic.nximg.cn/file/20190718/28170468_214109363000_2.jpg',
        name: '复方膏贴',
        count: 10,
        expressNo: ''
      }
    ]
  },
  methods: {
    async load() {
      wx.showLoading({ title: '加载中' });
      try {
        const dataset = await getDietMethod(this.data.id);
        this.setData({ dataset, title: dataset.name });
      } catch (error) {
        getTickleContext.call(this).showWarnMessage(error.errMsg);
      }
      wx.hideLoading();
    },
    copyExpressNo(e) {
      wx.setClipboardData({
        data: e.currentTarget.dataset.no,
        success: () => wx.showToast({ title: '已复制', icon: 'none' })
      });
    }
  }
})