goods-log.js 8.1 KB

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