千目品牌领券机
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.
 

56 lines
1.0 KiB

import QRCode from '../../js/qrcode'
// components/ticket/ticket.js
Component({
/**
* 组件的属性列表
*/
properties: {
state: String, //['mall','my','verified','detail']
code: String,
},
/**
* 组件的初始数据
*/
data: {
url: ''
},
attached() {
const {
coupons
} = getApp()
const coupon = coupons.get(this.data.code)
coupons.onUpdate(this.data.code, (coupon) => {
this.setData({
coupon
})
})
this.setData({
coupon,
}, () => {
if (this.data.state === 'detail') {
const query = wx.createSelectorQuery().in(this)
query.select('#qrcode').node((res) => {
const canvas = res.node;
QRCode.toCanvas(canvas, coupon.orderNo, function (error) {
if (error) console.error(error)
})
}).exec()
}
})
},
/**
* 组件的方法列表
*/
methods: {
collect() {
this.triggerEvent('collect', {
code: this.data.code
})
}
}
})