Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
5 лет назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. // pages/receiveTicket/receiveTicket.js
  2. const app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. yesGet: true,//是否被领取
  9. ticketUser:[],//优惠券信息
  10. userPhone:"",//手机号
  11. titleWord:"",
  12. presentId:"",//接受的id
  13. ticketNum:0,
  14. moreClick:false,//防止重复点击领取
  15. showAll:false,
  16. type:null,
  17. },
  18. /**
  19. * 生命周期函数--监听页面加载
  20. */
  21. onLoad: function (options) {
  22. app.globalData.present_id = options.shareId;
  23. this.data.presentId = options.shareId;
  24. this.setData({
  25. type:options.type
  26. })
  27. app.globalData.number = options.number;
  28. app.globalData.type = options.type;
  29. this.setData({
  30. ticketNum: options.number
  31. })
  32. app.globalData.present_id = "p1591272747o13"
  33. app.globalData.number = 1
  34. var state = wx.getStorageSync('state');
  35. if (state == 1) {//已注册
  36. if (app.globalData.openId) {
  37. this.getTicketUser();
  38. } else {
  39. app.globalData.openidSuccessFuc = this.getTicketUser;
  40. }
  41. this.setData({
  42. showAll:true
  43. })
  44. } else if (state == 0) {//未注册
  45. wx.navigateTo({
  46. url: '/pages/register/register'
  47. })
  48. } else if (state == -1) {
  49. app.globalData.userInfoBackFn = res => {//等待结果
  50. if (res) {
  51. if (app.globalData.openId) {
  52. this.getTicketUser();
  53. } else {
  54. app.globalData.openidSuccessFuc = this.getTicketUser;
  55. }
  56. this.setData({
  57. showAll: true
  58. })
  59. } else {
  60. wx.navigateTo({
  61. url: '/pages/register/register'
  62. })
  63. }
  64. }
  65. }
  66. },
  67. getTicketUser: function () {//获取赠送优惠券信息
  68. app.wxRequest(app.globalData.httpUrl + 'couponbuy/presentvisit', { present_id: app.globalData.present_id, present_num: app.globalData.number }, e => {
  69. console.log(e)
  70. if (e.code == 201) {
  71. e.data.original_price = parseInt(e.data.original_price);
  72. e.data.coupon_price = parseInt(e.data.coupon_price);
  73. var partPhone = e.data.user_phone.slice(0, 3) + "****" + e.data.user_phone.slice(7)
  74. this.setData({
  75. ticketUser: e.data,
  76. yesGet: true,
  77. userPhone: partPhone
  78. })
  79. } else if (e.code == 202) {
  80. var partPhone = e.data.user_phone.slice(0, 3) + "****" + e.data.user_phone.slice(7)
  81. this.setData({
  82. yesGet: false,
  83. ticketUser: e.data,
  84. titleWord: e.message,
  85. userPhone: partPhone
  86. })
  87. } else if (e.code == 203) {
  88. var partPhone = e.data.user_phone.slice(0, 3) + "****" + e.data.user_phone.slice(7)
  89. this.setData({
  90. yesGet: false,
  91. ticketUser: e.data,
  92. titleWord: e.message,
  93. userPhone: partPhone
  94. })
  95. } else if (e.code == 204) {
  96. var partPhone = e.data.user_phone.slice(0, 3) + "****" + e.data.user_phone.slice(7)
  97. this.setData({
  98. yesGet: false,
  99. ticketUser: e.data,
  100. titleWord: e.message,
  101. userPhone: partPhone
  102. })
  103. } else if (e.code == 205) {
  104. var partPhone = e.data.user_phone.slice(0, 3) + "****" + e.data.user_phone.slice(7)
  105. this.setData({
  106. yesGet: false,
  107. ticketUser: e.data,
  108. titleWord: e.message,
  109. userPhone: partPhone
  110. })
  111. }
  112. }, this)
  113. },
  114. /**
  115. * 生命周期函数--监听页面初次渲染完成
  116. */
  117. onReady: function () {
  118. },
  119. /**
  120. * 生命周期函数--监听页面显示
  121. */
  122. onShow: function () {
  123. },
  124. /**
  125. * 生命周期函数--监听页面隐藏
  126. */
  127. onHide: function () {
  128. },
  129. /**
  130. * 生命周期函数--监听页面卸载
  131. */
  132. onUnload: function () {
  133. },
  134. /**
  135. * 页面相关事件处理函数--监听用户下拉动作
  136. */
  137. onPullDownRefresh: function () {
  138. },
  139. /**
  140. * 页面上拉触底事件的处理函数
  141. */
  142. onReachBottom: function () {
  143. },
  144. /**
  145. * 用户点击右上角分享
  146. */
  147. onShareAppMessage: function () {
  148. return {
  149. title: "老门框爆肚会员",
  150. success: res => {
  151. console.log(res, "转发成功")
  152. },
  153. }
  154. },
  155. // "p1583474312b94"
  156. getTicketFn: function () {//点击领取优惠券
  157. var id = this.data.presentId;
  158. if (this.data.moreClick){
  159. return;
  160. }
  161. this.data.moreClick = true;
  162. app.wxRequest(app.globalData.httpUrl + 'couponbuy/receivepresent', { present_id: id }, e => {
  163. console.log(e)
  164. if (e.code == 200) {
  165. wx.showToast({
  166. title: '领取成功',
  167. duration: 500
  168. })
  169. setTimeout(() => {
  170. wx.switchTab({
  171. url: '/pages/index/index'
  172. })
  173. }, 500)
  174. } else {
  175. this.data.moreClick = false;
  176. wx.showToast({
  177. title: e.message,
  178. icon:"none",
  179. duration: 1000
  180. })
  181. }
  182. }, this, "POST")
  183. },
  184. backIndex:function(){//优惠券已被领取,点击确定返回首页
  185. wx.switchTab({
  186. url: '/pages/index/index'
  187. })
  188. },
  189. })