sort.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <view>
  3. <view class="zaiui-bar-search-title-box">
  4. <view class="cu-bar fixed no-shadow bg-white">
  5. <view class="action" @tap="BackPage">
  6. <text class="cuIcon-back"/>
  7. </view>
  8. <view class="content search" @tap="searchTap">
  9. <view class="search-form round">
  10. <text class="cuIcon-search"/>
  11. <text class="margin-left-xs">输入您正在找的宝贝</text>
  12. </view>
  13. </view>
  14. </view>
  15. <!--占位的-->
  16. <view class="zaiui-seat-height"/>
  17. </view>
  18. <view class="VerticalBox">
  19. <scroll-view class="VerticalNav nav" scroll-y scroll-with-animation :scroll-top="verticalNavTop">
  20. <block v-for="(item,index) in list" :key="index">
  21. <view class="cu-item" :class="index==tabCur?'text-red cur':''" @tap="TabSelect" :data-id="index">
  22. <view :class="index==tabCur?'text-black text-bold':''">分类-{{item.name}}</view>
  23. </view>
  24. </block>
  25. </scroll-view>
  26. <scroll-view class="VerticalMain" scroll-y scroll-with-animation :scroll-into-view="'main-'+mainCur" @scroll="VerticalMain">
  27. <block v-for="(item,index) in list" :key="index">
  28. <view class="padding-top padding-lr" :id="'main-'+index">
  29. <!--标题栏-->
  30. <view class="cu-bar bg-white">
  31. <view class="action">
  32. <text class="cuIcon-title text-red"/>
  33. <text>标题栏-{{item.name}}</text>
  34. </view>
  35. </view>
  36. <!--图标导航-->
  37. <view class="zaiui-grid-icon-box">
  38. <view class="cu-list grid col-3 no-border">
  39. <block v-for="(items,indexs) in sortList" :key="indexs">
  40. <view class="cu-item">
  41. <view class="grid-icon">
  42. <image class="icon" :src="items.img" lazy-load mode="widthFix"/>
  43. </view>
  44. <text class="text-black">{{items.name}}</text>
  45. </view>
  46. </block>
  47. </view>
  48. </view>
  49. </view>
  50. </block>
  51. </scroll-view>
  52. </view>
  53. </view>
  54. </template>
  55. <script>
  56. import _sort_data from '@/static/zaiui/data/sort_vue.js'; //虚拟数据
  57. import _tool from '@/static/zaiui/util/tools.js'; //工具函数
  58. export default {
  59. data() {
  60. return {
  61. list: [], tabCur: 0, mainCur: 0, verticalNavTop: 0, load: true, sortList: [],
  62. }
  63. },
  64. onLoad() {
  65. let list = [{}];
  66. for (let i = 0; i < 26; i++) {
  67. list[i] = {};
  68. list[i].name = String.fromCharCode(65 + i);
  69. list[i].id = i;
  70. }
  71. this.list = list;
  72. this.listCur = list[0];
  73. this.sortList = _sort_data.sortListData();
  74. },
  75. onReady() {
  76. _tool.setBarColor(true);
  77. uni.pageScrollTo({
  78. scrollTop: 0,
  79. duration: 0
  80. });
  81. },
  82. methods: {
  83. BackPage() {
  84. uni.navigateBack();
  85. },
  86. TabSelect(e) {
  87. this.tabCur = e.currentTarget.dataset.id;
  88. this.mainCur = e.currentTarget.dataset.id;
  89. this.verticalNavTop = (e.currentTarget.dataset.id - 1) * 50
  90. },
  91. VerticalMain(e) {
  92. // #ifdef MP-ALIPAY
  93. return false //支付宝小程序暂时不支持双向联动
  94. // #endif
  95. let that = this;
  96. let tabHeight = 0;
  97. if (this.load) {
  98. for (let i = 0; i < this.list.length; i++) {
  99. let view = uni.createSelectorQuery().select("#main-" + this.list[i].id);
  100. view.fields({
  101. size: true
  102. }, data => {
  103. this.list[i].top = tabHeight;
  104. tabHeight = tabHeight + data.height;
  105. this.list[i].bottom = tabHeight;
  106. }).exec();
  107. }
  108. this.load = false
  109. }
  110. let scrollTop = e.detail.scrollTop + 10;
  111. for (let i = 0; i < this.list.length; i++) {
  112. if (scrollTop > this.list[i].top && scrollTop < this.list[i].bottom) {
  113. this.verticalNavTop = (this.list[i].id - 1) * 50
  114. this.tabCur = this.list[i].id
  115. console.log(scrollTop)
  116. return false
  117. }
  118. }
  119. },
  120. searchTap() {
  121. uni.navigateTo({
  122. url: "/pages/home/search"
  123. });
  124. }
  125. }
  126. }
  127. </script>
  128. <style lang="scss">
  129. /* #ifdef APP-PLUS */
  130. @import "../../static/colorui/main.css";
  131. @import "../../static/colorui/icon.css";
  132. @import "../../static/zaiui/style/app.scss";
  133. /* #endif */
  134. @import "../../static/zaiui/style/sort_vue.scss";
  135. </style>