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

133 lines
3.0 KiB

  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. {
  11. name:"未使用",
  12. value:"0"
  13. },
  14. {
  15. name:"已使用",
  16. value:"1"
  17. },
  18. {
  19. name:"已过期",
  20. value:"2"
  21. },
  22. {
  23. name:"已退款",
  24. value:"3"
  25. },
  26. ],
  27. boatFlag:"0",
  28. content:"",
  29. loading: false, //"上拉加载"的变量,默认false,隐藏
  30. pageNum:1,
  31. allow_load: true,
  32. list:[],
  33. },
  34. setBoatFlag(e){
  35. let index = e.currentTarget.dataset.index
  36. console.log(index);
  37. this.setData({
  38. boatFlag:index,
  39. pageNum:1,
  40. list:[],
  41. allow_load: true,
  42. loading: false, //"上拉加载"的变量,默认false,隐藏
  43. })
  44. this.getList()
  45. },
  46. getList(){
  47. let that = this
  48. if (that.data.allow_load) {
  49. that.setData({
  50. loading: true,
  51. content: '小主,我在玩命加载中...'
  52. })
  53. Http.get({
  54. url:config.api.couponOrderList,
  55. data:{
  56. pageNum:that.data.pageNum,
  57. pageSize: 10,
  58. couponOrderStatus:that.data.boatFlag=="all"?"":that.data.boatFlag,
  59. }
  60. }).then(res=>{
  61. if(that.data.pageNum==1){
  62. that.setData({
  63. list: []
  64. })
  65. }
  66. let tempArr= that.data.list
  67. if(tempArr.length>0){
  68. tempArr.map(item=>{
  69. item.expiredTime = util.formatTime(item.expiredTime, "yyyy-MM-dd ");
  70. })
  71. }
  72. if(that.data.pageNum>=res.data.pages){
  73. that.setData({
  74. allow_load: false
  75. })
  76. }
  77. if(that.data.pageNum>1){//分页
  78. that.setData({
  79. list: res.data.list?[...tempArr ,...res.data.list]:tempArr,
  80. loading:false
  81. })
  82. }else{
  83. let tempLsit = res.data.list?res.data.list:[]
  84. if(tempLsit.length>0){
  85. tempLsit.map(item=>{
  86. item.expiredTime = util.formatTime(item.expiredTime, "yyyy-MM-dd");
  87. })
  88. }
  89. that.setData({
  90. list: tempLsit,
  91. loading:false
  92. })
  93. }
  94. }).catch(err => {
  95. tt.showToast({
  96. title: err.message ? err.message : err.data, // 内容
  97. icon: "none"
  98. });
  99. })
  100. }else {
  101. that.setData({
  102. loading: true,
  103. content: "——— 再拉裤子就掉了啦 ———"
  104. })
  105. setTimeout(function () {
  106. that.setData({
  107. loading: false,
  108. })
  109. }, 1400)
  110. }
  111. },
  112. onLoad: function (options) {
  113. },
  114. onReachBottom(){//触底
  115. console.log(111);
  116. this.setData({
  117. pageNum:this.data.pageNum+1
  118. })
  119. this.getList()
  120. },
  121. onShow:function(){
  122. this.getList()
  123. }
  124. })