goodsList.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <template>
  2. <div class="goodsList">
  3. <van-sticky>
  4. <m-header :backUrl="backUrl2" :isFixed="false" name="商品列表" />
  5. <search @onSearch="onSearch" placeholder="请输入商品名称">
  6. <template #left>
  7. <van-dropdown-menu
  8. active-color="#01C1B5"
  9. style="padding-right: 0.1rem"
  10. >
  11. <!-- <van-dropdown-item :title="valueText1" v-model="value1" :options="option1" @change="onOptionChange" /> -->
  12. <van-dropdown-item
  13. :title="valueText2"
  14. v-model="value2"
  15. :options="option2"
  16. @change="onOptionChange"
  17. />
  18. </van-dropdown-menu>
  19. </template>
  20. </search>
  21. </van-sticky>
  22. <div>
  23. <van-list
  24. v-model="loading"
  25. class="studentContainer"
  26. v-if="dataShow"
  27. key="data"
  28. :immediate-check="false"
  29. :finished="finished"
  30. finished-text=""
  31. @load="getRepair"
  32. >
  33. <van-cell-group>
  34. <van-cell
  35. style="align-items: flex-start"
  36. v-for="(item, index) in dataList"
  37. :key="index"
  38. class="input-cell"
  39. @click="onChoiceGood(item)"
  40. :center="true"
  41. >
  42. <template slot="icon">
  43. <div class="logo-section">
  44. <img class="logo" v-if="item.image" :src="item.image" alt="" />
  45. <img
  46. class="logo"
  47. v-else
  48. src="@/assets/images/icon_student.png"
  49. alt=""
  50. />
  51. </div>
  52. </template>
  53. <template slot="title">
  54. <div
  55. style="
  56. display: flex;
  57. align-items: center;
  58. justify-content: space-between;
  59. "
  60. >
  61. {{ item.name }}
  62. </div>
  63. <van-tag plain color="#C2A076" style="margin: 0.04rem 0"
  64. >品牌:{{ item.brand }}</van-tag
  65. >
  66. <p style="padding: 0.02rem 0; font-size: 0.14rem; color: #808080">
  67. 型号:{{ item.specification }}
  68. </p>
  69. <div class="price-section">
  70. <div>
  71. <span class="money"
  72. ><span style="font-weight: 400; font-size: 0.14rem"
  73. >现价:</span
  74. ><i>¥</i>{{ item.discountPrice | moneyFormat }}</span
  75. ><del>原价:¥{{ item.marketPrice | moneyFormat }}</del>
  76. </div>
  77. <div style="font-size: 0.14rem; color: #808080">×1</div>
  78. </div>
  79. </template>
  80. </van-cell>
  81. </van-cell-group>
  82. </van-list>
  83. <m-empty class="empty" msg="暂无商品" v-else key="data" />
  84. </div>
  85. </div>
  86. </template>
  87. <script>
  88. import MHeader from "@/components/header";
  89. import MEmpty from "@/components/MEmpty";
  90. import Search from "@/components/Search";
  91. import { queryGoodsPage, queryGoodsCategoryPage } from "../api";
  92. export default {
  93. components: { MHeader, MEmpty, Search },
  94. data() {
  95. // const query = this.$route.query
  96. return {
  97. loading: false,
  98. finished: false,
  99. params: {
  100. status: 1,
  101. // educationalShow: 1,
  102. // studentShowOrganId: query.organId,
  103. page: 1,
  104. rows: 20,
  105. },
  106. dataShow: true, // 是否有数据
  107. backUrl2: {
  108. callBack: () => {
  109. this.$emit("input", false);
  110. },
  111. },
  112. value2: "all",
  113. valueText2: "商品: 全部",
  114. search: null,
  115. option2: [],
  116. dataList: [],
  117. };
  118. },
  119. async mounted() {
  120. await queryGoodsCategoryPage({ delFlag: 0, rows: 9999 }).then((res) => {
  121. let result = res.data;
  122. if (result.code == 200) {
  123. let tempArray = [{ text: "全部", value: "all" }];
  124. result.data.rows.forEach((row) => {
  125. tempArray.push({
  126. text: row.name,
  127. value: row.id,
  128. });
  129. });
  130. this.option2 = tempArray;
  131. }
  132. });
  133. this.loading = true;
  134. this.getRepair();
  135. },
  136. methods: {
  137. onSearch(value) {
  138. // 商品搜索
  139. this.search = value;
  140. this.params.page = 1;
  141. this.dataList = [];
  142. this.loading = true;
  143. this.finished = false;
  144. this.dataShow = true;
  145. this.getRepair();
  146. },
  147. onOptionChange() {
  148. this.option2.forEach((item) => {
  149. if (item.value == this.value2) {
  150. this.valueText2 = item.value == "all" ? "商品: 全部" : item.text;
  151. }
  152. });
  153. this.params.page = 1;
  154. this.dataList = [];
  155. this.dataShow = true;
  156. this.loading = true;
  157. this.finished = false;
  158. this.getRepair();
  159. },
  160. onChoiceGood(item) {
  161. this.$emit("getChoiceGood", {
  162. marketPrice: item.marketPrice,
  163. discountPrice: item.discountPrice,
  164. specification: item.specification,
  165. brand: item.brand,
  166. image: item.image,
  167. name: item.name,
  168. id: item.id,
  169. type: item.type,
  170. });
  171. this.$emit("input", false);
  172. },
  173. async getRepair() {
  174. let params = this.params;
  175. params.type = "ACCESSORIES"; // 只查询辅件
  176. params.goodsCategoryId = this.value2 == "all" ? null : this.value2;
  177. params.search = this.search ? this.search : null;
  178. // params.groupGoods = 0
  179. await queryGoodsPage(params).then((res) => {
  180. let result = res.data;
  181. this.loading = false;
  182. if (result.code == 200) {
  183. params.page = result.data.pageNo;
  184. this.dataList = this.dataList.concat(result.data.rows);
  185. if (params.page >= result.data.totalPage) {
  186. this.finished = true;
  187. }
  188. this.params.page++;
  189. } else {
  190. this.finished = true;
  191. }
  192. // 判断是否有数据
  193. if (this.dataList.length <= 0) {
  194. this.dataShow = false;
  195. }
  196. });
  197. },
  198. },
  199. };
  200. </script>
  201. <style lang="less" scoped>
  202. @import url("../../../assets/commonLess/variable.less");
  203. .studentContainer {
  204. /deep/.van-cell-group {
  205. margin-top: 0;
  206. }
  207. /deep/.van-cell__title {
  208. font-size: 0.16rem;
  209. color: @mFontColor;
  210. // flex: 1 auto;
  211. flex-basis: 70% !important;
  212. }
  213. .logo-section {
  214. flex-basis: 30%;
  215. }
  216. .logo {
  217. width: 0.82rem;
  218. height: 0.82rem;
  219. // margin-right: .12rem;
  220. border-radius: 0.05rem;
  221. overflow: hidden;
  222. }
  223. .input-cell {
  224. padding: 0.12rem 0.16rem;
  225. .van-radio {
  226. justify-content: flex-end;
  227. }
  228. }
  229. /deep/.van-cell__value {
  230. height: 0.2rem;
  231. }
  232. .van-tag {
  233. margin-left: 0.08rem;
  234. }
  235. }
  236. .input-cell {
  237. .price-section {
  238. display: flex;
  239. justify-content: space-between;
  240. align-items: center;
  241. del {
  242. font-size: 0.12rem;
  243. color: #666666;
  244. padding-left: 0.1rem;
  245. }
  246. }
  247. .money {
  248. color: #ff3535;
  249. font-weight: 600;
  250. font-size: 0.16rem;
  251. i {
  252. font-style: normal;
  253. font-size: 0.14rem;
  254. }
  255. }
  256. }
  257. /deep/.van-dropdown-menu__bar {
  258. background: transparent;
  259. box-shadow: inherit;
  260. height: 34px;
  261. }
  262. </style>