index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. <template>
  2. <app-layout>
  3. <scroll-view @scrolltolower="getMore" scroll-y :style="{'height':`${windowHeight}px`}">
  4. <app-tab-nav setTop="0" :tabList="tabList" padding="0" :theme="getTheme" :activeItem="activeTab" @click="tabStatus"></app-tab-nav>
  5. <view v-if="list.length > 0">
  6. <view v-for="(item,index) in list" :key="item.id" class="list">
  7. <view class="title main-between cross-center">
  8. <view class="title-name">
  9. <view class="title-text">{{item.title}}</view>
  10. <view v-if="item.condition > 0">满{{item.num}}{{item.condition == 1 ? '人':'件'}}成团,已参团{{item.condition_count ? item.condition_count : '0'}}{{item.condition == 1 ? '人':'件'}}</view>
  11. </view>
  12. <view class="status-text" :style="{'color': getTheme.color}">{{item.statusText}}</view>
  13. </view>
  14. <view @click="toDetail(item.id)" class="goods-list">
  15. <view class="dir-left-nowrap">
  16. <view class="goods" v-for="goods in item.communityGoods_4" :key="goods.id">
  17. <image mode='aspectFill' :src="goods.cover_pic"></image>
  18. </view>
  19. </view>
  20. <image class="right-arrow" src="/static/image/icon/arrow-right.png"></image>
  21. </view>
  22. <view class="main-between cross-center other">
  23. <view>共{{item.goods_count}}件商品</view>
  24. <view class="dir-right-nowrap">
  25. <view @click="showHiddenClick(item)" class="other-button normal-button" v-if="item.status_name == '未开始' || item.status_name == '进行中'">分享</view>
  26. <view @click="toRemind(item.id,index)" class="other-button" :style="{'color': getTheme.color, 'border-color': getTheme.border}" v-if="item.status_name == '已结束' && item.is_success == 1 && item.is_remind == 0">通知提货</view>
  27. <view class="other-button un-active" v-if="item.status_name == '已结束' && item.is_success == 1 && item.is_remind == 1">通知提货</view>
  28. <view v-if="item.status_name != '未开始'" @click="toOrder(item)" class="other-button normal-button">本团订单</view>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. <view v-else class="empty-box">
  34. <image src="/static/image/order-empty.png"></image>
  35. <span>暂无{{activeTab == 0?'未开始': activeTab == 1?'进行中':activeTab == 2?'已结束':''}}活动</span>
  36. </view>
  37. <view>
  38. <app-share-qr-code @share="hShareAppMessage" :posterUrl="'/plugins/community/poster/poster?activity_id='+id + '&middleman_id=0'" :hasPosterNav="showShare" v-model="showShare" :url="poster" title="生成活动海报"></app-share-qr-code>
  39. </view>
  40. <view v-if="showRemind" class="dialog-bg main-center cross-center">
  41. <view class="dialog">
  42. <view class="dialog-content">确认通知提货?</view>
  43. <view class="dialog-btn main-between">
  44. <view @click="toRemind" class="btn" style="color: #666">取消</view>
  45. <view class="line"></view>
  46. <view @click="remind" class="btn" :style="{'color': getTheme.color}">确认</view>
  47. </view>
  48. </view>
  49. </view>
  50. <app-menu :theme="getTheme" active="activity"></app-menu>
  51. </scroll-view>
  52. </app-layout>
  53. </template>
  54. <script>
  55. import {mapGetters, mapState} from 'vuex';
  56. import appMenu from '../components/app-menu';
  57. import appTabNav from "../../../components/basic-component/app-tab-nav/app-tab-nav.vue";
  58. import appShareQrCode from '../../../components/page-component/app-share-qr-code-poster/app-share-qr-code-poster.vue';
  59. export default {
  60. data() {
  61. return {
  62. tabList: [
  63. {id:-1, name: '全部'},
  64. {id:1, name: '进行中'},
  65. {id:0, name: '未开始'},
  66. {id:2, name: '已结束'}
  67. ],
  68. activeTab: -1,
  69. list: [],
  70. setting: {},
  71. detail: {},
  72. id: 0,
  73. windowHeight: 0,
  74. index: -1,
  75. page: 1,
  76. showShare: false,
  77. showRemind: false,
  78. more: false,
  79. poster: '',
  80. middleman: {}
  81. }
  82. },
  83. components: {
  84. "app-tab-nav": appTabNav,
  85. "app-menu": appMenu,
  86. appShareQrCode
  87. },
  88. computed: {
  89. ...mapGetters('mallConfig', {
  90. getTheme: 'getTheme',
  91. }),
  92. ...mapState({
  93. stock: state => state.mallConfig.__wxapp_img.stock,
  94. bonusImg: state => state.mallConfig.__wxapp_img.bonus,
  95. userInfo: state => state.user.info,
  96. })
  97. },
  98. onLoad(options) { this.$commonLoad.onload(options);
  99. let that = this;
  100. uni.getSystemInfo({
  101. success: function (res) {
  102. that.windowHeight = res.windowHeight;
  103. }
  104. })
  105. that.getStatus();
  106. },
  107. // #ifdef MP
  108. onShareAppMessage() {
  109. return this.hShareAppMessage();
  110. },
  111. // #endif
  112. methods: {
  113. hShareAppMessage(s = false) {
  114. return this.$shareAppMessage({
  115. title: this.setting.app_share_title ? this.setting.app_share_title : this.$children[0].navigationBarTitle,
  116. imageUrl: this.setting.app_share_pic ? this.setting.app_share_pic : this.detail.communityGoods_4[0].cover_pic,
  117. path: "/plugins/community/activity/activity",
  118. params: {
  119. id: this.id
  120. }
  121. },s);
  122. },
  123. toRemind(id,index) {
  124. if(id > 0) {
  125. this.id = id;
  126. this.index = index;
  127. }
  128. this.showRemind = !this.showRemind
  129. },
  130. remind(item) {
  131. let that = this;
  132. that.toRemind();
  133. uni.showLoading({
  134. mask: true,
  135. title: '发送提醒...'
  136. });
  137. that.$request({
  138. url: that.$api.community.notice,
  139. data: {
  140. activity_id: that.id
  141. }
  142. }).then(response=>{
  143. uni.hideLoading();
  144. uni.showToast({
  145. title: response.msg,
  146. icon: 'none',
  147. duration: 1000
  148. });
  149. that.id = 0;
  150. if(response.code == 0) {
  151. that.list[that.index].is_remind = 1;
  152. that.index = -1;
  153. }
  154. })
  155. },
  156. toDetail(id) {
  157. uni.navigateTo({
  158. url: '/plugins/community/detail/detail?id=' + id + '&middleman_id=' + this.middleman.user_id
  159. });
  160. },
  161. toOrder(item) {
  162. uni.redirectTo({
  163. url: '/plugins/community/order/order?keyword=' + item.title
  164. });
  165. },
  166. showHiddenClick(detail) {
  167. this.showShare = !this.showShare;
  168. this.detail = detail;
  169. this.id = detail.id;
  170. },
  171. tabStatus(e) {
  172. if(this.loading) {
  173. return false
  174. }
  175. this.list = [];
  176. this.page = 1;
  177. this.activeTab = e.currentTarget.dataset.id;
  178. uni.showLoading({
  179. mask: true,
  180. title: '加载中...'
  181. });
  182. this.getList();
  183. },
  184. getStatus() {
  185. let that = this;
  186. that.$showLoading({
  187. type: 'global',
  188. text: '加载中...'
  189. });
  190. that.$request({
  191. url: that.$api.community.index,
  192. }).then(response=>{
  193. if(response.code == 0) {
  194. this.setting = response.data.setting;
  195. if(response.data.middleman.status == 1) {
  196. that.getList();
  197. this.middleman = response.data.middleman;
  198. }else {
  199. that.$hideLoading();
  200. uni.showToast({
  201. title: '您还不是团长,现在前往申请页面',
  202. icon: 'none',
  203. duration: 1000
  204. });
  205. setTimeout(function(){
  206. uni.redirectTo({
  207. url: '/plugins/community/apply/apply'
  208. });
  209. },1000)
  210. }
  211. }else {
  212. that.$hideLoading();
  213. uni.showToast({
  214. title: response.msg,
  215. icon: 'none',
  216. duration: 1000
  217. });
  218. }
  219. }).catch(response => {
  220. that.$hideLoading();
  221. });
  222. },
  223. getMore() {
  224. if(this.more) {
  225. this.page++;
  226. this.getMoreList();
  227. this.more = false;
  228. }
  229. },
  230. getMoreList() {
  231. let that = this;
  232. that.$request({
  233. url: that.$api.community.activity_list,
  234. data: {
  235. status: that.activeTab,
  236. page: that.page
  237. },
  238. method: 'get'
  239. }).then(response=>{
  240. that.$hideLoading();
  241. uni.hideLoading();
  242. if(response.code == 0) {
  243. that.more = false;
  244. if(response.list.length == 20) {
  245. that.more = true;
  246. }
  247. for(let index in response.list) {
  248. if(response.list[index].goods_count == 0) {
  249. response.list.splice(index,1)
  250. }
  251. }
  252. let list = response.list;
  253. for(let i in list) {
  254. if(list[i].status_name == '已结束') {
  255. list[i].statusText = '活动失败'
  256. if(list[i].is_success) {
  257. list[i].statusText = '活动成功'
  258. }
  259. }else if(list[i].status_name == '进行中') {
  260. list[i].statusText = list[i].end_at + '结束'
  261. }else if(list[i].status_name == '未开始') {
  262. list[i].statusText = list[i].start_at + '开始'
  263. }
  264. }
  265. that.list = that.list.concat(list)
  266. }else {
  267. uni.showToast({
  268. title: response.msg,
  269. icon: 'none',
  270. duration: 1000
  271. });
  272. }
  273. }).catch(response => {
  274. uni.hideLoading();
  275. that.$hideLoading();
  276. });
  277. },
  278. getList() {
  279. let that = this;
  280. that.$request({
  281. url: that.$api.community.activity_list,
  282. data: {
  283. status: that.activeTab
  284. },
  285. method: 'post'
  286. }).then(response=>{
  287. that.$hideLoading();
  288. uni.hideLoading();
  289. if(response.code == 0) {
  290. that.more = false;
  291. if(response.list.length == 20) {
  292. that.more = true;
  293. }
  294. for(let index in response.list) {
  295. if(response.list[index].goods_count == 0) {
  296. response.list.splice(index,1)
  297. }
  298. }
  299. that.list = response.list;
  300. for(let i in that.list) {
  301. if(that.list[i].status_name == '已结束') {
  302. that.list[i].statusText = '活动失败'
  303. if(that.list[i].is_success) {
  304. that.list[i].statusText = '活动成功'
  305. }
  306. }else if(that.list[i].status_name == '进行中') {
  307. that.list[i].statusText = that.list[i].end_at + '结束'
  308. }else if(that.list[i].status_name == '未开始') {
  309. that.list[i].statusText = that.list[i].start_at + '开始'
  310. }
  311. }
  312. }else {
  313. uni.showToast({
  314. title: response.msg,
  315. icon: 'none',
  316. duration: 1000
  317. });
  318. }
  319. }).catch(response => {
  320. uni.hideLoading();
  321. that.$hideLoading();
  322. });
  323. }
  324. }
  325. }
  326. </script>
  327. <style scoped lang="scss">
  328. .dialog-bg {
  329. position: fixed;
  330. top: 0;
  331. left: 0;
  332. width: 100%;
  333. height: 100%;
  334. background-color: rgba(0,0,0,.3);
  335. z-index: 1000;
  336. .dialog {
  337. font-size: 30rpx;
  338. color: #353535;
  339. width: 480rpx;
  340. height: 200rpx;
  341. border-radius: 16rpx;
  342. text-align: center;
  343. background-color: #fff;
  344. .dialog-content {
  345. height: 110rpx;
  346. line-height: 110rpx;
  347. }
  348. .dialog-btn {
  349. position: relative;
  350. height: 90rpx;
  351. border-top: 2rpx solid #e2e2e2;
  352. .btn {
  353. width: 240rpx;
  354. height: 90rpx;
  355. text-align: center;
  356. line-height: 90rpx;
  357. font-size: 26rpx;
  358. }
  359. .line {
  360. position: absolute;
  361. top: 20rpx;
  362. left: 50%;
  363. margin-left: -1rpx;
  364. width: 2rpx;
  365. height: 45rpx;
  366. background-color: #e2e2e2;
  367. }
  368. }
  369. }
  370. }
  371. .list {
  372. background-color: #fff;
  373. border-radius: 16rpx;
  374. margin: 24rpx;
  375. width: 702rpx;
  376. padding: 0 24rpx 40rpx;
  377. .title {
  378. height: 115rpx;
  379. border-bottom: 2rpx solid #e2e2e2;
  380. font-size: 22rpx;
  381. .title-name {
  382. font-size: 22rpx;
  383. color: #666;
  384. .title-text {
  385. font-size: 28rpx;
  386. font-weight: 600;
  387. color: #353535;
  388. }
  389. }
  390. .status-text {
  391. width: 145rpx;
  392. text-align: right;
  393. }
  394. }
  395. .goods-list {
  396. position: relative;
  397. height: 160rpx;
  398. .goods {
  399. height: 160rpx;
  400. padding-top: 20rpx;
  401. padding-bottom: 20rpx;
  402. image {
  403. margin-right: 20rpx;
  404. height: 120rpx;
  405. width: 120rpx;
  406. border-radius: 16rpx;
  407. }
  408. }
  409. .right-arrow {
  410. position: absolute;
  411. top: 50%;
  412. margin-top: #{-12rpx};
  413. right: #{24rpx};
  414. width: #{12rpx};
  415. height: #{24rpx};
  416. }
  417. }
  418. .other {
  419. font-size: 22rpx;
  420. color: #666;
  421. height: 60rpx;
  422. .other-button {
  423. line-height: 58rpx;
  424. height: 58rpx;
  425. padding: 0 35rpx;
  426. border-radius: 30rpx;
  427. border: 2rpx solid;
  428. display: inline-block;
  429. font-size: 24rpx;
  430. margin-left: 25rpx;
  431. &.un-active {
  432. background-color: #F7F7F7;
  433. border-color: #F7F7F7;
  434. color: #E2E2E2;
  435. }
  436. &.normal-button {
  437. border-color: #e2e2e2;
  438. }
  439. }
  440. }
  441. }
  442. .empty-box {
  443. width: 100%;
  444. height: 60vh;
  445. display: flex;
  446. justify-content: center;
  447. align-items: center;
  448. flex-direction: column;
  449. image {
  450. width: 280#{rpx};
  451. height: 280#{rpx};
  452. }
  453. span {
  454. margin-top: 15#{rpx};
  455. color: #999;
  456. font-size: 28#{rpx};
  457. }
  458. }
  459. </style>