onlineproductselection.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <template>
  2. <view class="online-class-wrapper">
  3. <view class="headers">
  4. <headersVue
  5. headerTitle="在线选品列表"
  6. @headerJump="headerJump"
  7. ></headersVue>
  8. <view class="headers-box">
  9. <searchVue
  10. placeholder="请输入商品名称"
  11. @search="onHandleSearch"
  12. ></searchVue>
  13. <CategoryNav
  14. :category="quanbuData"
  15. :curruntActive="curruntActivesd"
  16. @tabs="tabsCategoryNav"
  17. />
  18. <Statistics
  19. :category="categoryData"
  20. :curruntActive="curruntActive"
  21. @tabs="tabsStatistics"
  22. />
  23. <!-- <ActionButtons class="mt"/> -->
  24. <!-- <view class="sort-buttons">
  25. <button type="default" size="mini" @click="sortByPrice">{{ sortBy === 'price'? '销售价 ▲' : '销售价 ▼' }}</button>
  26. <button type="default" size="mini" @click="sortByProfit">{{ sortBy === 'profit'? '创客利润 ▲' : '创客利润 ▼' }}</button>
  27. </view> -->
  28. </view>
  29. </view>
  30. <view class="online-content">
  31. <view class="product-list">
  32. <template v-if="list.length > 0">
  33. <ProductCard
  34. :product="product"
  35. v-for="(product, index) in list"
  36. :key="index"
  37. @success="initData"
  38. />
  39. </template>
  40. <template v-else>
  41. <emptyDataVue />
  42. </template>
  43. </view>
  44. <view
  45. class=""
  46. v-if="tihsi == 0 && list.length > 0"
  47. style="margin: 60rpx 0 30rpx 0; color: #999999; font-size: 26rpx"
  48. >
  49. —— 已经到最底部了哦 ——
  50. </view>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. import headersVue from "../../shop/components/headers/headers.vue";
  56. import searchVue from "../../shop/commodity/components/search/search.vue";
  57. import CategoryNav from "./components/listCard/CategoryNav.vue";
  58. import Statistics from "./components/listCard/Statistics.vue";
  59. import ActionButtons from "./components/listCard/ActionButtons.vue";
  60. import ProductCard from "./components/listCard/ProductCardOnline.vue";
  61. import emptyDataVue from "../../shop/components/emptyData/emptyData.vue";
  62. import {
  63. statusFilterApi,
  64. categoryFilterApi,
  65. productSelectListApi,
  66. productDetailApi,
  67. } from "@/commit/product.js";
  68. export default {
  69. components: {
  70. headersVue,
  71. searchVue,
  72. CategoryNav,
  73. Statistics,
  74. ActionButtons,
  75. ProductCard,
  76. emptyDataVue,
  77. },
  78. data() {
  79. return {
  80. curruntActive: 0,
  81. curruntActivesd: 0,
  82. categoryData: [],
  83. quanbuData: [
  84. {
  85. cateIds: "",
  86. cateName: "全部",
  87. },
  88. ],
  89. list: [],
  90. tihsi: "",
  91. is_panudn: true,
  92. products: [
  93. {
  94. imageUrl: "商品图片地址1",
  95. title: "DT15100心相印茶语丝享100抽*20包三层塑装纸面巾",
  96. salePrice: 43.06,
  97. pension: 0.0,
  98. creatorProfit: 7.17,
  99. status: "正常",
  100. description: "心相印经典纸巾产品",
  101. isChecked: false,
  102. },
  103. {
  104. imageUrl: "商品图片地址2",
  105. title: "测试商品 请勿下单",
  106. salePrice: 72.88,
  107. pension: 0.0,
  108. creatorProfit: 12.14,
  109. status: "正常",
  110. description: "伊利测试商品 不会发货",
  111. isChecked: false,
  112. },
  113. ],
  114. searchValue: "",
  115. formData: {
  116. cate_ids: "",
  117. page: 1,
  118. limit: 10,
  119. type: "", //筛选类型
  120. profit: "", //筛选利润
  121. title: "", //筛选标题
  122. price: "", //筛选价格
  123. },
  124. };
  125. },
  126. async onLoad(params) {
  127. await this.getCategoryFilterApi();
  128. await this.initData();
  129. },
  130. onPullDownRefresh() {
  131. uni.showLoading({
  132. title: "加载中",
  133. });
  134. this.formData.page = 1;
  135. this.is_panudn = true;
  136. this.list = [];
  137. this.getProductList();
  138. },
  139. onReachBottom() {
  140. if (this.is_panudn == true) {
  141. this.formData.page++;
  142. this.getProductList();
  143. } else {
  144. return;
  145. }
  146. },
  147. methods: {
  148. async initData() {
  149. await this.getStatusFilter();
  150. await this.getProductList();
  151. },
  152. async getStatusFilter() {
  153. try {
  154. const res = await statusFilterApi();
  155. if (res.data.status == 200) {
  156. this.categoryData = res.data.data || [];
  157. }
  158. } catch (error) {}
  159. },
  160. async getCategoryFilterApi() {
  161. try {
  162. const res = await categoryFilterApi({
  163. page: 1,
  164. limit: 12,
  165. });
  166. if (res.data.status == 200) {
  167. let data = res.data.data.data || [];
  168. this.quanbuData = [
  169. {
  170. cateIds: "",
  171. cateName: "全部",
  172. },
  173. ];
  174. data.forEach((item) => {
  175. this.quanbuData.push(item);
  176. });
  177. }
  178. console.log(res.data, "9981");
  179. } catch (error) {}
  180. },
  181. headerJump() {
  182. uni.switchTab({ url: "../../shop/productManagementModule/index" });
  183. },
  184. goJump() {
  185. uni.redirectTo({ url: "./onlineDetail" });
  186. },
  187. onHandleSearch(val) {
  188. console.log(val);
  189. this.formData.title = val;
  190. this.getProductList();
  191. },
  192. async getProductList() {
  193. uni.showLoading({
  194. title: "加载中",
  195. mask: true,
  196. });
  197. try {
  198. const res = await productSelectListApi(this.formData);
  199. uni.stopPullDownRefresh();
  200. if (res.data.status == 200) {
  201. this.tihsi = res.data.data.data.lenght || 0;
  202. if (res.data.data.count > 0) {
  203. if (this.formData.page == 1) {
  204. this.list = res.data.data.data;
  205. } else {
  206. this.list = this.list.concat(res.data.data.data);
  207. }
  208. } else {
  209. if (this.formData.page == 1) {
  210. this.list = [];
  211. }
  212. this.is_panudn = false;
  213. }
  214. uni.hideLoading();
  215. }
  216. uni.hideLoading();
  217. } catch (error) {
  218. uni.hideLoading();
  219. }finally{
  220. // uni.hideLoading();
  221. }
  222. },
  223. sortByPrice() {
  224. this.sortBy = this.sortBy === "price" ? "" : "price";
  225. },
  226. sortByProfit() {
  227. this.sortBy = this.sortBy === "profit" ? "" : "profit";
  228. },
  229. tabsStatistics({ index, item }) {
  230. this.curruntActive = index;
  231. this.formData.type = item.type;
  232. this.list = [];
  233. this.formData.page = 1;
  234. uni.pageScrollTo({
  235. scrollTop: 0,
  236. duration: 300,
  237. });
  238. this.getProductList();
  239. },
  240. tabsCategoryNav({ index, item }) {
  241. this.curruntActivesd = index;
  242. this.formData.cate_ids = item.cateIds;
  243. uni.pageScrollTo({
  244. scrollTop: 0,
  245. duration: 300,
  246. });
  247. this.list = [];
  248. this.formData.page = 1;
  249. this.getStatusFilter();
  250. this.getProductList();
  251. },
  252. },
  253. computed: {
  254. filteredProducts() {
  255. let filtered = this.products.filter((product) => {
  256. return product.title.includes(this.searchValue);
  257. });
  258. if (this.sortBy === "price") {
  259. return filtered.sort((a, b) => a.salePrice - b.salePrice);
  260. } else if (this.sortBy === "profit") {
  261. return filtered.sort((a, b) => a.creatorProfit - b.creatorProfit);
  262. }
  263. return filtered;
  264. },
  265. },
  266. };
  267. </script>
  268. <style>
  269. page {
  270. background-color: #f7f8fc;
  271. height: 100%;
  272. }
  273. </style>
  274. <style lang="scss" scoped>
  275. .online-class-wrapper {
  276. height: 100%;
  277. .headers {
  278. width: 100%;
  279. box-sizing: border-box;
  280. .headers-box {
  281. margin-top: 95rpx;
  282. position: fixed;
  283. top: 0rpx;
  284. width: 100%;
  285. z-index: 666;
  286. }
  287. }
  288. .online-content {
  289. display: flex;
  290. flex-direction: column;
  291. align-items: center;
  292. margin-top: 450rpx;
  293. box-sizing: border-box;
  294. padding-bottom: 60rpx;
  295. width: 100%;
  296. .product-list {
  297. width: 100%;
  298. display: flex;
  299. flex-direction: column;
  300. align-items: center;
  301. }
  302. }
  303. }
  304. .mt {
  305. margin-top: 30rpx;
  306. padding: 0 15rpx;
  307. }
  308. .sort-buttons {
  309. display: flex;
  310. // align-items: center;
  311. margin-bottom: 20rpx;
  312. }
  313. .sort-buttons button {
  314. margin-right: 10rpx;
  315. }
  316. </style>