goods_cate1.vue 12 KB

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