class.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. <template>
  2. <view class="root">
  3. <view class="topBox dffs">
  4. <u-tabs
  5. :list="dataList.grade"
  6. keyName="name"
  7. :current="current"
  8. :itemStyle="{ fontSize: '28rpx', height: '100rpx' }"
  9. :activeStyle="{ color: '#87C477',borderBottom:'2px solid #87C477' }"
  10. lineHeight="0"
  11. sticky
  12. @click="topHandle"
  13. ></u-tabs>
  14. </view>
  15. <view class="content dfsb">
  16. <view class="secTop">
  17. <scroll-view :scroll-top="0" scroll-y="true" class="scroll-Y">
  18. <view @tap="choose(item.id)" :class="['topLi', leftSel == item.id ? 'topsel' : '']" v-for="(item, index) in dataList.subject" :key="index">
  19. {{ item.name }}
  20. </view>
  21. </scroll-view>
  22. </view>
  23. <view class="topInfo">
  24. <view class="topCInfo">
  25. <scroll-view :scroll-top="0" scroll-y="true" class="scroll-Y" @scrolltolower="lower">
  26. <view class="box">
  27. <view class="swipe">
  28. <u-swiper :autoplay="false" :list="banner" keyName="img" height="84" border-radius="20" @click="bannerClick"></u-swiper>
  29. </view>
  30. <!-- -->
  31. <view v-if="showVideo==1" class="goodLi dffd">
  32. <view class="fontsm textgrey">{{ '视频类' }}</view>
  33. <view class="son dffs">
  34. <navigator
  35. :url="'/pages/index/video/video?cat=' + item.id"
  36. class="li fontmid"
  37. :class="ind == 0 ? 'sel' : ''"
  38. v-for="(item, ind) in vedio_cats"
  39. :key="ind"
  40. >
  41. {{ item.name }}
  42. </navigator>
  43. </view>
  44. </view>
  45. <view class="goodLi dffd" v-for="(item, index) in classList" :key="index">
  46. <view class="fontsm textgrey">{{ item.name || '商品名称' }}</view>
  47. <view class="son dffs">
  48. <view @click="toNext(2, ite)" class="fontmid" v-for="(ite, ind) in item.children" :key="ind">{{ ite.name || '商品名称' }}</view>
  49. </view>
  50. </view>
  51. </view>
  52. </scroll-view>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </template>
  58. <script>
  59. export default {
  60. data() {
  61. return {
  62. showVideo: uni.getStorageSync('showVideo') || '0',
  63. current: 0,
  64. vedio_cats: [], // 视频列表
  65. banner:[],
  66. dataList: {}, //一层
  67. classList: [
  68. // { name: '姓名', goods_img: '/static/img/pro/hotbgzj.png' },
  69. ], //商品
  70. leftSel: 0, //一层分类选中
  71. status: 'loadmore',
  72. page: 1,
  73. pagnum: 15
  74. };
  75. },
  76. async onLoad(opt) {
  77. await this.onload();
  78. await this.getVidList();
  79. },
  80. onPullDownRefresh() {
  81. this.page = 1;
  82. this.leftSel = 0;
  83. this.current = 0;
  84. this.dataList = {};
  85. this.classList = [];
  86. this.onload();
  87. setTimeout(function() {
  88. uni.stopPullDownRefresh();
  89. }, 800);
  90. },
  91. // onReachBottom() {
  92. // if (this.status == 'nomore') return;
  93. // this.status = 'loadmore';
  94. // this.page = ++this.page;
  95. // this.onload();
  96. // },
  97. onShow() {},
  98. methods: {
  99. getBanner() {
  100. this.$api
  101. .request('index/getBanner', {
  102. field: 'tabbar_cate_banner',
  103. cate_type: 1,
  104. cat_id: this.current,
  105. two_cat_id: this.leftSel,
  106. })
  107. .then(data => {
  108. console.log("getBanner",data)
  109. if (data.code == 200) {
  110. this.banner = data.data;
  111. } else {
  112. this.$api.toast(data.msg);
  113. }
  114. });
  115. },
  116. getVidList() {
  117. this.$api
  118. .request('index/index', {
  119. school_type: '',
  120. video_cat: '',
  121. page: 1,
  122. limit: 6
  123. })
  124. .then(data => {
  125. console.log("index",data)
  126. if (data.code == 200) {
  127. this.showVideo = data.data.vedio_status;
  128. uni.setStorageSync('showVideo', data.data.vedio_status);
  129. this.vedio_cats = data.data.vedio_cats;
  130. } else {
  131. this.$api.toast(data.msg);
  132. }
  133. });
  134. },
  135. // 轮播
  136. bannerClick(e) {
  137. console.log(e);
  138. let item = this.dataList.banner[e];
  139. if (item.goods_id != 0) {
  140. if (item.type == 1) {
  141. uni.navigateTo({
  142. url: '/pages/index/video/videoInfo?id=' + item.goods_id
  143. });
  144. } else {
  145. uni.navigateTo({
  146. url: '/pages/index/navInfo?id=' + item.goods_id
  147. });
  148. }
  149. }
  150. },
  151. // 顶部按钮被点击
  152. topHandle(e) {
  153. console.log('top: ',e);
  154. this.current = e.id;
  155. // this.onload();
  156. this.getBanner();
  157. },
  158. toNext(val, item) {
  159. console.log(item);
  160. if (val == 1) {
  161. uni.navigateTo({
  162. url: '/pages/index/video/video'
  163. });
  164. return;
  165. }
  166. // console.log('跳转时:',item.id);
  167. uni.navigateTo({
  168. // url: `/pages/index/classList?flag=${val}&subject_id=${val}&grade_id=${this.current}&title=${ item.name }`
  169. url: `/pages/index/classList?flag=${val}&cat_id=${item.id}&subject_id=${this.leftSel}&grade_id=${this.current}&title=${ item.name }`
  170. });
  171. },
  172. choose(index) {
  173. console.log('leftSel: ',index);
  174. this.leftSel = index;
  175. console.log('this.leftSel',this.leftSel);
  176. // this.onload();
  177. this.getBanner();
  178. },
  179. onload() {
  180. this.status = 'loadmore';
  181. this.$api
  182. .request('index/getCateList', {
  183. grade_id: this.current,
  184. subject_id: this.leftSel
  185. })
  186. .then(data => {
  187. console.log(data);
  188. if (data.code == 200) {
  189. this.current = data.data.grade[0].id;
  190. this.leftSel = data.data.subject[0].id;
  191. this.dataList = data.data;
  192. this.classList = data.data.class_cate;
  193. this.getBanner();
  194. } else {
  195. this.$api.toast(data.msg);
  196. }
  197. });
  198. }
  199. }
  200. };
  201. </script>
  202. <style lang="scss" scoped>
  203. page {
  204. height: 100vh;
  205. }
  206. .content {
  207. background-color: #fff;
  208. align-items: flex-start;
  209. .topBox {
  210. background-color: #fff;
  211. }
  212. .secTop {
  213. .scroll-Y {
  214. height: calc(100vh - 120rpx);
  215. flex-wrap: wrap;
  216. }
  217. .topLi {
  218. font-size: 26rpx;
  219. width: 168rpx;
  220. padding: 26rpx 0;
  221. line-height: 37rpx;
  222. text-align: center;
  223. background: #f4f4f4;
  224. color: #666;
  225. }
  226. .topsel {
  227. font-size: 28rpx;
  228. box-sizing: border-box;
  229. background-color: #fff;
  230. color: $promain;
  231. font-weight: 600;
  232. }
  233. }
  234. .topInfo {
  235. width: 582rpx;
  236. padding-right: 30rpx;
  237. padding-left: 12rpx;
  238. background-color: #f5f5f5;
  239. // background-color: #fff;
  240. .swipe {
  241. width: 540rpx;
  242. height: 166rpx;
  243. margin: 20rpx 0;
  244. }
  245. .topClass {
  246. position: fixed;
  247. z-index: 1;
  248. background-color: #fff;
  249. padding-left: 12rpx;
  250. width: 556rpx;
  251. .topClaBox {
  252. flex: 1;
  253. height: 98rpx;
  254. line-height: 98rpx;
  255. display: -webkit-box;
  256. overflow-x: auto;
  257. /*适应苹果*/
  258. -webkit-overflow-scrolling: touch;
  259. //父盒子隐藏滚动条
  260. &::-webkit-scrollbar {
  261. display: none;
  262. }
  263. .topClasLi {
  264. font-size: 28rpx;
  265. padding: 0 15rpx;
  266. }
  267. .topClasel {
  268. color: $promain;
  269. }
  270. }
  271. .classDown {
  272. height: 98rpx;
  273. width: 70rpx;
  274. box-shadow: -2rpx -5rpx 2rpx 5rpx rgba($color: #000000, $alpha: 0.05);
  275. background-color: #fff;
  276. .xuanz {
  277. transform: translate(180deg);
  278. }
  279. }
  280. }
  281. .topCInfo {
  282. flex: 1;
  283. height: calc(100vh - 120rpx);
  284. .maskbg {
  285. position: fixed;
  286. top: 170rpx;
  287. left: 200rpx;
  288. width: calc(100% - 200rpx);
  289. height: calc(100% - 100rpx);
  290. background-color: rgba(0, 0, 0, 0.65);
  291. z-index: 2;
  292. }
  293. /* #ifdef MP */
  294. .maskbg {
  295. position: fixed;
  296. top: 70rpx;
  297. }
  298. /* #endif */
  299. .scroll-Y {
  300. height: calc(100vh - 120rpx);
  301. }
  302. .box {
  303. width: 100%;
  304. flex-wrap: wrap;
  305. }
  306. .goodLi {
  307. width: 100%;
  308. margin-top: 20rpx;
  309. padding: 20rpx;
  310. background-color: #fff;
  311. border-radius: 10rpx;
  312. .gdImg {
  313. width: 100%;
  314. height: 120rpx;
  315. background-color: #fbf9fa;
  316. margin-bottom: 36rpx;
  317. }
  318. .oneelli {
  319. text-align: center;
  320. font-size: 24rpx;
  321. }
  322. .son {
  323. margin-top: 10rpx;
  324. margin-left: 30rpx;
  325. flex-wrap: wrap;
  326. .fontmid {
  327. margin-right: 30rpx;
  328. margin-bottom: 20rpx;
  329. font-size: 24rpx !important;
  330. }
  331. }
  332. }
  333. }
  334. }
  335. }
  336. .cartBox {
  337. width: 710rpx;
  338. position: fixed;
  339. bottom: 10rpx;
  340. /* #ifdef H5 */
  341. bottom: 128rpx;
  342. /* #endif */
  343. left: 0;
  344. z-index: 999;
  345. margin: 0 20rpx;
  346. .leftbox {
  347. height: 100rpx;
  348. flex: 1;
  349. background: #000000;
  350. border-radius: 200rpx 0px 0px 200rpx;
  351. padding-left: 30rpx;
  352. .imgBox {
  353. position: relative;
  354. image {
  355. width: 90rpx;
  356. height: 82rpx;
  357. }
  358. }
  359. .priceInfo {
  360. position: relative;
  361. margin-left: 60rpx;
  362. .price {
  363. color: #fff;
  364. }
  365. }
  366. }
  367. .rightbox {
  368. height: 100rpx;
  369. line-height: 100rpx;
  370. text-align: center;
  371. color: #fff;
  372. background: #d8d8d8 linear-gradient(90deg, #6fd237 0%, #57c32a 100%);
  373. border-radius: 0px 200rpx 200rpx 0px;
  374. width: 194rpx;
  375. }
  376. .ordbox {
  377. font-size: 24rpx;
  378. text-align: center;
  379. margin-bottom: 10rpx;
  380. text {
  381. font-size: 30rpx;
  382. }
  383. // height: 100rpx;
  384. // line-height: 100rpx;
  385. // text-align: center;
  386. // color: #fff;
  387. // background: linear-gradient(90deg, #6fd237 0%, #57c32a 100%);
  388. // border-radius: 200rpx ;
  389. // margin-right: 15rpx;
  390. // padding: 0 20rpx;
  391. }
  392. .rightBlack {
  393. background: #000;
  394. color: #999;
  395. }
  396. }
  397. .ordbtn {
  398. position: fixed;
  399. bottom: 130rpx;
  400. right: 0;
  401. z-index: 999;
  402. width: 150rpx;
  403. height: 150rpx;
  404. line-height: 150rpx;
  405. border-radius: 50%;
  406. color: #fff;
  407. text-align: center;
  408. vertical-align: middle;
  409. font-size: 30rpx;
  410. background: radial-gradient(#68e670 0%, #5dce2c 100%);
  411. }
  412. </style>