// pages/my/coupon/coupon.js Page({ /** * 页面的初始数据 */ data: { down: false, shopping: [ { list: [ 'sss', 'sss', 'sss', ], isExpire:false }, { list: [ 'sss', 'sss', 'sss', ], isExpire:false }, ], isNum:false, code:'' }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { }, changeBtn(e) { console.log(e.detail); if (e.detail.value || e.detail.value != '') { this.setData({ isNum:true }) }else{ this.setData({ isNum:false }) } }, onReady: function () { this.toast = this.selectComponent("#toast"); }, listenerLogin: function () { this.toast.showToast('优惠券无效'); }, exchange(){ if (!this.data.isNum) return this.listenerLogin() }, clearValue(){ this.setData({ code:'', isNum:false }) } })