import { couponDetail } from '../../api/other'; import {BASE_URL} from '../../utils/request'; Page({ data: { baseUrl:BASE_URL, codeType: 'qr', status:0, id:'', couponInfo:{} }, goPage(){ wx.switchTab({ url: '/pages/store/store' }) }, onLoad(options) { this.setData({ status:options.status, id:options.id }) }, onReady(){ this.getcouponDetail(); }, async getcouponDetail(){ const res = await couponDetail(this.data.id); if(res.code == 200){ let item = { ...res.data, verify_status_text:res.data.verify_status == 0?'未核销':res.data.verify_status == 1?'已核销':'已过期' } this.setData({ couponInfo:item }) }else{ wx.showToast({ title: res.message || '请求失败', icon: 'none', duration: 2000 }); } console.log(res) }, toggleCode() { this.setData({ codeType: this.data.codeType === 'qr' ? 'bar' : 'qr' }); }, onChange(){ this.getcouponDetail(); } })