index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. <template>
  2. <!-- 拼团活动模块 -->
  3. <view class="group-list" :style="colorStyle">
  4. <view class="swiper" v-if="bannerList.length">
  5. <swiper indicator-dots="true" :autoplay="true" :circular="circular"
  6. :interval="interval" :duration="duration" indicator-color="rgba(0,0,0,0.3)">
  7. <block v-for="(item,index) in bannerList" :key="index">
  8. <swiper-item>
  9. <view @click="goDetail(item)" class='slide-navigator acea-row row-between-wrapper'>
  10. <image :src="item.img" class="slide-image"></image>
  11. </view>
  12. </swiper-item>
  13. </block>
  14. </swiper>
  15. </view>
  16. <view class="groupMember acea-row row-center-wrapper">
  17. <view class="line"><image src="../static/groupLine.png"></image></view>
  18. <view class="member acea-row row-center-wrapper">
  19. <view class="pictrue" v-for="(item,index) in pinkPeople" :key="index" v-if="index<6"><image :src="item"></image></view>
  20. <text class="ml10">{{pinkCount}}人参与</text>
  21. <view class="pictrue" v-if="pinkPeople.length>5">
  22. <image :src="pinkPeople[pinkPeople.length-1]"></image>
  23. <view class="iconfont icon-gengduo1"></view>
  24. </view>
  25. </view>
  26. <view class="line right"><image src="../static/groupLine.png"></image></view>
  27. </view>
  28. <view class="list">
  29. <view class="item acea-row row-between-wrapper" v-for="(item,index) in combinationList" :key='index' @tap="openSubcribe(item)">
  30. <view class="pictrue"><image :src="item.image"></image></view>
  31. <view class="text">
  32. <view class="name line2">{{item.title}}</view>
  33. <view class="bottom acea-row row-between row-bottom">
  34. <view class="y_money">
  35. <view class="price">¥{{item.product_price}}</view>
  36. <view class="money">¥<text class="num">{{item.price}}</text></view>
  37. </view>
  38. <view class="bnt acea-row row-center-wrapper" v-if="item.stock>0&&item.quota>0">
  39. <view class="light"><image src="../static/lightning.png"></image></view>
  40. <view class="num">{{item.people}}人团</view>
  41. <view class="go">去拼团</view>
  42. </view>
  43. <view class="bnt gray acea-row row-center-wrapper" v-else>已售罄</view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. <view class="no-goods" :class="bannerList.length?'':'on'" v-if="!combinationList.length && !loading && isBanner">
  49. <image :src="imgHost + '/statics/images/no-thing.png'" mode=""></image>
  50. <text class="tip">暂无拼团商品,去看看其他商品吧~</text>
  51. </view>
  52. <home v-if="navigation"></home>
  53. </view>
  54. </template>
  55. <script>
  56. import {
  57. getCombinationList,getCombinationBannerList,getPink
  58. } from '@/api/activity.js';
  59. import {
  60. openPinkSubscribe
  61. } from '../../../utils/SubscribeMessage.js';
  62. import home from '@/components/home/index.vue'
  63. import colors from "@/mixins/color";
  64. import {HTTP_REQUEST_URL} from '@/config/app';
  65. let app = getApp();
  66. export default {
  67. components: {
  68. home
  69. },
  70. mixins: [colors],
  71. data() {
  72. return {
  73. pinkPeople:[],
  74. pinkCount:0,
  75. bannerList:[],
  76. circular: true,
  77. autoplay: true,
  78. interval: 3000,
  79. duration: 500,
  80. combinationList: [],
  81. limit: 10,
  82. page: 1,
  83. loading: false,
  84. loadend: false,
  85. isBanner: false,
  86. imgHost:HTTP_REQUEST_URL
  87. }
  88. },
  89. onLoad() {
  90. uni.setNavigationBarTitle({
  91. title:"拼团列表"
  92. })
  93. this.getCombinationList();
  94. this.getBannerList();
  95. this.getPink();
  96. },
  97. onShow(){
  98. uni.removeStorageSync('form_type_cart');
  99. },
  100. methods: {
  101. getPink:function(){
  102. getPink({type:2}).then(res=>{
  103. this.pinkPeople = res.data.avatars;
  104. this.pinkCount = res.data.pink_count;
  105. })
  106. },
  107. getBannerList: function(){
  108. getCombinationBannerList().then(res=>{
  109. this.bannerList = res.data;
  110. this.isBanner = true;
  111. })
  112. },
  113. goDetail(item) {
  114. let url = item.link;
  115. if (url.indexOf("http") != -1) {
  116. // #ifdef H5
  117. location.href = url
  118. // #endif
  119. } else {
  120. if (['/pages/goods_cate/goods_cate', '/pages/order_addcart/order_addcart', '/pages/user/index', '/pages/index/index','/pages/store_cate/store_cate']
  121. .indexOf(url) == -1) {
  122. uni.navigateTo({
  123. url: url
  124. })
  125. } else {
  126. uni.switchTab({
  127. url: url
  128. })
  129. }
  130. }
  131. },
  132. openSubcribe: function(item) {
  133. let page = item;
  134. // #ifndef MP
  135. uni.navigateTo({
  136. url: `/pages/activity/goods_combination_details/index?id=${item.id}`
  137. });
  138. // #endif
  139. // #ifdef MP
  140. uni.showLoading({
  141. title: '正在加载',
  142. })
  143. openPinkSubscribe().then(res => {
  144. uni.hideLoading();
  145. uni.navigateTo({
  146. url: `/pages/activity/goods_combination_details/index?id=${item.id}`
  147. });
  148. }).catch(() => {
  149. uni.hideLoading();
  150. });
  151. // #endif
  152. },
  153. getCombinationList: function() {
  154. var that = this;
  155. if (that.loadend) return;
  156. if (that.loading) return;
  157. var data = {
  158. page: that.page,
  159. limit: that.limit
  160. };
  161. this.loading = true
  162. getCombinationList(data).then(function(res) {
  163. var combinationList = that.combinationList;
  164. var limit = that.limit;
  165. that.page++;
  166. that.loadend = limit > res.data.length;
  167. that.combinationList = combinationList.concat(res.data);
  168. that.page = that.data.page;
  169. that.loading = false;
  170. }).catch(() => {
  171. that.loading = false
  172. })
  173. },
  174. },
  175. onReachBottom: function() {
  176. this.getCombinationList();
  177. },
  178. }
  179. </script>
  180. <style lang="scss">
  181. .ml10 {
  182. margin-left: 10rpx;
  183. }
  184. page {
  185. // background-color: var(--view-theme) !important;
  186. }
  187. .no-goods{
  188. margin: 0 30rpx;
  189. background-color: #fff;
  190. text-align: center;
  191. padding: 20rpx 0 100rpx 0;
  192. color: #999;
  193. border-radius: 10rpx;
  194. height: calc(100vh - 500rpx);
  195. box-sizing: border-box;
  196. &.on{
  197. height: calc(100vh - 200rpx);
  198. }
  199. image{
  200. width: 414rpx;
  201. height: 304rpx;
  202. margin: 40rpx auto 0 auto;
  203. display: block;
  204. }
  205. }
  206. .group-list{
  207. min-height: 100vh;
  208. background-color: var(--view-theme) !important;
  209. padding: 30rpx 0;
  210. .swiper{
  211. width: 100%;
  212. position: relative;
  213. box-sizing: border-box;
  214. padding: 0 30rpx;
  215. swiper{
  216. width: 100%;
  217. height: 300rpx;
  218. .slide-image{
  219. width: 100%;
  220. height: 300rpx;
  221. border-radius: 20rpx;
  222. }
  223. /deep/.uni-swiper-dot {
  224. width: 8rpx !important;
  225. height: 8rpx !important;
  226. border-radius: 50%;
  227. }
  228. /deep/.uni-swiper-dot-active{
  229. width: 18rpx !important;
  230. border-radius: 4rpx;
  231. background-color: var(--view-theme) !important;
  232. }
  233. }
  234. }
  235. .groupMember{
  236. height: 100rpx;
  237. .line{
  238. width: 102rpx;
  239. height: 4rpx;
  240. &.right{
  241. transform:rotate(180deg);
  242. }
  243. image{
  244. width: 100%;
  245. height: 100%;
  246. display: block;
  247. }
  248. }
  249. .member{
  250. margin: 0 30rpx;
  251. color: #fff;
  252. .pictrue{
  253. width: 46rpx;
  254. height: 46rpx;
  255. position: relative;
  256. image{
  257. border:2rpx solid #fff;
  258. width: 100%;
  259. height: 100%;
  260. border-radius: 50%;
  261. }
  262. &~.pictrue{
  263. margin-left: -8rpx;
  264. }
  265. .iconfont{
  266. position: absolute;
  267. width: 43rpx;
  268. height: 43rpx;
  269. background: rgba(51, 51, 51, 0.6);
  270. border-radius: 50%;
  271. top: 2rpx;
  272. left:2rpx;
  273. color: #fff;
  274. font-size: 10rpx;
  275. text-align: center;
  276. line-height: 43rpx;
  277. }
  278. }
  279. }
  280. }
  281. .list{
  282. .item{
  283. width: 690rpx;
  284. height: 230rpx;
  285. background-color: #fff;
  286. border-radius: 14rpx;
  287. padding: 0 22rpx;
  288. margin: 0 auto 18rpx auto;
  289. .pictrue{
  290. width: 186rpx;
  291. height: 186rpx;
  292. image{
  293. width: 100%;
  294. height: 100%;
  295. border-radius: 10rpx;
  296. }
  297. }
  298. .text{
  299. width: 440rpx;
  300. .name{
  301. color: #333;
  302. font-size: 30rpx;
  303. height: 82rpx;
  304. }
  305. .bottom{
  306. margin-top: 10rpx;
  307. .y_money{
  308. font-size: 24rpx;
  309. color: #999;
  310. .price{
  311. text-decoration: line-through;
  312. }
  313. .money{
  314. color: var(--view-priceColor);
  315. font-weight: 600;
  316. .num{
  317. font-size: 34rpx;
  318. }
  319. }
  320. }
  321. .bnt{
  322. height: 58rpx;
  323. font-size: 24rpx;
  324. text-align: center;
  325. position: relative;
  326. background-color: var(--view-theme);
  327. border-radius: 28rpx;
  328. .light{
  329. position: absolute;
  330. width: 28rpx;
  331. height: 58rpx;
  332. top:0;
  333. left:50%;
  334. margin-left: -8rpx;
  335. image{
  336. width: 100%;
  337. height: 100%;
  338. }
  339. }
  340. .num{
  341. width: 120rpx;
  342. background-color: rgba(255,255,255,0.85);
  343. color: var(--view-theme);
  344. height: 100%;
  345. line-height: 58rpx;
  346. border-radius: 28rpx 0 14rpx 28rpx;
  347. }
  348. .go{
  349. width: 112rpx;
  350. background-color: var(--view-theme);
  351. height: 100%;
  352. line-height: 58rpx;
  353. border-radius: 0 28rpx 28rpx 0;
  354. color: #fff;
  355. }
  356. &.gray{
  357. width: 148rpx;
  358. background-color: #cccccc;
  359. color: #fff;
  360. }
  361. }
  362. }
  363. }
  364. }
  365. }
  366. }
  367. </style>