index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. <template>
  2. <view style="height: 100%;" @touchstart="startTouch" @touchmove="moveTouch" @touchend="endTouch">
  3. <zs-skeleton type="activity" :loading="loading"></zs-skeleton>
  4. <view class="zs-header" :style="{ height: statusBarHeight + navBareight + 'px', background: '#fff' }">
  5. <view class="title">
  6. <view @click="changeTab(0)" :class="['title-text', headerTab === 0 ? 'active' : '']">
  7. 平台活动
  8. </view>
  9. <view @click="changeTab(1)" :class="['title-text', headerTab === 1 ? 'active' : '']">
  10. 我的活动
  11. </view>
  12. </view>
  13. </view>
  14. <view :style="{ marginTop: statusBarHeight + navBareight + 'px' }">
  15. <view class="activity" v-if="headerTab === 0">
  16. <zs-list mt="0" @load="loadMore" :status="status">
  17. <view class="item" v-for="item in list" :key="item.id" @click="goDetail(item.id)">
  18. <zs-img :src="item.activityCover" width="710rpx" height="320rpx"></zs-img>
  19. <view class="info">
  20. <view class="title">
  21. {{ item.activityName }}
  22. </view>
  23. <view class="desc">
  24. 活动时间: {{ item.activityStartTime }} 至 {{ item.activityEndTime }}
  25. </view>
  26. </view>
  27. </view>
  28. </zs-list>
  29. </view>
  30. <view class="activity" v-if="headerTab === 1">
  31. <zs-list mt="0" @load="loadEventMore" :status="eventStatus">
  32. <view class="event-item" v-for="item in eventList" :key="item.id" @click="toDetailStudy(item.orderNo)">
  33. <view class="info">
  34. <view class="content">
  35. <view class="main">
  36. <view class="title">
  37. {{ item.goodsInfoVo.goodsName || '低碳环保-云漫湖·森哒星生态度假哒星生态度哒星生态度哒星生态度' }}
  38. </view>
  39. <view class="description">
  40. {{ item.goodsInfoVo.goodsDescribe || '景观中国天眼探索宇宙深度的秘密宇宙深度的秘宇宙深度的秘宇宙深度的秘宇宙深度的秘' }}
  41. </view>
  42. <view class="itinerary">
  43. 出发时间 {{ $u.timeFormat(item.reserveTime, 'yyyy-mm-dd hh:MM:ss') }}·{{ item.stateStr }}
  44. </view>
  45. </view>
  46. <view class="image">
  47. <img :src="item.goodsInfoVo.goodsPath || 'https://via.placeholder.com/82'" alt="活动图片">
  48. </view>
  49. </view>
  50. <view class="footer">
  51. <view class="slogan">
  52. 研学旅行规划先行,请合理安排时间
  53. </view>
  54. <view class="action">
  55. 立即学习
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </zs-list>
  61. </view>
  62. </view>
  63. </view>
  64. </template>
  65. <script>
  66. import { activityList, studyList } from '@/api/activity'
  67. export default {
  68. data() {
  69. return {
  70. status: 'more',
  71. eventStatus: 'more',
  72. list: [],
  73. eventList: [],
  74. query: {
  75. currentPage: 1,
  76. pageSize: 10,
  77. shopId: 0,
  78. state: 2
  79. },
  80. eventQuery: {
  81. currentPage: 1,
  82. pageSize: 10,
  83. shopId: 0,
  84. state: 2
  85. },
  86. loading: true,
  87. statusBarHeight: 20,
  88. navBareight: 45,
  89. headerTab: 0,
  90. startX: 0,
  91. moveX: 0
  92. }
  93. },
  94. methods: {
  95. loadMore() {
  96. this.activityList()
  97. },
  98. loadEventMore() {
  99. this.getEventList()
  100. },
  101. goDetail(id) {
  102. uni.navigateTo({
  103. url: '/signUp/index?scene=' + id
  104. })
  105. },
  106. goStudyDetail(id) {
  107. uni.navigateTo({
  108. url: '/pages/activity/detail?scene=' + id
  109. })
  110. },
  111. activityList() {
  112. this.status = 'loading'
  113. activityList(this.query).then(res => {
  114. if (res.state == 'Success') {
  115. this.list = this.list.concat(res.content.records)
  116. if (this.list.length >= res.content.total) {
  117. this.status = 'noMore'
  118. } else {
  119. this.status = 'more'
  120. this.query.pageCurrent++
  121. }
  122. }
  123. this.loading = false
  124. })
  125. },
  126. getEventList() {
  127. this.eventStatus = 'loading'
  128. studyList(this.eventQuery).then(res => {
  129. if (res.state == 'Success') {
  130. this.eventList = this.eventList.concat(res.content.records)
  131. if (this.eventList.length >= res.content.total) {
  132. this.eventStatus = 'noMore'
  133. } else {
  134. this.eventStatus = 'more'
  135. this.eventQuery.pageCurrent++
  136. }
  137. }
  138. })
  139. },
  140. changeTab(v) {
  141. this.headerTab = v
  142. uni.vibrateShort()
  143. },
  144. startTouch(e) {
  145. this.startX = e.changedTouches[0].clientX;
  146. },
  147. moveTouch(e) {
  148. this.moveX = e.changedTouches[0].clientX - this.startX;
  149. },
  150. endTouch(e) {
  151. console.log(this.moveX, this.headerTab)
  152. if (Math.abs(this.moveX) > 90) { // 滑动距离超过90px时才进行切换
  153. if (this.moveX > 0) {
  154. // 向右滑动
  155. if (this.headerTab === 0) {
  156. this.headerTab = 1
  157. } else {
  158. this.headerTab = 0
  159. }
  160. } else {
  161. // 向左滑动
  162. if (this.headerTab === 1) {
  163. this.headerTab = 0
  164. } else {
  165. this.headerTab = 1
  166. }
  167. }
  168. this.startX = 0; // 重置起始位置
  169. this.moveX = 0; // 重置移动距离
  170. }
  171. },
  172. toDetailStudy(orderNo) {
  173. console.log('====================================');
  174. console.log(orderNo);
  175. console.log('====================================');
  176. uni.navigateTo({
  177. url: '/pages/activity/detail?orderNo=' + orderNo
  178. })
  179. }
  180. },
  181. onLoad() {
  182. // this.activityList()
  183. },
  184. onShareTimeline() {
  185. return {
  186. title: "慧研学惠生活",
  187. query: "id=1",
  188. };
  189. },
  190. onShareAppMessage() {
  191. return {
  192. title: "慧研学惠生活",
  193. path: "/pages/activity/index",
  194. };
  195. },
  196. created() {
  197. //获取手机系统信息 -- 状态栏高度
  198. let {
  199. statusBarHeight,
  200. } = uni.getSystemInfoSync()
  201. this.statusBarHeight = statusBarHeight
  202. //去除
  203. //#ifndef H5 || MP-ALIPAY ||APP-PLUS
  204. //获取小程序胶囊的高度
  205. let {
  206. top,
  207. bottom,
  208. left
  209. } = uni.getMenuButtonBoundingClientRect()
  210. //高度 =(胶囊底部高低-状态栏高度)+(胶囊顶部高度-状态栏内的高度)
  211. this.navBareight = (bottom - statusBarHeight) + (top - statusBarHeight)
  212. //#endif
  213. this.headerTab = 0
  214. }
  215. }
  216. </script>
  217. <style lang="scss" scoped>
  218. .zs-header {
  219. position: fixed;
  220. width: 100%;
  221. // height: calc(44px + env(safe-area-inset-top));
  222. top: 0;
  223. left: 0;
  224. z-index: 999;
  225. display: flex;
  226. align-items: flex-end;
  227. justify-content: center;
  228. box-sizing: border-box;
  229. padding: 6px;
  230. transition: background .3s ease-in-out;
  231. .back {
  232. width: 30rpx;
  233. height: 30rpx;
  234. position: absolute;
  235. bottom: 10px;
  236. // top: calc(16px + env(safe-area-inset-top));
  237. left: 20rpx;
  238. }
  239. .title {
  240. display: flex;
  241. justify-content: center;
  242. align-items: center;
  243. .title-text {
  244. font-size: 32rpx;
  245. color: #333333;
  246. font-weight: 400;
  247. &:nth-child(1) {
  248. margin-right: 10rpx;
  249. }
  250. &:nth-child(2) {
  251. margin-left: 10rpx;
  252. }
  253. }
  254. .active {
  255. font-weight: bold;
  256. color: black;
  257. &::after {
  258. content: '';
  259. display: block;
  260. width: 100%;
  261. height: 4rpx;
  262. background: $uni-color-primary;
  263. border-radius: 2rpx 2rpx 0 0;
  264. }
  265. }
  266. }
  267. }
  268. .activity {
  269. padding: 20rpx;
  270. background: #F9F9F9;
  271. min-height: 100vh;
  272. .zs-list {
  273. .item {
  274. margin-bottom: 20rpx;
  275. border-radius: 16rpx 16rpx 16rpx 16rpx;
  276. .info {
  277. background: #fff;
  278. padding: 20rpx 24rpx;
  279. .title {
  280. font-size: 28rpx;
  281. color: #222222;
  282. width: 640rpx;
  283. white-space: nowrap;
  284. overflow: hidden;
  285. text-overflow: ellipsis;
  286. }
  287. .desc {
  288. font-size: 24rpx;
  289. color: #AAAAAA;
  290. overflow: hidden;
  291. text-overflow: ellipsis;
  292. /* 弹性伸缩盒子模型显示 */
  293. display: -webkit-box;
  294. /* 限制在一个块元素显示的文本的行数 */
  295. -webkit-line-clamp: 2;
  296. /* 设置或检索伸缩盒对象的子元素的排列方式 */
  297. -webkit-box-orient: vertical;
  298. margin-top: 20rpx;
  299. }
  300. }
  301. }
  302. .event-item {
  303. margin-bottom: 20rpx;
  304. border-radius: 16rpx;
  305. .info {
  306. background: #fff;
  307. padding: 24rpx;
  308. .content {
  309. display: flex;
  310. justify-content: space-between;
  311. .main {
  312. width: 70%;
  313. .title {
  314. font-size: 28rpx;
  315. color: #222222;
  316. font-weight: bold;
  317. white-space: nowrap;
  318. overflow: hidden;
  319. text-overflow: ellipsis;
  320. }
  321. .description,
  322. .itinerary {
  323. font-size: 24rpx;
  324. color: #AAAAAA;
  325. overflow: hidden;
  326. text-overflow: ellipsis;
  327. /* 弹性伸缩盒子模型显示 */
  328. display: -webkit-box;
  329. /* 限制在一个块元素显示的文本的行数 */
  330. -webkit-line-clamp: 2;
  331. /* 设置或检索伸缩盒对象的子元素的排列方式 */
  332. -webkit-box-orient: vertical;
  333. margin-top: 20rpx;
  334. }
  335. }
  336. .image {
  337. width: 164rpx;
  338. height: 164rpx;
  339. border-radius: 16rpx;
  340. overflow: hidden;
  341. img {
  342. width: 100%;
  343. height: 100%;
  344. }
  345. }
  346. }
  347. .footer {
  348. display: flex;
  349. justify-content: space-between;
  350. margin-top: 20rpx;
  351. background: #F9F9F9;
  352. border-radius: 16rpx;
  353. padding: 24rpx;
  354. .slogan,
  355. .action {
  356. font-size: 24rpx;
  357. color: #AAAAAA;
  358. }
  359. }
  360. }
  361. }
  362. }
  363. }
  364. </style>