抖音c端
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.

index.js 3.8 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. const app = getApp()
  2. const navigationBarHeight = (getApp().statusBarHeight + 50) + "px"
  3. const Http = require("../../../utils/HttpBasics");
  4. const config = require("../../../config/config");
  5. const util = require("../../../utils/util");
  6. Page({
  7. data: {
  8. navigationBarHeight,
  9. boatLsit: [{
  10. name: "未使用",
  11. value: "0"
  12. },
  13. {
  14. name: "已使用",
  15. value: "1"
  16. },
  17. {
  18. name: "已过期",
  19. value: "2"
  20. },
  21. {
  22. name: "已退款",
  23. value: "3"
  24. },
  25. ],
  26. boatFlag: "0",
  27. content: "",
  28. loading: false, //"上拉加载"的变量,默认false,隐藏
  29. pageNum: 1,
  30. allow_load: true,
  31. list: [],
  32. shopList: [],
  33. index: 0,
  34. mallTenantId: ''
  35. },
  36. setBoatFlag(e) {
  37. let index = e.currentTarget.dataset.index
  38. console.log(index);
  39. this.setData({
  40. boatFlag: index,
  41. pageNum: 1,
  42. list: [],
  43. allow_load: true,
  44. loading: false, //"上拉加载"的变量,默认false,隐藏
  45. })
  46. this.getList()
  47. },
  48. bindPickerChange(e) {
  49. const index = e.detail.value
  50. const mallTenantId = this.data.shopList[index].tenantId
  51. // tt.setStorageSync('mallTenantId', mallTenantId)
  52. // tt.setStorageSync('mallIndex', index)
  53. this.setData({
  54. index: index,
  55. mallTenantId: mallTenantId,
  56. allow_load: true
  57. });
  58. console.log(this.data.mallTenantId);
  59. this.getList(this.data.boatFlag, 1);
  60. },
  61. getList() {
  62. let that = this
  63. if (that.data.allow_load) {
  64. that.setData({
  65. loading: true,
  66. content: '小主,我在玩命加载中...'
  67. })
  68. Http.get({
  69. url: config.api.couponOrderList,
  70. data: {
  71. pageNum: that.data.pageNum,
  72. pageSize: 10,
  73. couponOrderStatus: that.data.boatFlag == "all" ? "" : that.data.boatFlag,
  74. mallTenantId: that.data.mallTenantId
  75. }
  76. }).then(res => {
  77. if (that.data.pageNum == 1) {
  78. that.setData({
  79. list: []
  80. })
  81. }
  82. let tempArr = that.data.list
  83. if (tempArr.length > 0) {
  84. tempArr.map(item => {
  85. item.expiredTime = util.formatTime(item.expiredTime, "yyyy-MM-dd ");
  86. })
  87. }
  88. if (that.data.pageNum >= res.data.pages) {
  89. that.setData({
  90. allow_load: false
  91. })
  92. }
  93. if (that.data.pageNum > 1) { //分页
  94. that.setData({
  95. list: res.data.list ? [...tempArr, ...res.data.list] : tempArr,
  96. loading: false
  97. })
  98. } else {
  99. let tempLsit = res.data.list ? res.data.list : []
  100. if (tempLsit.length > 0) {
  101. tempLsit.map(item => {
  102. item.expiredTime = util.formatTime(item.expiredTime, "yyyy-MM-dd");
  103. })
  104. }
  105. that.setData({
  106. list: tempLsit,
  107. loading: false
  108. })
  109. }
  110. }).catch(err => {
  111. tt.showToast({
  112. title: err.message ? err.message : err.data, // 内容
  113. icon: "none"
  114. });
  115. })
  116. } else {
  117. that.setData({
  118. loading: true,
  119. content: "——— 再拉裤子就掉了啦 ———"
  120. })
  121. setTimeout(function () {
  122. that.setData({
  123. loading: false,
  124. })
  125. }, 1400)
  126. }
  127. },
  128. onLoad: function (options) {
  129. Http.get({
  130. url: '/mall/subMall?isAll=1',
  131. }).then(res => {
  132. this.setData({
  133. shopList: res.data,
  134. // tt.getStorageSync('mallTenantId') ||
  135. mallTenantId: res.data[0].tenantId
  136. });
  137. console.log(this.data.shopList, 'list');
  138. }).catch(err => {
  139. console.log(err, 'err');
  140. })
  141. },
  142. onReachBottom() { //触底
  143. console.log(111);
  144. this.setData({
  145. pageNum: this.data.pageNum + 1
  146. })
  147. this.getList()
  148. },
  149. onShow: function () {
  150. this.getList()
  151. }
  152. })