myactivity.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. <template>
  2. <view class="myActivity">
  3. <!-- 页面头部 -->
  4. <view class="bg"></view>
  5. <u-navbar back-icon-color="#fff" :back-text="$t('common.Back')" :is-back="true"
  6. :background="{background:'#1777FE'}" :back-text-style="{color:'#fff'}" :border-bottom="true"
  7. title-color="#fff" :title="title" :custom-back="back">
  8. </u-navbar>
  9. <!-- 全屏选项卡 -->
  10. <view class="tabcontent">
  11. <u-tabs-swiper class="menu" ref="uTabs" swiperWidth="750" bar-width="100" bar-height="4"
  12. inactive-color="#666" :list="list" :current="current" :is-scroll="false" :bold="false"
  13. @change="tabsChange">
  14. </u-tabs-swiper>
  15. <!-- 选项卡绑定的页面 -->
  16. <swiper :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish">
  17. <swiper-item class="swiper-item" v-for="(item, index) in tabs" :key="index">
  18. <scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="onreachBottom">
  19. <view class="currentPage">
  20. <view class="pageitem" v-for="(pageitem,pageidx) in item.list" :key="pageidx"
  21. @click="showDetial(pageitem)">
  22. <view class="thumb">
  23. <image class="img" :src="pageitem.activityLogo"></image>
  24. <view class="tag" v-if="$i18n.locale=='en'"
  25. :class="{'uni':pageitem.activityTypeDict=='2','vip':pageitem.activityTypeDict=='1','ml':pageitem.activityTypeDict=='0'}">
  26. {{
  27. pageitem.activityType=='会员活动'?'Member':item.activityType=='联盟活动'?'Alliance':'Cooperation'
  28. }}
  29. </view>
  30. <view class="tag" v-else
  31. :class="{'uni':pageitem.activityTypeDict=='2','vip':pageitem.activityTypeDict=='1','ml':pageitem.activityTypeDict=='0'}">
  32. {{
  33. pageitem.activityType
  34. }}
  35. </view>
  36. </view>
  37. <view class="pageinfo">
  38. <view class="label">
  39. <view class="text">{{pageitem.activityName}}</view>
  40. <view class="sta unstart" v-if="pageitem.activityStatusDict=='0'">
  41. {{$t('common.Upcoming')}}
  42. </view>
  43. <view class="sta start" v-if="pageitem.activityStatusDict=='1'">
  44. {{$t('common.RegistrationOpen')}}
  45. </view>
  46. <view class="sta doing" v-if="pageitem.activityStatusDict=='2'">
  47. {{$t('common.Live')}}
  48. </view>
  49. <view class="sta finish" v-if="pageitem.activityStatusDict=='3'">
  50. {{$t('common.Closed')}}
  51. </view>
  52. </view>
  53. <view class="other">
  54. <view class="country">{{pageitem.activityCity}}</view>
  55. <view class="date"><text
  56. class="lab">{{$t('common.Releasedate')}}</text>{{formatDate(pageitem.activityStartTime)}}
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. <view class="nodata" v-if="!showLoading && tabs[swiperCurrent].list.length==0"
  63. style="text-align: center;margin-top: 120upx;">
  64. <view class="imgBox" style="height:400upx;margin-bottom:60upx">
  65. <image src="../../../static/img/public/7.png" style="width: 80%;margin:10%"
  66. mode="widthFix"></image>
  67. <text style="font-size:28upx;color:#ccc">{{$t('common.Nodata')}}</text>
  68. </view>
  69. </view>
  70. </scroll-view>
  71. </swiper-item>
  72. </swiper>
  73. </view>
  74. <!-- 页面优化提示 -->
  75. <view class="loading" v-if="showLoading" :class="{fixbottom:true}">
  76. <u-loadmore :status="status" iconType="flower" :load-text="{loading:this.$t('common.Loading')}" />
  77. </view>
  78. <u-toast ref="uToast" />
  79. </view>
  80. </template>
  81. <script>
  82. import UNavbar from '@/components/uni-nav-bar/uni-nav-bar.vue'
  83. export default {
  84. name: 'MyActivity',
  85. components: {
  86. UNavbar,
  87. },
  88. data() {
  89. return {
  90. title: '',
  91. list: [{
  92. name: this.$t('common.Live')
  93. },
  94. {
  95. name: this.$t('common.Finished'),
  96. }
  97. ],
  98. current: 0,
  99. swiperCurrent: 0,
  100. tabs: [{
  101. list: []
  102. },
  103. {
  104. list: []
  105. }
  106. ],
  107. pageNo: 1,
  108. pageSize: 10,
  109. totalPage: 0,
  110. showLoading: true,
  111. status: 'loading',
  112. token: '',
  113. userId: '',
  114. }
  115. },
  116. onLoad(e) {
  117. this.title = this.$i18n.locale == 'zh' ? '我的活动' : 'My Activity'
  118. },
  119. created() {
  120. },
  121. onShow() {
  122. this.token = uni.getStorageSync('Auth-Token') ? 'Bearer ' + uni.getStorageSync('Auth-Token') : '';
  123. this.userId = uni.getStorageSync('user') ? JSON.parse(uni.getStorageSync('user')).id : '';
  124. this.getActivityApplyById()
  125. },
  126. methods: {
  127. //路由后退一步
  128. back() {
  129. // #ifdef H5
  130. history.back()
  131. // #endif
  132. // #ifndef H5
  133. uni.navigateBack()
  134. // #endif
  135. },
  136. //切换选项卡
  137. tabsChange(index) {
  138. this.swiperCurrent = index;
  139. },
  140. transition(e) {
  141. let dx = e.detail.dx;
  142. this.$refs.uTabs.setDx(dx);
  143. },
  144. //滑动选项
  145. animationfinish(e) {
  146. let current = e.detail.current;
  147. this.$refs.uTabs.setFinishCurrent(current);
  148. this.swiperCurrent = current;
  149. this.current = current;
  150. this.showLoading = false;
  151. this.pageNo = 1;
  152. this.getActivityApplyById(this.swiperCurrent)
  153. },
  154. //下滑滚动刷新
  155. onreachBottom() {
  156. },
  157. // 获取我的活动列表
  158. async getActivityApplyById(index, loadmore) {
  159. this.tabs[0].list = [];
  160. this.tabs[1].list = [];
  161. let data = {
  162. pageNo: this.pageNo,
  163. pageSize: this.pageSize,
  164. id: this.userId,
  165. language: this.$i18n.locale.toUpperCase(),
  166. type: this.swiperCurrent.toString()
  167. };
  168. let res = await this.$myRequest({
  169. url: '/meeting/meetingApplys/getActivityApplyById',
  170. data,
  171. })
  172. if (res.status == 200) {
  173. if (res.data.activityInfos) {
  174. for (let i = 0; i < res.data.activityInfos.length; i++) {
  175. this.$set(res.data.activityInfos[i], 'activityLogo', 'https://m.geidcp.com/api/file/pub/' +
  176. res.data.activityInfos[i]
  177. .activityLogo)
  178. this.$set(res.data.activityInfos[i], 'activityStartTime', parseInt(res.data.activityInfos[
  179. i].activityStartTime))
  180. }
  181. if (loadmore) { // 加载更多
  182. this.tabs[this.swiperCurrent].list = [this.tabs[this.swiperCurrent].list, ...res.data
  183. .activityInfos
  184. ]
  185. } else {
  186. this.tabs[this.swiperCurrent].list = res.data.activityInfos
  187. }
  188. }
  189. this.showLoading = false;
  190. } else {
  191. this.showLoading = false;
  192. this.tabs[this.swiperCurrent].list = [];
  193. }
  194. },
  195. //路由跳转
  196. showDetial(item) {
  197. console.log(item)
  198. uni.navigateTo({
  199. url: '/pages/cooperationExchange/cooperationExchangeList/activitiesInfo?ActivitesId=' + item
  200. .baseActivityEntityId
  201. })
  202. }
  203. }
  204. }
  205. </script>
  206. <style lang="scss" scoped>
  207. .myActivity {
  208. .bg {
  209. position: fixed;
  210. width: 100%;
  211. right: 0;
  212. bottom: 0;
  213. top: 0;
  214. right: 0;
  215. background-color: #fafafa;
  216. z-index: -1;
  217. }
  218. .loading {
  219. width: 100%;
  220. padding: 20rpx 0;
  221. background-color: #fafafa;
  222. /deep/ .u-load-more-wrap {
  223. margin-top: 50rpx;
  224. }
  225. &.fixbottom {
  226. position: fixed;
  227. bottom: 0;
  228. z-index: 999;
  229. }
  230. }
  231. /deep/ .uni-swiper-wrapper {
  232. position: absolute;
  233. height: 90%;
  234. }
  235. .tabcontent {
  236. width: 100%;
  237. height: 90%;
  238. position: absolute;
  239. .menu {
  240. margin-bottom: 0px;
  241. border-bottom: 1px solid #eee;
  242. }
  243. }
  244. .currentPage {
  245. width: 96%;
  246. padding: 2%;
  247. margin: 0 auto;
  248. .pageitem {
  249. display: flex;
  250. margin: 20upx 0;
  251. border-radius: 20rpx;
  252. box-shadow: 1px 1px 6px 2px #f0f0f0;
  253. justify-content: space-between;
  254. overflow: hidden;
  255. .thumb {
  256. width: 220upx;
  257. height: 160upx;
  258. position: relative;
  259. overflow: hidden;
  260. .img {
  261. display: block;
  262. width: 100%;
  263. height: 160upx;
  264. }
  265. .tag {
  266. min-width: 120upx;
  267. height: 40upx;
  268. line-height: 40upx;
  269. text-align: center;
  270. position: absolute;
  271. left: 0;
  272. top: 0;
  273. z-index: 222;
  274. color: #fff;
  275. font-size: 24upx;
  276. border-radius: 0 0 20rpx 0;
  277. &.uni {
  278. background-color: #0091FF;
  279. }
  280. &.vip {
  281. background-color: #F19E38;
  282. }
  283. &.ml {
  284. background-color: #6DD400;
  285. }
  286. }
  287. }
  288. .pageinfo {
  289. width: 70%;
  290. padding: 0 16upx 0 16upx;
  291. .label {
  292. width: 100%;
  293. font-size: 28upx;
  294. display: flex;
  295. justify-content: space-between;
  296. margin-top: 10upx;
  297. .text {
  298. flex: 1;
  299. height: 80upx;
  300. line-height: 40upx;
  301. overflow: hidden;
  302. text-overflow: ellipsis;
  303. display: -webkit-box;
  304. -webkit-box-orient: vertical;
  305. -webkit-line-clamp: 2;
  306. font-size: 24upx;
  307. color: #555;
  308. }
  309. .sta {
  310. margin-left: 16upx;
  311. padding: 0 14upx;
  312. height: 36upx;
  313. line-height: 36upx;
  314. font-size: 24upx;
  315. font-weight: normal;
  316. text-align: center;
  317. border-radius: 20upx;
  318. &.unstart {
  319. border: 1px solid #0091FF;
  320. color: #0091FF;
  321. }
  322. &.start {
  323. border: 1px solid #80C93D;
  324. color: #80C93D;
  325. }
  326. &.doing {
  327. border: 1px solid #F7B500;
  328. color: #F7B500;
  329. }
  330. &.finish {
  331. border: 1px solid #aaa;
  332. color: #aaa;
  333. }
  334. }
  335. }
  336. .other {
  337. margin-top: 6upx;
  338. flex: 1;
  339. display: flex;
  340. justify-content: space-between;
  341. .country,
  342. .date {
  343. font-size: 24upx;
  344. color: #aaa;
  345. }
  346. .date {
  347. display: flex;
  348. justify-content: space-between;
  349. align-items: center;
  350. .lab {
  351. margin-right: 20upx;
  352. }
  353. }
  354. }
  355. }
  356. }
  357. }
  358. }
  359. </style>