index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  1. <template>
  2. <view class="">
  3. <view class="bg">
  4. </view>
  5. <view class="active position">
  6. <!-- 立即报名弹框 -->
  7. <u-popup v-model="show" mode="center" border-radius="19" :closeable="true" @close="close">
  8. <view class="pop_wrap">
  9. <view class="pop_top">
  10. <text class="title">请填写报名信息</text>
  11. </view>
  12. <view class="pop_center">
  13. <u-form label-width='120'>
  14. <u-form-item label="姓名" class="position">
  15. <view class="star">
  16. *
  17. </view>
  18. <u-input v-model="name" placeholder="请填写姓名" />
  19. </u-form-item>
  20. <u-form-item label="手机号" class="position">
  21. <view class="star">
  22. *
  23. </view>
  24. <u-input v-model="mobile" placeholder="请填写手机号" />
  25. </u-form-item>
  26. </u-form>
  27. </view>
  28. <view class="pop_bootom">
  29. <button type="default" @click="sure_sign">确认</button>
  30. </view>
  31. </view>
  32. </u-popup>
  33. <!-- <view :class="[this.is_weixin()?'':'wrap1','wrap']"> -->
  34. <view class="wrap">
  35. <view class="top_wrap">
  36. <!-- <view :class="[this.is_weixin()?'':'top1','top']"> -->
  37. <view class="top">
  38. <view class="search">
  39. <image src="../../static/images/search.png" mode=""></image>
  40. <input type="text" value="" v-model="query.title" placeholder="请输入活动名称"
  41. placeholder-style="font-size:14px;color:#D9D0C8;" @confirm="search" @input="get_text" />
  42. </view>
  43. <view class="search_right" @click="to_create">
  44. <image src="../../static/images/user-plus.png" mode=""></image>
  45. <text>发起活动</text>
  46. </view>
  47. </view>
  48. <view :class="[is_click?'':'close','menu']">
  49. <u-dropdown active-color="#674023" inactive-color="#6F6F6F" title-size="30" @open="menuClick"
  50. @close="close_menu">
  51. <u-dropdown-item v-model="active_type" title="活动类型" :options="type" @change="type_select">
  52. </u-dropdown-item>
  53. <u-dropdown-item v-model="sctive_shape" title="活动形式" :options="shape"
  54. @change="shape_select">
  55. </u-dropdown-item>
  56. </u-dropdown>
  57. </view>
  58. </view>
  59. </view>
  60. <!-- </view> -->
  61. <view class="active_list">
  62. <view class="empty" v-if="my_list.length == 0">
  63. <image src="../../static/images/empty_active.png" mode=""></image>
  64. <text>暂无内容</text>
  65. </view>
  66. <view class="item" v-for="(item,index) in my_list" :key="index" @click="to_detail(item)">
  67. <view class="img">
  68. <image :src="item.cover_resource.url" mode="aspectFill"></image>
  69. </view>
  70. <view class="right">
  71. <view class="title">{{item.title}}</view>
  72. <view class="logo">
  73. <image :src="item.organization?item.organization.logo:logo" mode=""></image>
  74. <text>{{item.organization?item.organization.name:'--'}}</text>
  75. </view>
  76. <view class="time">
  77. <!-- <text>{{item.start_time}}--{{item.end_time}}</text>|<text>{{item.shape_text}}活动</text> -->
  78. <text>{{getTime(item.start_time)}}-{{getTime(item.end_time)}}</text>|<text>{{item.shape_text}}活动</text>
  79. </view>
  80. <view class="bottom">
  81. <view class="free">
  82. <!-- {{item.money}} -->
  83. {{item.sign_up_nums}}/{{item.total_nums}}
  84. </view>
  85. <view class="btn" @click.stop="signUp(item)" v-if="item.state.status == 1">
  86. 马上报名
  87. </view>
  88. <view v-else :class="item.state.status == 3 ? 'btn_over' :'btn_check'">
  89. {{item.state.status_text}}
  90. </view>
  91. </view>
  92. </view>
  93. </view>
  94. </view>
  95. </view>
  96. </view>
  97. </template>
  98. <script>
  99. export default {
  100. components: {},
  101. data() {
  102. return {
  103. show: false,
  104. prop: '',
  105. type: [
  106. {
  107. label: '全部',
  108. value: 0
  109. },
  110. ],
  111. shape: [
  112. {
  113. label: '全部',
  114. value: 0
  115. }
  116. ],
  117. active_type: '',
  118. sctive_shape: '',
  119. my_list: [],
  120. query: {},
  121. logo: '../../static/images/logo.png',
  122. page: 1,
  123. last: false,
  124. mobile: '',
  125. name: '',
  126. // 解决吸顶遮挡问题
  127. is_click: false
  128. }
  129. },
  130. onShow() {
  131. },
  132. async onLoad() {
  133. this.page = 1
  134. this.my_list = []
  135. this.last = false
  136. await this.getList()
  137. this.get_shape()
  138. this.get_setting()
  139. },
  140. onReachBottom() {
  141. if (!this.last) {
  142. this.page++
  143. }
  144. this.getList()
  145. },
  146. methods: {
  147. menuClick(e) {
  148. this.is_click = true
  149. },
  150. close_menu() {
  151. this.is_click = false
  152. },
  153. to_detail(item) {
  154. uni.navigateTo({
  155. url: '/pages/activity/active_detail?id=' + item.id,
  156. success: res => {
  157. },
  158. fail: (e) => {
  159. },
  160. complete: () => {}
  161. })
  162. },
  163. getTime(time) {
  164. let time1 = time.split(' ')
  165. let time2 = time1[0]
  166. return time2.replace(/\-/g, '.')
  167. },
  168. close() {
  169. this.name = ''
  170. this.mobile = ''
  171. },
  172. //立即报名
  173. signUp(item) {
  174. if (this.vuex_token) {
  175. this.prop = item
  176. let time = item.start_time
  177. let time1 = time.split(' ')
  178. let time2 = time1[0]
  179. this.prop.start_time = time2
  180. this.show = true
  181. } else {
  182. uni.reLaunch({
  183. url: '../login/index'
  184. })
  185. }
  186. },
  187. sure_sign(id) {
  188. if (!this.name) {
  189. uni.showToast({
  190. title: '请输入姓名!',
  191. icon: 'none'
  192. })
  193. return
  194. }
  195. if (!this.mobile) {
  196. uni.showToast({
  197. title: '请输入手机号!',
  198. icon: 'none'
  199. })
  200. return
  201. }
  202. let data = {
  203. activity_id: this.prop.id,
  204. name: this.name,
  205. mobile: this.mobile
  206. }
  207. this.$u.post('/page/sign-up-activity', data).then(res => {
  208. console.log(res, '报名提交成功')
  209. this.show = false
  210. uni.reLaunch({
  211. url: '../organization/success'
  212. })
  213. })
  214. },
  215. get_text(e) {
  216. console.log(e, '0000')
  217. this.query.title = e.detail.value
  218. },
  219. search() {
  220. this.page = 1
  221. this.my_list = []
  222. console.log(this.query, 'query')
  223. this.getList()
  224. },
  225. //获取活动
  226. getList() {
  227. this.query.page = this.page
  228. this.$u.get('/page/activities', this.query).then(res => {
  229. console.log(res, 'ppp')
  230. if (this.page > 1 && res.data.data.length == 0) {
  231. uni.showToast({
  232. title: '暂无更多',
  233. icon: 'none'
  234. })
  235. this.last = true
  236. } else {
  237. this.my_list = this.my_list.concat(res.data.data)
  238. // this.my_list = this.my_list.map(item => {
  239. // item.start_time = item.start_time.slice(0, 10)
  240. // item.end_time = item.end_time.slice(0, 10)
  241. // return item
  242. // })
  243. }
  244. })
  245. },
  246. //点击下拉菜单
  247. search_type(e) {
  248. console.log(e, 'searchj')
  249. },
  250. //选择活动类型
  251. type_select(e) {
  252. console.log(e, 'tuyp')
  253. this.query.type_id = e
  254. this.page = 1
  255. this.last = false
  256. this.my_list = []
  257. this.getList()
  258. console.log(this.type, 'type')
  259. },
  260. //选择活动形式
  261. shape_select(e) {
  262. this.query.shape = e
  263. console.log(this.query.shape, 'this.query.shape')
  264. this.page = 1
  265. this.last = false
  266. this.my_list = []
  267. this.getList()
  268. console.log(this.shape, 'shape')
  269. },
  270. //获取类型配置
  271. get_setting() {
  272. this.$u.get('/setting/get-lists?key=ACTIVITY_TYPE').then(res => {
  273. console.log(res.data, 'leix')
  274. this.type = this.type.concat(res.data.data.map((item, index) => {
  275. return {
  276. label: item.value,
  277. value: item.id
  278. }
  279. }))
  280. console.log(this.type, '11111111')
  281. uni.setStorageSync('type', this.type)
  282. })
  283. },
  284. //获取活动形式
  285. get_shape() {
  286. this.$u.get('/common/enums').then(res => {
  287. console.log(res,'0000000000000')
  288. for(var key in res.data.ActivityShapeEnum){
  289. console.log(key,'key')
  290. this.shape.push({label: res.data.ActivityShapeEnum[key],
  291. value: key})
  292. }
  293. console.log(this.shape,'shapoe')
  294. uni.setStorageSync('shape', this.shape)
  295. })
  296. },
  297. to_create() {
  298. if (this.vuex_token) {
  299. uni.navigateTo({
  300. url: './create_active',
  301. success: res => {
  302. console.log(111)
  303. },
  304. fail: (e) => {
  305. console.log(e)
  306. },
  307. complete: () => {}
  308. })
  309. } else {
  310. uni.reLaunch({
  311. url: '../login/index'
  312. })
  313. }
  314. }
  315. }
  316. }
  317. </script>
  318. <style lang="scss" scoped>
  319. page {
  320. // padding-top: 10px;
  321. background-color: #F9F9FB;
  322. }
  323. .active {
  324. padding: 0 0 20px;
  325. // background-color: #F9F9FB;
  326. //添加弹框
  327. .pop_wrap {
  328. width: 290px;
  329. height: 280px;
  330. display: flex;
  331. flex-direction: column;
  332. align-items: center;
  333. .pop_top {
  334. margin-top: 20px;
  335. text {
  336. display: block;
  337. font-size: 13px;
  338. color: rgba(40, 40, 40, 0.5);
  339. text-align: center;
  340. line-height: 22px;
  341. padding: 0 20px;
  342. }
  343. .title {
  344. font-size: 18px;
  345. font-weight: bold;
  346. color: #282828;
  347. line-height: 25px;
  348. margin-bottom: 2px;
  349. }
  350. }
  351. .pop_center {
  352. margin-top: 15px;
  353. text {
  354. font-size: 14px;
  355. font-family: PingFang SC;
  356. font-weight: 400;
  357. line-height: 20px;
  358. color: #353535;
  359. opacity: 0.79;
  360. display: block;
  361. margin-bottom: 6px;
  362. }
  363. .position{
  364. position: relative;
  365. .star{
  366. position: absolute;
  367. left: -10px;
  368. color: red;
  369. }
  370. }
  371. }
  372. .pop_bootom {
  373. margin-top: 25px;
  374. button {
  375. border: 1px solid #FF5A26;
  376. width: 98px;
  377. // height: 36px;
  378. padding: 0 5px;
  379. line-height: 36px;
  380. background-color: #fff;
  381. color: #FF5A26;
  382. }
  383. }
  384. }
  385. .wrap {
  386. position: fixed;
  387. width: 100%;
  388. background-color: #F9F9FB;
  389. top: 0;
  390. z-index: 12;
  391. height: 140px;
  392. }
  393. .wrap1{
  394. height: 160px;
  395. }
  396. .top_wrap {
  397. position: fixed;
  398. // top: 40px;
  399. top: 0;
  400. left: 16px;
  401. right: 16px;
  402. z-index: 12;
  403. // background-color: #F9F9FB;
  404. }
  405. // .top_wrap1 {
  406. // position: fixed;
  407. // // top: 10px;
  408. // left: 16px;
  409. // right: 16px;
  410. // z-index: 12;
  411. // background-color: #F9F9FB;
  412. // }
  413. .top {
  414. display: flex;
  415. align-items: center;
  416. justify-content: space-between;
  417. // padding: 0 16px;
  418. // padding-top: 10px;
  419. margin-top: 10px;
  420. height: 52px;
  421. .search {
  422. display: flex;
  423. align-items: center;
  424. height: 52px;
  425. box-shadow: 0px 8px 16px rgba(12, 20, 61, 0.06);
  426. border-radius: 10px;
  427. flex-shrink: 0;
  428. margin-right: 14px;
  429. flex: 1;
  430. image {
  431. width: 16px;
  432. height: 16px;
  433. margin-left: 20px;
  434. margin-right: 20px;
  435. }
  436. }
  437. .search_right {
  438. font-size: 12px;
  439. font-family: PingFang SC;
  440. font-weight: bold;
  441. line-height: 20px;
  442. color: #84705E;
  443. // width: 48px;
  444. height: 39px;
  445. text-align: center;
  446. image {
  447. width: 25px;
  448. height: 20px;
  449. }
  450. text {
  451. display: block;
  452. }
  453. }
  454. }
  455. .top1 {
  456. margin-top: 50px
  457. }
  458. .menu {
  459. height: 40px;
  460. // margin-top: 100px;
  461. margin-top: 20px;
  462. // overflow: hidden;
  463. }
  464. .close {
  465. overflow: hidden;
  466. }
  467. .active_list {
  468. padding: 120px 16px 0;
  469. // padding: 0 16px;
  470. // margin-top: 120px;
  471. .empty {
  472. display: flex;
  473. flex-direction: column;
  474. align-items: center;
  475. justify-content: center;
  476. font-size: 14px;
  477. font-family: PingFang HK;
  478. font-weight: 400;
  479. line-height: 20px;
  480. color: #696969;
  481. opacity: 0.47;
  482. image {
  483. width: 94px;
  484. height: 51px;
  485. margin-bottom: 25px;
  486. }
  487. }
  488. .item {
  489. // height: 113px;
  490. background: #FFFFFF;
  491. box-shadow: 0px 8px 12px rgba(12, 20, 61, 0.06);
  492. border-radius: 10px;
  493. display: flex;
  494. align-items: center;
  495. margin-top: 14px;
  496. padding: 16px 10px;
  497. &:first-child{
  498. // margin-top: 45px;
  499. }
  500. .img {
  501. width: 100px;
  502. height: 92px;
  503. overflow: hidden;
  504. border-radius: 6px;
  505. flex-shrink: 0;
  506. margin-right: 8px;
  507. image {
  508. width: 100px;
  509. height: 92px;
  510. }
  511. }
  512. .right {
  513. width: 100%;
  514. .title {
  515. font-size: 15px;
  516. font-family: Graphit;
  517. font-weight: 500;
  518. color: #282828;
  519. overflow: hidden;
  520. -webkit-line-clamp: 1;
  521. text-overflow: ellipsis;
  522. display: -webkit-box;
  523. -webkit-box-orient: vertical;
  524. }
  525. .logo {
  526. display: flex;
  527. align-items: center;
  528. font-size: 13px;
  529. font-family: Graphit;
  530. font-weight: 500;
  531. color: #696969;
  532. margin-top: 2px;
  533. image {
  534. width: 24px;
  535. height: 24px;
  536. border-radius: 50%;
  537. margin-right: 6px;
  538. }
  539. }
  540. .time {
  541. font-size: 12px;
  542. font-family: PingFang HK;
  543. font-weight: 400;
  544. color: #B2B2B2;
  545. margin-top: 2px;
  546. overflow: hidden;
  547. -webkit-line-clamp: 1;
  548. text-overflow: ellipsis;
  549. display: -webkit-box;
  550. -webkit-box-orient: vertical;
  551. text:first-child {
  552. margin-right: 2px;
  553. }
  554. text:last-child {
  555. margin-left: 2px;
  556. }
  557. }
  558. .bottom {
  559. display: flex;
  560. align-items: center;
  561. justify-content: space-between;
  562. margin-top: 6px;
  563. .free {
  564. font-size: 14px;
  565. font-family: PingFang HK;
  566. font-weight: 500;
  567. color: #79573D;
  568. }
  569. .btn {
  570. width: 80px;
  571. height: 22px;
  572. background: #79573D;
  573. border-radius: 6px;
  574. font-size: 12px;
  575. font-family: PingFang HK;
  576. font-weight: 400;
  577. line-height: 22px;
  578. color: #FFFFFF;
  579. text-align: center;
  580. margin-right: 10px;
  581. }
  582. .btn_over {
  583. background: #A0A0A0;
  584. width: 80px;
  585. height: 22px;
  586. border-radius: 6px;
  587. font-size: 12px;
  588. font-family: PingFang HK;
  589. font-weight: 400;
  590. line-height: 22px;
  591. color: #FFFFFF;
  592. text-align: center;
  593. margin-right: 10px;
  594. }
  595. .btn_check {
  596. background: #fff;
  597. width: 80px;
  598. height: 22px;
  599. border-radius: 6px;
  600. font-size: 12px;
  601. font-family: PingFang HK;
  602. font-weight: 400;
  603. line-height: 20px;
  604. color: #79573D;
  605. text-align: center;
  606. margin-right: 10px;
  607. border: 1px solid #79573D;
  608. }
  609. }
  610. }
  611. }
  612. }
  613. }
  614. </style>