index.vue 7.3 KB

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