activity.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. <template>
  2. <view class="box">
  3. <!-- 自定义导航 -->
  4. <view class="zdyNavBox">
  5. <view class="status_bar" :style="{height: iStatusBarHeight + 'px'}"></view>
  6. <view class="zdyNav">
  7. <view class="zdyNavLeft">
  8. <image src="../../static/img/nav_icon_back.png" mode="aspectFit" class="backImg" @click="goback">
  9. </image>
  10. </view>
  11. <view class="zdyNavTitle">活动</view>
  12. <image src="../../static/img/icon_nav_add.png" mode="aspectFit" class="addImg" @click="goAdd"></image>
  13. </view>
  14. </view>
  15. <view class="status_bar" :style="{height: iStatusBarHeight + 'px'}"></view>
  16. <view style="height: 44px;"></view>
  17. <view class="tab">
  18. <view class="tabLine" :class="{tabActive:tabIndex==''}" @click="tabClick('')">全部</view>
  19. <view class="tabLine" :class="{tabActive:tabIndex=='未启用'}" @click="tabClick('未启用')">未启用</view>
  20. <view class="tabLine" :class="{tabActive:tabIndex=='未开始'}" @click="tabClick('未开始')">未开始</view>
  21. <view class="tabLine" :class="{tabActive:tabIndex=='进行中'}" @click="tabClick('进行中')">进行中</view>
  22. <view class="tabLine" :class="{tabActive:tabIndex=='已结束'}" @click="tabClick('已结束')">已结束</view>
  23. </view>
  24. <view class="conBox">
  25. <view class="itemHistory" v-for="(item,index) in itemData" :key="index">
  26. <image :src="item.Img" mode="" class="itemImg" @click="goDetail(item.ID)"></image>
  27. <view class="timeBox">
  28. <image v-if="item.state=='进行中'" src="../../static/img/bg_huangse.png" mode="" class="state"></image>
  29. <image v-if="item.state=='未开始'" src="../../static/img/bg_hongse.png" mode="" class="state"></image>
  30. <image v-if="item.state=='未启用'" src="../../static/img/bg_weiqiyong.png" mode="" class="state">
  31. </image>
  32. <image v-if="item.state=='已结束'" src="../../static/img/bg_jieshu.png" mode="" class="state"></image>
  33. <view class="time" v-if="item.StartTime">{{item.StartTime.slice(0,10)}}-{{item.EndTime.slice(0,10)}}
  34. </view>
  35. </view>
  36. <view class="name">{{item.ActivityName}}</view>
  37. <view class="btns">
  38. <view class="btnBox">
  39. <view class="btn" style="width: 120rpx;" @click="changeMore(item)">更多</view>
  40. <view class="btn" @click="goSign(item)">报名详情</view>
  41. <view class="btn" @click="goStatis(item)">数据统计</view>
  42. <view class="btn" style="width: 120rpx;" @click="goshare(item)">分享</view>
  43. </view>
  44. <view class="moreBtn" v-if="item.showMoreBtn==true">
  45. <view class="more" @click="goEdit(item.ID)">
  46. <image src="../../static/img/icon_bianji.png" mode="" class="btnImg"></image>
  47. <view class="btn2">编辑</view>
  48. </view>
  49. <view class="more" @click="open(item)" v-if="item.state=='未启用'">
  50. <image src="../../static/img/icon_tingyong.png" mode="" class="btnImg"></image>
  51. <view class="btn2">启用</view>
  52. </view>
  53. <view class="more" @click="stop(item)" v-else>
  54. <image src="../../static/img/icon_tingyong.png" mode="" class="btnImg"></image>
  55. <view class="btn2">停用</view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. <!-- 上拉 加载更多 -->
  61. <view class="noMore" v-if="noMoreShow && (itemData.length!=0)">没有更多数据</view>
  62. <!-- 无数据空白页 -->
  63. <nodata v-if="itemData.length==0"></nodata>
  64. </view>
  65. </view>
  66. </template>
  67. <script scoped>
  68. import nodata from '../../components/nodata/nodata.vue'
  69. export default {
  70. components: {
  71. nodata,
  72. },
  73. data() {
  74. return {
  75. iStatusBarHeight: '',
  76. page: 1,
  77. itemData: [],
  78. noMoreShow: false,
  79. tabIndex: '',
  80. type:'',
  81. }
  82. },
  83. // onBackPress(options){
  84. // if (options.from === 'navigateBack') {
  85. // return false
  86. // }
  87. // console.log(options)
  88. // console.log("返回")
  89. // return true;
  90. // },
  91. onLoad(opt) {
  92. this.iStatusBarHeight = uni.getSystemInfoSync().statusBarHeight;
  93. this.page = 1
  94. this.myOrderCoupon();
  95. this.type=opt.type
  96. },
  97. methods: {
  98. goAdd(){
  99. uni.navigateTo({
  100. url:'choice?type=2'
  101. })
  102. },
  103. goshare(item){
  104. var standalone = window.navigator.standalone
  105. var userAgent = window.navigator.userAgent.toLowerCase()
  106. var safari = /safari/.test(userAgent)
  107. var ios = /iphone|ipod|ipad|mac/.test(userAgent)
  108. var android = /android/.test(userAgent)
  109. if (ios) {
  110. if ( true) {//!standalone&& !safari
  111. window.webkit.messageHandlers.goShare.postMessage(item)
  112. }
  113. } else if (android) {
  114. window.android.postMessage()
  115. }
  116. },
  117. goback(){
  118. if(this.type==2){
  119. uni.navigateBack()
  120. }else{
  121. var standalone = window.navigator.standalone
  122. var userAgent = window.navigator.userAgent.toLowerCase()
  123. var safari = /safari/.test(userAgent)
  124. var ios = /iphone|ipod|ipad|mac/.test(userAgent)
  125. var android = /android/.test(userAgent)
  126. if (ios) {
  127. if ( true) {//!standalone&& !safari
  128. window.webkit.messageHandlers.goMyNav.postMessage(null)
  129. }
  130. } else if (android) {
  131. window.android.postMessage()
  132. }
  133. }
  134. },
  135. open(item) {
  136. var that = this;
  137. uni.showLoading({
  138. title: '加载中'
  139. });
  140. that.$http('openH5SetTheGuest/updateAtivitySate', {
  141. id: item.ID,
  142. clState: 2
  143. }, 'POST').then(res => {
  144. uni.showToast({
  145. title: '成功',
  146. icon: 'none',
  147. duration: 3000
  148. });
  149. that.page = 1;
  150. that.myOrderCoupon()
  151. })
  152. },
  153. stop(item) {
  154. var that = this;
  155. uni.showModal({
  156. title: '提示',
  157. content: '停用后,用户将不可见此活动',
  158. success: function(res) {
  159. if (res.confirm) {
  160. uni.showLoading({
  161. title: '加载中'
  162. });
  163. that.$http('openH5SetTheGuest/updateAtivitySate', {
  164. id: item.ID,
  165. clState: 1
  166. }, 'POST').then(res => {
  167. uni.showToast({
  168. title: '成功',
  169. icon: 'none',
  170. duration: 3000
  171. });
  172. that.page = 1;
  173. that.myOrderCoupon()
  174. })
  175. } else if (res.cancel) {
  176. }
  177. }
  178. });
  179. },
  180. changeMore(item) {
  181. item.showMoreBtn = !item.showMoreBtn
  182. },
  183. tabClick(state) {
  184. this.tabIndex = state;
  185. this.page = 1;
  186. this.myOrderCoupon()
  187. },
  188. goDetail(id) {
  189. uni.navigateTo({
  190. url: 'activityDetail?id=' + id
  191. })
  192. },
  193. goEdit(id) {
  194. uni.navigateTo({
  195. url: 'eadit?id=' + id
  196. })
  197. },
  198. goSign(item) {
  199. uni.navigateTo({
  200. url: 'signJkDetail?activity=' + JSON.stringify(item)
  201. })
  202. },
  203. goStatis(item) {
  204. uni.navigateTo({
  205. url: 'statistics?activity=' + JSON.stringify(item)
  206. })
  207. },
  208. myOrderCoupon() {
  209. uni.showLoading({
  210. title: '加载中'
  211. })
  212. this.$http('openH5SetTheGuest/getAtivity', {
  213. page: this.page,
  214. limit: 10,
  215. state: this.tabIndex
  216. }, 'GET').then(res => {
  217. uni.hideLoading();
  218. // var list = res.data.Items
  219. var list = res.data.Items
  220. list.forEach((item, index) => {
  221. item.showMoreBtn = false
  222. })
  223. if (this.page == 1) {
  224. this.itemData = list
  225. } else {
  226. this.itemData = this.itemData.concat(list)
  227. }
  228. if (list.length < 10) {
  229. this.noMoreShow = true
  230. } else {
  231. this.noMoreShow = false
  232. }
  233. })
  234. },
  235. },
  236. // 下拉刷新 上拉加载更多
  237. onPullDownRefresh() {
  238. this.page = 1
  239. this.myOrderCoupon()
  240. setTimeout(function() {
  241. uni.stopPullDownRefresh();
  242. }, 1000);
  243. },
  244. onReachBottom() {
  245. this.page++;
  246. this.myOrderCoupon()
  247. },
  248. }
  249. </script>
  250. <style scoped lang="less">
  251. .box {
  252. background: #F4F5F7;
  253. min-height: 100vh;
  254. }
  255. .zdyNavBox {
  256. width: 100vw;
  257. background: #FFFFFF;
  258. position: fixed;
  259. top: 0;
  260. left: 0;
  261. z-index: 9999999;
  262. }
  263. .zdyNav {
  264. height: 44px;
  265. display: flex;
  266. justify-content: space-between;
  267. align-items: center;
  268. }
  269. .backImg {
  270. width: 44rpx;
  271. height: 44rpx;
  272. margin-left: 10rpx;
  273. margin-right: 20rpx;
  274. }
  275. .homeImg {
  276. width: 44rpx;
  277. height: 44rpx;
  278. }
  279. .zdyNavLeft {
  280. display: flex;
  281. align-items: center;
  282. }
  283. .zdyNavTitle {
  284. height: 44px;
  285. background: #FFFFFF;
  286. text-align: center;
  287. font-size: 34rpx;
  288. line-height: 44px;
  289. }
  290. .addImg {
  291. width: 36rpx;
  292. height: 36rpx;
  293. margin-right: 20rpx;
  294. }
  295. .tab {
  296. background: #FFFFFF;
  297. display: flex;
  298. justify-content: space-between;
  299. line-height: 87rpx;
  300. position: fixed;
  301. width: calc(100vw - 100rpx);
  302. padding-left: 50rpx;
  303. padding-right: 50rpx;
  304. height: 87rpx;
  305. z-index: 11;
  306. border-top: 1rpx solid #EEEEEE;
  307. }
  308. .tabLine {
  309. font-size: 32rpx;
  310. color: #666666;
  311. text-align: center;
  312. }
  313. .tabActive {
  314. color: #3F90F7;
  315. font-weight: bold;
  316. border-bottom: 4rpx solid #3F90F7;
  317. }
  318. .conBox {
  319. padding-top: 107rpx;
  320. }
  321. .itemHistory {
  322. margin: 0rpx 24rpx 20rpx;
  323. background-color: #FFFFFF;
  324. border-radius: 10rpx;
  325. }
  326. .itemImg {
  327. height: 280rpx;
  328. width: 702rpx;
  329. border-radius: 10rpx 10rpx 0px 0px;
  330. display: block;
  331. }
  332. .timeBox {
  333. display: flex;
  334. margin-top: -52rpx;
  335. align-items: flex-end;
  336. position: relative;
  337. }
  338. .state {
  339. width: 102rpx;
  340. height: 53rpx;
  341. }
  342. .time {
  343. padding: 5rpx 10rpx;
  344. color: #FFFFFF;
  345. font-size: 24rpx;
  346. background: rgba(0, 0, 0, 0.5);
  347. margin-left: -8rpx;
  348. border-radius: 0 10rpx 0 0;
  349. }
  350. .name {
  351. padding: 24rpx 20rpx;
  352. color: #333333;
  353. font-size: 28rpx;
  354. background: #FFFFFF;
  355. border-radius: 0 0 10rpx 10rpx;
  356. border-bottom: 1rpx solid #eeeeee;
  357. }
  358. .btns {
  359. position: relative;
  360. }
  361. .btnBox {
  362. padding: 26rpx 20rpx;
  363. border-radius: 0 0 10rpx 10rpx;
  364. display: flex;
  365. justify-content: space-between;
  366. align-items: center;
  367. }
  368. .moreBtn {
  369. background-image: url("../../static/img/bg_more.png");
  370. background-size: 100% 100%;
  371. width: 196rpx;
  372. height: 234rpx;
  373. position: absolute;
  374. z-index: 999;
  375. top: 84rpx;
  376. }
  377. .more {
  378. display: flex;
  379. align-items: center;
  380. padding: 32rpx 46rpx 0;
  381. }
  382. .btnImg {
  383. width: 32rpx;
  384. height: 32rpx;
  385. margin-right: 15rpx;
  386. }
  387. .btn {
  388. font-size: 28rpx;
  389. color: #333333;
  390. width: 160rpx;
  391. height: 60rpx;
  392. border-radius: 30rpx;
  393. border: 1rpx solid #DDDDDD;
  394. text-align: center;
  395. line-height: 60rpx;
  396. }
  397. .btn2 {
  398. font-size: 28rpx;
  399. color: #333333;
  400. height: 60rpx;
  401. border-radius: 30rpx;
  402. text-align: center;
  403. line-height: 60rpx;
  404. }
  405. .noMore {
  406. text-align: center;
  407. line-height: 50rpx;
  408. color: #999999;
  409. font-size: 28rpx;
  410. }
  411. </style>