activity.vue 11 KB

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