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.

128 line
2.5KB

  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. id:""
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad: function (options) {
  18. console.log(options.id)
  19. this.data.id = options.id;
  20. if (app.globalData.openId) {
  21. this.getTicketUser()
  22. this.getCodeFn()
  23. } else {
  24. app.globalData.openidSuccessFuc = this.getTicketUser;
  25. app.globalData.openidSuccessFuc = this.getCodeFn;
  26. }
  27. if (state == 1) {//已注册
  28. } else if (state == 0) {//未注册
  29. wx.navigateTo({
  30. url: '/pages/register/register',
  31. })
  32. } else if (state == -1) {
  33. app.globalData.userInfoBackFn = res => {//等待结果
  34. console.log(res)
  35. if (res) {
  36. } else {
  37. wx.navigateTo({
  38. url: '/pages/register/register',
  39. })
  40. }
  41. }
  42. }
  43. },
  44. getTicketUser: function () {//获取优惠券信息
  45. app.wxRequest(app.globalData.httpUrl + 'couponsell/detail', { coupon_sell_id: this.data.id, from: 1}, e => {
  46. console.log(e)
  47. if (e.code == 200) {
  48. this.setData({
  49. ticketUser: e.data
  50. })
  51. }
  52. }, this)
  53. },
  54. getCodeFn:function(){//获取二维码
  55. app.wxRequest(app.globalData.httpUrl + 'couponbuy/getqrcode', { coupon_sell_id: this.data.id}, e => {
  56. console.log(e)
  57. if (e.code == 200) {
  58. this.setData({
  59. codePicUrl: e.data.coupon_url,
  60. })
  61. }
  62. }, this)
  63. },
  64. showCode:function(){//查看二维码
  65. this.setData({
  66. yesCode: true,
  67. })
  68. },
  69. /**
  70. * 生命周期函数--监听页面初次渲染完成
  71. */
  72. onReady: function () {
  73. },
  74. /**
  75. * 生命周期函数--监听页面显示
  76. */
  77. onShow: function () {
  78. },
  79. /**
  80. * 生命周期函数--监听页面隐藏
  81. */
  82. onHide: function () {
  83. },
  84. /**
  85. * 生命周期函数--监听页面卸载
  86. */
  87. onUnload: function () {
  88. },
  89. /**
  90. * 页面相关事件处理函数--监听用户下拉动作
  91. */
  92. onPullDownRefresh: function () {
  93. },
  94. /**
  95. * 页面上拉触底事件的处理函数
  96. */
  97. onReachBottom: function () {
  98. },
  99. /**
  100. * 用户点击右上角分享
  101. */
  102. onShareAppMessage: function () {
  103. return {
  104. title: "老门框爆肚会员",
  105. success: res => {
  106. console.log(res, "转发成功")
  107. },
  108. }
  109. }
  110. })