activity.vue 12 KB

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