product.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  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 :focus="searchShow" :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. return new Promise((resolve, reject) => {
  98. if (this.sa_fadclassid == item.sa_fadclassid) return resolve();
  99. this.sa_fadclassid = item.sa_fadclassid;
  100. this.crumbs = [item, {
  101. classname: '全部',
  102. sa_fadclassid: item.sa_fadclassid
  103. }];
  104. if (item.children.length && item.children[0].classname != '全部') item.children.unshift({
  105. classname: "全部",
  106. sa_fadclassid: item.sa_fadclassid,
  107. children: []
  108. });
  109. this.tabs2 = item.children;
  110. this.tabs2Active = 0;
  111. if (this.tabs2.length) setTimeout(() => {
  112. this.$refs.tabs2.update()
  113. }, 100)
  114. this.tabs3 = [];
  115. this.tabs3Active = 0;
  116. this.getList(true).then(res => resolve())
  117. });
  118. },
  119. changeClass2(index) {
  120. let item = this.tabs2[index];
  121. if (this.sa_fadclassid == item.sa_fadclassid) return;
  122. this.sa_fadclassid = item.sa_fadclassid;
  123. this.crumbs = [this.crumbs[0], item];
  124. if (item.classname != '全部') this.crumbs.push({
  125. classname: '全部',
  126. sa_fadclassid: item.sa_fadclassid,
  127. children: []
  128. })
  129. if (item.children.length && item.children[0].classname != '全部') item.children.unshift({
  130. classname: "全部",
  131. sa_fadclassid: item.sa_fadclassid
  132. });
  133. this.tabs3 = item.children || [];
  134. this.tabs3Active = 0;
  135. if (this.tabs3.length) setTimeout(() => {
  136. this.$refs.tabs3.update()
  137. }, 100)
  138. this.getList(true);
  139. },
  140. changeClass3(index) {
  141. let item = this.tabs3[index];
  142. if (this.sa_fadclassid == item.sa_fadclassid) return;
  143. this.sa_fadclassid = item.sa_fadclassid;
  144. this.crumbs[2] = item;
  145. this.getList(true);
  146. },
  147. getList(init = false) {
  148. return new Promise((resolve, reject) => {
  149. if (this.paging(this.content, init)) return resolve();
  150. this.content.where.sa_fadclassids = [[this.crumbs[this.crumbs.length - 1].sa_fadclassid]];
  151. this.$Http.basic({
  152. "id": "20240418141302",
  153. content: this.content
  154. }).then(res => {
  155. this.$refs.List.setHeight()
  156. this.$refs.List.RefreshToComplete()
  157. console.log("获取产品列表", res)
  158. resolve();
  159. if (this.cutoff(res.msg)) return;
  160. res.data = res.data.map(v => {
  161. v.cover = v.attinfos.length ? this.getSpecifiedImage(v.attinfos.find(s => s.usetype == "sa_fad") || v.attinfos[0]) : uni.getStorageSync("site").logo || ''
  162. return v
  163. })
  164. this.list = res.pageNumber == 1 ? res.data : this.list.concat(res.data);
  165. this.content = this.$refs.List.paging(this.content, res)
  166. this.total = res.total;
  167. })
  168. })
  169. },
  170. onSearch(condition) {
  171. if (condition == this.content.where.condition) return;
  172. this.content.where.condition = condition;
  173. this.getList(true);
  174. },
  175. changeSearchShow(searchShow) {
  176. this.searchShow = !searchShow;
  177. clearTimeout(this.searchShowAntiShake)
  178. this.searchShowAntiShake = setTimeout(() => {
  179. this.$refs.List.setHeight();
  180. }, 350)
  181. }
  182. },
  183. }
  184. </script>
  185. <style lang="scss">
  186. .nav-search {
  187. display: flex;
  188. align-items: center;
  189. padding: 0 15px;
  190. height: 44px;
  191. border-radius: 8px;
  192. margin-right: 5px;
  193. }
  194. .My_search-box {
  195. background: #fff;
  196. width: 100vw;
  197. padding: 5px;
  198. padding-left: 10px;
  199. box-sizing: border-box;
  200. .cancel {
  201. line-height: 30px;
  202. margin-left: 10px;
  203. padding: 0 10px;
  204. font-family: Source Han Sans SC, Source Han Sans SC;
  205. font-size: 14px;
  206. color: #666666;
  207. border-radius: 4px;
  208. }
  209. }
  210. .tabs2-box,
  211. .tabs3-box {
  212. padding-left: 10px;
  213. box-sizing: border-box;
  214. }
  215. .tabs2-box {
  216. padding-top: 6px;
  217. background: linear-gradient(90deg, #202E42 0%, #3D405F 100%);
  218. height: 40px;
  219. width: 100vw;
  220. }
  221. .tabs3-box {
  222. background: #fff;
  223. padding-top: 8px;
  224. height: 30px;
  225. width: 100vw;
  226. }
  227. .list-box {
  228. display: flex;
  229. flex-wrap: wrap;
  230. justify-content: space-between;
  231. .item {
  232. width: 173px;
  233. height: 207px;
  234. margin-top: 10px;
  235. border-radius: 5px;
  236. overflow: hidden;
  237. flex-shrink: 0;
  238. .image {
  239. width: 173px;
  240. height: 172px;
  241. background: #F5F5F5;
  242. border-radius: 5px;
  243. }
  244. .title {
  245. width: 100%;
  246. height: 25px;
  247. line-height: 20px;
  248. font-family: PingFang SC, PingFang SC;
  249. font-size: 14px;
  250. color: #333333;
  251. margin-top: 10px;
  252. text-align: center;
  253. }
  254. }
  255. }
  256. .list {
  257. width: 100vw;
  258. padding: 10px;
  259. box-sizing: border-box;
  260. background: #fff;
  261. .head {
  262. display: flex;
  263. align-items: center;
  264. justify-content: space-between;
  265. height: 17px;
  266. line-height: 17px;
  267. .crumbs {
  268. flex: 1;
  269. width: 0;
  270. .crumb {
  271. flex-shrink: 0;
  272. font-size: 12px;
  273. font-family: PingFang SC, PingFang SC;
  274. }
  275. .crumb::after {
  276. content: ">";
  277. padding: 0 2px;
  278. }
  279. .crumb:last-child {
  280. font-weight: bold;
  281. }
  282. .crumb:last-child::after {
  283. content: "";
  284. }
  285. }
  286. .total {
  287. flex-shrink: 0;
  288. font-family: Source Han Sans SC, Source Han Sans SC;
  289. font-size: 12px;
  290. color: #999999;
  291. margin-left: 20px;
  292. }
  293. }
  294. }
  295. </style>