dashboard.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <template>
  2. <view class="box">
  3. <u-navbar :autoBack="true" title="答题" bgColor="rgba(255,255,255,0)" :placeholder="true" titleStyle="font-weight:bold;color:#000000"></u-navbar>
  4. <view>
  5. <u-swiper
  6. :list="bannerlist"
  7. imgMode="aspectFill"
  8. :height="200"
  9. :indicator="true"
  10. radius="5"
  11. :autoplay="true"
  12. :circular="true"
  13. indicatorStyle="bottom: 10px"
  14. indicatorMode="dot"
  15. indicatorActiveColor="#fff"
  16. indicatorInactiveColor="rgba(255, 255, 255, 0.35)"
  17. ></u-swiper>
  18. </view>
  19. <view>
  20. <view class="flex justify-center gui-margin-top" style="margin-top: 40rpx">
  21. <view style="width: 300rpx">
  22. <u-subsection :list="tablist" :current="testIndex" mode="subsection" @change="onTestSelect"></u-subsection>
  23. </view>
  24. </view>
  25. <view class="activity-list">
  26. <view class="b-items" v-if="state.items.length > 0">
  27. <view class="b-item" v-for="(item, index) in state.items" :key="index" @click="onJumpActivitty(item.id)">
  28. <view class="b-cover" v-if="item.cover_url">
  29. <image :src="item.cover_url" mode="aspectFill"></image>
  30. </view>
  31. <view class="b-main">
  32. <text class="b-title">{{ item.name }}</text>
  33. <view class="b-time">
  34. <view class="s-start">开始时间 {{ datetime(item.start_time) }}</view>
  35. <view class="s-end">结束时间 {{ datetime(item.end_time) }}</view>
  36. </view>
  37. <view class="b-foot">
  38. <view class="b-state">
  39. <view class="s-state f-wait" v-if="item.state == 0">未开始</view>
  40. <view class="s-state f-ing" v-else-if="item.state == 1">进行中</view>
  41. <view class="s-state f-end" v-else-if="item.state == 2">已结束</view>
  42. </view>
  43. <view class="b-action">
  44. <view class="s-enter">进入活动</view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. <!-- 加载中 -->
  53. <load-more :loadingType="loadingType" :loadingText="loadingText"></load-more>
  54. </view>
  55. </template>
  56. <script>
  57. import { getActivityList } from '@/service/api/common.js';
  58. import { formatDate } from '../../common/util.js';
  59. // import mixinsCommon from '@/mixins/common.js';
  60. let that;
  61. export default {
  62. // mixins: [mixinsCommon],
  63. data() {
  64. return {
  65. official: false,
  66. tablist: ['全部', '比赛', '练习'],
  67. src: 'https://huli-app.wenlvti.net/uploads/20230608/8432937eabc5a32dcdbab19d2ab68f51.png',
  68. shh: 'https://huli-app.wenlvti.net/uploads/20230608/667d2bde4141dbe791d8a080edc90d38.png',
  69. jfdh: 'https://huli-app.wenlvti.net/uploads/20230608/462f2c03a21e5e66a82837e253198bac.png',
  70. testIndex: 0,
  71. testList: [
  72. {
  73. name: '全部',
  74. value: 'all'
  75. },
  76. {
  77. name: '比赛',
  78. value: '1'
  79. },
  80. {
  81. name: '练习',
  82. value: '2'
  83. }
  84. ],
  85. state: {
  86. items: []
  87. },
  88. loadingType: 1,
  89. loadingText: '',
  90. bannerlist: ['https://huli-app.wenlvti.net/app_static/WenWuGuanJia/image/dati_bg.png'],
  91. tasklist: [],
  92. page: 1
  93. };
  94. },
  95. onLoad(options) {
  96. that = this;
  97. this.loadActivityList(true);
  98. // 清空了activityId导致积分进不去
  99. // if (this.$store.getters.activityId) {
  100. // this.$store.commit('delActivityId');
  101. // }
  102. // this.getBannerList();
  103. },
  104. onShow() {
  105. // 获取任务列暂时注释
  106. // this.getTaskList();
  107. },
  108. onReachBottom() {
  109. if (this.loadingType !== 1 && this.loadingType !== 2) {
  110. this.loadActivityList();
  111. }
  112. },
  113. computed: {
  114. datetime() {
  115. return (timestamp) => {
  116. return formatDate(timestamp, 'yyyy-MM-dd hh:mm');
  117. };
  118. }
  119. },
  120. methods: {
  121. // getBannerList() {
  122. // this.$api.getBannerList({ block: 'Examine', type: 'banner' }, function (res) {
  123. // if (res.code > 0) {
  124. // that.bannerlist = [];
  125. // for (var i = 0; i < res.data.length; i++) {
  126. // that.bannerlist.push({ title: res.data[i].title, url: that.$config.baseUrl + res.data[i].image, page: res.data[i].url });
  127. // }
  128. // }
  129. // });
  130. // },
  131. bannerClick(index) {
  132. this.$common.navigateTo(this.bannerlist[index].page);
  133. },
  134. getTaskList() {
  135. this.$api.getTaskList({}, function (res) {
  136. console.log(res);
  137. that.tasklist = res.data;
  138. });
  139. },
  140. loadActivityList(refresh) {
  141. // console.log('-------------------------------');
  142. // console.log('loadActivityList', refresh);
  143. if (refresh) {
  144. this.page = 1;
  145. this.state.items = [];
  146. } else {
  147. this.page++;
  148. }
  149. this.loadingType = 1;
  150. this.loadingText = '';
  151. getActivityList(this.testList[this.testIndex].value, this.page, 10).then(([err, res]) => {
  152. console.log('getActivityList', err, res);
  153. this.loadingType = -1;
  154. if (!err) {
  155. if (res.items.length > 0) {
  156. this.state.items = [...this.state.items, ...res.items];
  157. } else {
  158. this.loadingType = 2;
  159. if (this.page == 1) {
  160. this.loadingText = '暂无数据';
  161. }
  162. this.page--; // 重置分页
  163. }
  164. } else {
  165. this.loadingType = 3;
  166. }
  167. });
  168. },
  169. onTestSelect(index) {
  170. this.testIndex = index;
  171. this.loadActivityList(true);
  172. },
  173. onJumpActivitty(id) {
  174. uni.navigateTo({
  175. url: '/answer_pages/home/welcome?from=jump&aid=' + id
  176. });
  177. }
  178. }
  179. };
  180. </script>
  181. <style lang="scss">
  182. /deep/.u-swiper-indicator__wrapper__dot--active {
  183. width: 5px !important;
  184. }
  185. .box {
  186. height: auto;
  187. width: 100%;
  188. padding-bottom: 50rpx;
  189. background-image: url('https://huli-app.wenlvti.net/app_static/WenWuGuanJia/image/xy_bgt.png');
  190. background-repeat: repeat-y;
  191. background-attachment: fixed;
  192. background-size: 100% 100%;
  193. }
  194. .number {
  195. background-color: #ff5500;
  196. width: 60rpx;
  197. height: 60rpx;
  198. color: white;
  199. text-align: center;
  200. font-size: 40rpx;
  201. padding: 10rpx;
  202. margin: 35rpx;
  203. border-radius: 60upx;
  204. }
  205. .wrap {
  206. }
  207. .filter-box {
  208. padding: 40upx;
  209. background: #fff;
  210. display: flex;
  211. align-items: center;
  212. justify-content: space-around;
  213. .b-item {
  214. width: 240upx;
  215. display: flex;
  216. align-items: center;
  217. justify-content: center;
  218. font-size: 30upx;
  219. &.f-active {
  220. font-weight: bold;
  221. }
  222. .s-tit {
  223. color: #333;
  224. }
  225. }
  226. }
  227. .activity-list {
  228. padding: 40upx 40upx 0 40upx;
  229. .b-items {
  230. .b-item {
  231. margin-bottom: 40upx;
  232. border-bottom: 1upx solid #eee;
  233. display: flex;
  234. flex-direction: column;
  235. background: #fff;
  236. border-radius: 20upx;
  237. &:last-child {
  238. border-bottom: none;
  239. margin-bottom: 0;
  240. }
  241. .b-cover {
  242. width: 670upx;
  243. height: 300upx;
  244. image {
  245. border-radius: 20upx 20upx 0 0;
  246. width: 670upx;
  247. height: 300upx;
  248. }
  249. }
  250. .b-main {
  251. padding: 20upx;
  252. }
  253. .b-title {
  254. font-size: 32upx;
  255. }
  256. .b-time {
  257. margin-top: 10upx;
  258. display: flex;
  259. flex-direction: column;
  260. font-size: 26upx;
  261. color: #999;
  262. line-height: 40upx;
  263. }
  264. .b-foot {
  265. margin-top: 10upx;
  266. display: flex;
  267. align-items: center;
  268. justify-content: space-between;
  269. .b-state {
  270. .s-state {
  271. padding: 0 20upx;
  272. background: #da5650;
  273. color: #fff;
  274. font-size: 24upx;
  275. height: 40upx;
  276. line-height: 40upx;
  277. &.f-wait {
  278. background: #444c69;
  279. }
  280. &.f-ing {
  281. background: #ffc300;
  282. }
  283. &.f-end {
  284. background: #c4c4c4;
  285. }
  286. }
  287. }
  288. .b-action {
  289. .s-enter {
  290. padding: 0 30upx;
  291. height: 60upx;
  292. line-height: 60upx;
  293. text-align: center;
  294. color: #fff;
  295. font-size: 28upx;
  296. background: #da5650;
  297. border-radius: 30upx;
  298. }
  299. }
  300. }
  301. }
  302. }
  303. }
  304. </style>