goods_cate1.vue 11 KB

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