goods_cate1.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. <template>
  2. <view class='productSort copy-data' :style="{height:pageHeight}">
  3. <!-- #ifdef APP-PLUS || MP -->
  4. <!-- <view class="sys-head" :style="{height:sysHeight}"></view> -->
  5. <!-- #endif -->
  6. <view class='header acea-row row-center-wrapper'>
  7. <view class='acea-row row-between-wrapper input'>
  8. <text class='iconfont icon-sousuo'></text>
  9. <input type='text' :placeholder="$t('搜索商品名称')" @confirm="searchSubmitValue" confirm-type='search'
  10. name="search" placeholder-class='placeholder'></input>
  11. </view>
  12. </view>
  13. <view class="scroll-box">
  14. <view class='aside'>
  15. <scroll-view scroll-y="true" scroll-with-animation='true' style="height: calc(100% - 100rpx)">
  16. <view class='item acea-row row-center-wrapper' :class='index==navActive?"on":""'
  17. v-for="(item,index) in productList" :key="index" @click='tap(index,"b"+index)'>
  18. <text>{{$t(item.cate_name)}}</text>
  19. </view>
  20. <!-- #ifdef APP-PLUS -->
  21. <view class="item" v-if="newData.status && newData.status.status"></view>
  22. <!-- #endif -->
  23. </scroll-view>
  24. </view>
  25. <view class='conter'>
  26. <scroll-view scroll-y="true" :scroll-into-view="toView" @scroll="scroll" scroll-with-animation='true'
  27. style="height: 100%;" class="conterScroll">
  28. <block v-for="(item,index) in productList" :key="index">
  29. <view class='listw' :id="'b'+index">
  30. <view class='title acea-row row-center-wrapper'>
  31. <view class='line'></view>
  32. <view class='name'>{{$t(item.cate_name)}}</view>
  33. <view class='line'></view>
  34. </view>
  35. <view class='list acea-row'>
  36. <block v-for="(itemn,indexn) in item.children" :key="indexn">
  37. <navigator hover-class='none'
  38. :url='"/pages/goods/goods_list/index?sid="+itemn.id+"&title="+itemn.cate_name'
  39. class='item acea-row row-column row-middle'>
  40. <view class='picture'>
  41. <image :src='itemn.pic' v-if="itemn.pic"></image>
  42. <image src="/static/images/sort-img.png" v-else></image>
  43. </view>
  44. <view class='name line1'>{{$t(itemn.cate_name)}}</view>
  45. </navigator>
  46. </block>
  47. </view>
  48. </view>
  49. </block>
  50. <view :style='"height:"+(height-300)+"rpx;"' v-if="number<15"></view>
  51. </scroll-view>
  52. </view>
  53. </view>
  54. <tabBar v-if="!is_diy" :pagePath="'/pages/goods_cate/goods_cate'"></tabBar>
  55. <view class="foot" v-else-if="is_diy && newData.status && newData.status.status">
  56. <view class="page-footer" id="target" :style="{'background-color':newData.bgColor.color[0].item}">
  57. <view class="foot-item" v-for="(item,index) in newData.menuList" :key="index" @click="goRouter(item)">
  58. <block v-if="item.link == activeRouter">
  59. <image :src="item.imgList[0]"></image>
  60. <view class="txt" :style="{color:newData.activeTxtColor.color[0].item}">{{$t(item.name)}}</view>
  61. </block>
  62. <block v-else>
  63. <image :src="item.imgList[1]"></image>
  64. <view class="txt" :style="{color:newData.txtColor.color[0].item}">{{$t(item.name)}}</view>
  65. </block>
  66. <div class="count-num" v-if="item.link === '/pages/order_addcart/order_addcart' && cartNum > 0">
  67. {{cartNum}}
  68. </div>
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. </template>
  74. <script>
  75. let sysHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
  76. import {
  77. getCategoryList
  78. } from '@/api/store.js';
  79. import {
  80. mapState,
  81. mapGetters
  82. } from "vuex"
  83. import pageFooter from '@/components/pageFooter/index.vue'
  84. import {
  85. getNavigation
  86. } from '@/api/public.js'
  87. import tabBar from "@/pages/index/visualization/components/tabBar.vue";
  88. const app = getApp();
  89. export default {
  90. components: {
  91. pageFooter,
  92. tabBar
  93. },
  94. data() {
  95. return {
  96. navlist: [],
  97. productList: [],
  98. navActive: 0,
  99. number: "",
  100. is_diy: uni.getStorageSync('is_diy'),
  101. height: 0,
  102. hightArr: [],
  103. toView: "",
  104. tabbarH: 0,
  105. footH: 0,
  106. windowHeight: 0,
  107. newData: {},
  108. activeRouter: '',
  109. pageHeight: '100%',
  110. sysHeight: sysHeight,
  111. // #ifdef APP-PLUS
  112. pageHeight: app.globalData.windowHeight,
  113. // #endif
  114. footerStatus: false,
  115. lock: false
  116. }
  117. },
  118. computed: {
  119. ...mapState({
  120. cartNum: state => state.indexData.cartNum
  121. })
  122. },
  123. mounted() {
  124. let that = this
  125. // #ifdef H5
  126. uni.getSystemInfo({
  127. success: function(res) {
  128. that.pageHeight = res.windowHeight + 'px'
  129. }
  130. });
  131. // #endif
  132. let routes = getCurrentPages();
  133. let curRoute = routes[routes.length - 1].route
  134. this.activeRouter = '/' + curRoute
  135. this.getAllCategory();
  136. // if (uni.getStorageSync('FOOTER_BAR')) {
  137. // this.footerStatus = true
  138. // uni.hideTabBar()
  139. // getNavigation().then(res => {
  140. // this.newData = res.data
  141. // })
  142. // }
  143. },
  144. methods: {
  145. getNav() {
  146. getNavigation().then(res => {
  147. this.newData = res.data
  148. })
  149. },
  150. goRouter(item) {
  151. var pages = getCurrentPages();
  152. var page = (pages[pages.length - 1]).$page.fullPath;
  153. if (item.link == page) return
  154. uni.switchTab({
  155. url: item.link,
  156. fail(err) {
  157. uni.redirectTo({
  158. url: item.link
  159. })
  160. }
  161. })
  162. },
  163. footHeight(data) {
  164. this.footH = data
  165. },
  166. infoScroll: function() {
  167. let that = this;
  168. let len = that.productList.length;
  169. this.number = that.productList[len - 1].children.length;
  170. //设置商品列表高度
  171. uni.getSystemInfo({
  172. success: function(res) {
  173. that.height = (res.windowHeight) * (750 / res.windowWidth) - 98;
  174. },
  175. });
  176. let height = 0;
  177. let hightArr = [];
  178. for (let i = 0; i < len; i++) {
  179. //获取元素所在位置
  180. let query = uni.createSelectorQuery().in(this);
  181. let idView = "#b" + i;
  182. query.select(idView).boundingClientRect();
  183. query.exec(function(res) {
  184. let top = res[0].top;
  185. hightArr.push(top);
  186. that.hightArr = hightArr
  187. });
  188. };
  189. },
  190. tap: function(index, id) {
  191. this.toView = id;
  192. this.navActive = index;
  193. this.$set(this, 'lock', true);
  194. },
  195. getAllCategory: function() {
  196. let that = this;
  197. getCategoryList().then(res => {
  198. that.productList = res.data;
  199. that.$nextTick(res => {
  200. that.infoScroll();
  201. })
  202. })
  203. },
  204. scroll: function(e) {
  205. let scrollTop = e.detail.scrollTop;
  206. let scrollArr = this.hightArr;
  207. if (this.lock) {
  208. this.$set(this, 'lock', false);
  209. return;
  210. }
  211. for (let i = 0; i < scrollArr.length; i++) {
  212. if (scrollTop >= 0 && scrollTop < scrollArr[1] - scrollArr[0]) {
  213. this.navActive = 0
  214. } else if (scrollTop >= scrollArr[i] - scrollArr[0] && scrollTop < scrollArr[i + 1] - scrollArr[
  215. 0]) {
  216. this.navActive = i
  217. } else if (scrollTop >= scrollArr[scrollArr.length - 1] - scrollArr[0]) {
  218. this.navActive = scrollArr.length - 1
  219. }
  220. }
  221. },
  222. searchSubmitValue: function(e) {
  223. if (this.$util.trim(e.detail.value).length > 0)
  224. uni.navigateTo({
  225. url: '/pages/goods/goods_list/index?searchValue=' + e.detail.value
  226. })
  227. else
  228. return this.$util.Tips({
  229. title: this.$t(`搜索商品名称`)
  230. });
  231. },
  232. }
  233. }
  234. </script>
  235. <style>
  236. page {
  237. height: 100%;
  238. }
  239. </style>
  240. <style scoped lang="scss">
  241. /deep/uni-scroll-view {
  242. padding-bottom: 0 !important;
  243. }
  244. .sys-title {
  245. z-index: 10;
  246. position: relative;
  247. height: 40px;
  248. line-height: 40px;
  249. font-size: 30rpx;
  250. color: #333;
  251. background-color: #fff;
  252. // #ifdef APP-PLUS
  253. text-align: center;
  254. // #endif
  255. // #ifdef MP
  256. text-align: left;
  257. padding-left: 30rpx;
  258. // #endif
  259. }
  260. .sys-head {
  261. background-color: #fff;
  262. }
  263. .productSort {
  264. display: flex;
  265. flex-direction: column;
  266. //#ifdef MP
  267. height: calc(100vh - var(--window-top)) !important;
  268. //#endif
  269. //#ifndef MP
  270. height: 100vh //#endif
  271. }
  272. .productSort .header {
  273. width: 100%;
  274. height: 96rpx;
  275. background-color: #fff;
  276. border-bottom: 1rpx solid #f5f5f5;
  277. }
  278. .productSort .header .input {
  279. width: 700rpx;
  280. height: 60rpx;
  281. background-color: #f5f5f5;
  282. border-radius: 50rpx;
  283. box-sizing: border-box;
  284. padding: 0 25rpx;
  285. }
  286. .productSort .header .input .iconfont {
  287. font-size: 35rpx;
  288. color: #555;
  289. }
  290. .productSort .header .input .placeholder {
  291. color: #999;
  292. }
  293. .productSort .header .input input {
  294. font-size: 26rpx;
  295. height: 100%;
  296. width: 597rpx;
  297. }
  298. .productSort .scroll-box {
  299. flex: 1;
  300. overflow: hidden;
  301. display: flex;
  302. }
  303. // #ifndef MP
  304. uni-scroll-view {
  305. padding-bottom: 100rpx;
  306. }
  307. // #endif
  308. .productSort .aside {
  309. width: 180rpx;
  310. height: 100%;
  311. overflow: hidden;
  312. background-color: #f7f7f7;
  313. }
  314. .productSort .aside .item {
  315. height: 100rpx;
  316. width: 100%;
  317. font-size: 26rpx;
  318. color: #424242;
  319. text-align: center;
  320. }
  321. .productSort .aside .item.on {
  322. background-color: #fff;
  323. border-left: 4rpx solid var(--view-theme);
  324. width: 100%;
  325. color: var(--view-theme);
  326. font-weight: bold;
  327. }
  328. .productSort .conter {
  329. flex: 1;
  330. height: 100%;
  331. overflow: hidden;
  332. padding: 0 14rpx;
  333. background-color: #fff;
  334. position: relative;
  335. }
  336. .productSort .conter .listw {
  337. padding-top: 20rpx;
  338. }
  339. .productSort .conter .listw .title {
  340. height: 90rpx;
  341. }
  342. .productSort .conter .listw .title .line {
  343. width: 100rpx;
  344. height: 2rpx;
  345. background-color: #f0f0f0;
  346. }
  347. .productSort .conter .listw .title .name {
  348. font-size: 28rpx;
  349. color: #333;
  350. margin: 0 30rpx;
  351. font-weight: bold;
  352. }
  353. .productSort .conter .list {
  354. flex-wrap: wrap;
  355. }
  356. .productSort .conter .list .item {
  357. width: 177rpx;
  358. margin-top: 26rpx;
  359. }
  360. .productSort .conter .list .item .picture {
  361. width: 120rpx;
  362. height: 120rpx;
  363. border-radius: 50%;
  364. }
  365. .productSort .conter .list .item .picture image {
  366. width: 100%;
  367. height: 100%;
  368. border-radius: 50%;
  369. }
  370. .productSort .conter .list .item .name {
  371. font-size: 24rpx;
  372. color: #333;
  373. height: 56rpx;
  374. line-height: 56rpx;
  375. width: 120rpx;
  376. text-align: center;
  377. }
  378. .page-footer {
  379. position: fixed;
  380. bottom: 0;
  381. z-index: 30;
  382. display: flex;
  383. align-items: center;
  384. justify-content: space-around;
  385. width: 100%;
  386. height: calc(98rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
  387. height: calc(98rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
  388. box-sizing: border-box;
  389. border-top: solid 1rpx #F3F3F3;
  390. background-color: #fff;
  391. box-shadow: 0px 0px 17rpx 1rpx rgba(206, 206, 206, 0.32);
  392. padding-bottom: constant(safe-area-inset-bottom); ///兼容 IOS<11.2/
  393. padding-bottom: env(safe-area-inset-bottom); ///兼容 IOS>11.2/
  394. .foot-item {
  395. display: flex;
  396. width: max-content;
  397. align-items: center;
  398. justify-content: center;
  399. flex-direction: column;
  400. position: relative;
  401. .count-num {
  402. position: absolute;
  403. display: flex;
  404. justify-content: center;
  405. align-items: center;
  406. width: 40rpx;
  407. height: 40rpx;
  408. top: 0rpx;
  409. right: -15rpx;
  410. color: #fff;
  411. font-size: 20rpx;
  412. background-color: #FD502F;
  413. border-radius: 50%;
  414. padding: 4rpx;
  415. }
  416. }
  417. .foot-item image {
  418. height: 50rpx;
  419. width: 50rpx;
  420. text-align: center;
  421. margin: 0 auto;
  422. }
  423. .foot-item .txt {
  424. font-size: 24rpx;
  425. &.active {}
  426. }
  427. }
  428. </style>