integral.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. "use strict";
  2. const common_vendor = require("../common/vendor.js");
  3. const Loading = () => "../components/Loading.js";
  4. const _sfc_main = {
  5. components: {
  6. Loading
  7. },
  8. data() {
  9. return {
  10. typeOptions: [],
  11. isDaySign: false,
  12. top: 0,
  13. signNum: 0,
  14. integral: 0,
  15. sign: [],
  16. // 状态栏的高度
  17. statusBarHeight: common_vendor.index.getStorageSync("menuInfo").statusBarHeight,
  18. // tab切换
  19. tags: [{ lable: "全部", value: 0 }, { lable: "获得", value: 1 }, { lable: "消耗", value: 2 }],
  20. // 选中的tab
  21. tabIndex: 0,
  22. current: 0,
  23. page: {
  24. type: 0,
  25. page: 1,
  26. pageSize: 10
  27. },
  28. list: [],
  29. loaded: false,
  30. loading: false
  31. };
  32. },
  33. onLoad(option) {
  34. this.getDictByKey("sys_integral_log_type");
  35. this.getUserSign();
  36. this.getUserIntegralLogsList();
  37. },
  38. onReachBottom() {
  39. !this.loading && this.getUserIntegralLogsList();
  40. },
  41. onPageScroll(e) {
  42. if (e.scrollTop > 30) {
  43. this.topFixed = true;
  44. } else {
  45. this.topFixed = false;
  46. }
  47. },
  48. onPageScroll(e) {
  49. this.top = e.scrollTop;
  50. },
  51. computed: {
  52. // 计算属性的 getter
  53. bg: function() {
  54. return "rgba(255,142,60, " + this.top / 30 + ")";
  55. }
  56. },
  57. methods: {
  58. getDictByKey(key) {
  59. var data = { key };
  60. getDictByKey(data).then(
  61. (res) => {
  62. if (res.code == 200) {
  63. this.typeOptions = res.data;
  64. }
  65. },
  66. (err) => {
  67. }
  68. );
  69. },
  70. doSign() {
  71. var data = {};
  72. common_vendor.index.showLoading({
  73. title: "正在加载中..."
  74. });
  75. doSign(data).then(
  76. (res) => {
  77. common_vendor.index.hideLoading();
  78. if (res.code == 200) {
  79. common_vendor.index.showToast({
  80. icon: "success",
  81. title: res.msg
  82. });
  83. this.list = [];
  84. this.page.page = 1;
  85. this.list = [];
  86. this.loaded = false;
  87. this.loading = false;
  88. this.getUserIntegralLogsList();
  89. this.getUserSign();
  90. } else {
  91. common_vendor.index.showToast({
  92. icon: "none",
  93. title: res.msg
  94. });
  95. }
  96. },
  97. (rej) => {
  98. }
  99. );
  100. },
  101. getUserSign() {
  102. getUserSign().then(
  103. (res) => {
  104. if (res.code == 200) {
  105. this.data = res.member;
  106. this.signNum = res.signNum;
  107. this.isDaySign = res.isDaySign;
  108. this.integral = res.integral;
  109. this.sign = JSON.parse(res.sign);
  110. } else {
  111. common_vendor.index.showToast({
  112. icon: "none",
  113. title: "请求失败"
  114. });
  115. }
  116. },
  117. (rej) => {
  118. }
  119. );
  120. },
  121. getUserIntegralLogsList() {
  122. let that = this;
  123. if (that.loaded == true || that.loading == true)
  124. return;
  125. that.loading = true;
  126. common_vendor.index.showLoading({
  127. title: "加载中..."
  128. });
  129. getUserIntegralLogsList(that.page).then(
  130. (res) => {
  131. that.loading = false;
  132. that.loaded = res.data.list.length < that.page.pageSize;
  133. that.page.page = that.page.page + 1;
  134. that.list.push.apply(that.list, res.data.list);
  135. common_vendor.index.hideLoading();
  136. },
  137. (err) => {
  138. common_vendor.index.hideLoading();
  139. common_vendor.index.showToast({
  140. title: err.msg,
  141. icon: "none",
  142. duration: 2e3
  143. });
  144. }
  145. );
  146. },
  147. // 返回上一页
  148. back() {
  149. common_vendor.index.navigateBack();
  150. },
  151. // tab选择
  152. tabChange(item) {
  153. console.log(item);
  154. this.tabIndex = item.value;
  155. this.page.type = this.tabIndex;
  156. this.page.page = 1;
  157. this.list = [];
  158. this.loaded = false;
  159. this.loading = false;
  160. this.getUserIntegralLogsList();
  161. }
  162. }
  163. };
  164. if (!Array) {
  165. const _component_Loading = common_vendor.resolveComponent("Loading");
  166. _component_Loading();
  167. }
  168. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  169. return common_vendor.e({
  170. a: $data.statusBarHeight,
  171. b: common_vendor.o((...args) => $options.back && $options.back(...args)),
  172. c: $options.bg,
  173. d: $data.statusBarHeight,
  174. e: common_vendor.t($data.integral),
  175. f: common_vendor.t($data.signNum),
  176. g: common_vendor.f($data.sign, (item, index, i0) => {
  177. return common_vendor.e({
  178. a: $data.signNum >= index + 1
  179. }, $data.signNum >= index + 1 ? {} : {}, {
  180. b: common_vendor.t(item.day),
  181. c: index,
  182. d: common_vendor.n($data.signNum >= index + 1 ? "item active" : "item")
  183. });
  184. }),
  185. h: $data.isDaySign == false
  186. }, $data.isDaySign == false ? {
  187. i: common_vendor.o(($event) => $options.doSign())
  188. } : {}, {
  189. j: common_vendor.f($data.tags, (item, index, i0) => {
  190. return {
  191. a: common_vendor.t(item.lable),
  192. b: $data.tabIndex == item.value,
  193. c: index,
  194. d: common_vendor.n($data.tabIndex == item.value ? "item active" : "item"),
  195. e: common_vendor.o(($event) => $options.tabChange(item), index)
  196. };
  197. }),
  198. k: common_vendor.f($data.list, (item, index, i0) => {
  199. return common_vendor.e({
  200. a: common_vendor.t(_ctx.$getDictLabelName($data.typeOptions, item.logType)),
  201. b: common_vendor.t(item.createTime),
  202. c: item.integral < 0
  203. }, item.integral < 0 ? {
  204. d: common_vendor.t(item.integral)
  205. } : {
  206. e: common_vendor.t(item.integral)
  207. }, {
  208. f: index
  209. });
  210. }),
  211. l: common_vendor.p({
  212. loaded: $data.loaded,
  213. loading: $data.loading
  214. })
  215. });
  216. }
  217. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
  218. _sfc_main.__runtimeHooks = 1;
  219. wx.createPage(MiniProgramPage);