多租户商城-商户小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

239 lines
5.2 KiB

2 years ago
  1. <template>
  2. <view>
  3. <global-loading />
  4. <view class="header">
  5. <image class="logo" src="https://ceres.zkthink.com//assets/img/logo.png" mode="widthFix"></image>
  6. </view>
  7. <view class="content">
  8. <!-- 分类中心 -->
  9. <scroll-view scroll-y class="left-aside">
  10. <view v-for="(item,index) in flist" :key="item.classifyId" class="f-item b-b" :class="{active: index === currentIndex}" @click="tabtap(item,index)">
  11. {{item.classifyName}}
  12. </view>
  13. </scroll-view>
  14. <scroll-view scroll-with-animation scroll-y class="right-aside">
  15. <view v-for="item in slist" :key="item.classifyId" class="s-list">
  16. <view class="classBox flex-items-plus" v-if="item.childs.length>0">
  17. <image class="emptyOrder-img" src="https://ceres.zkthink.com/static/images/classRight.png"></image>
  18. <text class="s-item" >{{item.classifyName}}</text>
  19. <image class="emptyOrder-img" src="https://ceres.zkthink.com/static/images/classLeft.png"></image>
  20. </view>
  21. <view class="t-list">
  22. <view @click="navToList(item.classifyId, titem.classifyId)" class="t-item" v-for="titem in item.childs" :key="titem.classifyId">
  23. <image :src="titem.classifyImage" class="pic-img default-img"></image>
  24. <text>{{titem.classifyName}}</text>
  25. </view>
  26. </view>
  27. </view>
  28. </scroll-view>
  29. <view v-if="ifEmpty" class="emptyOrder-box flex-items-plus flex-column">
  30. <image class="emptyOrder-img" src="https://ceres.zkthink.com/static/img/bgnull.png"></image>
  31. <label class="font-color-999 fs26 mar-top-30">该分类没有商品</label>
  32. </view>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. const NET = require('../../../utils/request')
  38. const API = require('../../../config/api')
  39. export default {
  40. data() {
  41. return {
  42. sizeCalcState: false,
  43. tabScrollTop: 0,
  44. currentIndex: 0,
  45. currentId:'',
  46. flist: [],
  47. slist: [],
  48. ifEmpty: false
  49. }
  50. },
  51. onLoad() {
  52. this.loadData();
  53. },
  54. methods: {
  55. loadData(){
  56. // uni.showLoading({
  57. // mask: true,
  58. // title:'加载中...'
  59. // })
  60. NET.request(API.FindCategoryListByDepth, {
  61. classifyId: "",
  62. }, 'GET').then(res => {
  63. this.flist = res.data
  64. this.currentId = this.flist[0].classifyId
  65. uni.hideLoading()
  66. this.getChildCategory()
  67. }).catch(res => {
  68. uni.hideLoading()
  69. })
  70. },
  71. getChildCategory(){
  72. // uni.showLoading({
  73. // mask: true,
  74. // title:'加载中...'
  75. // })
  76. NET.request(API.FindCategoryListByDepth,{
  77. classifyId:this.currentId
  78. },'GET').then(res => {
  79. uni.hideLoading()
  80. this.slist = res.data
  81. if (this.slist.length === 0) {
  82. this.ifEmpty = true
  83. }
  84. }).catch(res => {
  85. uni.hideLoading()
  86. })
  87. },
  88. //一级分类点击
  89. tabtap(item,index){
  90. this.ifEmpty = false
  91. if(this.currentIndex == index){
  92. return;
  93. }
  94. this.currentId = item.classifyId;
  95. this.currentIndex = index
  96. this.getChildCategory()
  97. },
  98. //右侧栏滚动
  99. asideScroll(e){
  100. if(!this.sizeCalcState){
  101. this.calcSize();
  102. }
  103. let scrollTop = e.detail.scrollTop;
  104. let tabs = this.slist.filter(item=>item.top <= scrollTop).reverse();
  105. if(tabs.length > 0){
  106. this.currentId = tabs[0].pid;
  107. }
  108. },
  109. //计算右侧栏每个tab的高度等信息
  110. calcSize(){
  111. let h = 0;
  112. this.slist.forEach(item=>{
  113. let view = uni.createSelectorQuery().select("#main-" + item.id);
  114. view.fields({
  115. size: true
  116. }, data => {
  117. item.top = h;
  118. h += data.height;
  119. item.bottom = h;
  120. }).exec();
  121. })
  122. this.sizeCalcState = true;
  123. },
  124. navToList(sid, tid){
  125. uni.navigateTo({
  126. url: `../../../pages_category_page1/goodsModule/goodsList?category3Id=${tid}`
  127. })
  128. }
  129. }
  130. }
  131. </script>
  132. <style lang='scss'>
  133. page,
  134. .content {
  135. height: 100%;
  136. /* background-color: #f8f8f8; */
  137. }
  138. .header{
  139. border-bottom: 1px solid #F3F4F5FF;
  140. }
  141. .logo {
  142. width: 280rpx;
  143. height: 42rpx;
  144. }
  145. .content {
  146. display: flex;
  147. }
  148. .left-aside {
  149. flex-shrink: 0;
  150. width: 200upx;
  151. height: 100vh;
  152. background-color: #F8F8F8;
  153. }
  154. .f-item {
  155. display: flex;
  156. align-items: center;
  157. justify-content: center;
  158. width: 100%;
  159. height: 100upx;
  160. font-size: 28upx;
  161. color: $font-color-base;
  162. position: relative;
  163. &.active{
  164. color: $base-color;
  165. background: #FFFFFF;
  166. }
  167. }
  168. .right-aside{
  169. flex: 1;
  170. padding: 20upx 0 20upx 0;
  171. background: #fff;
  172. height: 100vh;
  173. }
  174. .s-item{
  175. display: flex;
  176. align-items: center;
  177. justify-content: center;
  178. height: 70upx;
  179. padding-top: 8upx;
  180. font-size: 28upx;
  181. color: $font-color-dark;
  182. }
  183. .t-list{
  184. display: flex;
  185. flex-wrap: wrap;
  186. width: 100%;
  187. background: #fff;
  188. padding-top: 12upx;
  189. &:after{
  190. content: '';
  191. flex: 99;
  192. height: 0;
  193. }
  194. image{
  195. width: 140rpx;
  196. height: 140rpx;
  197. }
  198. }
  199. .t-item{
  200. flex-shrink: 0;
  201. display: flex;
  202. justify-content: center;
  203. align-items: center;
  204. flex-direction: column;
  205. width: 176upx;
  206. font-size: 26upx;
  207. color: #666;
  208. padding-bottom: 20upx;
  209. image{
  210. width: 140upx;
  211. height: 140upx;
  212. }
  213. }
  214. .emptyOrder-box{
  215. margin-left: 180upx;
  216. .emptyOrder-img{
  217. margin-top: -130upx;
  218. width: 113upx;
  219. height: 98upx;
  220. }
  221. }
  222. .classBox {
  223. image {
  224. width: 66rpx;
  225. height: 4rpx;
  226. margin-top: 10rpx;
  227. }
  228. .s-item {
  229. margin: 0 10rpx;
  230. }
  231. }
  232. </style>