index.vue 12 KB

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