index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. <!-- #ifdef MP-TOUTIAO -->
  22. <view class='money font-color' v-if="power">¥<text class='num'>{{item.price}}</text></view>
  23. <!-- #endif -->
  24. <!-- #ifndef MP-TOUTIAO -->
  25. <view class='money font-color' >¥<text class='num'>{{item.price}}</text></view>
  26. <!-- #endif -->
  27. <text class="coupon font-color-red" v-if="item.issetCoupon">领券</text>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. import {mapGetters} from "vuex";
  36. import { goShopDetail } from '@/libs/order.js'
  37. import {openBargainSubscribe} from '@/utils/SubscribeMessage.js';
  38. import {initiateAssistApi} from '@/api/activity.js';
  39. import {toLogin} from '@/libs/login.js';
  40. export default {
  41. computed: mapGetters(['uid']),
  42. props: {
  43. hostProduct: {
  44. type: Array,
  45. default: function() {
  46. return [];
  47. }
  48. },
  49. indexP:{
  50. type: Boolean,
  51. default: false
  52. },
  53. isLogin:{
  54. type: Boolean,
  55. default: false
  56. }
  57. },
  58. data() {
  59. return {
  60. // #ifdef MP-TOUTIAO
  61. power: '',
  62. // #endif
  63. };
  64. },
  65. onLoad() {
  66. // #ifdef MP-TOUTIAO
  67. this.power = uni.getStorageSync('power')
  68. // #endif
  69. },
  70. methods: {
  71. goDetail(item){
  72. goShopDetail(item, this.uid).then(res => {
  73. if (this.isLogin) {
  74. initiateAssistApi(item.activity_id).then(res => {
  75. let id = res.data.product_assist_set_id;
  76. uni.hideLoading();
  77. // #ifndef MP
  78. uni.navigateTo({
  79. url: '/pages/activity/assist_detail/index?id=' + id
  80. });
  81. // #endif
  82. // #ifdef MP
  83. openBargainSubscribe().then(res => {
  84. uni.hideLoading();
  85. uni.navigateTo({
  86. url: '/pages/activity/assist_detail/index?id=' + id
  87. });
  88. }).catch((err) => {
  89. uni.hideLoading();
  90. });
  91. // #endif
  92. }).catch((err) => {
  93. uni.showToast({
  94. title: err,
  95. icon: 'none'
  96. })
  97. });
  98. } else {
  99. // #ifdef H5 || APP-PLUS
  100. toLogin();
  101. // #endif
  102. // #ifdef MP
  103. this.$emit('isShowAuth', true);
  104. this.$emit('isAuto', true);
  105. // #endif
  106. }
  107. })
  108. }
  109. }
  110. }
  111. </script>
  112. <style scoped lang="scss">
  113. .common-hd {
  114. display: flex;
  115. align-items: center;
  116. justify-content: center;
  117. height: 118rpx;
  118. .title {
  119. padding: 15rpx 150rpx;
  120. font-size: 34rpx;
  121. // color: $theme-color;
  122. color: #bc7b00;
  123. // padding: 0 80rpx;
  124. // font-size: 34rpx;
  125. // color: $theme-color;
  126. font-weight: bold;
  127. background-image: url("~@/static/images/index-foryou.png");
  128. background-repeat: no-repeat;
  129. background-size: 100% auto;
  130. background-position: left center;
  131. }
  132. }
  133. .recommend .recommendList {
  134. padding: 0 20rpx;
  135. }
  136. .recommend .recommendList.on{
  137. padding: 0;
  138. }
  139. .recommend .recommendList .item {
  140. width: 340rpx;
  141. margin-bottom: 30rpx;
  142. background-color: #fff;
  143. border-radius: 16rpx;
  144. padding-bottom: 20rpx;
  145. }
  146. .recommend .recommendList .item .text{
  147. padding: 0 20rpx;
  148. }
  149. .recommend .recommendList .item .coupon{
  150. background:rgba(255,248,247,1);
  151. border:1px solid rgba(233,51,35,1);
  152. border-radius:4rpx;
  153. font-size:20rpx;
  154. margin-left: 18rpx;
  155. padding: 1rpx 4rpx;
  156. }
  157. .recommend .recommendList .item .pictrue {
  158. position: relative;
  159. width: 100%;
  160. height: 345rpx;
  161. }
  162. .recommend .recommendList .item .pictrue image {
  163. width: 100%;
  164. height: 100%;
  165. border-radius: 16rpx 16rpx 0 0;
  166. }
  167. .recommend .recommendList .item .name {
  168. font-size: 28rpx;
  169. color: #282828;
  170. margin: 20rpx 0 10rpx 0;
  171. }
  172. .recommend .recommendList .item .money {
  173. font-size: 20rpx;
  174. font-weight: bold;
  175. }
  176. .recommend .recommendList .item .money .num {
  177. font-size: 34rpx;
  178. }
  179. </style>