1
0

list.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. <template>
  2. <app-layout>
  3. <image class="banner" :src="setting.banner"></image>
  4. <view class="nav-area">
  5. <view class="nav main-center cross-center" :class="getTheme + '-m-back ' + getTheme">
  6. <view @click="tabStatus(item,index)" :key="item.id" class="nav-item" v-for="(item,index) in tabList">
  7. <text>{{item.name}}</text>
  8. </view>
  9. <view class="active" :animation="animationData" :class="getTheme + '-m-text ' + getTheme">{{activeTabName}}</view>
  10. </view>
  11. </view>
  12. <view class="placeholder"></view>
  13. <view v-if="list.length > 0">
  14. <view v-for="item in list" :key="item.id" v-if="item.goods_count > 0" class="list">
  15. <view class="title main-center dir-top-nowrap" :class="getTheme + '-m-gradient ' + getTheme">
  16. <view class="title-text t-omit">{{item.title}}
  17. <image class="hot-icon" src="./../image/hot.png"></image>
  18. </view>
  19. <view class="sec-title-text t-omit" v-if="item.condition > 0">
  20. <text v-if="item.num - item.condition_count > 0">还差{{item.num - item.condition_count}}{{item.condition == 1 ? '人':'件商品'}}成团</text>
  21. <text v-else>已成团</text>
  22. ,已<text v-if="item.condition == 1">参</text>团{{item.condition_count ? item.condition_count : '0'}}{{item.condition == 1 ? '人':'件'}}
  23. </view>
  24. </view>
  25. <view class="status-text" :class="getTheme + '-m-text ' + getTheme">
  26. <view class="status-bg" :class="getTheme + '-m-back ' + getTheme"></view>
  27. {{item.statusText}}
  28. </view>
  29. <view @click="toDetail(item)" class="goods-list">
  30. <view class="dir-left-nowrap">
  31. <view class="goods" v-for="goods in item.communityGoods_4" :key="goods.id">
  32. <image mode='aspectFill' :src="goods.cover_pic"></image>
  33. </view>
  34. </view>
  35. <image class="right-arrow" src="/static/image/icon/arrow-right.png"></image>
  36. </view>
  37. <view class="main-between cross-center other">
  38. <view>共{{item.goods_count}}件商品</view>
  39. </view>
  40. </view>
  41. </view>
  42. <view v-else class="empty-box">
  43. <image v-if="!loading" src="/static/image/no-goods.png"></image>
  44. <span v-if="!loading">暂无{{activeTab == 0?'未开始': activeTab == 1?'进行中':activeTab == 2?'已结束':''}}活动</span>
  45. </view>
  46. </app-layout>
  47. </template>
  48. <script>
  49. import {mapGetters, mapState} from 'vuex';
  50. import appMenu from '../components/app-menu';
  51. import appTabNav from "../../../components/basic-component/app-tab-nav/app-tab-nav.vue";
  52. import appShareQrCode from '../../../components/page-component/app-share-qr-code-poster/app-share-qr-code-poster.vue';
  53. export default {
  54. data() {
  55. return {
  56. tabList: [
  57. {id:-1, name: '全部'},
  58. {id:1, name: '进行中'},
  59. {id:0, name: '未开始'},
  60. {id:2, name: '已结束'}
  61. ],
  62. activeTab: -1,
  63. activeTabName: '全部',
  64. list: [],
  65. setting: {},
  66. widthRate: 1,
  67. id: 0,
  68. loading: false,
  69. more: false,
  70. page: 1,
  71. first: true,
  72. poster: '',
  73. longitude: '',
  74. latitude: '',
  75. middleman: {},
  76. middleman_id: '',
  77. animation: {},
  78. animationData: {}
  79. }
  80. },
  81. components: {
  82. "app-tab-nav": appTabNav,
  83. "app-menu": appMenu,
  84. appShareQrCode
  85. },
  86. computed: {
  87. ...mapGetters('mallConfig', {
  88. getTheme: 'getTheme'
  89. }),
  90. ...mapState({
  91. stock: state => state.mallConfig.__wxapp_img.stock,
  92. bonusImg: state => state.mallConfig.__wxapp_img.bonus,
  93. userInfo: state => state.user.info,
  94. })
  95. },
  96. // #ifdef MP-WEIXIN
  97. onShareTimeline() {
  98. // 分享朋友圈beta
  99. return this.$shareTimeline({
  100. title: this.setting.app_share_title ? this.setting.app_share_title : this.$children[0].navigationBarTitle,
  101. query: {} // 此处填写页面的参数
  102. });
  103. },
  104. // #endif
  105. onShow() {
  106. let that = this;
  107. that.animation = uni.createAnimation({
  108. duration: 400,
  109. timingFunction: 'linear',
  110. });
  111. if(that.first) {
  112. return false;
  113. }
  114. uni.getStorage({
  115. key: 'middleman_info',
  116. success(res) {
  117. if(res.data && res.data.id > 0) {
  118. that.middleman_id = res.data.user_id
  119. }
  120. that.getList();
  121. },
  122. fail() {
  123. that.getList();
  124. }
  125. })
  126. },
  127. onLoad: function () {
  128. let that = this;
  129. uni.getSystemInfo({
  130. success: function (res) {
  131. let width = res.screenWidth * 2;
  132. that.widthRate = width / 750;
  133. }
  134. });
  135. // #ifdef MP-WEIXIN
  136. wx.showShareMenu({
  137. menus: ['shareAppMessage', 'shareTimeline']
  138. })
  139. // #endif
  140. uni.getLocation({
  141. success: (e) => {
  142. uni.hideLoading();
  143. this.longitude = e.longitude;
  144. this.latitude = e.latitude;
  145. this.$showLoading({
  146. type: 'global',
  147. text: '加载中...'
  148. });
  149. this.getSetting();
  150. },
  151. fail: () => {
  152. uni.hideLoading();
  153. uni.showModal({
  154. title: '提示',
  155. content: '获取位置信息失败,需要授权获取您的位置信息',
  156. showCancel: false,
  157. confirmText: '打开授权',
  158. success(e) {
  159. if (e.confirm) {
  160. uni.openSetting({});
  161. }
  162. }
  163. });
  164. },
  165. });
  166. },
  167. onReachBottom() {
  168. if(this.more) {
  169. this.page++;
  170. this.getMore();
  171. this.more = false;
  172. }
  173. },
  174. onShareAppMessage: function() {
  175. return this.$shareAppMessage({
  176. title: this.setting.app_share_title ? this.setting.app_share_title : this.$children[0].navigationBarTitle,
  177. imageUrl: this.setting.app_share_pic ? this.setting.app_share_pic : '',
  178. path: "/plugins/community/list/list"
  179. });
  180. },
  181. methods: {
  182. getMore() {
  183. let that = this;
  184. that.loading = true;
  185. let para = {
  186. longitude: that.longitude,
  187. latitude: that.latitude,
  188. page: that.page,
  189. status: that.activeTab
  190. };
  191. if(that.middleman_id > 0) {
  192. para.middleman_id = that.middleman_id
  193. }
  194. that.$request({
  195. url: that.$api.community.list,
  196. data: para,
  197. }).then(response=>{
  198. that.loading = false;
  199. that.first = false;
  200. that.$hideLoading();
  201. uni.hideLoading();
  202. if(response.code === 0) {
  203. if (response.list.length === 20) {
  204. that.more = true;
  205. }else {
  206. that.more = false
  207. }
  208. for(let index in response.list) {
  209. if(response.list[index].goods_count == 0) {
  210. response.list.splice(index,1)
  211. }
  212. }
  213. that.list = that.list.concat(response.list);
  214. for(let i in that.list) {
  215. if(that.list[i].status_name === '已结束') {
  216. that.list[i].statusText = '活动结束'
  217. }else if(that.list[i].status_name === '进行中') {
  218. that.list[i].statusText = that.list[i].end_at + '结束'
  219. }else if(that.list[i].status_name === '未开始') {
  220. that.list[i].statusText = that.list[i].start_at + '开始'
  221. }
  222. }
  223. }else {
  224. uni.showToast({
  225. title: response.msg,
  226. icon: 'none',
  227. duration: 1000
  228. });
  229. }
  230. }).catch(() => {
  231. that.loading = false;
  232. uni.hideLoading();
  233. that.$hideLoading();
  234. });
  235. },
  236. toDetail(item) {
  237. uni.navigateTo({
  238. url: '/plugins/community/activity/activity?id=' + item.id + '&title=' + item.title
  239. });
  240. },
  241. tabStatus(e,index) {
  242. let that = this;
  243. if(that.loading) {
  244. return false
  245. }
  246. that.list = [];
  247. that.page = 1;
  248. that.activeTab = e.id;
  249. that.activeTabName = e.name;
  250. let width = 88* +that.widthRate * index;
  251. that.animation.translate(width, 0).step();
  252. that.animationData = that.animation.export();
  253. // uni.showLoading({
  254. // title: '加载中...'
  255. // });
  256. that.getList();
  257. },
  258. getSetting() {
  259. let that = this;
  260. that.$showLoading({
  261. type: 'global',
  262. text: '加载中...'
  263. });
  264. that.$request({
  265. url: that.$api.community.setting,
  266. }).then(response=>{
  267. if(response.code === 0) {
  268. that.setting = response.data;
  269. uni.getStorage({
  270. key: 'middleman_info',
  271. success: function (res) {
  272. if(res.data && res.data.id > 0) {
  273. that.middleman_id = res.data.user_id
  274. }
  275. that.getList();
  276. },
  277. fail() {
  278. that.getList();
  279. }
  280. })
  281. }else {
  282. that.$hideLoading();
  283. uni.showToast({
  284. title: response.msg,
  285. icon: 'none',
  286. duration: 1000
  287. });
  288. }
  289. }).catch(() => {
  290. that.$hideLoading();
  291. });
  292. },
  293. getList() {
  294. let that = this;
  295. that.loading = true;
  296. let para = {
  297. longitude: that.longitude,
  298. latitude: that.latitude,
  299. status: that.activeTab
  300. };
  301. if(that.middleman_id > 0) {
  302. para.middleman_id = that.middleman_id
  303. }
  304. that.$request({
  305. url: that.$api.community.list,
  306. data: para,
  307. method: 'post'
  308. }).then(response=>{
  309. that.loading = false;
  310. that.first = false;
  311. that.$hideLoading();
  312. uni.hideLoading();
  313. if(response.code === 0) {
  314. if (response.list.length === 20) {
  315. that.more = true;
  316. }else {
  317. that.more = false
  318. }
  319. for(let index in response.list) {
  320. if(response.list[index].goods_count == 0) {
  321. response.list.splice(index,1)
  322. }
  323. }
  324. that.list = response.list;
  325. for(let i in that.list) {
  326. if(that.list[i].status_name === '已结束') {
  327. that.list[i].statusText = '活动结束'
  328. }else if(that.list[i].status_name === '进行中') {
  329. that.list[i].statusText = that.list[i].end_at + '结束'
  330. }else if(that.list[i].status_name === '未开始') {
  331. that.list[i].statusText = that.list[i].start_at + '开始'
  332. }
  333. }
  334. }else {
  335. uni.showToast({
  336. title: response.msg,
  337. icon: 'none',
  338. duration: 1000
  339. });
  340. }
  341. }).catch(() => {
  342. that.loading = false;
  343. uni.hideLoading();
  344. that.$hideLoading();
  345. });
  346. }
  347. }
  348. }
  349. </script>
  350. <style scoped lang="scss">
  351. .list {
  352. margin: #{24rpx};
  353. width: #{702rpx};
  354. .title {
  355. height: #{115rpx};
  356. font-size: #{22rpx};
  357. color: #fff;
  358. border-top-left-radius: #{16rpx};
  359. border-top-right-radius: #{16rpx};
  360. padding-left: 63rpx;
  361. .title-text {
  362. font-size: #{30rpx};
  363. font-weight: 600;
  364. height: #{35rpx};
  365. line-height: #{35rpx};
  366. max-width: #{600rpx};
  367. position: relative;
  368. overflow: inherit;
  369. .hot-icon {
  370. position: absolute;
  371. top: 0;
  372. left: #{-49rpx};
  373. width: #{35rpx};
  374. height: #{35rpx};
  375. }
  376. }
  377. .sec-title-text {
  378. width: #{600rpx};
  379. }
  380. }
  381. .status-text {
  382. text-align: center;
  383. position: relative;
  384. width: 100%;
  385. height: #{48rpx};
  386. line-height: #{48rpx};
  387. font-size: #{26rpx};
  388. .status-bg {
  389. position: absolute;
  390. top: 0;
  391. left: 0;
  392. width: 100%;
  393. height: 100%;
  394. opacity: 0.1;
  395. z-index: 0;
  396. }
  397. }
  398. .goods-list {
  399. position: relative;
  400. height: #{160rpx};
  401. background-color: #fff;
  402. padding: 0 #{24rpx} #{24rpx};
  403. .goods {
  404. height: #{160rpx};
  405. padding-top: #{22rpx};
  406. padding-bottom: #{22rpx};
  407. image {
  408. margin-right: #{38rpx};
  409. height: #{120rpx};
  410. width: #{120rpx};
  411. border-radius: #{16rpx};
  412. }
  413. }
  414. .right-arrow {
  415. position: absolute;
  416. top: 50%;
  417. margin-top: #{-12rpx};
  418. right: #{30rpx};
  419. width: #{12rpx};
  420. height: #{24rpx};
  421. }
  422. }
  423. .other {
  424. padding: 0 #{24rpx} #{24rpx};
  425. font-size: #{24rpx};
  426. color: #999;
  427. height: #{60rpx};
  428. background-color: #fff;
  429. border-bottom-left-radius: #{16rpx};
  430. border-bottom-right-radius: #{16rpx};
  431. .other-button {
  432. line-height: #{58rpx};
  433. height: #{58rpx};
  434. padding: 0 #{35rpx};
  435. border-radius: #{30rpx};
  436. border: #{2rpx} solid #e2e2e2;
  437. display: inline-block;
  438. font-size: #{24rpx};
  439. margin-left: #{25rpx};
  440. &.active {
  441. border-color: #ff4544;
  442. color: #ff4544;
  443. }
  444. }
  445. }
  446. }
  447. .banner {
  448. position: fixed;
  449. top: 0;
  450. left: 0;
  451. z-index: 10;
  452. height: #{280rpx};
  453. width: #{750rpx};
  454. background-color: #f7f7f7;
  455. }
  456. .nav-area {
  457. background-color: #f7f7f7;
  458. position: fixed;
  459. top: #{280rpx};
  460. left: 0;
  461. z-index: 10;
  462. .nav {
  463. height: #{54rpx};
  464. width: #{702rpx};
  465. margin: #{35rpx} #{24rpx};
  466. border-radius: 27rpx;
  467. box-shadow: rgba(186, 186, 186, 0.35) 0 4rpx 4rpx;
  468. .active {
  469. position: absolute;
  470. top: 28rpx;
  471. left: #{24rpx};
  472. width: 182rpx;
  473. height: 68rpx;
  474. line-height: 68rpx;
  475. z-index: 10;
  476. background-color: #fff;
  477. border-radius: 27rpx;
  478. text-align: center;
  479. box-shadow: rgba(186, 186, 186, 0.35) 0 4rpx 4rpx;
  480. }
  481. .nav-item {
  482. width: 25%;
  483. height: #{54rpx};
  484. color: #ffffff;
  485. font-size: #{28rpx};
  486. text-align: center;
  487. line-height: #{54rpx};
  488. position: relative;
  489. }
  490. }
  491. }
  492. .placeholder {
  493. height: #{380rpx};
  494. }
  495. .empty-box {
  496. width: 100%;
  497. height: 60vh;
  498. display: flex;
  499. justify-content: center;
  500. align-items: center;
  501. flex-direction: column;
  502. image {
  503. width: 280#{rpx};
  504. height: 280#{rpx};
  505. }
  506. span {
  507. margin-top: 15#{rpx};
  508. color: #999;
  509. font-size: 28#{rpx};
  510. }
  511. }
  512. </style>