product.vue 9.9 KB

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