C端小程序
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

172 行
4.0 KiB

  1. var config = require("../../config/config.js");
  2. const Http = require("../../utils/HttpBasics");
  3. const imgurl = require("../../utils/imgurl");
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. bannerUrl: imgurl.banner.url,
  10. loadingUrl: imgurl.loading.url,
  11. nodata: imgurl.nodata.url,
  12. wangmeimeicredit: imgurl.wangmeimeicredit.url,
  13. list: [],
  14. lists: [],
  15. myLists: [],
  16. page: 1, // 设置加载的第几次,默认是第一次
  17. pageSize: 10, //返回数据的个数
  18. searchLoadingComplete: false, //“没有数据”的变量,默认false,隐藏
  19. allow_load: true, // 是否允许继续加载标识 默认 true 允许,false 加载完成
  20. myorder: false,
  21. actUrl: imgurl.act.url,
  22. loading: true,
  23. content: '数据正在加载中',
  24. reloadIf: false
  25. },
  26. onLoad: function (options) {
  27. let that = this;
  28. console.log(options)
  29. if (options &&options.credit){
  30. that.setData({
  31. credit: options.credit
  32. })
  33. }
  34. var todayDate = new Date().getTime();
  35. that.setData({
  36. optionsData: options,
  37. todayDate: todayDate
  38. })
  39. if (options && options.from == 'myhtml') {
  40. that.getmyList();
  41. }
  42. else {
  43. that.getList(1);
  44. that.setData({
  45. lists: null
  46. })
  47. }
  48. },
  49. onShow() {
  50. let that = this;
  51. if (this.data.reloadIf) {
  52. wx.setNavigationBarTitle({
  53. title: '积分商城'
  54. })
  55. that.getList(1);
  56. that.setData({
  57. lists: null
  58. })
  59. }
  60. },
  61. gotojifen(){
  62. wx.navigateTo({
  63. url: '/pages/integralmall/integraHistory/index',
  64. })
  65. },
  66. getList(pageNum) {
  67. var that = this;
  68. console.log(pageNum)
  69. if (that.data.allow_load) {
  70. that.setData({
  71. loading: true,
  72. content: '小主,我在玩命加载中...'
  73. })
  74. var param = {};
  75. var param = {
  76. pageNum: pageNum,
  77. pageSize: 10,
  78. targetAd: 50
  79. };
  80. var url = config.api.couponChannelList;
  81. // 请求接口
  82. Http.get({
  83. url: url,
  84. data: param
  85. }).then(res => {
  86. console.log(res)
  87. /**
  88. * 加载完成
  89. */
  90. if (pageNum >= res.data.pages) {
  91. if (res.data.pages == 0 || res.data.pages == 1) {
  92. that.setData({
  93. allow_load: true,
  94. loading: false,
  95. content: ""
  96. });
  97. } else {
  98. that.setData({
  99. allow_load: false,
  100. loading: true,
  101. content: "——— 再拉裤子就掉了啦 ———",
  102. });
  103. }
  104. }
  105. if (pageNum == 1) {
  106. that.setData({
  107. lists: [],
  108. })
  109. }
  110. var tmpArr = that.data.lists;
  111. tmpArr.push.apply(tmpArr, res.data.list);
  112. that.setData({
  113. lists: tmpArr
  114. })
  115. wx.stopPullDownRefresh();
  116. })
  117. .catch(err => {
  118. wx.stopPullDownRefresh();
  119. wx.showToast({
  120. title: err.message,
  121. icon: 'none',
  122. duration: 2000,
  123. mask: false
  124. });
  125. })
  126. setTimeout(function () {
  127. that.setData({
  128. loading: false,
  129. })
  130. }, 1400);
  131. } else {
  132. that.setData({
  133. loading: true,
  134. content: "——— 再拉裤子就掉了啦 ———"
  135. })
  136. setTimeout(function () {
  137. that.setData({
  138. loading: false,
  139. })
  140. }, 1400)
  141. }
  142. },
  143. /**
  144. *
  145. * @param goto拼团券详情
  146. */
  147. invite: function (e) {
  148. let couponChannelId = e.currentTarget.dataset.id;
  149. let couponId = e.currentTarget.dataset.couponid;
  150. if (couponChannelId && couponId) {
  151. wx.navigateTo({
  152. url: `/pages/integralmall/integcoupondetail/index?couponChannelId=${couponChannelId}&couponId=${couponId}`
  153. })
  154. }
  155. },
  156. //加载更多
  157. onReachBottom: function () {
  158. let that = this;
  159. that.data.page++;
  160. that.setData({
  161. page: that.data.page
  162. });
  163. that.getList(that.data.page, that.data.flag);
  164. },
  165. /**
  166. * 刷新
  167. */
  168. onPullDownRefresh: function (e) {
  169. let that = this;
  170. that.getList(1);
  171. }
  172. })