C端小程序
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

180 wiersze
4.2 KiB

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