index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. <template>
  2. <view class="study">
  3. <zs-header title="慧研学" color="#000"></zs-header>
  4. <view class="top-box">
  5. <image class="bg" src="https://hyxhsh.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/bdb/user/avatar/06qgjHTlTxWEb95dd5bef869e62f2a78c625ea6bef78.jpg/1.jpg" mode=""></image>
  6. <view class="type-box">
  7. <view class="type-item" v-for="item in typeList" :key="item.id" @click="handleType(item.id,{
  8. img:item.secondaryImg,
  9. name:item.columnName
  10. })">
  11. <image class="icon" :src="item.columnImg" mode=""></image>
  12. <view class="label">
  13. {{item.columnName}}
  14. </view>
  15. </view>
  16. </view>
  17. </view>
  18. <scroll-view class="tab-box" enable-flex scroll-x >
  19. <!-- <view class="tab" :class="[tab == item.value?'active':'']" v-for="(item,index) in tabList" :key="index" @click="handleTab(item.value)">
  20. {{item.label}}
  21. </view> -->
  22. <view class="tab active">
  23. 猜你喜欢
  24. </view>
  25. <view class="tab" @click="handleTest">
  26. MBTI测试
  27. </view>
  28. </scroll-view>
  29. <!-- 列表 -->
  30. <zs-list class="store-box" mt="0" @load="loadMore" :status="status">
  31. <view class="left">
  32. <view class="store-item" v-for="(item,index) in list" :key="index" @click="goGoodsDetail(item.goodsId)">
  33. <zs-img :src="item.logoPath" width="344rpx" height="344rpx" mode=""></zs-img>
  34. <view class="info">
  35. <view class="title">
  36. {{item.goodsName}}
  37. </view>
  38. <view class="user-info">
  39. <!-- <image class="head" :src="item.logoPath"></image> -->
  40. <view class="user-name">
  41. {{item.shopName}}
  42. </view>
  43. </view>
  44. <view class="price-box">
  45. <view class="left">
  46. <view class="unit">
  47. </view>
  48. <view class="price">
  49. {{item.realPrice}}
  50. </view>
  51. <view class="old-price">
  52. ¥{{item.marketPrice}}
  53. </view>
  54. </view>
  55. <view class="right">
  56. {{item.saleNum}}人已购
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. <view class="right">
  63. <view class="store-item" v-for="(item,index) in list1" :key="index" @click="goGoodsDetail(item.goodsId)">
  64. <zs-img :src="item.logoPath" width="344rpx" height="344rpx" mode=""></zs-img>
  65. <view class="info">
  66. <view class="title">
  67. {{item.goodsName}}
  68. </view>
  69. <view class="user-info">
  70. <!-- <image class="head" :src="item.logoPath" mode=""></image> -->
  71. <view class="user-name">
  72. {{item.shopName}}
  73. </view>
  74. </view>
  75. <view class="price-box">
  76. <view class="left">
  77. <view class="unit">
  78. </view>
  79. <view class="price">
  80. {{item.realPrice}}
  81. </view>
  82. <view class="old-price">
  83. ¥{{item.marketPrice}}
  84. </view>
  85. </view>
  86. <view class="right">
  87. {{item.saleNum}}人已购
  88. </view>
  89. </view>
  90. </view>
  91. </view>
  92. </view>
  93. </zs-list>
  94. </view>
  95. </template>
  96. <script>
  97. import {getMenu,getTab,getItem,studyGoodsByUser,getResult} from '@/api/study.js';
  98. import {getBanner} from '@/api/common.js'
  99. export default {
  100. data() {
  101. return {
  102. status: 'more',
  103. singleType:{
  104. columnName: "",
  105. columnMsg: "",
  106. columnImg: "",
  107. },
  108. typeList:[],
  109. list: [],
  110. list1: [],
  111. communityList:[],
  112. bannerList:[],
  113. tab:0,
  114. tabList:[],
  115. userId:'',
  116. query:{userId:this.userId,currentPage:1,pageSize:10,belongType:2}
  117. }
  118. },
  119. methods: {
  120. handleTest(){
  121. uni.navigateTo({
  122. url:'/study/test'
  123. })
  124. },
  125. // swiper变动
  126. swiperChange(val) {
  127. },
  128. handleType(id,{img,name}){
  129. uni.navigateTo({
  130. url:'/study/type?id='+id,
  131. success(res) {
  132. res.eventChannel.emit('img', img, name)
  133. }
  134. })
  135. },
  136. jump(){
  137. uni.navigateTo({
  138. url:'/study/community/index?id='+this.tab
  139. })
  140. },
  141. // 点击社区tab
  142. handleTab(tab){
  143. this.tab = tab
  144. this.getItem(tab)
  145. },
  146. // 去社区
  147. goDetail(item){
  148. uni.navigateTo({
  149. url:'/study/community/detail?id='+item.tabId,
  150. success: function(res) {
  151. // 通过eventChannel向被打开页面传送数据
  152. res.eventChannel.emit('detail', item)
  153. }
  154. })
  155. },
  156. // 去商品详情
  157. goGoodsDetail(id){
  158. uni.navigateTo({
  159. url:'/study/studyGoodsDetail?id='+id
  160. })
  161. },
  162. loadMore() {
  163. this.studyGoodsByUser()
  164. },
  165. // 获取顶部栏目
  166. getMenu(){
  167. let userId = uni.getStorageSync('userInfo')?JSON.parse(uni.getStorageSync('userInfo')).userId:''
  168. getMenu({currentPage:1,pageSize:5,userId,belongType:2}).then(res=>{
  169. if(res.state == 'Success'){
  170. this.typeList = res.content.records
  171. console.log(res.content.records);
  172. }
  173. })
  174. },
  175. // 获取banner
  176. getBanner(){
  177. getBanner({type:2}).then(res=>{
  178. if(res.state == 'Success'){
  179. this.bannerList = res.content.records
  180. }
  181. })
  182. },
  183. getTab(){
  184. getTab().then(res=>{
  185. if(res.state == 'Success'){
  186. for (const key in res.content) {
  187. if (Object.hasOwnProperty.call(res.content, key)) {
  188. this.tabList.push({
  189. value:Number(key),
  190. label:res.content[key]
  191. })
  192. }
  193. }
  194. this.tab = this.tabList[0].value
  195. this.getItem(this.tabList[0].value)
  196. }
  197. })
  198. },
  199. //获取社区分类列表
  200. getItem(communityId){
  201. getItem({communityId,currentPage:1,pageSize:2,state:2}).then(res=>{
  202. if(res.state == 'Success'){
  203. this.communityList = res.content.records
  204. }
  205. })
  206. },
  207. studyGoodsByUser(){
  208. this.status = 'loading'
  209. studyGoodsByUser(this.query).then(res=>{
  210. if(res.state == 'Success'){
  211. let list = []
  212. let list1 = []
  213. res.content.records.map((item,index)=>{
  214. if(index%2){
  215. list1.push(item)
  216. }else{
  217. list.push(item)
  218. }
  219. })
  220. this.list = this.list.concat(list)
  221. this.list1 = this.list1.concat(list1)
  222. let total = this.list.length+this.list1.length
  223. if(total>=res.content.total){
  224. this.status = 'noMore'
  225. }else{
  226. this.status = 'more'
  227. this.query.currentPage++
  228. }
  229. }
  230. })
  231. },
  232. // 获取测试结果
  233. getResult(){
  234. let userId = uni.getStorageSync('userInfo')?JSON.parse(uni.getStorageSync('userInfo')).userId:''
  235. getResult({userId}).then(r=>{
  236. if(!r.state == 'Success'||!r.content.resultMsg){
  237. uni.reLaunch({
  238. url:'/study/test'
  239. })
  240. }
  241. })
  242. }
  243. },
  244. created() {
  245. this.getMenu()
  246. this.getBanner()
  247. this.getTab()
  248. if(uni.getStorageSync('userInfo')){
  249. this.getResult()
  250. this.userId = JSON.parse(uni.getStorageSync('userInfo')).userId
  251. }
  252. }
  253. }
  254. </script>
  255. <style lang="scss" >
  256. .study {
  257. background: #F9F9F9;
  258. padding: 0 20rpx;
  259. .top-box{
  260. .bg{
  261. width: 750rpx;
  262. height: 480rpx;
  263. position: relative;
  264. left: -20rpx;
  265. border-radius: 0 0 5% 5%;
  266. }
  267. .type-box{
  268. display: flex;
  269. align-items: center;
  270. width: 710rpx;
  271. height: 228rpx;
  272. border-radius: 16rpx 16rpx 16rpx 16rpx;
  273. background: #FFFFFF;
  274. margin-top: -80rpx;
  275. position: relative;
  276. z-index: 2;
  277. .type-item{
  278. flex: 1;
  279. text-align: center;
  280. .icon{
  281. width: 80rpx;
  282. height: 80rpx;
  283. border-radius: 50%;
  284. }
  285. .label{
  286. font-weight: 300;
  287. font-size: 24rpx;
  288. color: #222222;
  289. margin-top: 15rpx;
  290. }
  291. }
  292. }
  293. }
  294. .swiper {
  295. height: 272rpx;
  296. border-radius: 16rpx;
  297. margin-top: 28rpx;
  298. .swiper-item {
  299. width: 100%;
  300. height: 100%;
  301. border-radius: 16rpx;
  302. object-fit: cover;
  303. }
  304. }
  305. .more-title{
  306. display: flex;
  307. justify-content: space-between;
  308. align-items: center;
  309. .more-box{
  310. display: flex;
  311. align-items: center;
  312. font-size: 24rpx;
  313. color: #AAAAAA;
  314. .more{
  315. width: 20rpx;
  316. height: 20rpx;
  317. display: block;
  318. margin-left: 6rpx;
  319. }
  320. }
  321. }
  322. .type-title{
  323. font-weight: bold;
  324. color: #222222;
  325. font-size: 32rpx;
  326. margin: 30rpx 0 20rpx;
  327. }
  328. .tab-box{
  329. display: flex;
  330. align-items: flex-start;
  331. .tab{
  332. flex-shrink: 0;
  333. padding: 10rpx 24rpx;
  334. margin-top: 28rpx;
  335. color: #AAAAAA;
  336. background: #EEEEEE;
  337. font-size: 28rpx;
  338. margin-right: 20rpx;
  339. border-radius: 8rpx;
  340. }
  341. .tab.active{
  342. color: #222222;
  343. // background: #CEE0FF;
  344. }
  345. }
  346. .list{
  347. display: flex;
  348. justify-content: space-between;
  349. flex-wrap: wrap;
  350. .item{
  351. box-shadow: 0rpx 0rpx 24rpx 2rpx rgba(0,0,0,0.08);
  352. border-radius: 16rpx;
  353. width: 344rpx;
  354. height: 566rpx;
  355. margin-top: 20rpx;
  356. display: flex;
  357. flex-direction: column;
  358. .info{
  359. padding: 20rpx;
  360. height: auto;
  361. flex: 1;
  362. display: flex;
  363. flex-direction: column;
  364. justify-content: space-between;
  365. .title{
  366. color: #222222;
  367. font-size: 28rpx;
  368. height: 76rpx;
  369. width: 100%;
  370. font-weight: bold;
  371. display: -webkit-box;
  372. -webkit-box-orient: vertical;
  373. -webkit-line-clamp: 2; /* 显示的最大行数 */
  374. overflow: hidden;
  375. }
  376. .user-info{
  377. display: flex;
  378. align-items: center;
  379. margin-top: 20rpx;
  380. .head{
  381. width: 40rpx;
  382. height: 40rpx;
  383. border-radius: 50%;
  384. }
  385. .user-name{
  386. color: #AAAAAA;
  387. font-size: 24rpx;
  388. // margin-left: 12rpx;
  389. }
  390. }
  391. .price-box{
  392. display: flex;
  393. justify-content: space-between;
  394. align-items: center;
  395. margin-top: 12rpx;
  396. .left{
  397. display: flex;
  398. align-items: flex-end;
  399. .unit{
  400. font-size: 24rpx;
  401. color: $uni-color-primary;
  402. font-weight: bold;
  403. }
  404. .price{
  405. font-size: 32rpx;
  406. color: $uni-color-primary;
  407. font-weight: bold;
  408. }
  409. .old-price{
  410. font-size: 20rpx;
  411. color: #AAAAAA;
  412. text-decoration: line-through;
  413. margin-left: 10rpx;
  414. }
  415. }
  416. .right{
  417. font-size: 20rpx;
  418. color: #AAAAAA;
  419. }
  420. }
  421. }
  422. }
  423. }
  424. .zs-list {
  425. display: flex;
  426. flex-wrap: wrap;
  427. justify-content: space-between;
  428. .left {
  429. }
  430. .right {
  431. }
  432. .store-item{
  433. box-shadow: 0rpx 0rpx 24rpx 2rpx rgba(0,0,0,0.08);
  434. border-radius: 16rpx;
  435. width: 344rpx;
  436. height: 566rpx;
  437. margin-top: 20rpx;
  438. display: flex;
  439. flex-direction: column;
  440. .info{
  441. padding: 20rpx;
  442. flex: 1;
  443. display: flex;
  444. flex-direction: column;
  445. justify-content: space-between;
  446. .title{
  447. color: #222222;
  448. font-size: 28rpx;
  449. height: 76rpx;
  450. width: 100%;
  451. font-weight: bold;
  452. display: -webkit-box;
  453. -webkit-box-orient: vertical;
  454. -webkit-line-clamp: 2; /* 显示的最大行数 */
  455. overflow: hidden;
  456. }
  457. .user-info{
  458. display: flex;
  459. align-items: center;
  460. margin-top: 20rpx;
  461. .head{
  462. width: 40rpx;
  463. height: 40rpx;
  464. border-radius: 50%;
  465. }
  466. .user-name{
  467. color: #AAAAAA;
  468. font-size: 24rpx;
  469. overflow: hidden;
  470. // margin-left: 12rpx;
  471. }
  472. }
  473. .price-box{
  474. display: flex;
  475. justify-content: space-between;
  476. align-items: center;
  477. margin-top: 12rpx;
  478. .left{
  479. display: flex;
  480. align-items: flex-end;
  481. .unit{
  482. font-size: 24rpx;
  483. color: $uni-color-primary;
  484. font-weight: bold;
  485. }
  486. .price{
  487. font-size: 32rpx;
  488. color: $uni-color-primary;
  489. font-weight: bold;
  490. }
  491. .old-price{
  492. font-size: 20rpx;
  493. color: #AAAAAA;
  494. text-decoration: line-through;
  495. margin-left: 10rpx;
  496. }
  497. }
  498. .right{
  499. font-size: 20rpx;
  500. color: #AAAAAA;
  501. }
  502. }
  503. }
  504. }
  505. }
  506. }
  507. </style>