index.vue 7.4 KB

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