integralGoodsList.js 5.8 KB

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