technicaldetailcategory.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. <template>
  2. <view class="container">
  3. <view class="tui-searchbox">
  4. <view class="tui-search-input" @tap="search">
  5. <icon type="search" :size="13" color="#999"></icon>
  6. <text class="tui-search-text">搜索</text>
  7. </view>
  8. </view>
  9. <scroll-view scroll-y scroll-with-animation class="tab-view" :scroll-into-view="scrollViewId"
  10. :style="{ height: height + 'px', top: top + 'px' }">
  11. <view :id="`id_${index}`" v-for="(item, index) in Category" :key="item.id" class="tab-bar-item"
  12. :class="[currentTab == index ? 'active' : '']" :data-current="index"
  13. @tap.stop="swichNav(item.id,index)">
  14. <text>{{ item.title }}</text>
  15. </view>
  16. </scroll-view>
  17. <scroll-view @scrolltolower="tolower" scroll-y class="right-box" :scroll-into-view="floorNum"
  18. :style="{ height: height + 'px', top: top + 'px' }">
  19. <view class="page-view">
  20. <swiper v-if="banners.length>0" indicator-dots autoplay circular :interval="5000" :duration="150"
  21. class="swiper">
  22. <swiper-item v-for="(item, index) in banners" :key="index">
  23. <image :data-url="item.url" @tap="navigationTo" :src="item.pic" mode="widthFix"
  24. class="slide-image" />
  25. </swiper-item>
  26. </swiper>
  27. <view class="class-box">
  28. <block v-if="categorystyle==1">
  29. <block v-for="(goods, index) in goodsList" :key="index">
  30. <view class="goods-item" @tap="toDetailsTap" :data-id="goods.id">
  31. <image class="goods-pic" lazy-load="true"
  32. :src="goods.touxiang || '/static/images/my/mine_def_touxiang_3x.png'"></image>
  33. <view class="goods-info">
  34. <text>{{goods.title}}</text>
  35. </view>
  36. </view>
  37. </block>
  38. </block>
  39. <block v-if="categorystyle==2">
  40. <view class="class-item" :id="'b'+item.id" v-if="Category.length>0"
  41. v-for="(item, index) in Category" :key="index">
  42. <view class="class-name">{{ item.title }}</view>
  43. <view class="g-container">
  44. <view class="g-box" v-for="(son, i1) in item.son" :key="i1" @tap.stop="gogoodsList"
  45. :data-cid="son.id" :data-key="son.title">
  46. <image :src="son.icon" class="g-image" />
  47. <view class="g-title">{{ son.title }}</view>
  48. </view>
  49. </view>
  50. </view>
  51. </block>
  52. </view>
  53. </view>
  54. <view :style='"height:"+(height-300)+"rpx;"' v-if="number<15"></view>
  55. </scroll-view>
  56. <tui-tabbar :current="current">
  57. </tui-tabbar>
  58. </view>
  59. </template>
  60. <script>
  61. export default {
  62. data() {
  63. return {
  64. current: '',
  65. banners: [],
  66. Category: [],
  67. categoryId: "",
  68. categorystyle: "1",
  69. goodsList: [],
  70. page: 1,
  71. getSon: [],
  72. height: 0, //scroll-view高度
  73. top: 0,
  74. currentTab: 0, //预设当前项的值
  75. floorNum: '',
  76. number: "",
  77. scrollViewId: "id_0"
  78. };
  79. },
  80. onLoad: function(options) {
  81. let _this = this
  82. // #ifdef MP-WEIXIN
  83. this.current = "/" + this.__route__;
  84. // #endif
  85. //#ifdef H5
  86. this.current = this.$route.path;
  87. //#endif
  88. setTimeout(() => {
  89. uni.getSystemInfo({
  90. success: res => {
  91. let header = 92;
  92. let top = 0;
  93. console.log(res.windowHeight);
  94. this.height = res.windowHeight - uni.upx2px(header);
  95. this.top = top + uni.upx2px(header);
  96. }
  97. });
  98. }, 50);
  99. this.getbanners()
  100. this.getCategoryall();
  101. },
  102. onShow() {
  103. let _this = this;
  104. _this.$request.post('config', {
  105. mo: 'pagestyle'
  106. }).then(res => {
  107. if (res.errno == 0) {
  108. if (res.data.categorystyle) {
  109. _this.categorystyle = res.data.categorystyle
  110. }
  111. }
  112. });
  113. },
  114. methods: {
  115. // 点击标题切换当前页时改变样式
  116. swichNav: function(Categoryid, e) {
  117. let cur = e;
  118. if (this.currentTab == cur) {
  119. return false;
  120. } else {
  121. this.currentTab = cur;
  122. this.checkCor();
  123. }
  124. if (this.categorystyle == 1) {
  125. this.categoryId = Categoryid;
  126. this.page = 1;
  127. this.getGoodsList();
  128. } else {
  129. this.floorNum = 'b' + Categoryid;
  130. }
  131. },
  132. //判断当前滚动超过一屏时,设置tab标题滚动条。
  133. checkCor: function() {
  134. if (this.currentTab > 6) {
  135. this.scrollViewId = `id_${this.currentTab - 2}`;
  136. } else {
  137. this.scrollViewId = `id_0`;
  138. }
  139. },
  140. gogoodsList(e) {
  141. let key = e.currentTarget.dataset.key;
  142. let cid = e.currentTarget.dataset.cid;
  143. uni.navigateTo({
  144. url: '/pages/goodsList/goodsList?cid=' + cid + '&searchKey=' + key
  145. });
  146. },
  147. toDetailsTap: function(e) {
  148. uni.navigateTo({
  149. url: "/pages/technical/details?id=" + e.currentTarget.dataset.id
  150. });
  151. },
  152. navigationTo: function(e) {
  153. this.sam.navigateTo(e.currentTarget.dataset.url)
  154. },
  155. search: function() {
  156. uni.navigateTo({
  157. url: '/pages/common/search/search'
  158. });
  159. },
  160. getbanners: function() {
  161. let _this = this;
  162. this.$request.get('ad.indexlist').then(res => {
  163. if (res.errno == 0) {
  164. this.banners = res.data;
  165. }
  166. })
  167. },
  168. getCategoryall: function() {
  169. let _this = this;
  170. this.$request.get('Category.all', {
  171. ptype: 2,
  172. showLoading:true
  173. }).then(res => {
  174. if (res.errno == 0) {
  175. _this.Category = res.data;
  176. _this.categoryId = _this.Category[0].id;
  177. _this.getGoodsList();
  178. setTimeout(function() {
  179. _this.infoScroll();
  180. }, 500)
  181. console.info("services---request---getsonList--右侧二级三级分类成功")
  182. }
  183. })
  184. },
  185. getGoodsList: function() {
  186. let that = this;
  187. if (that.page == 1) {
  188. that.goodsList = [];
  189. }
  190. this.$request.post('Technical.list', {
  191. categoryId: that.categoryId,
  192. page: that.page,
  193. pageSize: 1000
  194. }).then(res => {
  195. that.goodsList = that.goodsList.concat(res.data.data);
  196. that.page = that.page + 1
  197. //console.log(goodsList);
  198. uni.hideNavigationBarLoading();
  199. }).catch(e => {
  200. uni.hideNavigationBarLoading();
  201. });
  202. },
  203. infoScroll: function() {
  204. let _this = this;
  205. let len = _this.Category.length;
  206. if (_this.Category[len - 1].son) {
  207. this.number = _this.Category[len - 1].son.length;
  208. }
  209. },
  210. tolower: function() {
  211. if (this.categorystyle == 1) {
  212. this.getGoodsList();
  213. }
  214. }
  215. },
  216. /**
  217. * 页面相关事件处理函数--监听用户下拉动作
  218. */
  219. onPullDownRefresh: function() {
  220. setTimeout(() => {
  221. uni.stopPullDownRefresh()
  222. }, 200);
  223. },
  224. };
  225. </script>
  226. <style>
  227. page {
  228. background: #fcfcfc;
  229. }
  230. /* 左侧导航布局 start*/
  231. /* 隐藏scroll-view滚动条*/
  232. ::-webkit-scrollbar {
  233. width: 0;
  234. height: 0;
  235. color: transparent;
  236. }
  237. .tui-searchbox {
  238. width: 100%;
  239. height: 92rpx;
  240. padding: 0 30rpx;
  241. box-sizing: border-box;
  242. background: #fff;
  243. display: flex;
  244. align-items: center;
  245. justify-content: center;
  246. position: fixed;
  247. left: 0;
  248. top: 0;
  249. z-index: 100;
  250. }
  251. .tui-searchbox::after {
  252. content: '';
  253. position: absolute;
  254. border-bottom: 1rpx solid #d2d2d2;
  255. -webkit-transform: scaleY(0.5);
  256. transform: scaleY(0.5);
  257. bottom: 0;
  258. right: 0;
  259. left: 0;
  260. }
  261. .tui-search-input {
  262. width: 100%;
  263. height: 60rpx;
  264. background: #f1f1f1;
  265. border-radius: 30rpx;
  266. font-size: 26rpx;
  267. color: #999;
  268. display: flex;
  269. align-items: center;
  270. justify-content: center;
  271. }
  272. .tui-search-text {
  273. padding-left: 16rpx;
  274. }
  275. .tab-view {
  276. /* height: 100%; */
  277. background: #f6f6f6;
  278. width: 200rpx;
  279. position: fixed;
  280. left: 0;
  281. z-index: 10;
  282. }
  283. .tab-bar-item {
  284. width: 200rpx;
  285. height: 110rpx;
  286. background: #f6f6f6;
  287. box-sizing: border-box;
  288. display: flex;
  289. align-items: center;
  290. justify-content: center;
  291. font-size: 26rpx;
  292. color: #444;
  293. font-weight: 400;
  294. }
  295. .active {
  296. position: relative;
  297. color: #000;
  298. font-size: 30rpx;
  299. font-weight: 600;
  300. background: #fcfcfc;
  301. }
  302. .active::before {
  303. content: '';
  304. position: absolute;
  305. border-left: 8rpx solid #e41f19;
  306. height: 30rpx;
  307. left: 0;
  308. }
  309. /* 左侧导航布局 end*/
  310. .right-box {
  311. width: 100%;
  312. position: fixed;
  313. padding-left: 220rpx;
  314. box-sizing: border-box;
  315. left: 0;
  316. }
  317. .page-view {
  318. width: 100%;
  319. overflow: hidden;
  320. padding-top: 20rpx;
  321. padding-right: 20rpx;
  322. box-sizing: border-box;
  323. padding-bottom: env(safe-area-inset-bottom);
  324. }
  325. .swiper {
  326. width: 100%;
  327. height: 150rpx;
  328. border-radius: 12rpx;
  329. overflow: hidden;
  330. transform: translateZ(0);
  331. }
  332. /* #ifdef MP-WEIXIN */
  333. .swiper .wx-swiper-dot {
  334. width: 8rpx;
  335. height: 8rpx;
  336. display: inline-flex;
  337. background: none;
  338. justify-content: space-between;
  339. }
  340. .swiper .wx-swiper-dot::before {
  341. content: '';
  342. flex-grow: 1;
  343. background: rgba(255, 255, 255, 0.8);
  344. border-radius: 16rpx;
  345. overflow: hidden;
  346. }
  347. .swiper .wx-swiper-dot-active::before {
  348. background: #fff;
  349. }
  350. .swiper .wx-swiper-dot.wx-swiper-dot-active {
  351. width: 16rpx;
  352. }
  353. /* #endif */
  354. /* #ifndef MP-WEIXIN */
  355. >>>.swiper .uni-swiper-dot {
  356. width: 8rpx;
  357. height: 8rpx;
  358. display: inline-flex;
  359. background: none;
  360. justify-content: space-between;
  361. }
  362. >>>.swiper .uni-swiper-dot::before {
  363. content: '';
  364. flex-grow: 1;
  365. background: rgba(255, 255, 255, 0.8);
  366. border-radius: 16rpx;
  367. overflow: hidden;
  368. }
  369. >>>.swiper .uni-swiper-dot-active::before {
  370. background: #fff;
  371. }
  372. >>>.swiper .uni-swiper-dot.uni-swiper-dot-active {
  373. width: 16rpx;
  374. }
  375. /* #endif */
  376. .slide-image {
  377. width: 100%;
  378. height: 100%;
  379. }
  380. .class-box {
  381. padding-top: 10rpx;
  382. }
  383. .class-item {
  384. background: #fff;
  385. width: 100%;
  386. box-sizing: border-box;
  387. padding: 20rpx;
  388. margin-bottom: 20rpx;
  389. border-radius: 12rpx;
  390. }
  391. .class-name {
  392. font-size: 22rpx;
  393. }
  394. .g-container {
  395. /* padding-top: 20rpx; */
  396. display: flex;
  397. display: -webkit-flex;
  398. justify-content: flex-start;
  399. flex-direction: row;
  400. flex-wrap: wrap;
  401. }
  402. .g-box {
  403. width: 33.3333%;
  404. text-align: center;
  405. padding-top: 40rpx;
  406. }
  407. .g-image {
  408. width: 120rpx;
  409. height: 120rpx;
  410. border-radius: 12rpx;
  411. }
  412. .g-title {
  413. font-size: 22rpx;
  414. }
  415. .goods-item {
  416. width: 96%;
  417. height: 150rpx;
  418. display: flex;
  419. padding-left: 5px;
  420. padding-right: 5px;
  421. padding-top: 12px;
  422. padding-bottom: 12px;
  423. flex-direction: row;
  424. margin-left: 20rpx;
  425. align-items: center;
  426. justify-content: flex-start;
  427. border-bottom: 1rpx dotted #f2f2f2;
  428. }
  429. .goods-pic {
  430. width: 80px;
  431. height: 80px;
  432. flex-shrink: 0;
  433. }
  434. .goods-info {
  435. display: flex;
  436. flex-direction: column;
  437. padding: 6px 5px 0px 5px;
  438. height: 70px;
  439. font-size: 24rpx;
  440. justify-content: space-between;
  441. }
  442. </style>