index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <template>
  2. <view id="category" :style="{paddingTop:CustomBar+'px'}">
  3. <!--顶部搜索导航栏-->
  4. <view class="'search-input-fixed" :style="{top:CustomBar/2+'px'}">
  5. <cat-search :systeminfo='systeminfo' :navbar-data='nvabarData' :headerBtnPosi ="headerBtnPosi" @click="hanldTabClick"></cat-search>
  6. </view>
  7. <view class="category-list">
  8. <!-- 左侧分类导航 -->
  9. <scroll-view class="left-aside" scroll-y="true" scroll-with-animation :scroll-top="verticalNavTop" :style="{top:(CustomBar+38)+'px',height:(windowHeight-CustomBar+38)+'px'}">
  10. <view class="row" v-for="(m, index) in categoryList" :key="index" :class="[index==showCategoryIndex?'on':'']" @tap="showCategory($event,index)" :data-id="index">
  11. <view class="text">{{m.name}}</view>
  12. <view class="block"></view>
  13. </view>
  14. </scroll-view>
  15. <!--右侧子导航-->
  16. <scroll-view scroll-y="true" class="right-aside" :style="{top:(CustomBar+38)+'px',height:(windowHeight-CustomBar+38)+'px'}">
  17. <view class="category" v-if="first.smalltypeList.length > 0" v-for="(first,index) in categoryList" :key="index" v-show="index==showCategoryIndex" >
  18. <view class="category-box" v-for="(small,oIndex) in n.smalltypeList" :key="oIndex">
  19. <view class="title">{{small.name}}</view>
  20. <view class="list" v-if="small.tinytypeList.length > 0">
  21. <view class="box" v-for="(pro,proIndex) in small.tinytypeList" :key="proIndex" @click.stop="navToListPage(pro,3)">
  22. <image :src="pro.icon"></image>
  23. <view class="text">{{pro.name}}</view>
  24. </view>
  25. </view>
  26. <view v-else class="no-data">
  27. <view class="box" @click.stop="navToListPage(first,1)">
  28. <image src="https://static-b.caimei365.com/app/img/icon/icon-noneproduct.jpg"></image>
  29. <view class="text">全部商品</view>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. <view v-else class="no-data">
  35. <view class="box" @click.stop="navToListPage(small,2)">
  36. <image src="https://static-b.caimei365.com/app/img/icon/icon-noneproduct.jpg"></image>
  37. <view class="text">全部商品</view>
  38. </view>
  39. </view>
  40. </scroll-view>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. import catSearch from '@/components/uni-search/cat-search.vue'
  46. export default {
  47. components: {
  48. catSearch
  49. },
  50. data() {
  51. return {
  52. nvabarData: { //顶部自定义导航
  53. showCapsule: 1, // 是否显示左上角图标 1表示显示 0表示不显示
  54. title: '' // 导航栏 中间的标题
  55. },
  56. CustomBar:this.CustomBar,// 顶部导航栏高度
  57. headerBtnPosi: this.setHeaderBtnPosi(), //获取设备顶部胶囊高度
  58. systeminfo: this.setSysteminfo(), //获取设备信息
  59. headerShow:true,
  60. showCategoryIndex: 0,
  61. categoryList: [],//分类列表
  62. search: '',
  63. cateTop: {},
  64. verticalNavTop: 0,
  65. categoryTabIndex:1,
  66. windowHeight:0,
  67. scrollHeight:0,
  68. }
  69. },
  70. onLoad() {
  71. this.initData();
  72. },
  73. methods: {
  74. // 数据初始化
  75. initData() {
  76. this.GetProductCate(this.categoryTabIndex);
  77. const {windowHeight, pixelRatio} = wx.getSystemInfoSync();
  78. this.windowHeight = windowHeight - 1;
  79. this.scrollHeight = windowHeight - 1;
  80. },
  81. hanldTabClick(data){
  82. this.categoryList = []
  83. this.GetProductCate(data);
  84. },
  85. // 获取商品分类列表
  86. GetProductCate (index) {
  87. this.CommonService.GetFirstClassly({typeSort:index,source :'crm'}).then(response =>{
  88. this.categoryList = response.data
  89. // 查询第一个拥有二级菜单的子菜单
  90. for (let i = 0; i < this.categoryList.length; i++) {
  91. if (this.categoryList[i].smalltypeList.length > 0) {
  92. this.showCategoryIndex = i;
  93. break;
  94. }
  95. }
  96. }).catch(error =>{
  97. this.$util.msg(error.msg,2000)
  98. })
  99. },
  100. showCategory(e,index){//分类切换显示
  101. this.showCategoryIndex = index;
  102. this.verticalNavTop = (e.currentTarget.dataset.id - 1) * 50
  103. },
  104. toSearch () {// 跳转至搜索详情页
  105. uni.navigateTo({
  106. url: `/pages/search/search?search=${JSON.stringify(this.search)}`
  107. })
  108. },
  109. navToListPage(item,index){//分类导航跳转
  110. switch(index){
  111. case 1:
  112. this.$api.navigateTo(`/pages/goods/goods-classify?title=${item.name}&id=${item.bigTypeID}`)
  113. break;
  114. case 2:
  115. this.$api.navigateTo(`/pages/goods/goods-classify?title=${item.name}&id=${item.smallTypeID}`)
  116. break;
  117. case 3:
  118. this.$api.navigateTo(`/pages/goods/goods-classify?title=${item.name}&id=${item.tinyTypeID}`)
  119. break;
  120. }
  121. },
  122. setHeaderBtnPosi(){
  123. // 获得胶囊按钮位置信息
  124. let headerBtnPosi = uni.getMenuButtonBoundingClientRect();
  125. return headerBtnPosi
  126. },
  127. setSysteminfo(){
  128. let systeminfo;
  129. uni.getSystemInfo({ // 获取设备信息
  130. success: (res) => {
  131. systeminfo = res
  132. },
  133. })
  134. return systeminfo
  135. },
  136. }
  137. }
  138. </script>
  139. <style scoped lang="scss">
  140. page {
  141. background-color: #fff;
  142. }
  143. .search-input-fixed{
  144. width: 100%;
  145. height:auto;
  146. position: fixed;
  147. top: 0;
  148. left: 0;
  149. z-index: 1000;
  150. background: #FFFFFF;
  151. border-bottom: 1px solid #F7F7F7;
  152. }
  153. #category {
  154. /*模块分类*/
  155. .category-list{
  156. width: 100%;
  157. background-color: #fff;
  158. display: flex;
  159. .left-aside,.right-aside{
  160. position: absolute;
  161. top: 100rpx;
  162. /* #ifdef APP-PLUS */
  163. top: calc(100rpx + var(--status-bar-height));
  164. /* #endif */
  165. bottom: 0rpx;
  166. }
  167. .left-aside{
  168. width: 200rpx;
  169. left: 0rpx;
  170. background-color: #f2f2f2;
  171. .row{
  172. width: 100%;
  173. height: 100rpx;
  174. display: flex;
  175. align-items: center;
  176. position: relative;
  177. .text{
  178. width: 100%;
  179. position: relative;
  180. font-size: $font-size-28;
  181. display: flex;
  182. justify-content: center;
  183. color: $text-color;
  184. /* transition: transform 0.3s ease;*/
  185. transition-property: transform;
  186. transition-duration: 0.2s;
  187. transition-timing-function: ease;
  188. }
  189. .block{
  190. position: absolute;
  191. width: 0rpx;
  192. left: 0;
  193. /* transition: transform 0.3s ease;*/
  194. transition-property: transform;
  195. transition-duration: 0.2s;
  196. transition-timing-function: ease;
  197. }
  198. &.on{
  199. height: 100rpx;
  200. background-color: #fff;
  201. .text{
  202. font-size: $font-size-28;
  203. color: $color-system;
  204. }
  205. .block{
  206. width: 10rpx;
  207. height: 60rpx;
  208. top: 20rpx;
  209. background-color: $color-system;
  210. border-radius: 0 15rpx 15rpx 0;
  211. }
  212. }
  213. }
  214. }
  215. .right-aside{
  216. width: 550rpx;
  217. left: 200rpx;
  218. .category{
  219. width: calc(100%);
  220. padding: 0 15rpx 20rpx 0;
  221. background: #F7F7F7;
  222. .category-box{
  223. background: #FFFFFF;
  224. margin-bottom: 20rpx;
  225. .title{
  226. padding: 0 24rpx;
  227. line-height: 80rpx;
  228. height: 80rpx;
  229. text-align: left;
  230. color: $text-color;
  231. font-size: $font-size-26;
  232. border-bottom: 1px solid #F7F7F7;
  233. font-weight: 600;
  234. }
  235. .list{
  236. margin-top: 24rpx;
  237. width: 100%;
  238. display: flex;
  239. flex-wrap: wrap;
  240. .box{
  241. width: calc(71.44vw / 3);
  242. margin-bottom: 40rpx;
  243. display: flex;
  244. justify-content: center;
  245. align-items: center;
  246. flex-wrap: wrap;
  247. image{
  248. width: 140rpx;
  249. height: 140rpx;
  250. }
  251. .text{
  252. margin-top: 8rpx;
  253. width: 100%;
  254. display: flex;
  255. justify-content: center;
  256. font-size: $font-size-24;
  257. }
  258. }
  259. }
  260. .no-data {
  261. text-align: center;
  262. margin: 30rpx 0;
  263. color: #666666;
  264. font-size: 24rpx;
  265. line-height: 80rpx;
  266. .box{
  267. width: calc(71.44vw / 3);
  268. margin-bottom: 40rpx;
  269. display: flex;
  270. justify-content: center;
  271. align-items: center;
  272. flex-wrap: wrap;
  273. image{
  274. width: 140rpx;
  275. height: 140rpx;
  276. }
  277. .text{
  278. margin-top: 8rpx;
  279. width: 100%;
  280. display: flex;
  281. justify-content: center;
  282. font-size: $font-size-24;
  283. }
  284. }
  285. }
  286. }
  287. }
  288. }
  289. }
  290. }
  291. </style>