var wxbarcode = require('../../utils/wxbarcode.js'); Page({ /** * 页面的初始数据 */ data: { screenBrightness: 0.5, content: "" }, /** * 生命周期函数--监听页面加载 */ onLoad: function(options) { wx.hideShareMenu(); var content = JSON.parse(options.content); var oldCode = content.code; var code = oldCode.replace(/[\s]/g, '').replace(/(\d{4})(?=\d)/g, "$1 "); this.setData({ content: content, title: content.title, code: code, useTime: content.startDate + "至" + content.endDate, useCondition: content.useLabel }); wxbarcode.barcode('barcode', oldCode, 600, 160); wxbarcode.qrcode('qrcode', oldCode, 400, 400); }, /** * 使用说明 */ cy_couponUseExplain: function(e) { var coupon = this.data.content; var code = coupon.code; var title = coupon.title; var subTitle = coupon.subTitle; var startDate = coupon.startDate; var endDate = coupon.endDate; var couponDesc = coupon.couponDesc; var useLabel = coupon.useLabel; var url = "couponInstructions?title=" + title + '&startDate=' + startDate + '&endDate=' + endDate + '&couponDesc=' + couponDesc + '&useLabel=' + useLabel; wx.navigateTo({ url: url, }) }, /** * 分享转赠 */ cy_couponShare: function(e) { var url = "couponShare"; wx.navigateTo({ url: url, }) }, /** * 使用门店 */ cy_couponUseStore: function(e) { var coupon = this.data.content; var url = "couponUseStore"; wx.navigateTo({ url: url, }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function() { }, /** * 生命周期函数--监听页面显示 */ onShow: function() { var that = this; wx.getScreenBrightness({ success: function(res) { that.data.screenBrightness = res.value; wx.setScreenBrightness({ value: 0.75, }) } }); }, /** * 生命周期函数--监听页面隐藏 */ onHide: function() { var that = this; wx.setScreenBrightness({ value: that.data.screenBrightness, }) }, /** * 生命周期函数--监听页面卸载 */ onUnload: function() { var that = this; wx.setScreenBrightness({ value: that.data.screenBrightness, }) }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function() { }, /** * 用户点击右上角分享 */ onShareAppMessage: function() { } })