index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <template>
  2. <view class='recommend'>
  3. <view class="common-hd">
  4. <view class="title">为你推荐</view>
  5. </view>
  6. <view class='recommendList acea-row row-between-wrapper' :class="indexP?'on':''">
  7. <view class='item' v-for="(item,index) in hostProduct" :key="index" hover-class='none' @tap="goDetail(item)">
  8. <view class='pictrue'>
  9. <image :src='item.image'></image>
  10. <span class="pictrue_log_big pictrue_log_class" v-if="item.activity && item.activity.type === '1'">秒杀</span>
  11. <span class="pictrue_log_big pictrue_log_class" v-if="item.activity && item.activity.type === '2'">砍价</span>
  12. <span class="pictrue_log_big pictrue_log_class" v-if="item.activity && item.activity.type === '3'">拼团</span>
  13. </view>
  14. <view class="text">
  15. <view class='name line1'>
  16. <text v-if="item.product_type == 0" class="font-bg-red">{{item.merchant.is_trader ? '自营' : '' }}</text>
  17. <span v-if="item.product_type != 0" :class="'font_bg-red type'+item.product_type">{{item.product_type == 1 ? "秒杀" : item.product_type == 2 ? "预售" : item.product_type == 3 ? "助力" : item.product_type == 4 ? "拼团" : ""}}</span>
  18. {{item.store_name}}
  19. </view>
  20. <view class="acea-row row-middle">
  21. <view class='money font-color'>¥<text class='num'>{{item.price}}</text></view>
  22. <text class="coupon font-color-red" v-if="item.issetCoupon">领券</text>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. import {mapGetters} from "vuex";
  31. import { goShopDetail } from '@/libs/order.js'
  32. import {openBargainSubscribe} from '@/utils/SubscribeMessage.js';
  33. import {initiateAssistApi} from '@/api/activity.js';
  34. import {toLogin} from '@/libs/login.js';
  35. export default {
  36. computed: mapGetters(['uid']),
  37. props: {
  38. hostProduct: {
  39. type: Array,
  40. default: function() {
  41. return [];
  42. }
  43. },
  44. indexP:{
  45. type: Boolean,
  46. default: false
  47. },
  48. isLogin:{
  49. type: Boolean,
  50. default: false
  51. }
  52. },
  53. data() {
  54. return {
  55. };
  56. },
  57. methods: {
  58. goDetail(item){
  59. goShopDetail(item, this.uid).then(res => {
  60. if (this.isLogin) {
  61. initiateAssistApi(item.activity_id).then(res => {
  62. let id = res.data.product_assist_set_id;
  63. uni.hideLoading();
  64. // #ifndef MP
  65. uni.navigateTo({
  66. url: '/pages/activity/assist_detail/index?id=' + id
  67. });
  68. // #endif
  69. // #ifdef MP
  70. openBargainSubscribe().then(res => {
  71. uni.hideLoading();
  72. uni.navigateTo({
  73. url: '/pages/activity/assist_detail/index?id=' + id
  74. });
  75. }).catch((err) => {
  76. uni.hideLoading();
  77. });
  78. // #endif
  79. }).catch((err) => {
  80. uni.showToast({
  81. title: err,
  82. icon: 'none'
  83. })
  84. });
  85. } else {
  86. // #ifdef H5 || APP-PLUS
  87. toLogin();
  88. // #endif
  89. // #ifdef MP
  90. this.$emit('isShowAuth', true);
  91. this.$emit('isAuto', true);
  92. // #endif
  93. }
  94. })
  95. }
  96. }
  97. }
  98. </script>
  99. <style scoped lang="scss">
  100. .common-hd {
  101. display: flex;
  102. align-items: center;
  103. justify-content: center;
  104. height: 118rpx;
  105. .title {
  106. padding: 0 80rpx;
  107. font-size: 34rpx;
  108. color: $theme-color;
  109. font-weight: bold;
  110. background-image: url("~@/static/images/index-title.png");
  111. background-repeat: no-repeat;
  112. background-size: 100% auto;
  113. background-position: left center;
  114. }
  115. }
  116. .recommend .recommendList {
  117. padding: 0 20rpx;
  118. }
  119. .recommend .recommendList.on{
  120. padding: 0;
  121. }
  122. .recommend .recommendList .item {
  123. width: 340rpx;
  124. margin-bottom: 30rpx;
  125. background-color: #fff;
  126. border-radius: 16rpx;
  127. padding-bottom: 20rpx;
  128. }
  129. .recommend .recommendList .item .text{
  130. padding: 0 20rpx;
  131. }
  132. .recommend .recommendList .item .coupon{
  133. background:rgba(255,248,247,1);
  134. border:1px solid rgba(233,51,35,1);
  135. border-radius:4rpx;
  136. font-size:20rpx;
  137. margin-left: 18rpx;
  138. padding: 1rpx 4rpx;
  139. }
  140. .recommend .recommendList .item .pictrue {
  141. position: relative;
  142. width: 100%;
  143. height: 345rpx;
  144. }
  145. .recommend .recommendList .item .pictrue image {
  146. width: 100%;
  147. height: 100%;
  148. border-radius: 16rpx 16rpx 0 0;
  149. }
  150. .recommend .recommendList .item .name {
  151. font-size: 28rpx;
  152. color: #282828;
  153. margin: 20rpx 0 10rpx 0;
  154. }
  155. .recommend .recommendList .item .money {
  156. font-size: 20rpx;
  157. font-weight: bold;
  158. }
  159. .recommend .recommendList .item .money .num {
  160. font-size: 34rpx;
  161. }
  162. </style>