integral.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. "use strict";
  2. var common_vendor = require("../common/vendor.js");
  3. var api_common = require("../api/common.js");
  4. var api_integral = require("../api/integral.js");
  5. require("../common/request.js");
  6. const Loading = () => "../components/Loading.js";
  7. const _sfc_main = {
  8. components: {
  9. Loading
  10. },
  11. data() {
  12. return {
  13. typeOptions: [],
  14. isDaySign: false,
  15. top: 0,
  16. signNum: 0,
  17. integral: 0,
  18. sign: [],
  19. statusBarHeight: common_vendor.index.getStorageSync("menuInfo").statusBarHeight,
  20. tags: [{ lable: "\u5168\u90E8", value: 0 }, { lable: "\u83B7\u5F97", value: 1 }, { lable: "\u6D88\u8017", value: 2 }],
  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. bg: function() {
  53. return "rgba(255,142,60, " + this.top / 30 + ")";
  54. }
  55. },
  56. methods: {
  57. getDictByKey(key) {
  58. var data = { key };
  59. api_common.getDictByKey(data).then((res) => {
  60. if (res.code == 200) {
  61. this.typeOptions = res.data;
  62. }
  63. }, (err) => {
  64. });
  65. },
  66. doSign() {
  67. var data = {};
  68. api_integral.doSign(data).then((res) => {
  69. if (res.code == 200) {
  70. common_vendor.index.showToast({
  71. icon: "success",
  72. title: res.msg
  73. });
  74. this.list = [];
  75. this.page.page = 1;
  76. this.list = [];
  77. this.loaded = false;
  78. this.loading = false;
  79. this.getUserIntegralLogsList();
  80. this.getUserSign();
  81. } else {
  82. common_vendor.index.showToast({
  83. icon: "none",
  84. title: res.msg
  85. });
  86. }
  87. }, (rej) => {
  88. });
  89. },
  90. getUserSign() {
  91. api_integral.getUserSign().then((res) => {
  92. if (res.code == 200) {
  93. this.data = res.member;
  94. this.signNum = res.signNum;
  95. this.isDaySign = res.isDaySign;
  96. this.integral = res.integral;
  97. this.sign = JSON.parse(res.sign);
  98. } else {
  99. common_vendor.index.showToast({
  100. icon: "none",
  101. title: "\u8BF7\u6C42\u5931\u8D25"
  102. });
  103. }
  104. }, (rej) => {
  105. });
  106. },
  107. getUserIntegralLogsList() {
  108. let that = this;
  109. if (that.loaded == true || that.loading == true)
  110. return;
  111. that.loading = true;
  112. common_vendor.index.showLoading({
  113. title: "\u52A0\u8F7D\u4E2D..."
  114. });
  115. api_integral.getUserIntegralLogsList(that.page).then((res) => {
  116. that.loading = false;
  117. that.loaded = res.data.list.length < that.page.pageSize;
  118. that.page.page = that.page.page + 1;
  119. that.list.push.apply(that.list, res.data.list);
  120. common_vendor.index.hideLoading();
  121. }, (err) => {
  122. common_vendor.index.hideLoading();
  123. common_vendor.index.showToast({
  124. title: err.msg,
  125. icon: "none",
  126. duration: 2e3
  127. });
  128. });
  129. },
  130. back() {
  131. common_vendor.index.navigateBack();
  132. },
  133. tabChange(item) {
  134. console.log(item);
  135. this.tabIndex = item.value;
  136. this.page.type = this.tabIndex;
  137. this.page.page = 1;
  138. this.list = [];
  139. this.loaded = false;
  140. this.loading = false;
  141. this.getUserIntegralLogsList();
  142. }
  143. }
  144. };
  145. if (!Array) {
  146. const _component_Loading = common_vendor.resolveComponent("Loading");
  147. _component_Loading();
  148. }
  149. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  150. return common_vendor.e({
  151. a: $data.statusBarHeight,
  152. b: common_vendor.o((...args) => $options.back && $options.back(...args)),
  153. c: $options.bg,
  154. d: $data.statusBarHeight,
  155. e: common_vendor.t($data.integral),
  156. f: common_vendor.t($data.signNum),
  157. g: common_vendor.f($data.sign, (item, index, i0) => {
  158. return common_vendor.e({
  159. a: $data.signNum >= index + 1
  160. }, $data.signNum >= index + 1 ? {} : {}, {
  161. b: common_vendor.t(item.day),
  162. c: index,
  163. d: common_vendor.n($data.signNum >= index + 1 ? "item active" : "item")
  164. });
  165. }),
  166. h: $data.isDaySign == false
  167. }, $data.isDaySign == false ? {
  168. i: common_vendor.o(($event) => $options.doSign())
  169. } : {}, {
  170. j: common_vendor.f($data.tags, (item, index, i0) => {
  171. return {
  172. a: common_vendor.t(item.lable),
  173. b: $data.tabIndex == item.value,
  174. c: index,
  175. d: common_vendor.n($data.tabIndex == item.value ? "item active" : "item"),
  176. e: common_vendor.o(($event) => $options.tabChange(item), index)
  177. };
  178. }),
  179. k: common_vendor.f($data.list, (item, index, i0) => {
  180. return common_vendor.e({
  181. a: common_vendor.t(_ctx.$getDictLabelName($data.typeOptions, item.logType)),
  182. b: common_vendor.t(item.createTime),
  183. c: item.integral < 0
  184. }, item.integral < 0 ? {
  185. d: common_vendor.t(item.integral)
  186. } : {
  187. e: common_vendor.t(item.integral)
  188. }, {
  189. f: index
  190. });
  191. }),
  192. l: common_vendor.p({
  193. loaded: $data.loaded,
  194. loading: $data.loading
  195. })
  196. });
  197. }
  198. var MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "E:/Project/2023/\u95EE\u8BCA\u5E73\u53F0/his_user_miniapp/pages_user/integral.vue"]]);
  199. _sfc_main.__runtimeHooks = 1;
  200. wx.createPage(MiniProgramPage);