integralGoodsList.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. "use strict";
  2. const common_vendor = require("../common/vendor.js");
  3. const _sfc_main = {
  4. mixins: [MescrollMixin],
  5. data() {
  6. return {
  7. integral: 0,
  8. type: "0",
  9. typeOptions: [],
  10. tabIndex: 0,
  11. tabs: [],
  12. mescroll: null,
  13. downOption: {
  14. //下拉刷新
  15. use: true,
  16. auto: false
  17. // 不自动加载 (mixin已处理第一个tab触发downCallback)
  18. },
  19. upOption: {
  20. onScroll: false,
  21. use: true,
  22. // 是否启用上拉加载; 默认true
  23. page: {
  24. pae: 0,
  25. // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  26. size: 10
  27. // 每页数据的数量,默认10
  28. },
  29. noMoreSize: 10,
  30. // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  31. textNoMore: "已经到底了",
  32. empty: {
  33. icon: "https://cos.his.cdwjyyh.com/fs/20240423/cf4a86b913a04341bb44e34bb4d37aa2.png",
  34. tip: "暂无数据"
  35. }
  36. },
  37. dataList: []
  38. };
  39. },
  40. onLoad() {
  41. this.getDictByKey("sys_integral_goods_type");
  42. this.getUserInfo();
  43. },
  44. methods: {
  45. getUserInfo() {
  46. getUserInfo().then(
  47. (res) => {
  48. if (res.code == 200) {
  49. if (res.user != null) {
  50. this.integral = res.user.integral;
  51. }
  52. } else {
  53. common_vendor.index.showToast({
  54. icon: "none",
  55. title: "请求失败"
  56. });
  57. }
  58. },
  59. (rej) => {
  60. }
  61. );
  62. },
  63. navTo(url) {
  64. common_vendor.index.navigateTo({
  65. url
  66. });
  67. },
  68. goIntegral() {
  69. let pages = getCurrentPages();
  70. let url = pages[pages.length - 2];
  71. if (pages.length > 1 && url && url.route == "pages/user/integral/points") {
  72. common_vendor.index.navigateBack();
  73. } else {
  74. common_vendor.index.navigateTo({
  75. url: "/pages/user/integral/points"
  76. });
  77. }
  78. },
  79. getDictByKey(key) {
  80. var data = { key };
  81. var that = this;
  82. getDictByKey(data).then(
  83. (res) => {
  84. if (res.code == 200) {
  85. this.typeOptions = res.data;
  86. this.typeOptions.forEach(function(item, index) {
  87. var data2 = { name: item.dictLabel };
  88. that.tabs.push(data2);
  89. });
  90. if (this.tabs.length > 0) {
  91. this.tabIndex = 0;
  92. }
  93. }
  94. },
  95. (err) => {
  96. }
  97. );
  98. },
  99. tabChange(item) {
  100. console.log(item.index);
  101. this.type = this.typeOptions[item.index].dictValue;
  102. this.mescroll.resetUpScroll();
  103. },
  104. mescrollInit(mescroll) {
  105. this.mescroll = mescroll;
  106. },
  107. /*下拉刷新的回调 */
  108. downCallback(mescroll) {
  109. mescroll.resetUpScroll();
  110. },
  111. upCallback(page) {
  112. var that = this;
  113. var data = {
  114. pageNum: page.num,
  115. pageSize: page.size
  116. };
  117. if (this.type != null) {
  118. data.goodsType = this.type;
  119. }
  120. getIntegralGoodsList(data).then((res) => {
  121. if (res.code == 200) {
  122. if (page.num == 1) {
  123. that.dataList = res.data.list;
  124. } else {
  125. that.dataList = that.dataList.concat(res.data.list);
  126. }
  127. that.mescroll.endBySize(res.data.list.length, res.data.total);
  128. } else {
  129. common_vendor.index.showToast({
  130. icon: "none",
  131. title: "请求失败"
  132. });
  133. that.dataList = null;
  134. that.mescroll.endErr();
  135. }
  136. });
  137. }
  138. }
  139. };
  140. if (!Array) {
  141. const _easycom_u_tabs2 = common_vendor.resolveComponent("u-tabs");
  142. const _easycom_u_sticky2 = common_vendor.resolveComponent("u-sticky");
  143. const _component_mescroll_body = common_vendor.resolveComponent("mescroll-body");
  144. (_easycom_u_tabs2 + _easycom_u_sticky2 + _component_mescroll_body)();
  145. }
  146. const _easycom_u_tabs = () => "../uni_modules/uview-plus/components/u-tabs/u-tabs.js";
  147. const _easycom_u_sticky = () => "../uni_modules/uview-plus/components/u-sticky/u-sticky.js";
  148. if (!Math) {
  149. (_easycom_u_tabs + _easycom_u_sticky)();
  150. }
  151. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  152. return common_vendor.e({
  153. a: common_vendor.t($data.integral),
  154. b: common_vendor.o((...args) => $options.goIntegral && $options.goIntegral(...args)),
  155. c: common_vendor.o(($event) => $options.navTo("/pages/user/integral/integralLogsList")),
  156. d: common_vendor.o(($event) => $options.navTo("/pages/user/integral/integralOrderList")),
  157. e: $data.tabs.length > 0
  158. }, $data.tabs.length > 0 ? {
  159. f: common_vendor.o($options.tabChange),
  160. g: common_vendor.p({
  161. current: $data.tabIndex,
  162. scrollable: true,
  163. list: $data.tabs,
  164. lineColor: "#FF5C03"
  165. })
  166. } : {}, {
  167. h: common_vendor.f($data.dataList, (item, index, i0) => {
  168. return {
  169. a: item.imgUrl,
  170. b: common_vendor.t(item.goodsName),
  171. c: common_vendor.t(item.integral),
  172. d: common_vendor.t(item.otPrice.toFixed(2)),
  173. e: common_vendor.o(($event) => $options.navTo("/pages/user/integral/integralGoodsDetails?goodsId=" + item.goodsId))
  174. };
  175. }),
  176. i: common_vendor.sr("mescrollRef", "a55124e7-2"),
  177. j: common_vendor.o($options.mescrollInit),
  178. k: common_vendor.o($options.downCallback),
  179. l: common_vendor.o($options.upCallback),
  180. m: common_vendor.p({
  181. bottom: "0",
  182. down: $data.downOption,
  183. up: $data.upOption
  184. })
  185. });
  186. }
  187. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-a55124e7"]]);
  188. wx.createPage(MiniProgramPage);