my_active.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. <template>
  2. <view class="my_active">
  3. <view class="search">
  4. <image src="../../static/images/search.png" mode=""></image>
  5. <input type="text" value="" placeholder="请输入活动名称" v-model="search_text"
  6. placeholder-style="font-size:14px;color:#D9D0C8;" @confirm="search" @input="get_text" />
  7. </view>
  8. <view class="card">
  9. <view class="tab">
  10. <u-tabs-swiper ref="uTabs" :list="list" bar-height="8" bar-width="60" bg-color="" font-size="36" :bold="false"
  11. active-color="#674023" inactive-color="#A2A2A2" @change="tabsChange"></u-tabs-swiper>
  12. </view>
  13. <swiper :style="{'height': scrollHeight+'px'}" class="swiper" :current="swiperCurrent"
  14. @transition="transition" @change="animationfinish">
  15. <swiper-item class="swiper-item">
  16. <scroll-view class="scrollbox" :style="{'height': scrollHeight+'px'}" :scroll-y='true'
  17. @scrolltolower="onreachBottom">
  18. <!-- scroll-y -->
  19. <view class="empty" v-if="my_list.length == 0">
  20. <image src="../../static/images/empty_active.png" mode=""></image>
  21. <text>没有相关活动哦,快返回活动列表去寻找您感兴趣的活动加入吧!</text>
  22. </view>
  23. <view class="item" v-for="(item,index) in my_list" :key="index" @click="to_detail(item)">
  24. <view class="img"
  25. :style="{backgroundImage:'url('+ (item.cover_resource?item.cover_resource.url :'' ) +')'}">
  26. <!-- <image :src="item.cover_resource.url" mode=""></image> -->
  27. </view>
  28. <view class="right">
  29. <view class="title">{{item.title}}</view>
  30. <view class="logo">
  31. <image
  32. :src="item.organization?item.organization.logo != null?item.organization.logo:'':''"
  33. mode=""></image>
  34. <text>{{item.organization?item.organization.name:'--'}}</text>
  35. </view>
  36. <view class="time">
  37. <text>{{item.start_time}}--{{item.end_time}}</text>|<text>{{item.shape_text}}活动</text>
  38. </view>
  39. <view class="free">
  40. <!-- {{item.money}} -->
  41. {{item.sign_up_nums}}/{{item.total_nums}}
  42. </view>
  43. </view>
  44. </view>
  45. </scroll-view>
  46. </swiper-item>
  47. <swiper-item class="swiper-item">
  48. <scroll-view class="scrollbox" :style="{'height': scrollHeight+'px'}" :scroll-y='true'
  49. @scrolltolower="onreachBottom">
  50. <view class="empty" v-if="my_list2.length == 0">
  51. <image src="../../static/images/empty_active.png" mode=""></image>
  52. <text>您还没有参与任何一项活动,快返回活动列表去寻找您感兴趣的活动加入吧!</text>
  53. </view>
  54. <view class="item" v-for="(item,index) in my_list2" :key="index" @click="to_detail(item)">
  55. <view class="img"
  56. :style="{backgroundImage:'url('+ (item.cover_resource?item.cover_resource.url :'' ) +')'}">
  57. <!-- <image :src="item.cover_resource.url" mode=""></image> -->
  58. </view>
  59. <view class="right">
  60. <view class="title">{{item.title}}</view>
  61. <view class="logo">
  62. <image
  63. :src="item.organization?item.organization.logo != null?item.organization.logo:'':''"
  64. mode=""></image>
  65. <text>{{item.organization?item.organization.name:'--'}}</text>
  66. </view>
  67. <view class="time">
  68. <text>{{item.start_time}}--{{item.end_time}}</text>|<text>{{item.shape_text}}活动</text>
  69. </view>
  70. <view class="free">
  71. <!-- {{item.money}} -->
  72. {{item.sign_up_nums}}/{{item.total_nums}}
  73. </view>
  74. </view>
  75. </view>
  76. </scroll-view>
  77. </swiper-item>
  78. </swiper>
  79. </view>
  80. </view>
  81. </template>
  82. <script>
  83. export default {
  84. data() {
  85. return {
  86. list: [{
  87. name: '我发起的'
  88. }, {
  89. name: '我参与的'
  90. }],
  91. current: 0, // tabs组件的current值,表示当前活动的tab选项
  92. swiperCurrent: 0, // swiper组件的current值,表示当前那个swiper-item是活动的
  93. search_text: '',
  94. my_list: [{
  95. title: '河南中医药大学药学院举办校友院举办校友…',
  96. logo: '../../static/images/logo.png',
  97. school: '河南中医药学院主办',
  98. time: '2021.09.28-2021.10.28',
  99. type: '线下活动',
  100. money: '免费'
  101. },
  102. {
  103. title: '河南中医药大学药学院举办校友院举办校友…',
  104. logo: '../../static/images/logo.png',
  105. school: '河南中医药学院主办',
  106. time: '2021.09.28-2021.10.28',
  107. type: '线下活动',
  108. money: '免费'
  109. },
  110. {
  111. title: '河南中医药大学药学院举办校友院举办校友…',
  112. logo: '../../static/images/logo.png',
  113. school: '河南中医药学院主办',
  114. time: '2021.09.28-2021.10.28',
  115. type: '线下活动',
  116. money: '免费'
  117. },
  118. {
  119. title: '河南中医药大学药学院举办校友院举办校友…',
  120. logo: '../../static/images/logo.png',
  121. school: '河南中医药学院主办',
  122. time: '2021.09.28-2021.10.28',
  123. type: '线下活动',
  124. money: '免费'
  125. }
  126. ],
  127. my_list2: [],
  128. scrollHeight: '',
  129. params: {
  130. },
  131. join_params: {},
  132. page: 1,
  133. last: false,
  134. }
  135. },
  136. onShow() {
  137. },
  138. onLoad() {
  139. this.my_list = []
  140. this.my_list2 = []
  141. this.get_active_list()
  142. },
  143. mounted() {
  144. let that = this;
  145. const res = uni.getSystemInfoSync();
  146. let height = res.windowHeight
  147. this.scrollHeight = height - 150
  148. console.log(that.scrollHeight)
  149. },
  150. methods: {
  151. // tabs通知swiper切换
  152. tabsChange(index) {
  153. console.log(index, '0')
  154. this.swiperCurrent = index;
  155. },
  156. // swiper-item左右移动,通知tabs的滑块跟随移动
  157. transition(e) {
  158. let dx = e.detail.dx;
  159. this.$refs.uTabs.setDx(dx);
  160. },
  161. // 由于swiper的内部机制问题,快速切换swiper不会触发dx的连续变化,需要在结束时重置状态
  162. // swiper滑动结束,分别设置tabs和swiper的状态
  163. animationfinish(e) {
  164. let current = e.detail.current;
  165. this.$refs.uTabs.setFinishCurrent(current);
  166. this.swiperCurrent = current;
  167. this.current = current;
  168. this.page = 1
  169. this.last = false
  170. this.search_text = ''
  171. if (this.current == 0) {
  172. this.my_list = []
  173. this.get_active_list()
  174. } else {
  175. console.log(this.current)
  176. this.my_list2 = []
  177. this.get_join_list()
  178. }
  179. },
  180. // scroll-view到底部加载更多
  181. onreachBottom() {
  182. console.log(';;;;;;;;;;;;;;;;;;;;;;;;;pppp')
  183. if (!this.last) {
  184. this.page++
  185. }
  186. if (this.swiperCurrent == 0) {
  187. this.get_active_list()
  188. } else {
  189. this.get_join_list()
  190. }
  191. },
  192. get_active_list() {
  193. this.params.title = this.search_text
  194. this.params.page = this.page
  195. this.params.me = 1
  196. this.$u.get('/page/activities', this.params).then(res => {
  197. console.log(res, 'active')
  198. let data = res.data.data
  199. if (this.page > 1 && data.length == 0) {
  200. uni.showToast({
  201. title: '暂无更多',
  202. icon: 'none'
  203. })
  204. this.last = true
  205. } else {
  206. this.my_list = this.my_list.concat(data)
  207. this.my_list = this.my_list.map(item => {
  208. item.start_time = item.start_time.slice(0, 10)
  209. item.end_time = item.end_time.slice(0, 10)
  210. return item
  211. })
  212. }
  213. })
  214. },
  215. get_join_list() {
  216. this.join_params.title = this.search_text
  217. this.join_params.page = this.page
  218. this.$u.get('/page/me-join-activity', this.join_params).then(res => {
  219. console.log(res, 'join')
  220. if (this.page > 1 && res.data.data.length == 0) {
  221. uni.showToast({
  222. title: '暂无更多',
  223. icon: 'none'
  224. })
  225. this.last = true
  226. } else {
  227. this.my_list2 = this.my_list2.concat(res.data.data)
  228. this.my_list2 = this.my_list2.map(item => {
  229. item.start_time = item.start_time.slice(0, 10)
  230. item.end_time = item.end_time.slice(0, 10)
  231. return item
  232. })
  233. }
  234. })
  235. },
  236. search() {
  237. if (this.swiperCurrent == 0) {
  238. this.my_list = []
  239. this.get_active_list()
  240. } else {
  241. this.my_list2 = []
  242. this.get_join_list()
  243. }
  244. },
  245. to_detail(item) {
  246. uni.navigateTo({
  247. url: '../activity/active_detail?id=' + item.id
  248. })
  249. }
  250. }
  251. }
  252. </script>
  253. <style lang="scss" scoped>
  254. page {
  255. height: 100%;
  256. overflow: hidden;
  257. background-color: #F9F9FB;
  258. }
  259. .my_active {
  260. padding: 0 16px;
  261. .search {
  262. display: flex;
  263. align-items: center;
  264. height: 52px;
  265. box-shadow: 0px 8px 16px rgba(12, 20, 61, 0.06);
  266. border-radius: 10px;
  267. margin-top: 20px;
  268. image {
  269. width: 16px;
  270. height: 16px;
  271. margin-left: 20px;
  272. margin-right: 20px;
  273. }
  274. }
  275. .card {
  276. margin-top: 20px;
  277. width: 100%;
  278. .tab {
  279. padding-bottom: 10px;
  280. background-color: #F9F9FB;
  281. }
  282. .swiper {
  283. // height: 100vh;
  284. // padding-bottom: 20px;
  285. .swiper-item {
  286. .empty {
  287. display: flex;
  288. flex-direction: column;
  289. align-items: center;
  290. justify-content: center;
  291. font-size: 14px;
  292. font-family: PingFang HK;
  293. font-weight: 400;
  294. line-height: 20px;
  295. color: #696969;
  296. opacity: 0.47;
  297. image {
  298. width: 94px;
  299. height: 51px;
  300. margin-bottom: 25px;
  301. }
  302. }
  303. .item{
  304. // height: 113px;
  305. background: #FFFFFF;
  306. box-shadow: 0px 8px 12px rgba(12, 20, 61, 0.06);
  307. border-radius: 10px;
  308. display: flex;
  309. align-items: center;
  310. margin-top: 14px;
  311. padding: 16px 10px;
  312. &:last-child{
  313. // padding-bottom: 20px;
  314. margin-bottom: 30px;
  315. }
  316. .img{
  317. width: 100px;
  318. height: 90px;
  319. overflow: hidden;
  320. border-radius: 6px;
  321. flex-shrink: 0;
  322. margin-right: 8px;
  323. background-size: cover;
  324. background-repeat: no-repeat;
  325. background-position: center;
  326. image{
  327. width: 100px;
  328. height: 92px;
  329. }
  330. }
  331. .right{
  332. width: 100%;
  333. .title{
  334. font-size: 15px;
  335. font-family: Graphit;
  336. font-weight: 500;
  337. color: #282828;
  338. overflow: hidden;
  339. -webkit-line-clamp: 1;
  340. text-overflow: ellipsis;
  341. display: -webkit-box;
  342. -webkit-box-orient: vertical;
  343. }
  344. .logo{
  345. display: flex;
  346. align-items: center;
  347. font-size: 13px;
  348. font-family: Graphit;
  349. font-weight: 500;
  350. color: #696969;
  351. margin-top: 2px;
  352. image{
  353. width: 24px;
  354. height: 24px;
  355. border-radius: 50%;
  356. margin-right: 6px;
  357. }
  358. }
  359. .time{
  360. font-size: 12px;
  361. font-family: PingFang HK;
  362. font-weight: 400;
  363. color: #B2B2B2;
  364. margin-top: 2px;
  365. overflow: hidden;
  366. -webkit-line-clamp: 1;
  367. text-overflow: ellipsis;
  368. display: -webkit-box;
  369. -webkit-box-orient: vertical;
  370. text:first-child{
  371. margin-right: 2px;
  372. }
  373. text:last-child{
  374. margin-left: 2px;
  375. }
  376. }
  377. .free {
  378. font-size: 14px;
  379. font-family: PingFang HK;
  380. font-weight: 500;
  381. color: #79573D;
  382. margin-top: 8px;
  383. }
  384. }
  385. }
  386. }
  387. }
  388. }
  389. }
  390. </style>