activity.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  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. //app交互
  105. var standalone = window.navigator.standalone
  106. var userAgent = window.navigator.userAgent.toLowerCase()
  107. var safari = /safari/.test(userAgent)
  108. var ios = /iphone|ipod|ipad|mac/.test(userAgent)
  109. var android = /android/.test(userAgent)
  110. if (ios) {
  111. if ( true) {//!standalone&& !safari
  112. window.webkit.messageHandlers.goShare.postMessage(item)
  113. }
  114. } else if (android) {
  115. window.android.postMessage()
  116. }
  117. },
  118. goback(){
  119. if(this.type==2){
  120. uni.navigateBack()
  121. }else{
  122. //app交互
  123. var standalone = window.navigator.standalone
  124. var userAgent = window.navigator.userAgent.toLowerCase()
  125. var safari = /safari/.test(userAgent)
  126. var ios = /iphone|ipod|ipad|mac/.test(userAgent)
  127. var android = /android/.test(userAgent)
  128. if (ios) {
  129. if ( true) {//!standalone&& !safari
  130. window.webkit.messageHandlers.goMyNav.postMessage(null)
  131. }
  132. } else if (android) {
  133. window.android.postMessage()
  134. }
  135. }
  136. },
  137. open(item) {
  138. var that = this;
  139. uni.showLoading({
  140. title: '加载中'
  141. });
  142. that.$http('openH5SetTheGuest/updateAtivitySate', {
  143. id: item.ID,
  144. clState: 2
  145. }, 'POST').then(res => {
  146. uni.showToast({
  147. title: '成功',
  148. icon: 'none',
  149. duration: 3000
  150. });
  151. that.page = 1;
  152. that.myOrderCoupon()
  153. })
  154. },
  155. stop(item) {
  156. var that = this;
  157. uni.showModal({
  158. title: '提示',
  159. content: '停用后,用户将不可见此活动',
  160. success: function(res) {
  161. if (res.confirm) {
  162. uni.showLoading({
  163. title: '加载中'
  164. });
  165. that.$http('openH5SetTheGuest/updateAtivitySate', {
  166. id: item.ID,
  167. clState: 1
  168. }, 'POST').then(res => {
  169. uni.showToast({
  170. title: '成功',
  171. icon: 'none',
  172. duration: 3000
  173. });
  174. that.page = 1;
  175. that.myOrderCoupon()
  176. })
  177. } else if (res.cancel) {
  178. }
  179. }
  180. });
  181. },
  182. changeMore(item) {
  183. item.showMoreBtn = !item.showMoreBtn
  184. },
  185. tabClick(state) {
  186. this.tabIndex = state;
  187. this.page = 1;
  188. this.myOrderCoupon()
  189. },
  190. goDetail(id) {
  191. uni.navigateTo({
  192. url: 'activityDetail?id=' + id
  193. })
  194. },
  195. goEdit(id) {
  196. uni.navigateTo({
  197. url: 'eadit?id=' + id
  198. })
  199. },
  200. goSign(item) {
  201. uni.navigateTo({
  202. url: 'signJkDetail?activity=' + JSON.stringify(item)
  203. })
  204. },
  205. goStatis(item) {
  206. uni.navigateTo({
  207. url: 'statistics?activity=' + JSON.stringify(item)
  208. })
  209. },
  210. myOrderCoupon() {
  211. uni.showLoading({
  212. title: '加载中'
  213. })
  214. this.$http('openH5SetTheGuest/getAtivity', {
  215. page: this.page,
  216. limit: 10,
  217. state: this.tabIndex
  218. }, 'GET').then(res => {
  219. uni.hideLoading();
  220. // var list = res.data.Items
  221. var list = res.data.Items
  222. list.forEach((item, index) => {
  223. item.showMoreBtn = false
  224. })
  225. if (this.page == 1) {
  226. this.itemData = list
  227. } else {
  228. this.itemData = this.itemData.concat(list)
  229. }
  230. if (list.length < 10) {
  231. this.noMoreShow = true
  232. } else {
  233. this.noMoreShow = false
  234. }
  235. })
  236. },
  237. },
  238. // 下拉刷新 上拉加载更多
  239. onPullDownRefresh() {
  240. this.page = 1
  241. this.myOrderCoupon()
  242. setTimeout(function() {
  243. uni.stopPullDownRefresh();
  244. }, 1000);
  245. },
  246. onReachBottom() {
  247. this.page++;
  248. this.myOrderCoupon()
  249. },
  250. }
  251. </script>
  252. <style scoped lang="less">
  253. .box {
  254. background: #F4F5F7;
  255. min-height: 100vh;
  256. }
  257. .zdyNavBox {
  258. width: 100vw;
  259. background: #FFFFFF;
  260. position: fixed;
  261. top: 0;
  262. left: 0;
  263. z-index: 9999999;
  264. }
  265. .zdyNav {
  266. height: 44px;
  267. display: flex;
  268. justify-content: space-between;
  269. align-items: center;
  270. }
  271. .backImg {
  272. width: 44rpx;
  273. height: 44rpx;
  274. margin-left: 10rpx;
  275. margin-right: 20rpx;
  276. }
  277. .homeImg {
  278. width: 44rpx;
  279. height: 44rpx;
  280. }
  281. .zdyNavLeft {
  282. display: flex;
  283. align-items: center;
  284. }
  285. .zdyNavTitle {
  286. height: 44px;
  287. background: #FFFFFF;
  288. text-align: center;
  289. font-size: 34rpx;
  290. line-height: 44px;
  291. }
  292. .addImg {
  293. width: 36rpx;
  294. height: 36rpx;
  295. margin-right: 20rpx;
  296. }
  297. .tab {
  298. background: #FFFFFF;
  299. display: flex;
  300. justify-content: space-between;
  301. line-height: 87rpx;
  302. position: fixed;
  303. width: calc(100vw - 100rpx);
  304. padding-left: 50rpx;
  305. padding-right: 50rpx;
  306. height: 87rpx;
  307. z-index: 11;
  308. border-top: 1rpx solid #EEEEEE;
  309. }
  310. .tabLine {
  311. font-size: 32rpx;
  312. color: #666666;
  313. text-align: center;
  314. }
  315. .tabActive {
  316. color: #3F90F7;
  317. font-weight: bold;
  318. border-bottom: 4rpx solid #3F90F7;
  319. }
  320. .conBox {
  321. padding-top: 107rpx;
  322. }
  323. .itemHistory {
  324. margin: 0rpx 24rpx 20rpx;
  325. background-color: #FFFFFF;
  326. border-radius: 10rpx;
  327. }
  328. .itemImg {
  329. height: 280rpx;
  330. width: 702rpx;
  331. border-radius: 10rpx 10rpx 0px 0px;
  332. display: block;
  333. }
  334. .timeBox {
  335. display: flex;
  336. margin-top: -52rpx;
  337. align-items: flex-end;
  338. position: relative;
  339. }
  340. .state {
  341. width: 102rpx;
  342. height: 53rpx;
  343. }
  344. .time {
  345. padding: 5rpx 10rpx;
  346. color: #FFFFFF;
  347. font-size: 24rpx;
  348. background: rgba(0, 0, 0, 0.5);
  349. margin-left: -8rpx;
  350. border-radius: 0 10rpx 0 0;
  351. }
  352. .name {
  353. padding: 24rpx 20rpx;
  354. color: #333333;
  355. font-size: 28rpx;
  356. background: #FFFFFF;
  357. border-radius: 0 0 10rpx 10rpx;
  358. border-bottom: 1rpx solid #eeeeee;
  359. }
  360. .btns {
  361. position: relative;
  362. }
  363. .btnBox {
  364. padding: 26rpx 20rpx;
  365. border-radius: 0 0 10rpx 10rpx;
  366. display: flex;
  367. justify-content: space-between;
  368. align-items: center;
  369. }
  370. .moreBtn {
  371. background-image: url("../../static/img/bg_more.png");
  372. background-size: 100% 100%;
  373. width: 196rpx;
  374. height: 234rpx;
  375. position: absolute;
  376. z-index: 999;
  377. top: 84rpx;
  378. }
  379. .more {
  380. display: flex;
  381. align-items: center;
  382. padding: 32rpx 46rpx 0;
  383. }
  384. .btnImg {
  385. width: 32rpx;
  386. height: 32rpx;
  387. margin-right: 15rpx;
  388. }
  389. .btn {
  390. font-size: 28rpx;
  391. color: #333333;
  392. width: 160rpx;
  393. height: 60rpx;
  394. border-radius: 30rpx;
  395. border: 1rpx solid #DDDDDD;
  396. text-align: center;
  397. line-height: 60rpx;
  398. }
  399. .btn2 {
  400. font-size: 28rpx;
  401. color: #333333;
  402. height: 60rpx;
  403. border-radius: 30rpx;
  404. text-align: center;
  405. line-height: 60rpx;
  406. }
  407. .noMore {
  408. text-align: center;
  409. line-height: 50rpx;
  410. color: #999999;
  411. font-size: 28rpx;
  412. }
  413. </style>