C端小程序
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

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