C端小程序
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

120 satır
2.6 KiB

  1. var config = require("../../../config/config.js");
  2. var app = getApp();
  3. const Http = require("../../../utils/HttpBasics");
  4. let util = require("../../../utils/util");
  5. const imgurl = require("../../../utils/imgurl");
  6. const {creditType} = require("../../../utils/creditType");
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. score: 10,
  13. pageNum: 1,
  14. list: [],
  15. showcontent: false,
  16. loadingUrl: imgurl.loading.url,
  17. bgg: imgurl.bgg.url,
  18. allow_load: true,
  19. creditAmount:0
  20. },
  21. /**
  22. * 生命周期函数--监听页面加载
  23. */
  24. onLoad: function (options) {
  25. },
  26. gotorule: function () {
  27. wx.navigateTo({
  28. url: '/pages/grade/grade',
  29. })
  30. },
  31. /**
  32. * 生命周期函数--监听页面显示
  33. */
  34. onShow: function () {
  35. let that = this;
  36. that.getScore();
  37. that.record(1, 15);
  38. },
  39. record(pageNum) {
  40. var that = this;
  41. if (that.data.allow_load) {
  42. Http.get({
  43. url: config.api.integralList,
  44. data: {
  45. pageNum: pageNum,
  46. pageSize: 20,
  47. }
  48. }).then(res => {
  49. wx.stopPullDownRefresh();
  50. res.data.list.map(file => {
  51. creditType.map((item,index)=>{
  52. if (file.creditType==item.value){
  53. file.creditTypeName = item.name;
  54. }
  55. })
  56. file.createDate = util.formatTime(
  57. file.createDate,
  58. "yyyy-MM-dd hh:mm:ss"
  59. );
  60. });
  61. if (pageNum >= res.data.pages) {
  62. that.setData({
  63. allow_load: false,
  64. });
  65. }
  66. that.data.list = that.data.list.concat(res.data.list);
  67. console.log(that.data.list,22222222222)
  68. that.setData({
  69. list: that.data.list,
  70. creditAmount: that.data.list[0].creditAmount
  71. });
  72. })
  73. .catch(err => {
  74. wx.stopPullDownRefresh();
  75. wx.showToast({
  76. title: err.errMsg,
  77. icon: 'none',
  78. duration: 2000,
  79. mask: false
  80. });
  81. })
  82. }
  83. },
  84. getScore: function () {
  85. let that = this;
  86. Http.get({
  87. url: config.api.getScore,
  88. data: {}
  89. })
  90. .then(res => {
  91. console.log(res)
  92. that.setData({
  93. score: res.data.score,
  94. levelName: res.data.levelName,
  95. })
  96. })
  97. },
  98. /**
  99. * 刷新
  100. */
  101. onPullDownRefresh: function (e) {
  102. let that = this;
  103. that.setData({
  104. pageNum: 1,
  105. list:[]
  106. });
  107. that.record(1);
  108. },
  109. onReachBottom: function () {
  110. var that = this;
  111. that.data.pageNum++;
  112. that.setData({
  113. pageNum: that.data.pageNum
  114. });
  115. that.record(that.data.pageNum);
  116. }
  117. })