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.

102 lines
2.0KB

  1. // pages/TicketDetails/TicketDetails.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. ticketUser: [],//优惠券信息
  9. ticketStateArr:[],//优惠券使用状态
  10. codePicUrl:"",//二维码图片地址
  11. yesCode: false,//二维码图片隐藏
  12. },
  13. /**
  14. * 生命周期函数--监听页面加载
  15. */
  16. onLoad: function (options) {
  17. console.log(options.id)
  18. if (app.globalData.openId) {
  19. this.getTicketUser(options.id, 1)
  20. this.getCodeFn(options.id)
  21. } else {
  22. app.globalData.openidSuccessFuc = this.getTicketUser;
  23. app.globalData.openidSuccessFuc = this.getCodeFn;
  24. }
  25. },
  26. getTicketUser: function (id,from) {//获取优惠券信息
  27. app.wxRequest(app.globalData.httpUrl + 'couponsell/detail', { coupon_sell_id: id, from: from}, e => {
  28. console.log(e)
  29. if (e.code == 200) {
  30. this.setData({
  31. ticketUser: e.data
  32. })
  33. }
  34. }, this)
  35. },
  36. getCodeFn:function(id){//获取二维码
  37. app.wxRequest(app.globalData.httpUrl + 'couponbuy/getqrcode', { coupon_sell_id: id}, e => {
  38. console.log(e)
  39. if (e.code == 200) {
  40. this.setData({
  41. codePicUrl: e.data.coupon_url,
  42. })
  43. }
  44. }, this)
  45. },
  46. showCode:function(){//查看二维码
  47. this.setData({
  48. yesCode: true,
  49. })
  50. },
  51. /**
  52. * 生命周期函数--监听页面初次渲染完成
  53. */
  54. onReady: function () {
  55. },
  56. /**
  57. * 生命周期函数--监听页面显示
  58. */
  59. onShow: function () {
  60. },
  61. /**
  62. * 生命周期函数--监听页面隐藏
  63. */
  64. onHide: function () {
  65. },
  66. /**
  67. * 生命周期函数--监听页面卸载
  68. */
  69. onUnload: function () {
  70. },
  71. /**
  72. * 页面相关事件处理函数--监听用户下拉动作
  73. */
  74. onPullDownRefresh: function () {
  75. },
  76. /**
  77. * 页面上拉触底事件的处理函数
  78. */
  79. onReachBottom: function () {
  80. },
  81. /**
  82. * 用户点击右上角分享
  83. */
  84. onShareAppMessage: function () {
  85. }
  86. })