// pointExchange/pages/detail/detail.js var util = require("../../../utils/util.js") const app = getApp(); Page({ /** * 页面的初始数据 */ data: { appAssetsUrl:app.appAssetsUrl, bottomLeft: app.bottomLeft, options:{}, detail:{}, isApply: false }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.setData({ options, isApply:!!options.isApply }) this.loadData(); }, loadData: function() { let _this = this; wx.showLoading({ title: '努力加载中...', }) app._post_form('product/info', "", _this.data.options, function(res) { if (res.code === 0) { _this.setData({ detail: res.data }) } }) }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function() { //获得popup组件 this.popup = this.selectComponent("#popup"); this.popup2 = this.selectComponent("#popup2"); this.popup3 = this.selectComponent("#popup3"); }, showPopup(e) { this[e.currentTarget.dataset.name].showPopup(); }, //取消事件 _error(e) { this[e.currentTarget.dataset.name].hidePopup(); }, //卡券兑换商品 useCoupon(e) { this._error(e); let that = this; wx.showLoading({ title: '提交中...', }) app._post_form('product/exchange', "", { pId: that.data.detail.id, stuId: util.getUserId() }, function(res) { if (res.code === 0) { that.popup2.hidePopup(); } }) }, toPointExchangeByMe(){ wx.navigateTo({ url:'/pointExchange/pages/my/my' }) }, })