supplyChainGoods.vue 5.2 KB

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