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.

myReplace.js 4.2KB

5 년 전
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. // pages/myReplace/myReplace.js
  2. const app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. dataList:[],//需要展示的数据
  9. newData:[],
  10. pageNum:1,//页码,
  11. count:10,//每页条数
  12. total:0,//总条数
  13. total_page:0,//总页数
  14. mydeg: 0,
  15. myTicketArrows: true,
  16. historydeg: -90,
  17. historyTicketArrows: false,
  18. dataList2:[],//需要展示的数据
  19. newData2:[],
  20. pageNum2:1,//页码,
  21. count2:10,//每页条数
  22. total2:0,//总条数
  23. total_page2:0,//总页数
  24. myText:"",//"我的代金券"文案
  25. myHistory:"",
  26. index:1,//代金券还是菜品券
  27. },
  28. /**
  29. * 生命周期函数--监听页面加载
  30. */
  31. onLoad: function (options) {
  32. var index = options.index;
  33. this.data.index = index
  34. if(index==1){
  35. this.setData({
  36. myText:"我的代金券",
  37. myHistory:"代金券使用记录"
  38. })
  39. }else{
  40. this.setData({
  41. myText:"我的菜品券",
  42. myHistory:"菜品券使用记录"
  43. })
  44. }
  45. wx.setNavigationBarTitle({
  46. title: this.data.myText,
  47. })
  48. if (app.globalData.openId){
  49. this.getDataList();
  50. this.historyList();
  51. }else{
  52. app.globalData.openidSuccessFuc = this.getDataList;
  53. app.globalData.openidSuccessFuc = this.historyList;
  54. }
  55. },
  56. getDataList:function(index){
  57. let params = {
  58. item_type:this.data.index,
  59. cur_page:this.data.pageNum,
  60. show_num:this.data.count,
  61. }
  62. app.wxRequest(app.globalData.httpUrl + 'front/buy/pendinglist', params, e => {
  63. console.log(e)
  64. if (e.code == 200) {
  65. for(var i=0;i<e.data.length;i++){
  66. this.data.newData.push(e.data[i]);
  67. }
  68. this.setData({
  69. dataList:this.data.newData
  70. })
  71. this.data.total_page = e.total_page;
  72. }
  73. }, this)
  74. },
  75. getBot:function(){//scroll触底事件
  76. if(this.data.pageNum<this.data.total_page){
  77. this.data.pageNum++;
  78. this.getDataList();
  79. }else{
  80. wx.showToast({
  81. title: '没有更多数据了',
  82. icon:"none"
  83. })
  84. }
  85. },
  86. lookMyTicket:function(){
  87. this.setData({
  88. myTicketArrows: !this.data.myTicketArrows,
  89. })
  90. if (this.data.myTicketArrows){
  91. this.setData({
  92. mydeg: 0,
  93. })
  94. }else{
  95. this.setData({
  96. mydeg: -90,
  97. })
  98. }
  99. },
  100. lookHistory:function(){
  101. this.setData({
  102. historyTicketArrows: !this.data.historyTicketArrows,
  103. })
  104. if (this.data.historyTicketArrows) {
  105. this.setData({
  106. historydeg: 0,
  107. })
  108. } else {
  109. this.setData({
  110. historydeg: -90,
  111. })
  112. }
  113. },
  114. lower:function(){//检测上拉是否到底
  115. console.log("到底了")
  116. if(this.data.pageNum2<this.data.total_page2){
  117. this.data.pageNum2++;
  118. this.historyList();
  119. }else{
  120. wx.showToast({
  121. title: '没有更多数据了',
  122. icon:"none"
  123. })
  124. }
  125. },
  126. historyList:function(){
  127. let params = {
  128. item_type:this.data.index,
  129. cur_page:this.data.pageNum2,
  130. show_num:this.data.count2,
  131. }
  132. app.wxRequest(app.globalData.httpUrl + 'front/buy/usehistory', params, e => {
  133. console.log(e)
  134. if (e.code == 200) {
  135. for(var i=0;i<e.data.length;i++){
  136. this.data.newData2.push(e.data[i]);
  137. }
  138. this.setData({
  139. dataList2:this.data.newData2
  140. })
  141. this.data.total_page = e.total_page2;
  142. }
  143. }, this)
  144. },
  145. giveTicket:function(e){//赠送优惠券
  146. var id = e.target.dataset.id;
  147. wx.navigateTo({
  148. url: '../givePage/givePage?id=' + id+"&type="+this.data.index+"&type="+this.data.index,
  149. })
  150. },
  151. /**
  152. * 生命周期函数--监听页面初次渲染完成
  153. */
  154. onReady: function () {
  155. },
  156. /**
  157. * 生命周期函数--监听页面显示
  158. */
  159. onShow: function () {
  160. },
  161. /**
  162. * 生命周期函数--监听页面隐藏
  163. */
  164. onHide: function () {
  165. },
  166. /**
  167. * 生命周期函数--监听页面卸载
  168. */
  169. onUnload: function () {
  170. },
  171. /**
  172. * 页面相关事件处理函数--监听用户下拉动作
  173. */
  174. onPullDownRefresh: function () {
  175. },
  176. /**
  177. * 页面上拉触底事件的处理函数
  178. */
  179. onReachBottom: function () {
  180. },
  181. /**
  182. * 用户点击右上角分享
  183. */
  184. onShareAppMessage: function () {
  185. }
  186. })