goods-log.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const sheep_index = require("../../sheep/index.js");
  4. const sheep_api_product_history = require("../../sheep/api/product/history.js");
  5. const sheep_helper_utils = require("../../sheep/helper/utils.js");
  6. require("../../sheep/url/index.js");
  7. require("../../sheep/store/index.js");
  8. require("../../sheep/store/app.js");
  9. require("../../sheep/api/promotion/diy.js");
  10. require("../../sheep/request/index.js");
  11. require("../../sheep/config/index.js");
  12. require("../../sheep/platform/index.js");
  13. require("../../sheep/platform/provider/wechat/index.js");
  14. require("../../sheep/platform/provider/wechat/miniProgram.js");
  15. require("../../sheep/api/member/auth.js");
  16. require("../../sheep/api/member/social.js");
  17. require("../../sheep/api/member/user.js");
  18. require("../../sheep/platform/provider/apple/index.js");
  19. require("../../sheep/platform/share.js");
  20. require("../../sheep/router/index.js");
  21. require("../../sheep/hooks/useModal.js");
  22. require("../../sheep/helper/index.js");
  23. require("../../sheep/helper/test.js");
  24. require("../../sheep/helper/digit.js");
  25. require("../../sheep/helper/throttle.js");
  26. require("../../sheep/platform/pay.js");
  27. require("../../sheep/api/pay/order.js");
  28. require("../../sheep/store/user.js");
  29. require("../../sheep/store/cart.js");
  30. require("../../sheep/api/trade/cart.js");
  31. require("../../sheep/api/pay/wallet.js");
  32. require("../../sheep/api/trade/order.js");
  33. require("../../sheep/api/promotion/coupon.js");
  34. require("../../sheep/store/sys.js");
  35. require("../../sheep/store/modal.js");
  36. require("../../sheep/config/zIndex.js");
  37. if (!Array) {
  38. const _easycom_s_goods_item2 = common_vendor.resolveComponent("s-goods-item");
  39. const _easycom_su_fixed2 = common_vendor.resolveComponent("su-fixed");
  40. const _easycom_uni_load_more2 = common_vendor.resolveComponent("uni-load-more");
  41. const _easycom_s_empty2 = common_vendor.resolveComponent("s-empty");
  42. const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  43. (_easycom_s_goods_item2 + _easycom_su_fixed2 + _easycom_uni_load_more2 + _easycom_s_empty2 + _easycom_s_layout2)();
  44. }
  45. const _easycom_s_goods_item = () => "../../sheep/components/s-goods-item/s-goods-item.js";
  46. const _easycom_su_fixed = () => "../../sheep/ui/su-fixed/su-fixed.js";
  47. const _easycom_uni_load_more = () => "../../uni_modules/uni-load-more/components/uni-load-more/uni-load-more.js";
  48. const _easycom_s_empty = () => "../../sheep/components/s-empty/s-empty.js";
  49. const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js";
  50. if (!Math) {
  51. (_easycom_s_goods_item + _easycom_su_fixed + _easycom_uni_load_more + _easycom_s_empty + _easycom_s_layout)();
  52. }
  53. const _sfc_main = {
  54. __name: "goods-log",
  55. setup(__props) {
  56. common_vendor.useCssVars((_ctx) => ({
  57. "1ab964d1": common_vendor.unref(sys_navBar)
  58. }));
  59. const sys_navBar = sheep_index.sheep.$platform.navbar;
  60. const pagination = {
  61. list: [],
  62. pageNo: 1,
  63. total: 1,
  64. pageSize: 10
  65. };
  66. const state = common_vendor.reactive({
  67. pagination: sheep_helper_utils.cloneDeep(pagination),
  68. loadStatus: "",
  69. editMode: false,
  70. selectedSpuIdList: [],
  71. selectAll: false
  72. });
  73. async function getList() {
  74. state.loadStatus = "loading";
  75. const { code, data } = await sheep_api_product_history.SpuHistoryApi.getBrowseHistoryPage({
  76. pageNo: state.pagination.pageNo,
  77. pageSize: state.pagination.pageSize
  78. });
  79. if (code !== 0) {
  80. return;
  81. }
  82. state.pagination.list = common_vendor._.concat(state.pagination.list, data.list);
  83. state.pagination.total = data.total;
  84. state.loadStatus = state.pagination.list.length < state.pagination.total ? "more" : "noMore";
  85. }
  86. const onSelect = (id) => {
  87. if (!state.selectedSpuIdList.includes(id)) {
  88. state.selectedSpuIdList.push(id);
  89. } else {
  90. state.selectedSpuIdList.splice(state.selectedSpuIdList.indexOf(id), 1);
  91. }
  92. state.selectAll = state.selectedSpuIdList.length === state.pagination.list.length;
  93. };
  94. const onSelectAll = () => {
  95. state.selectAll = !state.selectAll;
  96. if (!state.selectAll) {
  97. state.selectedSpuIdList = [];
  98. } else {
  99. state.pagination.list.forEach((item) => {
  100. if (state.selectedSpuIdList.includes(item.spuId)) {
  101. state.selectedSpuIdList.splice(state.selectedSpuIdList.indexOf(item.spuId), 1);
  102. }
  103. state.selectedSpuIdList.push(item.spuId);
  104. });
  105. }
  106. };
  107. async function onDelete() {
  108. if (state.selectedSpuIdList.length <= 0) {
  109. return;
  110. }
  111. const { code } = await sheep_api_product_history.SpuHistoryApi.deleteBrowseHistory(state.selectedSpuIdList);
  112. if (code === 0) {
  113. reload();
  114. }
  115. }
  116. async function onClean() {
  117. const { code } = await sheep_api_product_history.SpuHistoryApi.cleanBrowseHistory();
  118. if (code === 0) {
  119. reload();
  120. }
  121. }
  122. function reload() {
  123. state.editMode = false;
  124. state.selectedSpuIdList = [];
  125. state.selectAll = false;
  126. state.pagination = pagination;
  127. getList();
  128. }
  129. function loadMore() {
  130. if (state.loadStatus !== "noMore") {
  131. state.pagination.pageNo += 1;
  132. getList();
  133. }
  134. }
  135. common_vendor.onReachBottom(() => {
  136. loadMore();
  137. });
  138. common_vendor.onLoad(() => {
  139. getList();
  140. });
  141. return (_ctx, _cache) => {
  142. return common_vendor.e({
  143. a: common_vendor.t(state.pagination.total),
  144. b: state.editMode && state.pagination.total
  145. }, state.editMode && state.pagination.total ? {
  146. c: common_vendor.o(($event) => state.editMode = false)
  147. } : {}, {
  148. d: !state.editMode && state.pagination.total
  149. }, !state.editMode && state.pagination.total ? {
  150. e: common_vendor.o(($event) => state.editMode = true)
  151. } : {}, {
  152. f: common_vendor.f(state.pagination.list, (item, k0, i0) => {
  153. return common_vendor.e(state.editMode ? {
  154. a: state.selectedSpuIdList.includes(item.spuId),
  155. b: common_vendor.o(($event) => onSelect(item.spuId), item.id),
  156. c: common_vendor.o(($event) => onSelect(item.spuId), item.id)
  157. } : {}, {
  158. d: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/goods/index", {
  159. id: item.spuId
  160. }), item.id),
  161. e: "e113b195-1-" + i0 + ",e113b195-0",
  162. f: common_vendor.p({
  163. title: item.spuName,
  164. img: item.picUrl,
  165. price: item.price,
  166. skuText: item.introduction,
  167. priceColor: "#FF3000",
  168. titleWidth: 400
  169. }),
  170. g: item.id
  171. });
  172. }),
  173. g: state.editMode,
  174. h: state.selectAll,
  175. i: common_vendor.o(onSelectAll),
  176. j: common_vendor.o(onSelectAll),
  177. k: common_vendor.n({
  178. "ui-BG-Main-Gradient": state.selectedSpuIdList.length > 0,
  179. "ui-Shadow-Main": state.selectedSpuIdList.length > 0
  180. }),
  181. l: common_vendor.o(onDelete),
  182. m: common_vendor.o(onClean),
  183. n: state.editMode,
  184. o: common_vendor.p({
  185. bottom: true,
  186. val: 0,
  187. placeholder: true
  188. }),
  189. p: state.pagination.total > 0
  190. }, state.pagination.total > 0 ? {
  191. q: common_vendor.o(loadMore),
  192. r: common_vendor.p({
  193. status: state.loadStatus,
  194. ["content-text"]: {
  195. contentdown: "上拉加载更多"
  196. }
  197. })
  198. } : {}, {
  199. s: state.pagination.total === 0
  200. }, state.pagination.total === 0 ? {
  201. t: common_vendor.p({
  202. text: "暂无浏览记录",
  203. icon: "/static/collect-empty.png"
  204. })
  205. } : {}, {
  206. v: common_vendor.s(_ctx.__cssVars()),
  207. w: common_vendor.p({
  208. title: "我的足迹",
  209. bgStyle: {
  210. color: "#f2f2f2"
  211. }
  212. })
  213. });
  214. };
  215. }
  216. };
  217. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-e113b195"], ["__file", "/Users/RuHu.Xu/Desktop/mall-newfeifan-zx-app/pages/user/goods-log.vue"]]);
  218. wx.createPage(MiniProgramPage);