activity.vue 11 KB

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