goods_cate1.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  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. let routes = getCurrentPages();
  126. let curRoute = routes[routes.length - 1].route
  127. this.activeRouter = '/' + curRoute
  128. this.getAllCategory();
  129. // if (uni.getStorageSync('FOOTER_BAR')) {
  130. // this.footerStatus = true
  131. // uni.hideTabBar()
  132. // getNavigation().then(res => {
  133. // this.newData = res.data
  134. // })
  135. // }
  136. // #ifdef H5
  137. uni.getSystemInfo({
  138. success: function(res) {
  139. that.pageHeight = res.windowHeight + 'px'
  140. }
  141. });
  142. // #endif
  143. },
  144. methods: {
  145. getNav() {
  146. getNavigation().then(res => {
  147. this.newData = res.data
  148. if (this.newData.status && this.newData.status.status) {
  149. uni.hideTabBar()
  150. } else {
  151. uni.showTabBar()
  152. }
  153. })
  154. },
  155. goRouter(item) {
  156. var pages = getCurrentPages();
  157. var page = (pages[pages.length - 1]).$page.fullPath;
  158. if (item.link == page) return
  159. uni.switchTab({
  160. url: item.link,
  161. fail(err) {
  162. uni.redirectTo({
  163. url: item.link
  164. })
  165. }
  166. })
  167. },
  168. footHeight(data) {
  169. this.footH = data
  170. },
  171. infoScroll: function() {
  172. let that = this;
  173. let len = that.productList.length;
  174. this.number = that.productList[len - 1].children.length;
  175. //设置商品列表高度
  176. uni.getSystemInfo({
  177. success: function(res) {
  178. that.height = (res.windowHeight) * (750 / res.windowWidth) - 98;
  179. },
  180. });
  181. let height = 0;
  182. let hightArr = [];
  183. for (let i = 0; i < len; i++) {
  184. //获取元素所在位置
  185. let query = uni.createSelectorQuery().in(this);
  186. let idView = "#b" + i;
  187. query.select(idView).boundingClientRect();
  188. query.exec(function(res) {
  189. let top = res[0].top;
  190. hightArr.push(top);
  191. that.hightArr = hightArr
  192. });
  193. };
  194. },
  195. tap: function(index, id) {
  196. this.toView = id;
  197. this.navActive = index;
  198. this.$set(this, 'lock', true);
  199. },
  200. getAllCategory: function() {
  201. let that = this;
  202. getCategoryList().then(res => {
  203. that.productList = res.data;
  204. that.$nextTick(res => {
  205. that.infoScroll();
  206. })
  207. })
  208. },
  209. scroll: function(e) {
  210. let scrollTop = e.detail.scrollTop;
  211. let scrollArr = this.hightArr;
  212. if (this.lock) {
  213. this.$set(this, 'lock', false);
  214. return;
  215. }
  216. for (let i = 0; i < scrollArr.length; i++) {
  217. if (scrollTop >= 0 && scrollTop < scrollArr[1] - scrollArr[0]) {
  218. this.navActive = 0
  219. } else if (scrollTop >= scrollArr[i] - scrollArr[0] && scrollTop < scrollArr[i + 1] - scrollArr[
  220. 0]) {
  221. this.navActive = i
  222. } else if (scrollTop >= scrollArr[scrollArr.length - 1] - scrollArr[0]) {
  223. this.navActive = scrollArr.length - 1
  224. }
  225. }
  226. },
  227. searchSubmitValue: function(e) {
  228. if (this.$util.trim(e.detail.value).length > 0)
  229. uni.navigateTo({
  230. url: '/pages/goods/goods_list/index?searchValue=' + e.detail.value
  231. })
  232. else
  233. return this.$util.Tips({
  234. title: this.$t(`搜索商品名称`)
  235. });
  236. },
  237. }
  238. }
  239. </script>
  240. <style>
  241. page {
  242. height: 100%;
  243. }
  244. </style>
  245. <style scoped lang="scss">
  246. /deep/uni-scroll-view {
  247. padding-bottom: 0 !important;
  248. }
  249. .sys-title {
  250. z-index: 10;
  251. position: relative;
  252. height: 40px;
  253. line-height: 40px;
  254. font-size: 30rpx;
  255. color: #333;
  256. background-color: #fff;
  257. // #ifdef APP-PLUS
  258. text-align: center;
  259. // #endif
  260. // #ifdef MP
  261. text-align: left;
  262. padding-left: 30rpx;
  263. // #endif
  264. }
  265. .sys-head {
  266. background-color: #fff;
  267. }
  268. .productSort {
  269. display: flex;
  270. flex-direction: column;
  271. //#ifdef MP
  272. height: calc(100vh - var(--window-top)) !important;
  273. //#endif
  274. //#ifndef MP
  275. height: 100vh //#endif
  276. }
  277. .productSort .header {
  278. width: 100%;
  279. height: 96rpx;
  280. background-color: #fff;
  281. border-bottom: 1rpx solid #f5f5f5;
  282. }
  283. .productSort .header .input {
  284. width: 700rpx;
  285. height: 60rpx;
  286. background-color: #f5f5f5;
  287. border-radius: 50rpx;
  288. box-sizing: border-box;
  289. padding: 0 25rpx;
  290. }
  291. .productSort .header .input .iconfont {
  292. font-size: 35rpx;
  293. color: #555;
  294. }
  295. .productSort .header .input .placeholder {
  296. color: #999;
  297. }
  298. .productSort .header .input input {
  299. font-size: 26rpx;
  300. height: 100%;
  301. width: 597rpx;
  302. }
  303. .productSort .scroll-box {
  304. flex: 1;
  305. overflow: hidden;
  306. display: flex;
  307. }
  308. // #ifndef MP
  309. uni-scroll-view {
  310. padding-bottom: 100rpx;
  311. }
  312. // #endif
  313. .productSort .aside {
  314. width: 180rpx;
  315. height: 100%;
  316. overflow: hidden;
  317. background-color: #f7f7f7;
  318. }
  319. .productSort .aside .item {
  320. height: 100rpx;
  321. width: 100%;
  322. font-size: 26rpx;
  323. color: #424242;
  324. text-align: center;
  325. }
  326. .productSort .aside .item.on {
  327. background-color: #fff;
  328. border-left: 4rpx solid var(--view-theme);
  329. width: 100%;
  330. color: var(--view-theme);
  331. font-weight: bold;
  332. }
  333. .productSort .conter {
  334. flex: 1;
  335. height: 100%;
  336. overflow: hidden;
  337. padding: 0 14rpx;
  338. background-color: #fff;
  339. position: relative;
  340. }
  341. .productSort .conter .listw {
  342. padding-top: 20rpx;
  343. }
  344. .productSort .conter .listw .title {
  345. height: 90rpx;
  346. }
  347. .productSort .conter .listw .title .line {
  348. width: 100rpx;
  349. height: 2rpx;
  350. background-color: #f0f0f0;
  351. }
  352. .productSort .conter .listw .title .name {
  353. font-size: 28rpx;
  354. color: #333;
  355. margin: 0 30rpx;
  356. font-weight: bold;
  357. }
  358. .productSort .conter .list {
  359. flex-wrap: wrap;
  360. }
  361. .productSort .conter .list .item {
  362. width: 177rpx;
  363. margin-top: 26rpx;
  364. }
  365. .productSort .conter .list .item .picture {
  366. width: 120rpx;
  367. height: 120rpx;
  368. border-radius: 50%;
  369. }
  370. .productSort .conter .list .item .picture image {
  371. width: 100%;
  372. height: 100%;
  373. border-radius: 50%;
  374. }
  375. .productSort .conter .list .item .name {
  376. font-size: 24rpx;
  377. color: #333;
  378. height: 56rpx;
  379. line-height: 56rpx;
  380. width: 120rpx;
  381. text-align: center;
  382. }
  383. .page-footer {
  384. position: fixed;
  385. bottom: 0;
  386. z-index: 30;
  387. display: flex;
  388. align-items: center;
  389. justify-content: space-around;
  390. width: 100%;
  391. height: calc(98rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
  392. height: calc(98rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
  393. box-sizing: border-box;
  394. border-top: solid 1rpx #F3F3F3;
  395. background-color: #fff;
  396. box-shadow: 0px 0px 17rpx 1rpx rgba(206, 206, 206, 0.32);
  397. padding-bottom: constant(safe-area-inset-bottom); ///兼容 IOS<11.2/
  398. padding-bottom: env(safe-area-inset-bottom); ///兼容 IOS>11.2/
  399. .foot-item {
  400. display: flex;
  401. width: max-content;
  402. align-items: center;
  403. justify-content: center;
  404. flex-direction: column;
  405. position: relative;
  406. .count-num {
  407. position: absolute;
  408. display: flex;
  409. justify-content: center;
  410. align-items: center;
  411. width: 40rpx;
  412. height: 40rpx;
  413. top: 0rpx;
  414. right: -15rpx;
  415. color: #fff;
  416. font-size: 20rpx;
  417. background-color: #FD502F;
  418. border-radius: 50%;
  419. padding: 4rpx;
  420. }
  421. }
  422. .foot-item image {
  423. height: 50rpx;
  424. width: 50rpx;
  425. text-align: center;
  426. margin: 0 auto;
  427. }
  428. .foot-item .txt {
  429. font-size: 24rpx;
  430. &.active {}
  431. }
  432. }
  433. </style>