product.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <template>
  2. <view>
  3. <u-tabs :list="types" :activeStyle="{ fontWeight: 'bold', color: '#C30D23' }" lineColor="#C30D23"
  4. keyName="classname" @change="changeClass1">
  5. <view slot="right" class="nav-search" hover-class="navigator-hover" @click="changeSearchShow(searchShow)">
  6. <view class="iconfont icon-sousuo" :style="{ color: searchShow ? '#C30D23' : '#999999' }" />
  7. </view>
  8. </u-tabs>
  9. <u-transition :show="searchShow">
  10. <view class="My_search-box">
  11. <My_search :value="content.where.condition" @onSearch="onSearch">
  12. <view class="cancel" v-if="content.where.condition" hover-class="navigator-hover" @click="onSearch('')">
  13. 取消
  14. </view>
  15. <view v-else style="width: 5px;" />
  16. </My_search>
  17. </view>
  18. </u-transition>
  19. <view class="tabs2-box" v-if="tabs2.length">
  20. <v-tabs v-model="tabs2Active" field="classname" :pills="true" height="28px" pillsBorderRadius="14px"
  21. pillsColor="#FFFFFF" bgColor="none" color="#FFFFFF" activeColor="#C30D23" lineScale="20px" :tabs="tabs2"
  22. @change="changeClass2" />
  23. </view>
  24. <view class="tabs3-box" v-if="tabs3.length">
  25. <v-tabs v-model="tabs3Active" field="classname" :pills="true" height="24px" pillsBorderRadius="12px"
  26. pillsColor="#C30D23" pillsUnColor="#eee" bgColor="none" itemMargin="0 4px 0 0" color="#333333"
  27. activeColor="#FFFFFF" lineScale="10px" :tabs="tabs3" @change="changeClass3" />
  28. </view>
  29. <view class="list">
  30. <view class="head">
  31. <view class="crumbs u-line-1">
  32. <text class="crumb" v-for="item in crumbs" :key="item.classname">{{ item.classname }}</text>
  33. </view>
  34. <view class="total">共{{ total }}件</view>
  35. </view>
  36. <My_listbox ref="List" @getlist="getList" :bottomHeight="70">
  37. <view class="list-box">
  38. <view class="item" v-for="item in list" :key="item.sa_fadid" hover-class="navigator-hover">
  39. <image class="image" :src="item.cover" mode="aspectFill" lazy-load="true" />
  40. <view class="title u-line-1">
  41. {{ item.name }}
  42. </view>
  43. </view>
  44. </view>
  45. </My_listbox>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. export default {
  51. name: "product",
  52. data() {
  53. return {
  54. types: [],
  55. tabs2: [],
  56. tabs2Active: 0,
  57. tabs3: [],
  58. tabs3Active: 0,
  59. crumbs: [],
  60. list: [],
  61. "content": {
  62. "where": {
  63. "condition": "",
  64. "isonsale": 1,
  65. "begindate_create": "",
  66. "enddate_create": "",
  67. "begindate_onsale": "",
  68. "enddate_onsale": "",
  69. }
  70. },
  71. total: 0,
  72. searchShow: false,
  73. searchShowAntiShake: null,
  74. sa_fadclassid: "",
  75. }
  76. },
  77. methods: {
  78. init(callBack) {
  79. this.$Http.basic({
  80. "id": "20240418112002",
  81. "content": {
  82. "parentid": 0,
  83. "where": { "isenable": 1 }
  84. }
  85. }).then(res => {
  86. console.log("获取单品分类", res)
  87. this.types = res.data;
  88. if (res.data.length) this.changeClass1(res.data[0]).then(res => {
  89. callBack()
  90. })
  91. })
  92. },
  93. changeClass1(item) {
  94. if (this.sa_fadclassid == item.sa_fadclassid) return;
  95. this.sa_fadclassid = item.sa_fadclassid;
  96. this.crumbs = [item, {
  97. classname: '全部',
  98. sa_fadclassid: item.sa_fadclassid
  99. }];
  100. if (item.children.length && item.children[0].classname != '全部') item.children.unshift({
  101. classname: "全部",
  102. sa_fadclassid: item.sa_fadclassid,
  103. children: []
  104. });
  105. this.tabs2 = item.children;
  106. this.tabs2Active = 0;
  107. this.tabs3 = [];
  108. this.tabs3Active = 0;
  109. return this.getList(true);
  110. },
  111. changeClass2(index) {
  112. let item = this.tabs2[index];
  113. if (this.sa_fadclassid == item.sa_fadclassid) return;
  114. this.sa_fadclassid = item.sa_fadclassid;
  115. this.crumbs = [this.crumbs[0], item];
  116. if (item.classname != '全部') this.crumbs.push({
  117. classname: '全部',
  118. sa_fadclassid: item.sa_fadclassid,
  119. children: []
  120. })
  121. if (item.children.length && item.children[0].classname != '全部') item.children.unshift({
  122. classname: "全部",
  123. sa_fadclassid: item.sa_fadclassid
  124. });
  125. this.tabs3 = item.children || [];
  126. this.tabs3Active = 0;
  127. this.getList(true);
  128. },
  129. changeClass3(index) {
  130. let item = this.tabs3[index];
  131. if (this.sa_fadclassid == item.sa_fadclassid) return;
  132. this.sa_fadclassid = item.sa_fadclassid;
  133. this.crumbs[2] = item;
  134. this.getList(true);
  135. },
  136. getList(init = false) {
  137. return new Promise((resolve, reject) => {
  138. if (this.paging(this.content, init)) return resolve();
  139. this.content.where.sa_fadclassids = [[this.crumbs[this.crumbs.length - 1].sa_fadclassid]];
  140. console.log(this.crumbs[this.crumbs.length - 1].sa_fadclassid)
  141. this.$Http.basic({
  142. "id": "20240418141302",
  143. content: this.content
  144. }).then(res => {
  145. this.$refs.List.setHeight()
  146. this.$refs.List.RefreshToComplete()
  147. console.log("获取产品列表", res)
  148. resolve();
  149. if (this.cutoff(res.msg)) return;
  150. res.data = res.data.map(v => {
  151. v.cover = v.attinfos.length ? this.getSpecifiedImage(v.attinfos.find(s => s.usetype == "sa_fad") || v.attinfos[0]) : ''
  152. return v
  153. })
  154. this.list = res.pageNumber == 1 ? res.data : this.list.concat(res.data);
  155. this.content = this.$refs.List.paging(this.content, res)
  156. this.total = res.total;
  157. })
  158. })
  159. },
  160. onSearch(condition) {
  161. if (condition == this.content.where.condition) return;
  162. this.content.where.condition = condition;
  163. this.getList(true);
  164. },
  165. changeSearchShow(searchShow) {
  166. this.searchShow = !searchShow;
  167. clearTimeout(this.searchShowAntiShake)
  168. this.searchShowAntiShake = setTimeout(() => {
  169. this.$refs.List.setHeight();
  170. }, 350)
  171. }
  172. },
  173. }
  174. </script>
  175. <style lang="scss">
  176. .nav-search {
  177. display: flex;
  178. align-items: center;
  179. padding: 0 15px;
  180. height: 44px;
  181. border-radius: 8px;
  182. margin-right: 5px;
  183. }
  184. .My_search-box {
  185. background: #fff;
  186. width: 100vw;
  187. padding: 5px;
  188. padding-left: 10px;
  189. box-sizing: border-box;
  190. .cancel {
  191. line-height: 30px;
  192. margin-left: 10px;
  193. padding: 0 10px;
  194. font-family: Source Han Sans SC, Source Han Sans SC;
  195. font-size: 14px;
  196. color: #666666;
  197. border-radius: 4px;
  198. }
  199. }
  200. .tabs2-box,
  201. .tabs3-box {
  202. padding-left: 10px;
  203. box-sizing: border-box;
  204. }
  205. .tabs2-box {
  206. display: flex;
  207. align-items: center;
  208. background: linear-gradient(90deg, #202E42 0%, #3D405F 100%);
  209. height: 40px;
  210. width: 100vw;
  211. }
  212. .tabs3-box {
  213. background: #fff;
  214. padding-top: 8px;
  215. height: 30px;
  216. width: 100vw;
  217. }
  218. .list-box {
  219. display: flex;
  220. flex-wrap: wrap;
  221. justify-content: space-between;
  222. .item {
  223. width: 173px;
  224. height: 207px;
  225. margin-top: 10px;
  226. border-radius: 5px;
  227. overflow: hidden;
  228. flex-shrink: 0;
  229. .image {
  230. width: 173px;
  231. height: 172px;
  232. background: #F5F5F5;
  233. border-radius: 5px;
  234. }
  235. .title {
  236. width: 100%;
  237. height: 25px;
  238. line-height: 20px;
  239. font-family: PingFang SC, PingFang SC;
  240. font-size: 14px;
  241. color: #333333;
  242. margin-top: 10px;
  243. text-align: center;
  244. }
  245. }
  246. }
  247. .list {
  248. width: 100vw;
  249. padding: 10px;
  250. box-sizing: border-box;
  251. background: #fff;
  252. .head {
  253. display: flex;
  254. align-items: center;
  255. justify-content: space-between;
  256. height: 17px;
  257. line-height: 17px;
  258. .crumbs {
  259. flex: 1;
  260. width: 0;
  261. .crumb {
  262. flex-shrink: 0;
  263. font-size: 12px;
  264. font-family: PingFang SC, PingFang SC;
  265. }
  266. .crumb::after {
  267. content: ">";
  268. padding: 0 2px;
  269. }
  270. .crumb:last-child {
  271. font-weight: bold;
  272. }
  273. .crumb:last-child::after {
  274. content: "";
  275. }
  276. }
  277. .total {
  278. flex-shrink: 0;
  279. font-family: Source Han Sans SC, Source Han Sans SC;
  280. font-size: 12px;
  281. color: #999999;
  282. margin-left: 20px;
  283. }
  284. }
  285. }
  286. </style>