bargain.vue 11 KB

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