index.vue 8.3 KB

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