index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. <template>
  2. <view class="active-list">
  3. <!-- 活动查询 -->
  4. <view class="active-list-search">
  5. <!-- 搜索框 -->
  6. <view class="search">
  7. <u-input placeholder="输入活动名称或参赛项目" border='none' v-model="search" @input="searchText">
  8. <template slot="suffix" style='margin-right:40rpx;'>
  9. <u-image :showLoading="true" :showError='true' src="/static/icon/search.png" width="40rpx"
  10. height="32rpx"></u-image>
  11. </template>
  12. </u-input>
  13. </view>
  14. <view class="tab_nav">
  15. <view class="navTitle" v-for="(item,index) in items" :key="index">
  16. <view :class="{'active':isActive === index}" @click="checked(index,item.id)">
  17. {{item.name}}
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="msg-null" v-if="List.length == 0">
  23. <image src="https://t9.9026.com/imgs/dataNull.png" style="width: 394rpx;height: 396rpx;" mode=""></image>
  24. <view class="msg-null-text">
  25. <text>暂无数据</text>
  26. </view>
  27. </view>
  28. <view class="List" v-if="List.length > 0">
  29. <template v-for="(item,index) in List" >
  30. <view class="ListItem" v-if="item.show_status" :key="index" @click="activeDetail(item.id)">
  31. <image :src="item.banners?item.cover_img:'http://t9.9026.com/imgs/Kudosbg.png'" style="width: 640rpx;height:420rpx;border-radius: 12rpx;"></image>
  32. <view class="kudosicon" @click.stop="kudosActive(item.id,index)">
  33. <image src="/static/icon/Kudos.png" v-if="item.is_like==0"></image>
  34. <image src="/static/icon/Kudos(1).png" v-if="item.is_like==1"></image>
  35. </view>
  36. <view class="nav">
  37. <view class="events">
  38. <text>{{item.title}}</text>
  39. </view>
  40. <view class="voteStatus" style="width: 100rpx;">
  41. <text style="font-size: 30rpx;color: #999;" v-if="item.activity_status==1">未开始</text>
  42. <text style="font-size: 30rpx;color: #FF6503;" v-if="item.activity_status==2">进行中</text>
  43. <text style="font-size: 30rpx;color: #999;" v-if="item.activity_status==3">已结束</text>
  44. </view>
  45. </view>
  46. <view class="foot">
  47. <image src="/static/icon/data.png"></image>
  48. <text>{{item.end_time}} 结束</text>
  49. </view>
  50. </view>
  51. </template>
  52. </view>
  53. <!-- 触底 -->
  54. <view class="home-bottom" v-if="List.length > 0">
  55. <uni-load-more :status="status" color="#CCCCCC" :content-text="contentText"/>
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. import util from '@/utils/util.js'
  61. export default {
  62. data() {
  63. return {
  64. //活动分类categoryId
  65. categoryId:'',
  66. // 搜索
  67. search:'',
  68. //分段器
  69. items: [{
  70. name: '热门活动'
  71. },
  72. {
  73. name: '西区活动'
  74. }, {
  75. name: '酒店评选'
  76. },
  77. {
  78. name: '旅游推选'
  79. }
  80. ],
  81. //激活指定table菜单
  82. isActive: 0,
  83. status: 'noMore',
  84. contentText: {
  85. contentdown: '查看更多',
  86. contentrefresh: '加载中',
  87. contentnomore: '—— 已经到底啦 ——'
  88. },
  89. // 活动列表
  90. List:[],
  91. }
  92. },
  93. onLoad() {
  94. // this.getList()
  95. this.getCategoryList()
  96. console.log(util,"until")
  97. },
  98. methods: {
  99. // 获取活动列表
  100. getList(category_id){
  101. this.$api.active.getActiveList({
  102. page:0,
  103. keyword:'',
  104. category_id:`${category_id}`
  105. }).then(res=>{
  106. console.log(res,'活动列表')
  107. if(res.code==0){
  108. this.List=res.data.data
  109. console.log(this.List,'--->this.List');
  110. }
  111. })
  112. },
  113. // 获取分类列表
  114. getCategoryList(){
  115. this.$api.category.getCategoryList({
  116. page:1,
  117. type:1
  118. }).then(res=>{
  119. console.log(res,"活动分类列表")
  120. if(res.code==0){
  121. this.items=res.data.data
  122. this.categoryId = this.items[0].id
  123. console.log(this.categoryId,'--->this.categoryId');
  124. this.getList(this.categoryId)
  125. }
  126. })
  127. },
  128. // 点赞活动
  129. kudosActive(id,index){
  130. let beforeLike=this.List[index].is_like
  131. this.$api.active.kudos({
  132. activity_id:id
  133. }).then(res=>{
  134. console.log(res,'点赞')
  135. if(res.code==0){
  136. if(beforeLike==1){
  137. this.List[index].is_like=0
  138. }else{
  139. this.List[index].is_like=1
  140. }
  141. }
  142. })
  143. },
  144. //菜单index切换
  145. checked(index,id) {
  146. this.isActive = index
  147. this.getList(id)
  148. console.log(this.isActive,'---->this.isActive');
  149. },
  150. // 活动详情页
  151. activeDetail(id){
  152. uni.navigateTo({
  153. url:'/pages/index/active-detail/index?id='+id
  154. })
  155. },
  156. // 搜索防抖
  157. searchText:util.debounce(function(){
  158. if(this.search !=''){
  159. this.goSearch()
  160. }else{
  161. this.getList(this.categoryId)
  162. }
  163. },1000),
  164. //搜索
  165. goSearch(){
  166. uni.showLoading({
  167. title:'加载中'
  168. })
  169. this.$api.active.getActiveList({
  170. page:1,
  171. keyword:this.search,
  172. category_id:''
  173. }).then(res=>{
  174. if(res.code==0){
  175. uni.hideLoading()
  176. this.List=res.data.data
  177. console.log(this.List,'--->this.list');
  178. }
  179. })
  180. },
  181. }
  182. }
  183. </script>
  184. <style lang="scss" scoped>
  185. $pageColor:#F9F9F9;
  186. $bgColor:#FFFFFF;
  187. @mixin flexlayout {
  188. display: flex;
  189. align-items: center;
  190. justify-content: center;
  191. }
  192. .active-list {
  193. height: 100%;
  194. background: #F9F9F9;
  195. }
  196. .msg-null{
  197. margin-top: 224rpx;
  198. display: flex;
  199. flex-direction: column;
  200. align-items: center;
  201. justify-content: center;
  202. padding-top: 60rpx;
  203. .msg-null-text{
  204. margin-top: 40rpx;
  205. font-size: 28rpx;
  206. color: #333;
  207. }
  208. }
  209. .home-bottom {
  210. background-color: #f9f9f9;
  211. padding-bottom: 84rpx;
  212. }
  213. .active-list-search {
  214. padding: 24rpx 30rpx 32rpx;
  215. height: 222rpx;
  216. background-color: #FFFFFF;
  217. width: 100%;
  218. position: fixed;
  219. top: 0;
  220. z-index: 99;
  221. // 搜索
  222. .search {
  223. ::v-deep .u-input {
  224. width: 690rpx !important;
  225. height: 68rpx !important;
  226. background: #F1F1F1;
  227. border-radius: 74rpx;
  228. }
  229. ::v-deep .u-input__content__field-wrapper {
  230. padding-left: 36rpx;
  231. }
  232. ::v-deep .u-input__content__field-wrapper__field{
  233. color:#999999 !important;
  234. font-size: 28rpx !important;
  235. }
  236. }
  237. //菜单切换
  238. .tab_nav {
  239. width: 100%;
  240. margin-top: 32rpx;
  241. display: flex;
  242. justify-content: space-between;
  243. align-items: center;
  244. font-family: PingFang-SC-Heavy, PingFang-SC;
  245. }
  246. .tab_nav .navTitle {
  247. width: 150rpx;
  248. flex: none;
  249. height: 28rpx;
  250. font-size: 32rpx;
  251. color: #666;
  252. position: relative;
  253. }
  254. .active {
  255. color: #D9A94D;
  256. font-weight: bold;
  257. &::after {
  258. display: inline-block;
  259. content: '';
  260. width: 48rpx;
  261. height: 12rpx;
  262. background: linear-gradient(90deg, #F3D69F 0%, #D9A94D 100%);
  263. border-radius: 6px;
  264. position: absolute;
  265. bottom:-40rpx;
  266. left:40rpx;
  267. }
  268. }
  269. }
  270. .List {
  271. padding: 0 30rpx;
  272. box-sizing: border-box;
  273. padding-top: 20rpx;
  274. padding-bottom:88rpx ;
  275. background-color: #F9F9F9;
  276. margin-top: 222rpx;
  277. .ListItem {
  278. position: relative;
  279. margin-bottom: 24rpx;
  280. width: 100%;
  281. height: 562rpx;
  282. background: #F9F9F9;
  283. box-shadow: 0rpx 12rpx 40rpx 0rpx rgba(220, 222, 229, 0.4);
  284. border-radius: 24rpx;
  285. padding: 20rpx 26rpx 26rpx 24rpx;
  286. .kudosicon {
  287. width: 48rpx;
  288. height: 48rpx;
  289. position: absolute;
  290. top: 52rpx;
  291. right: 58rpx;
  292. border-radius: 50%;
  293. background: #FFFFFF;
  294. opacity: 0.84;
  295. @include flexlayout() image {
  296. width: 32rpx;
  297. height: 28rpx;
  298. }
  299. }
  300. .nav {
  301. display: flex;
  302. align-items: flex-start;
  303. justify-content: space-between;
  304. .events {
  305. text {
  306. font-size: 30rpx;
  307. font-family: PingFang-SC-Bold, PingFang-SC;
  308. font-weight: bold;
  309. color: #333333;
  310. }
  311. }
  312. .voteStatus {
  313. font-size: 30rpx;
  314. font-family: PingFang-SC-Medium, PingFang-SC;
  315. font-weight: 500;
  316. color: #999999;
  317. }
  318. }
  319. .foot {
  320. margin-top: 10rpx;
  321. display: flex;
  322. align-items: center;
  323. image {
  324. width: 28rpx;
  325. height: 28rpx;
  326. margin-right: 8rpx;
  327. }
  328. text {
  329. font-size: 24rpx;
  330. font-family: PingFang-SC-Medium, PingFang-SC;
  331. font-weight: 500;
  332. color: #999999;
  333. display: block;
  334. }
  335. }
  336. }
  337. }
  338. </style>