index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  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" :class="getTheme + '-m-text ' + getTheme">{{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" :class="getTheme + '-m-text ' + getTheme + ' ' +getTheme + '-m-border ' + getTheme" 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 :posterUrl="'/plugins/community/poster/poster?activity_id='+id + '&middleman_id=0'" hasPosterNav="true" 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" :class="getTheme + '-m-text ' + getTheme">确认</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: function (options) {
  99. let that = this;
  100. uni.getSystemInfo({
  101. success: function (res) {
  102. that.windowHeight = res.windowHeight;
  103. }
  104. })
  105. that.getStatus();
  106. },
  107. onShareAppMessage: function() {
  108. return this.$shareAppMessage({
  109. title: this.setting.app_share_title ? this.setting.app_share_title : this.$children[0].navigationBarTitle,
  110. imageUrl: this.setting.app_share_pic ? this.setting.app_share_pic : this.detail.communityGoods_4[0].cover_pic,
  111. path: "/plugins/community/activity/activity",
  112. params: {
  113. id: this.id
  114. }
  115. });
  116. },
  117. methods: {
  118. toRemind(id,index) {
  119. if(id > 0) {
  120. this.id = id;
  121. this.index = index;
  122. }
  123. this.showRemind = !this.showRemind
  124. },
  125. remind(item) {
  126. let that = this;
  127. that.toRemind();
  128. uni.showLoading({
  129. title: '发送提醒...'
  130. });
  131. that.$request({
  132. url: that.$api.community.notice,
  133. data: {
  134. activity_id: that.id
  135. }
  136. }).then(response=>{
  137. uni.hideLoading();
  138. uni.showToast({
  139. title: response.msg,
  140. icon: 'none',
  141. duration: 1000
  142. });
  143. that.id = 0;
  144. if(response.code == 0) {
  145. that.list[that.index].is_remind = 1;
  146. that.index = -1;
  147. }
  148. })
  149. },
  150. toDetail(id) {
  151. uni.navigateTo({
  152. url: '/plugins/community/detail/detail?id=' + id + '&middleman_id=' + this.middleman.user_id
  153. });
  154. },
  155. toOrder(item) {
  156. uni.redirectTo({
  157. url: '/plugins/community/order/order?keyword=' + item.title
  158. });
  159. },
  160. showHiddenClick(detail) {
  161. this.showShare = !this.showShare;
  162. this.detail = detail;
  163. this.id = detail.id;
  164. },
  165. tabStatus(e) {
  166. if(this.loading) {
  167. return false
  168. }
  169. this.list = [];
  170. this.page = 1;
  171. this.activeTab = e.currentTarget.dataset.id;
  172. uni.showLoading({
  173. title: '加载中...'
  174. });
  175. this.getList();
  176. },
  177. getStatus() {
  178. let that = this;
  179. that.$showLoading({
  180. type: 'global',
  181. text: '加载中...'
  182. });
  183. that.$request({
  184. url: that.$api.community.index,
  185. }).then(response=>{
  186. if(response.code == 0) {
  187. this.setting = response.data.setting;
  188. if(response.data.middleman.status == 1) {
  189. that.getList();
  190. this.middleman = response.data.middleman;
  191. }else {
  192. that.$hideLoading();
  193. uni.showToast({
  194. title: '您还不是团长,现在前往申请页面',
  195. icon: 'none',
  196. duration: 1000
  197. });
  198. setTimeout(function(){
  199. uni.redirectTo({
  200. url: '/plugins/community/apply/apply'
  201. });
  202. },1000)
  203. }
  204. }else {
  205. that.$hideLoading();
  206. uni.showToast({
  207. title: response.msg,
  208. icon: 'none',
  209. duration: 1000
  210. });
  211. }
  212. }).catch(response => {
  213. that.$hideLoading();
  214. });
  215. },
  216. getMore() {
  217. if(this.more) {
  218. this.page++;
  219. this.getMoreList();
  220. this.more = false;
  221. }
  222. },
  223. getMoreList() {
  224. let that = this;
  225. that.$request({
  226. url: that.$api.community.activity_list,
  227. data: {
  228. status: that.activeTab,
  229. page: that.page
  230. },
  231. method: 'get'
  232. }).then(response=>{
  233. that.$hideLoading();
  234. uni.hideLoading();
  235. if(response.code == 0) {
  236. that.more = false;
  237. if(response.list.length == 20) {
  238. that.more = true;
  239. }
  240. for(let index in response.list) {
  241. if(response.list[index].goods_count == 0) {
  242. response.list.splice(index,1)
  243. }
  244. }
  245. let list = response.list;
  246. for(let i in list) {
  247. if(list[i].status_name == '已结束') {
  248. list[i].statusText = '活动失败'
  249. if(list[i].is_success) {
  250. list[i].statusText = '活动成功'
  251. }
  252. }else if(list[i].status_name == '进行中') {
  253. list[i].statusText = list[i].end_at + '结束'
  254. }else if(list[i].status_name == '未开始') {
  255. list[i].statusText = list[i].start_at + '开始'
  256. }
  257. }
  258. that.list = that.list.concat(list)
  259. }else {
  260. uni.showToast({
  261. title: response.msg,
  262. icon: 'none',
  263. duration: 1000
  264. });
  265. }
  266. }).catch(response => {
  267. uni.hideLoading();
  268. that.$hideLoading();
  269. });
  270. },
  271. getList() {
  272. let that = this;
  273. that.$request({
  274. url: that.$api.community.activity_list,
  275. data: {
  276. status: that.activeTab
  277. },
  278. method: 'post'
  279. }).then(response=>{
  280. that.$hideLoading();
  281. uni.hideLoading();
  282. if(response.code == 0) {
  283. that.more = false;
  284. if(response.list.length == 20) {
  285. that.more = true;
  286. }
  287. for(let index in response.list) {
  288. if(response.list[index].goods_count == 0) {
  289. response.list.splice(index,1)
  290. }
  291. }
  292. that.list = response.list;
  293. for(let i in that.list) {
  294. if(that.list[i].status_name == '已结束') {
  295. that.list[i].statusText = '活动失败'
  296. if(that.list[i].is_success) {
  297. that.list[i].statusText = '活动成功'
  298. }
  299. }else if(that.list[i].status_name == '进行中') {
  300. that.list[i].statusText = that.list[i].end_at + '结束'
  301. }else if(that.list[i].status_name == '未开始') {
  302. that.list[i].statusText = that.list[i].start_at + '开始'
  303. }
  304. }
  305. }else {
  306. uni.showToast({
  307. title: response.msg,
  308. icon: 'none',
  309. duration: 1000
  310. });
  311. }
  312. }).catch(response => {
  313. uni.hideLoading();
  314. that.$hideLoading();
  315. });
  316. }
  317. }
  318. }
  319. </script>
  320. <style scoped lang="scss">
  321. .dialog-bg {
  322. position: fixed;
  323. top: 0;
  324. left: 0;
  325. width: 100%;
  326. height: 100%;
  327. background-color: rgba(0,0,0,.3);
  328. z-index: 1000;
  329. .dialog {
  330. font-size: 30rpx;
  331. color: #353535;
  332. width: 480rpx;
  333. height: 200rpx;
  334. border-radius: 16rpx;
  335. text-align: center;
  336. background-color: #fff;
  337. .dialog-content {
  338. height: 110rpx;
  339. line-height: 110rpx;
  340. }
  341. .dialog-btn {
  342. position: relative;
  343. height: 90rpx;
  344. border-top: 2rpx solid #e2e2e2;
  345. .btn {
  346. width: 240rpx;
  347. height: 90rpx;
  348. text-align: center;
  349. line-height: 90rpx;
  350. font-size: 26rpx;
  351. }
  352. .line {
  353. position: absolute;
  354. top: 20rpx;
  355. left: 50%;
  356. margin-left: -1rpx;
  357. width: 2rpx;
  358. height: 45rpx;
  359. background-color: #e2e2e2;
  360. }
  361. }
  362. }
  363. }
  364. .list {
  365. background-color: #fff;
  366. border-radius: 16rpx;
  367. margin: 24rpx;
  368. width: 702rpx;
  369. padding: 0 24rpx 40rpx;
  370. .title {
  371. height: 115rpx;
  372. border-bottom: 2rpx solid #e2e2e2;
  373. font-size: 22rpx;
  374. .title-name {
  375. font-size: 22rpx;
  376. color: #666;
  377. .title-text {
  378. font-size: 28rpx;
  379. font-weight: 600;
  380. color: #353535;
  381. }
  382. }
  383. .status-text {
  384. width: 145rpx;
  385. text-align: right;
  386. }
  387. }
  388. .goods-list {
  389. position: relative;
  390. height: 160rpx;
  391. .goods {
  392. height: 160rpx;
  393. padding-top: 20rpx;
  394. padding-bottom: 20rpx;
  395. image {
  396. margin-right: 20rpx;
  397. height: 120rpx;
  398. width: 120rpx;
  399. border-radius: 16rpx;
  400. }
  401. }
  402. .right-arrow {
  403. position: absolute;
  404. top: 50%;
  405. margin-top: #{-12rpx};
  406. right: #{24rpx};
  407. width: #{12rpx};
  408. height: #{24rpx};
  409. }
  410. }
  411. .other {
  412. font-size: 22rpx;
  413. color: #666;
  414. height: 60rpx;
  415. .other-button {
  416. line-height: 58rpx;
  417. height: 58rpx;
  418. padding: 0 35rpx;
  419. border-radius: 30rpx;
  420. border: 2rpx solid;
  421. display: inline-block;
  422. font-size: 24rpx;
  423. margin-left: 25rpx;
  424. &.un-active {
  425. background-color: #F7F7F7;
  426. border-color: #F7F7F7;
  427. color: #E2E2E2;
  428. }
  429. &.normal-button {
  430. border-color: #e2e2e2;
  431. }
  432. }
  433. }
  434. }
  435. .empty-box {
  436. width: 100%;
  437. height: 60vh;
  438. display: flex;
  439. justify-content: center;
  440. align-items: center;
  441. flex-direction: column;
  442. image {
  443. width: 280#{rpx};
  444. height: 280#{rpx};
  445. }
  446. span {
  447. margin-top: 15#{rpx};
  448. color: #999;
  449. font-size: 28#{rpx};
  450. }
  451. }
  452. </style>