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.

296 lines
8.0 KiB

3 months ago
  1. <template>
  2. <view :data-theme="theme">
  3. <view class='productSort'>
  4. <skeleton :show="showSkeleton" :isNodes="isNodes" ref="skeleton" loading="chiaroscuro" selector="skeleton"
  5. bgcolor="#FFF"></skeleton>
  6. <view class="skeleton" :style="{visibility: showSkeleton ? 'hidden' : 'visible'}">
  7. <view class='header acea-row row-center-wrapper'>
  8. <view class='acea-row row-between-wrapper input'>
  9. <text class='iconfont icon-sousuo'></text>
  10. <input type='text' placeholder='点击搜索商品信息' @confirm="searchSubmitValue" confirm-type='search' name="search"
  11. placeholder-class='placeholder' maxlength="20"></input>
  12. </view>
  13. </view>
  14. <view class='aside' :style="{bottom: tabbarH + 'px',height: height + 'rpx'}">
  15. <scroll-view scroll-y="true" scroll-with-animation='true' style="height: 100%;">
  16. <view class='item acea-row row-center-wrapper' :class='index==navActive?"on":""' v-for="(item,index) in productList"
  17. :key="index" @click='tap(index,"b"+index)'><text class="skeleton-rect">{{item.name}}</text></view>
  18. </scroll-view>
  19. </view>
  20. <view class='conter'>
  21. <scroll-view scroll-y="true" :scroll-into-view="toView" :style='"height:"+height+"rpx;margin-top: 96rpx;"' @scroll="scroll"
  22. scroll-with-animation='true'>
  23. <block v-for="(item,index) in productList" :key="index">
  24. <view class='listw' :id="'b'+index">
  25. <view class='title acea-row row-center-wrapper'>
  26. <view class='line'></view>
  27. <view class='name'>{{item.name}}</view>
  28. <view class='line'></view>
  29. </view>
  30. <view class='list acea-row'>
  31. <block v-for="(itemn,indexn) in item.child" :key="indexn">
  32. <navigator hover-class='none' :url='"/pages/goods/goods_list/index?cid="+itemn.id+"&title="+itemn.name' class='item acea-row row-column row-middle'>
  33. <view class='picture skeleton-rect' :style="{'background-color':itemn.extra?'none':'#f7f7f7'}">
  34. <image :src='itemn.extra'></image>
  35. </view>
  36. <view class='name line1'>{{itemn.name}}</view>
  37. </navigator>
  38. </block>
  39. </view>
  40. </view>
  41. </block>
  42. <view :style='"height:"+(height-300)+"rpx;"' v-if="number<15"></view>
  43. </scroll-view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. import {getCategoryList} from '@/api/store.js';
  51. import ClipboardJS from "@/plugin/clipboard/clipboard.js";
  52. import animationType from '@/utils/animationType.js'
  53. export default {
  54. data() {
  55. return {
  56. showSkeleton: true, //骨架屏显示隐藏
  57. isNodes: 0, //控制什么时候开始抓取元素节点,只要数值改变就重新抓取
  58. navlist: [],
  59. productList: [{name:'占位占位',child:[{extra:''},{extra:''}]},{name:'占位占位',child:[{extra:''},{extra:''}]},{name:'占位占位',child:[{extra:''},{extra:''}]},{name:'占位占位'}],
  60. navActive: 0,
  61. number: "",
  62. height: 0,
  63. hightArr: [],
  64. toView: "",
  65. tabbarH: 0,
  66. theme:'theme1'
  67. }
  68. },
  69. created() {
  70. let _self = this;
  71. uni.getStorage({
  72. key: 'theme',
  73. success: function (res) {
  74. _self.theme = res.data;
  75. }
  76. });
  77. setTimeout(() => {
  78. this.isNodes++;
  79. }, 500);
  80. this.getAllCategory();
  81. },
  82. onShow() {
  83. this.getAllCategory();
  84. },
  85. methods: {
  86. infoScroll: function() {
  87. let that = this;
  88. let len = that.productList.length;
  89. let child = that.productList[len - 1]&&that.productList[len - 1].child?that.productList[len - 1].child:[];
  90. this.number = child?child.length:0;
  91. //设置商品列表高度
  92. uni.getSystemInfo({
  93. success: function(res) {
  94. that.height = (res.windowHeight) * (750 / res.windowWidth) - 98;
  95. },
  96. });
  97. let height = 0;
  98. let hightArr = [];
  99. for (let i = 0; i < len; i++) {
  100. //获取元素所在位置
  101. let query = uni.createSelectorQuery().in(this);
  102. let idView = "#b" + i;
  103. query.select(idView).boundingClientRect();
  104. query.exec(function(res) {
  105. let top = res[0].top;
  106. hightArr.push(top);
  107. that.hightArr = hightArr
  108. });
  109. };
  110. },
  111. tap: function(index, id) {
  112. this.toView = id;
  113. this.navActive = index;
  114. },
  115. getAllCategory: function() {
  116. let that = this;
  117. getCategoryList().then(res => {
  118. that.productList = res.data;
  119. let pid= uni.getStorageSync('categoryId');
  120. if(pid){
  121. let indexNow = that.productList.findIndex(item=>item.id==pid)
  122. this.tap(indexNow,'b'+indexNow)
  123. }
  124. setTimeout(function(){
  125. that.infoScroll();
  126. },500)
  127. setTimeout(() => {
  128. this.showSkeleton = false
  129. }, 1000)
  130. })
  131. },
  132. scroll: function(e) {
  133. let scrollTop = e.detail.scrollTop + 10;
  134. let scrollArr = this.hightArr;
  135. for (let i = 0; i < scrollArr.length; i++) {
  136. if (scrollTop >= 0 && scrollTop < scrollArr[1] - scrollArr[0]) {
  137. this.navActive = 0
  138. } else if (scrollTop >= scrollArr[i] - scrollArr[0] && scrollTop < scrollArr[i + 1] - scrollArr[0]) {
  139. this.navActive = i
  140. } else if (scrollTop >= scrollArr[scrollArr.length - 1] - scrollArr[0]) {
  141. this.navActive = scrollArr.length - 1
  142. }
  143. }
  144. },
  145. searchSubmitValue: function(e) {
  146. if (this.$util.trim(e.detail.value).length > 0)
  147. uni.navigateTo({
  148. animationType: animationType.type, animationDuration: animationType.duration,
  149. url: '/pages/goods/goods_list/index?searchValue=' + e.detail.value
  150. })
  151. else
  152. return this.$util.Tips({
  153. title: '请填写要搜索的产品信息'
  154. });
  155. },
  156. }
  157. }
  158. </script>
  159. <style scoped lang="scss">
  160. .productSort .header {
  161. width: 100%;
  162. height: 96rpx;
  163. background-color: #fff;
  164. position: fixed;
  165. left: 0;
  166. right: 0;
  167. top: 0;
  168. z-index: 9;
  169. border-bottom: 1rpx solid #f5f5f5;
  170. }
  171. .productSort .header .input {
  172. width: 700rpx;
  173. height: 60rpx;
  174. background-color: #f5f5f5;
  175. border-radius: 50rpx;
  176. box-sizing: border-box;
  177. padding: 0 25rpx;
  178. }
  179. .productSort .header .input .iconfont {
  180. font-size: 26rpx;
  181. color: #555;
  182. }
  183. .productSort .header .input .placeholder {
  184. color: #999;
  185. }
  186. .productSort .header .input input {
  187. font-size: 26rpx;
  188. height: 100%;
  189. width: 597rpx;
  190. }
  191. .productSort .aside {
  192. position: fixed;
  193. width: 180rpx;
  194. left: 0;
  195. top:0;
  196. background-color: #f7f7f7;
  197. overflow-y: scroll;
  198. overflow-x: hidden;
  199. height: auto;
  200. margin-top: 96rpx;
  201. }
  202. .productSort .aside .item {
  203. height: 100rpx;
  204. width: 100%;
  205. font-size: 26rpx;
  206. color: #424242;
  207. position: relative;
  208. }
  209. .productSort .aside .item.on {
  210. background-color: #fff;
  211. width: 100%;
  212. text-align: center;
  213. @include main_color(theme);
  214. font-weight: bold;
  215. }
  216. .productSort .aside .item.on ::before{
  217. content: '';
  218. width: 4rpx;
  219. height: 100rpx;
  220. position: absolute;
  221. left: 0;
  222. top: 0;
  223. @include main_bg_color(theme);
  224. }
  225. .productSort .conter {
  226. margin: 96rpx 0 0 180rpx;
  227. padding: 0 14rpx;
  228. background-color: #fff;
  229. }
  230. .productSort .conter .listw {
  231. padding-top: 20rpx;
  232. }
  233. .productSort .conter .listw .title {
  234. height: 90rpx;
  235. }
  236. .productSort .conter .listw .title .line {
  237. width: 100rpx;
  238. height: 2rpx;
  239. background-color: #f0f0f0;
  240. }
  241. .productSort .conter .listw .title .name {
  242. font-size: 28rpx;
  243. color: #333;
  244. margin: 0 30rpx;
  245. font-weight: bold;
  246. }
  247. .productSort .conter .list {
  248. flex-wrap: wrap;
  249. }
  250. .productSort .conter .list .item {
  251. width: 177rpx;
  252. margin-top: 26rpx;
  253. }
  254. .productSort .conter .list .item .picture {
  255. width: 120rpx;
  256. height: 120rpx;
  257. border-radius: 50%;
  258. }
  259. .productSort .conter .list .item .picture image {
  260. width: 100%;
  261. height: 100%;
  262. border-radius: 50%;
  263. div{
  264. background-color: #f7f7f7;
  265. }
  266. }
  267. .productSort .conter .list .item .name {
  268. font-size: 24rpx;
  269. color: #333;
  270. height: 56rpx;
  271. line-height: 56rpx;
  272. width: 120rpx;
  273. text-align: center;
  274. }
  275. </style>