bargain.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <template>
  2. <view v-if="assistList.length > 0">
  3. <view class="skeleton-rect" :style="'margin-top:'+mbConfig+'rpx;'">
  4. <view class="assist-count" :class="'wrapper-count'+styleType" :style="'border-radius:'+bgStyle+'rpx'">
  5. <view class="spike-bd">
  6. <view class="title line1"><image class="title-img" src="/static/images/assist_title.png"></image></view>
  7. <view v-if="!merId" class="activity_pic">
  8. <view v-for="(item, index) in assistUserList" class="picture">
  9. <text v-if="item.avatar_img" class="avatar" :style="'background-image: url(' + item.avatar_img + ')'"></text>
  10. <text v-else class="avatar" style="background-image: url('/static/images/f.png')"></text>
  11. </view>
  12. <text class="pic_count">{{ assistUserCount }}人助力成功</text>
  13. </view>
  14. <navigator v-if="!merId" url="/pages/activity/assist/index" class="more-btn" hover-class="none">
  15. 更多活动
  16. <text class="iconfont icon-jiantou" hover-class="none"></text>
  17. </navigator>
  18. </view>
  19. <view class="wapper_count">
  20. <view class="spike-wrapper" :class="'wrapper'+styleType">
  21. <scroll-view v-if="styleType != 2" :class="'colum'+styleType" :scroll-x="styleType == 0 ? true : false" show-scrollbar="false">
  22. <view class="spike-item assist-item" v-for="(item, index) in assistList" :key="index" @click="handleAssist(item.product_assist_id)">
  23. <view class="img-box" :class="'img-box'+conStyle">
  24. <easy-loadimage mode="widthFix" :image-src="item.product.image"></easy-loadimage>
  25. <text v-if="joinShow" class="participants">{{ item.user_count }}人参与</text>
  26. </view>
  27. <view v-if="titleShow || barginShow || priceShow" class="assist-info" :class="'assist-info'+styleType">
  28. <view class="price-box presell-price">
  29. <view v-if="titleShow" class="name line1">{{ item.store_name }}</view>
  30. <view :style="'color:'+themeColor" class="price">
  31. <text v-if="barginShow" class="assist_price">助力价</text>
  32. <text v-if="priceShow" class="line1 price_num">¥{{ item.assistSku[0].assist_price }}</text>
  33. </view>
  34. </view>
  35. <button v-if="bntShow" class="initiate_btn" :class="'initiate_btn'+styleType" :style="{background: `linear-gradient(180deg,${bgColor[0].item} 0%,${bgColor[1].item} 100%)`}">发起助力</button>
  36. </view>
  37. </view>
  38. </scroll-view>
  39. <block v-else class="acea-row row-between-wrapper combination">
  40. <view
  41. class="combination-item"
  42. v-for="(item, index) in assistList"
  43. :key="index"
  44. :style="'border-radius:'+conStyle"
  45. @click="handleAssist(item.product_assist_id)">
  46. <view class="info">
  47. <view class="price-box combination-price">
  48. <view v-if="titleShow" class="name line1">{{ item.product.store_name }}</view>
  49. <text :style="'color:'+themeColor" v-if="priceShow" class="price">
  50. <text>¥</text>
  51. {{ item.product.price }}
  52. </text>
  53. <text v-if="bntShow" class="gocom_btn" :style="{background: `linear-gradient(180deg,${bgColor[0].item} 0%,${bgColor[1].item} 100%)`}">
  54. 去助力
  55. <text class="iconfont icon-jiantou"></text>
  56. </text>
  57. </view>
  58. </view>
  59. <view class="img-box">
  60. <easy-loadimage mode="widthFix" :image-src="item.product.image"></easy-loadimage>
  61. </view>
  62. </view>
  63. <view v-if="assistList.length == 1"
  64. class="combination-item"
  65. :style="'border-radius:'+conStyle"
  66. @click="handleAssist(assistList[0].product_assist_id)">
  67. <view class="info">
  68. <view class="price-box combination-price">
  69. <view v-if="titleShow" class="name line1">{{ assistList[0].product.store_name }}</view>
  70. <text :style="'color:'+themeColor" v-if="priceShow" class="price">
  71. <text>¥</text>
  72. {{ assistList[0].product.price }}
  73. </text>
  74. <text v-if="bntShow" class="gocom_btn" :style="{background: `linear-gradient(180deg,${bgColor[0].item} 0%,${bgColor[1].item} 100%)`}">
  75. 去助力
  76. <text class="iconfont icon-jiantou"></text>
  77. </text>
  78. </view>
  79. </view>
  80. <view class="img-box">
  81. <easy-loadimage mode="widthFix" :image-src="assistList[0].product.image"></easy-loadimage>
  82. </view>
  83. </view>
  84. <view v-if="assistList.length == 1"
  85. class="combination-item"
  86. :style="'border-radius:'+conStyle"
  87. @click="handleAssist(assistList[0].product_assist_id)">
  88. <view class="info">
  89. <view class="price-box combination-price">
  90. <view v-if="titleShow" class="name line1">{{ assistList[0].product.store_name }}</view>
  91. <text :style="'color:'+themeColor" v-if="priceShow" class="price">
  92. <text>¥</text>
  93. {{ assistList[0].product.price }}
  94. </text>
  95. <text v-if="bntShow" class="gocom_btn" :style="{background: `linear-gradient(180deg,${bgColor[0].item} 0%,${bgColor[1].item} 100%)`}">
  96. 去助力
  97. <text class="iconfont icon-jiantou"></text>
  98. </text>
  99. </view>
  100. </view>
  101. <view class="img-box">
  102. <easy-loadimage mode="widthFix" :image-src="assistList[0].product.image"></easy-loadimage>
  103. </view>
  104. </view>
  105. <view v-if="assistList.length == 2"
  106. class="combination-item"
  107. :style="'border-radius:'+conStyle"
  108. @click="handleAssist(assistList[1].product_assist_id)">
  109. <view class="info">
  110. <view class="price-box combination-price">
  111. <view v-if="titleShow" class="name line1">{{ assistList[1].product.store_name }}</view>
  112. <text :style="'color:'+themeColor" v-if="priceShow" class="price">
  113. <text>¥</text>
  114. {{ assistList[1].product.price }}
  115. </text>
  116. <text v-if="bntShow" class="gocom_btn" :style="{background: `linear-gradient(180deg,${bgColor[0].item} 0%,${bgColor[1].item} 100%)`}">
  117. 去助力
  118. <text class="iconfont icon-jiantou"></text>
  119. </text>
  120. </view>
  121. </view>
  122. <view class="img-box">
  123. <easy-loadimage mode="widthFix" :image-src="assistList[1].product.image"></easy-loadimage>
  124. </view>
  125. </view>
  126. </block>
  127. </view>
  128. </view>
  129. </view>
  130. </view>
  131. <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse" :isGoIndex="false"></authorize>
  132. </view>
  133. </template>
  134. <script>
  135. import { mapGetters } from 'vuex';
  136. import { getAssistList, assistUserData, initiateAssistApi } from '@/api/activity.js';
  137. import { openBargainSubscribe } from '@/utils/SubscribeMessage.js';
  138. import easyLoadimage from '@/components/easy-loadimage/easy-loadimage.vue';
  139. import authorize from '@/components/Authorize';
  140. export default {
  141. computed: mapGetters(['isLogin', 'uid']),
  142. name: 'bargain',
  143. components:{
  144. easyLoadimage,
  145. authorize
  146. },
  147. props: {
  148. dataConfig: {
  149. type: Object,
  150. default: () => {}
  151. },
  152. merId: {
  153. type: String || Number,
  154. default: ''
  155. }
  156. },
  157. data() {
  158. return {
  159. isAuto: false, //没有授权的不会自动授权
  160. isShowAuth: false, //是否隐藏授权
  161. assistList: [], //助力
  162. assistUserList: [], //已助力数据
  163. assistUserCount: '',
  164. mbConfig: this.dataConfig.mbCongfig.val*2,
  165. styleType: this.dataConfig.tabConfig.tabVal, //单行,多行,板块
  166. bgStyle: this.dataConfig.bgStyle.type ? 20 : 0,
  167. conStyle: this.dataConfig.conStyle.type ? 16 : 0,
  168. bgColor: this.dataConfig.bgColor.color,
  169. themeColor: this.dataConfig.priceColor && this.dataConfig.priceColor.color[0].item,
  170. priceShow: this.dataConfig.priceShow.val,
  171. bntShow: this.dataConfig.bntShow.val,
  172. titleShow: this.dataConfig.titleShow.val,
  173. barginShow: this.dataConfig.barginShow.val, //助力标签
  174. joinShow: this.dataConfig.joinShow.val, //参与标签
  175. };
  176. },
  177. created() {},
  178. mounted() {
  179. console.log(this.dataConfig)
  180. this.getAssistUserCount();
  181. this.getAssistProduct();
  182. },
  183. methods: {
  184. // 助力
  185. getAssistProduct() {
  186. let that = this;
  187. getAssistList({
  188. mer_id: that.merId,limit: that.styleType == 2 ? 3 : 12
  189. }).then(res => {
  190. that.assistList = res.data.list;
  191. }).catch(e => {});
  192. },
  193. // 获取已助力成功数据
  194. getAssistUserCount() {
  195. let that = this;
  196. assistUserData()
  197. .then(res => {
  198. that.assistUserCount = res.data.count;
  199. that.assistUserList = res.data.list;
  200. })
  201. .catch(e => {});
  202. },
  203. handleAssist(id) {
  204. if (this.isLogin) {
  205. initiateAssistApi(id)
  206. .then(res => {
  207. let id = res.data.product_assist_set_id;
  208. uni.hideLoading();
  209. // #ifndef MP
  210. uni.navigateTo({
  211. url: '/pages/activity/assist_detail/index?id=' + id
  212. });
  213. // #endif
  214. // #ifdef MP
  215. openBargainSubscribe()
  216. .then(res => {
  217. uni.hideLoading();
  218. uni.navigateTo({
  219. url: '/pages/activity/assist_detail/index?id=' + id
  220. });
  221. })
  222. .catch(err => {
  223. uni.hideLoading();
  224. });
  225. // #endif
  226. })
  227. .catch(err => {
  228. uni.showToast({
  229. title: err,
  230. icon: 'none'
  231. });
  232. });
  233. } else {
  234. this.isAuto = true;
  235. this.isShowAuth = true
  236. }
  237. },
  238. // 微信登录回调
  239. onLoadFun: function(e) {
  240. this.isShowAuth = false;
  241. },
  242. // 授权关闭
  243. authColse: function(e) {
  244. this.isShowAuth = e;
  245. },
  246. }
  247. }
  248. </script>
  249. <style lang="scss">
  250. @import '../style/main.scss';
  251. .assist-count {
  252. background-color: #fff;
  253. margin: 0 20rpx;
  254. border-radius: 16rpx;
  255. padding: 20rpx 0 0 20rpx;
  256. box-shadow: 4rpx 2rpx 12rpx 2rpx rgba(0, 0, 0, 0.03);
  257. &.wrapper-count2{
  258. padding: 20rpx;
  259. }
  260. }
  261. .activity_pic {
  262. margin-left: 20rpx;
  263. padding-left: 20rpx;
  264. position: relative;
  265. &::before {
  266. content: '';
  267. display: inline-block;
  268. width: 2rpx;
  269. height: 40rpx;
  270. background: #dcdcdc;
  271. position: absolute;
  272. top: 0;
  273. left: 0;
  274. }
  275. .picture {
  276. display: inline-block;
  277. }
  278. .avatar {
  279. width: 42rpx;
  280. height: 42rpx;
  281. line-height: 20rem;
  282. display: inline-block;
  283. background-repeat: no-repeat;
  284. background-size: center/cover;
  285. position: relative;
  286. text-align: center;
  287. color: #fff;
  288. font-weight: 600;
  289. vertical-align: bottom;
  290. font-size: 0.875rem;
  291. -webkit-user-select: none;
  292. -moz-user-select: none;
  293. -ms-user-select: none;
  294. user-select: none;
  295. border-radius: 50%;
  296. background-repeat: no-repeat;
  297. background-size: cover;
  298. background-position: 0 0;
  299. margin-right: -10rpx;
  300. box-shadow: 0 0 0 1px #fff;
  301. }
  302. .pic_count {
  303. margin-left: 30rpx;
  304. color: #999999;
  305. font-size: 26rpx;
  306. position: relative;
  307. top: -4rpx;
  308. }
  309. }
  310. .price_num{
  311. display: inline-block;
  312. max-width: 100rpx;
  313. overflow: hidden;
  314. line-height: 32rpx;
  315. }
  316. </style>