supplyChainGoods.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <view>
  3. <view class="top-tab-search">
  4. <u--input
  5. placeholder="搜索商品名称"
  6. shape="circle"
  7. prefixIcon="search"
  8. prefixIconStyle="font-size: 22px;color: #909399"
  9. v-model="searchValue"
  10. @change="search"
  11. ></u--input>
  12. <view class="tab">
  13. <view class="top-tab">
  14. <view
  15. :class="{ commodity: follow == 'null' }"
  16. class="tab"
  17. @click="tabSwitch('null')"
  18. >
  19. 全部
  20. </view>
  21. <view
  22. :class="{ commodity: follow == 'normal' }"
  23. class="tab"
  24. @click="tabSwitch('normal')"
  25. >
  26. 已上架
  27. </view>
  28. <view
  29. :class="{ commodity: follow == 7 }"
  30. class="tab"
  31. @click="tabSwitch(7)"
  32. >
  33. 审核中
  34. </view>
  35. <view
  36. :class="{ commodity: follow == 2 }"
  37. class="tab"
  38. @click="tabSwitch(2)"
  39. >
  40. 审核失败
  41. </view>
  42. <view
  43. :class="{ commodity: follow == 'down' }"
  44. class="tab"
  45. @click="tabSwitch('down')"
  46. >
  47. 已下架
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="page">
  53. <view v-for="item in goodsList" :key="item.id">
  54. <GoodsInformation
  55. productAndCommodity="product"
  56. :status="status"
  57. @toDetail="toDetail"
  58. :itemInfo="item"
  59. @goodsUpDown="goodsUpDown"
  60. />
  61. </view>
  62. </view>
  63. <!-- <view class="footer">
  64. <button class="btn">添加供应链商品</button>
  65. </view> -->
  66. </view>
  67. </template>
  68. <script>
  69. import GoodsInformation from "../components/goodsInformation.vue";
  70. export default {
  71. components: {
  72. GoodsInformation,
  73. },
  74. data() {
  75. return {
  76. follow: "null",
  77. status: "null",
  78. page: 1,
  79. goodsList: [],
  80. reviewStatus: "",
  81. productStatus: "",
  82. searchValue: "",
  83. };
  84. },
  85. computed: {
  86. i18n() {
  87. return this.$t("index");
  88. },
  89. },
  90. methods: {
  91. tabSwitch(num) {
  92. this.follow = num;
  93. //num类型为数字时,搜索审核中的商品,为字符串是搜索审核完成的商品
  94. if (typeof num == "number") {
  95. this.reviewStatus = num;
  96. this.productStatus = "";
  97. } else {
  98. this.productStatus = num;
  99. this.reviewStatus = "";
  100. }
  101. this.getinfoList();
  102. },
  103. //跳转商品详情
  104. toDetail(value) {
  105. uni.navigateTo({
  106. url: `/pageD/productDetails/productDetails?goodsId=${value.id}&pageStatus=supply`,
  107. });
  108. },
  109. //搜索
  110. search(e) {
  111. console.log(e);
  112. this.getinfoList();
  113. },
  114. //获取供应链商品列表
  115. getinfoList() {
  116. let api;
  117. //判断字段存不存在,存在则向后端传输该字段,不存在则不传输
  118. if (this.productStatus) {
  119. api = `/api/goods/catena_goods?page=${this.page}&limit=10&status=${this.productStatus}`;
  120. } else if (this.reviewStatus) {
  121. api = `/api/goods/catena_goods?page=${
  122. this.page
  123. }&limit=10&review_status=${
  124. this.reviewStatus == 7 ? "0" : this.reviewStatus
  125. }`;
  126. } else {
  127. api = `/api/goods/catena_goods?page=${this.page}&limit=10`;
  128. }
  129. //拼接搜索字段
  130. api = api + `&keyword=${this.searchValue}`;
  131. uni.$u.http.get(api).then((res) => {
  132. this.goodsList = res.data;
  133. });
  134. },
  135. //商品上架,下架
  136. goodsUpDown(value, item) {
  137. // uni.#u.http.post(``)
  138. },
  139. },
  140. mounted() {
  141. this.getinfoList();
  142. uni.setNavigationBarTitle({
  143. title: "我的供应链商品",
  144. });
  145. },
  146. };
  147. </script>
  148. <style lang="scss" scoped>
  149. .top-tab-search {
  150. background-color: #fff;
  151. padding: 10rpx 24rpx;
  152. .top-tab {
  153. margin-top: 10rpx;
  154. padding: 0 20rpx;
  155. display: flex;
  156. justify-content: space-between;
  157. .tab {
  158. font-size: 26rpx;
  159. color: rgba(34, 34, 34, 0.8);
  160. flex-shrink: 0;
  161. height: 44rpx;
  162. display: flex;
  163. align-items: flex-end;
  164. padding-bottom: 12rpx;
  165. }
  166. .commodity {
  167. position: relative;
  168. font-weight: 600;
  169. }
  170. .commodity::before {
  171. content: "";
  172. display: block;
  173. height: 4rpx;
  174. width: 50%;
  175. background: #f83224;
  176. position: absolute;
  177. bottom: -10rpx;
  178. opacity: 0.8;
  179. left: 50%;
  180. transform: translate(-50%, 50%);
  181. }
  182. }
  183. }
  184. .page {
  185. padding: 20rpx 24rpx;
  186. }
  187. .footer {
  188. position: fixed;
  189. bottom: 0;
  190. background-color: #fff;
  191. width: 100%;
  192. padding: 16rpx 24rpx 70rpx 24rpx;
  193. .btn {
  194. border-radius: 52rpx;
  195. background-color: #f83224;
  196. color: #fff;
  197. border: none;
  198. padding: 0;
  199. margin: 0;
  200. width: 94%;
  201. font-size: 30rpx;
  202. }
  203. }
  204. </style>