index1.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. <template>
  2. <view class="active">
  3. <!-- <view class="top">
  4. </view> -->
  5. <view class="add" @click="add">
  6. <view class="add-buttom">
  7. <image src="../../static/images/plus.png" mode=""></image>
  8. </view>
  9. <view class="add-tips">
  10. 创建活动
  11. </view>
  12. </view>
  13. <view class="top">
  14. </view>
  15. <view class="tab">
  16. <view v-for="(item,index) in tab_list" :key='index' :class="current_tab==item.id ? 'active-item' : 'item'"
  17. @click="changTab(item.id,item.name)">
  18. <view class="week">
  19. {{item.name}}
  20. </view>
  21. <text class="line" v-if="current_tab==item.id">
  22. </text>
  23. </view>
  24. </view>
  25. <view class="list" v-if="list.length>0">
  26. <view class="list-item" @click="detail(item.id)" v-for="(item,index) in list" :key='index'>
  27. <view class="tips">
  28. <u-icon name="eye" style="margin-right: 5px;" size="30"></u-icon>{{item.view_count? item.view_count :'0'}}
  29. </view>
  30. <image :src="item.cover_resource ? item.cover_resource.url : '../../static/images/avator.png'" mode="">
  31. </image>
  32. <view class="right">
  33. <view class="title">
  34. {{item.title}}
  35. </view>
  36. <view class="text">
  37. 发布人:{{item.admin_name}}
  38. </view>
  39. <view class="time">
  40. {{item.published_at}}
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="empty" v-else>
  46. <view class="enptyStatus">
  47. <image src="../../static/empty.png" mode=""></image>
  48. <view class="words">
  49. 暂无内容
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </template>
  55. <script>
  56. export default {
  57. data() {
  58. return {
  59. current_tab: 0,
  60. tab_list: ['学术前沿', '自主活动'],
  61. list: [],
  62. page: 1,
  63. last: false,
  64. tab_name: ''
  65. }
  66. },
  67. async onShow() {
  68. if (this.is_weixin()) {
  69. this.navTitle()
  70. }
  71. this.list = []
  72. this.page = 1
  73. this.last = false
  74. await this.getTabList()
  75. },
  76. onReachBottom() {
  77. if (!this.last) {
  78. this.page++
  79. }
  80. this.getList()
  81. },
  82. methods: {
  83. //判断是否是微信
  84. is_weixin() {
  85. let ua = navigator.userAgent.toLowerCase();
  86. return ua.indexOf('micromessenger') != -1;
  87. },
  88. navTitle() {
  89. let navTitle = document.getElementsByTagName('uni-page-head');
  90. navTitle[0].style.display = 'none'
  91. },
  92. //选择本周还是下周
  93. changTab(id, name) {
  94. this.list = []
  95. this.current_tab = id
  96. this.tab_name = name
  97. this.page = 1
  98. this.getList()
  99. },
  100. getTabList() {
  101. this.$u.get('/inform/category-user-tree', {
  102. type: 1
  103. }).then(res => {
  104. console.log(res, 'pp')
  105. this.tab_list = res.data
  106. this.current_tab = res.data[0].id
  107. this.getList()
  108. })
  109. },
  110. getList() {
  111. this.$u.get('/inform/information', {
  112. category_id: this.current_tab,
  113. page: this.page,
  114. per_page:15
  115. }).then(res => {
  116. console.log(res, 'ppp')
  117. let data = res.data.list
  118. console.log(res, 'course1')
  119. if (this.page > 1 && data.length == 0) {
  120. uni.showToast({
  121. title: '暂无更多',
  122. icon: 'none'
  123. })
  124. this.last = true
  125. } else {
  126. this.list = this.list.concat(data)
  127. }
  128. })
  129. },
  130. detail(id) {
  131. uni.navigateTo({
  132. url: './details?id=' + id
  133. })
  134. },
  135. //创建活动
  136. add() {
  137. uni.navigateTo({
  138. url: './add?category_id=' + this.current_tab + '&tab_name=' + this.tab_name
  139. })
  140. }
  141. }
  142. }
  143. </script>
  144. <style lang="scss" scoped>
  145. page {
  146. position: relative;
  147. background-color: rgba(238, 238, 238, 1);
  148. }
  149. .enptyStatus{
  150. display: flex;
  151. justify-content: center;
  152. align-items: center;
  153. flex-direction: column;
  154. padding: 30px 10px;
  155. image{
  156. width: 120px;
  157. height: 150px;
  158. margin-top: 80px;
  159. }
  160. .words{
  161. color: #ffae21;
  162. font-size: 18px;
  163. padding-top: 16px;
  164. }
  165. }
  166. .add {
  167. position: fixed;
  168. bottom: 95px;
  169. right: 20px;
  170. text-align: center;
  171. z-index: 6;
  172. .add-buttom {
  173. width: 40px;
  174. height: 40px;
  175. display: inline-block;
  176. text-align: center;
  177. line-height: 40px;
  178. border-radius: 50%;
  179. overflow: hidden;
  180. image{
  181. width: 40px;
  182. height: 40px;
  183. }
  184. }
  185. .add-tips {
  186. font-size: 12px;
  187. font-family: PingFang SC;
  188. font-weight: bold;
  189. line-height: 14px;
  190. color: #292929;
  191. // margin-top: 5px;
  192. }
  193. }
  194. .active {
  195. position: relative;
  196. height: 100%;
  197. .top {
  198. height: 132px;
  199. background-image: url(../../static/images/active-bg1.png);
  200. background-size: 100%;
  201. background-repeat: no-repeat;
  202. }
  203. .tab {
  204. display: flex;
  205. align-items: center;
  206. width: 80%;
  207. margin: 0 auto;
  208. .item,
  209. .active-item {
  210. margin-top: 17px;
  211. view {
  212. display: block;
  213. }
  214. font-size: 18px;
  215. font-family: PingFang SC;
  216. font-weight: bold;
  217. line-height: 20px;
  218. color: rgba(113, 113, 113, .43);
  219. opacity: 0.43;
  220. opacity: 1;
  221. flex: 1;
  222. text-align: center;
  223. .week {
  224. padding-bottom: 12px;
  225. }
  226. .line {
  227. width: 48px;
  228. height: 4px;
  229. background: #3B7653;
  230. opacity: 1;
  231. border-radius: 1px;
  232. display: block;
  233. margin: 0 auto;
  234. }
  235. }
  236. .active-item {
  237. font-size: 18px;
  238. font-family: PingFang SC;
  239. font-weight: bold;
  240. line-height: 20px;
  241. color: #3B7653;
  242. .week {
  243. padding-bottom: 8px;
  244. }
  245. }
  246. }
  247. .list {
  248. padding: 15px 15px;
  249. .list-item {
  250. background: #FFFFFF;
  251. opacity: 1;
  252. border-radius: 12px;
  253. padding: 15px 12px;
  254. position: relative;
  255. display: flex;
  256. align-items: center;
  257. margin-bottom: 10px;
  258. .tips {
  259. position: absolute;
  260. width: 52px;
  261. height: 21px;
  262. text-align: center;
  263. line-height: 21px;
  264. background: #72D6A0;
  265. top: 0;
  266. right: 0;
  267. opacity: 1;
  268. border-radius: 0px 12px 0px 12px;
  269. font-size: 12px;
  270. font-family: PingFang SC;
  271. color: #fff;
  272. }
  273. image {
  274. flex: 0 0 86px;
  275. width: 86px;
  276. height: 60px;
  277. margin-right: 6px;
  278. }
  279. .right {
  280. flex: 1;
  281. margin-left: 3px;
  282. .title {
  283. width: 200px;
  284. font-size: 16px;
  285. font-family: PingFang SC;
  286. font-weight: bold;
  287. line-height: 20px;
  288. color: #282828;
  289. overflow: hidden;
  290. opacity: 1;
  291. white-space: nowrap;
  292. /*设置不换行*/
  293. overflow: hidden;
  294. /*设置隐藏*/
  295. text-overflow: ellipsis;
  296. /*设置隐藏部分为省略号*/
  297. }
  298. .text {
  299. font-size: 13px;
  300. font-family: PingFang SC;
  301. font-weight: 400;
  302. line-height: 20px;
  303. color: rgba(40, 40, 40, .47);
  304. margin-top: 3px;
  305. }
  306. .time {
  307. font-size: 10px;
  308. font-family: PingFang SC;
  309. font-weight: 400;
  310. line-height: 20px;
  311. color: #282828;
  312. }
  313. }
  314. }
  315. }
  316. }
  317. </style>