多租户商城-商户小程序端
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.

338 lines
7.9 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
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="flex-hor">
  8. <image class="cate-expand" src="https://wechat.hnthee.com/ceres-local-file/image/icon_cate_expand.png" @click="openMenu"/>
  9. <view class="search-content" @click="handleSearch">
  10. <image class="input-search" src="https://wechat.hnthee.com/ceres-local-file/image/icon_input_search.png"/>
  11. <input class="input-content" type="text" placeholder="搜索商品" disabled/>
  12. </view>
  13. </view>
  14. <view class="content" @touchstart="touchStart" @touchend="touchEnd">
  15. <!-- 分类中心 -->
  16. <!-- <scroll-view scroll-y class="left-aside">
  17. <view v-for="(item,index) in flist" :key="item.classifyId" class="f-item b-b" :class="{active: index === currentIndex}" @click="tabtap(item,index)">
  18. {{item.classifyName}}
  19. </view>
  20. </scroll-view>-->
  21. <scroll-view scroll-with-animation scroll-y class="right-aside" v-if="!ifEmpty">
  22. <view v-if="onlyTwoLayer">
  23. <view class="t-list" v-if="slist.length>0">
  24. <view @click="navToList(titem.classifyPid, titem.classifyId)" class="t-item" v-for="titem in slist" :key="titem.classifyId">
  25. <image :src="titem.classifyImage" class="pic-img"></image>
  26. <text class="cate-name-txt">{{titem.classifyName}}</text>
  27. </view>
  28. </view>
  29. </view>
  30. <view v-if="!onlyTwoLayer">
  31. <view v-for="item in slist" :key="item.classifyId" class="s-list">
  32. <view class="classBox flex-items-plus">
  33. <image src="https://wechat.hnthee.com/ceres-local-file/image/icon_class_left.png"></image>
  34. <text class="s-item" >{{item.classifyName}}</text>
  35. <image src="https://wechat.hnthee.com/ceres-local-file/image/icon_class_right.png"></image>
  36. </view>
  37. <view class="t-list" style="margin-top: 20rpx">
  38. <view @click="navToList(item.classifyId, titem.classifyId)" class="t-item" v-for="titem in item.childs" :key="titem.classifyId">
  39. <image :src="titem.classifyImage" class="pic-img"></image>
  40. <text class="cate-name-txt">{{titem.classifyName}}</text>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </scroll-view>
  46. <view v-if="ifEmpty" class="emptyOrder-box flex-items-plus flex-column">
  47. <image class="emptyOrder-img" src="https://ceres.zkthink.com/static/img/bgnull.png"></image>
  48. <label class="font-color-999 fs26 mar-top-30">{{$t('common.classifyproductempty')}}</label>
  49. </view>
  50. </view>
  51. <slide-cate v-model="showMenu" @checked="tabtap" :checked="currentIndex" :cate-list="flist"></slide-cate>
  52. </view>
  53. </template>
  54. <script>
  55. import SlideCate from "./slide-cate";
  56. const NET = require('../../../utils/request')
  57. const API = require('../../../config/api')
  58. export default {
  59. components: {SlideCate},
  60. data() {
  61. return {
  62. sizeCalcState: false,
  63. tabScrollTop: 0,
  64. currentIndex: 0,
  65. currentId:'',
  66. flist: [],
  67. slist: [],
  68. ifEmpty: false,
  69. onlyTwoLayer : true,
  70. showMenu: false,
  71. startTime: null, // 手势滑动时间
  72. startPosition: 0, // 手势进入时
  73. endPosition: 0 // 手势离开时
  74. }
  75. },
  76. onLoad() {
  77. this.loadData();
  78. },
  79. methods: {
  80. loadData(){
  81. // uni.showLoading({
  82. // mask: true,
  83. // title:'加载中...'
  84. // })
  85. NET.request(API.FindCategoryListByDepth, {
  86. classifyId: "",
  87. }, 'GET').then(res => {
  88. this.flist = res.data
  89. this.currentId = this.flist[0].classifyId
  90. uni.hideLoading()
  91. this.getChildCategory()
  92. }).catch(res => {
  93. uni.hideLoading()
  94. })
  95. },
  96. getChildCategory(){
  97. // uni.showLoading({
  98. // mask: true,
  99. // title:'加载中...'
  100. // })
  101. NET.request(API.FindCategoryListByDepth,{
  102. classifyId:this.currentId
  103. },'GET').then(res => {
  104. uni.hideLoading()
  105. if (res.data.length === 0) {
  106. this.ifEmpty = true
  107. }
  108. this.slist = res.data
  109. this.onlyTwoLayer = !this.slist.some(function(item){
  110. return item.childs.length>0
  111. });
  112. }).catch(res => {
  113. uni.hideLoading()
  114. })
  115. },
  116. //一级分类点击
  117. tabtap(item,index){
  118. this.ifEmpty = false
  119. if(this.currentIndex == index){
  120. return;
  121. }
  122. this.currentId = item.classifyId;
  123. this.currentIndex = index
  124. this.getChildCategory()
  125. },
  126. //右侧栏滚动
  127. asideScroll(e){
  128. if(!this.sizeCalcState){
  129. this.calcSize();
  130. }
  131. let scrollTop = e.detail.scrollTop;
  132. let tabs = this.slist.filter(item=>item.top <= scrollTop).reverse();
  133. if(tabs.length > 0){
  134. this.currentId = tabs[0].pid;
  135. }
  136. },
  137. //计算右侧栏每个tab的高度等信息
  138. calcSize(){
  139. let h = 0;
  140. this.slist.forEach(item=>{
  141. let view = uni.createSelectorQuery().select("#main-" + item.id);
  142. view.fields({
  143. size: true
  144. }, data => {
  145. item.top = h;
  146. h += data.height;
  147. item.bottom = h;
  148. }).exec();
  149. })
  150. this.sizeCalcState = true;
  151. },
  152. navToList(sid, tid){
  153. uni.navigateTo({
  154. url: `../../../pages_category_page1/goodsModule/goodsList?category3Id=${tid}`
  155. })
  156. },
  157. // 查询产品
  158. handleSearch() {
  159. uni.navigateTo({
  160. url: `/pages_category_page1/search/index/index`
  161. })
  162. },
  163. openMenu() {
  164. this.showMenu = true;
  165. //this.$refs.slideCate.open()
  166. },
  167. closeMenu() {
  168. this.showMenu = false;
  169. //this.$refs.slideCate.open()
  170. },
  171. // 手势进入时
  172. touchStart(e) {
  173. this.startTime = Date.now()
  174. this.startPosition = e.changedTouches[0].clientX
  175. },
  176. // 手势离开时
  177. touchEnd(e){
  178. const endTime = Date.now()
  179. if (endTime - this.startTime > 2000){
  180. return;
  181. }
  182. this.endPosition = e.changedTouches[0].clientX;
  183. var slideDistance = this.endPosition - this.startPosition;
  184. if( slideDistance > 50){
  185. this.openMenu()
  186. }
  187. if(slideDistance < -50){
  188. this.closeMenu()
  189. }
  190. }
  191. }
  192. }
  193. </script>
  194. <style lang='scss'>
  195. page,
  196. .content {
  197. height: 100%;
  198. /* background-color: #f8f8f8; */
  199. }
  200. .header{
  201. border-bottom: 1px solid #F3F4F5FF;
  202. }
  203. .logo {
  204. width: 280rpx;
  205. height: 42rpx;
  206. }
  207. .content {
  208. display: flex;
  209. }
  210. .right-aside{
  211. width: 100%;
  212. padding: 20upx 0 20upx 0;
  213. background-color: #FAFAFA;
  214. height: 100vh;
  215. }
  216. .s-item{
  217. display: flex;
  218. align-items: center;
  219. justify-content: center;
  220. height: 70upx;
  221. padding-top: 8upx;
  222. font-size: 28upx;
  223. color: #252744;
  224. font-weight: bold;
  225. }
  226. .t-list{
  227. display: flex;
  228. flex-wrap: wrap;
  229. width: 100%;
  230. background-color: #FAFAFA;
  231. padding-top: 12upx;
  232. &:after{
  233. content: '';
  234. flex: 99;
  235. height: 0;
  236. }
  237. image{
  238. width: 140rpx;
  239. height: 140rpx;
  240. }
  241. }
  242. .t-item{
  243. flex-shrink: 0;
  244. display: flex;
  245. justify-content: center;
  246. align-items: center;
  247. flex-direction: column;
  248. //width: 176upx;
  249. width: 248upx;
  250. font-size: 26upx;
  251. color: #666;
  252. padding-bottom: 20upx;
  253. image{
  254. width: 140upx;
  255. height: 140upx;
  256. }
  257. }
  258. .emptyOrder-box{
  259. margin-left: 280upx;
  260. .emptyOrder-img{
  261. margin-top: 310upx;
  262. width: 113upx;
  263. height: 98upx;
  264. }
  265. }
  266. .classBox {
  267. image {
  268. width: 66rpx;
  269. height: 20rpx;
  270. margin-top: 10rpx;
  271. }
  272. .s-item {
  273. margin: 0 10rpx;
  274. }
  275. }
  276. .flex-hor{
  277. width: 100%;
  278. display: flex;
  279. align-items: center;
  280. background-color: #FAFAFA;
  281. flex-direction: row;
  282. padding: 20rpx 30rpx;
  283. }
  284. .cate-expand{
  285. width: 32rpx;
  286. height: 30rpx;
  287. margin-right: 20rpx;
  288. }
  289. .search-content{
  290. display: flex;
  291. align-items: center;
  292. height: 55rpx;
  293. flex-grow: 1;
  294. padding-left: 17rpx;
  295. flex-direction: row;
  296. background-color: white;
  297. border-radius: 50rpx;
  298. }
  299. .input-search{
  300. width: 28rpx;
  301. height: 28rpx;
  302. }
  303. .input-content{
  304. font-size: 20rpx;
  305. flex-grow: 1;
  306. margin-left: 15rpx;
  307. }
  308. .cate-name-txt{
  309. margin-top: 12rpx;
  310. color: #252744;
  311. font-size: 14rpx;
  312. }
  313. </style>