goods-log.js 9.4 KB

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