combination.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. <template>
  2. <!-- 拼团活动 -->
  3. <view>
  4. <view :style="[boxStyle]" v-if="combinationList.length">
  5. <view>
  6. <!-- 拼团头部 -->
  7. <view class="w-full h-96 px-24 flex-between-center bg-cover" :style="[headerStyle]">
  8. <view class="flex-y-center">
  9. <text class="fs-32 lh-44rpx fw-500" :style="[titleStyle]" v-if="titleConfig">{{ titleTxtConfig }}</text>
  10. <image :src="titleImg" class="w-140 h-32" v-else></image>
  11. <text class="fs-28 text--w111-ccc px-20" :style="[dividerColor]">|</text>
  12. <view class="avatar-group flex-y-center mr-20" v-if="pinkInfo.avatars && pinkInfo.avatars.length">
  13. <image v-for="(item, index) in pinkInfo.avatars" :key="index" :src="item" mode="" class="w-36 h-36 rd-50-p111-"></image>
  14. </view>
  15. <text class="fs-26 text--w111-999 lh-36rpx" :style="[tipsColor]">{{ pinkInfo.pink_count }}{{ $t(`人参与拼团`) }}</text>
  16. </view>
  17. <view class="flex-y-center fs-24 text--w111-999" :style="[headerBntColor]" @tap="goPage('/pages/activity/goods_combination/index')">
  18. <text>{{ rightBntTxt }}</text>
  19. <text class="iconfont icon-ic_rightarrow fs-24" :style="[headerBntColor]"></text>
  20. </view>
  21. </view>
  22. <!-- 拼团列表 -->
  23. <!-- 单列 -->
  24. <view class="pt-32 pr-20 pb-32 pl-20" :style="[boxContentStyle]" v-if="goodStyleConfig == 0">
  25. <view class="w-full flex justify-between item" v-for="(item, index) in combinationList" :key="index" @tap="goDetail(item)">
  26. <easy-loadimage :image-src="item.image" width="240rpx" height="240rpx" :borderRadius="imgStyle"></easy-loadimage>
  27. <view class="flex-1 flex-col justify-between pl-20 h-240">
  28. <view class="w-full">
  29. <view class="w-full fs-28 h-80 lh-40rpx line2" :style="[productStyle]" v-if="checkboxInfo.includes(0)">{{ item.title }}</view>
  30. <view class="flex mt-14" v-if="checkboxInfo.includes(1)">
  31. <view class="flex fs-20 rd-8rpx" :style="[labelBg]">
  32. <text class="tuan-num text--w111-fff flex-center" v-if="checkboxInfo.includes(1)">{{ item.people }}{{ $t(`人团`) }}</text>
  33. <text class="complete flex-center" :style="[pinkNumStyle]">已拼{{ item.pink_count || 0 }}份</text>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="flex justify-between items-end">
  38. <view class="flex-col">
  39. <baseMoney
  40. :money="item.price"
  41. symbolSize="24"
  42. integerSize="36"
  43. decimalSize="36"
  44. weight
  45. :color="priceColor"
  46. preFix="拼团价"
  47. preFixSize="24"
  48. :textColor="priceColor"
  49. v-if="checkboxInfo.includes(2)"
  50. ></baseMoney>
  51. <text class="text-line fs-28 text--w111-999 pt-14 Regular" v-if="checkboxInfo.includes(3)" :style="[otPriceColor]">{{ $t(`¥`) }}{{ item.product_price }}</text>
  52. </view>
  53. <view class="w-144 h-56 rd-30rpx flex-center fs-24 text--w111-fff" v-if="!showBtn" :style="[btnBgColor]">{{ $t(`去拼团`) }}</view>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. <!-- 两列 -->
  59. <view class="grid-column-2 grid-gap-22rpx pt-32 pr-20 pb-32 pl-20" :style="[boxContentStyle]" v-if="goodStyleConfig == 1">
  60. <view v-for="(item, index) in combinationList" :key="index" @tap="goDetail(item)">
  61. <easy-loadimage :image-src="item.image" width="100%" height="324rpx" :borderRadius="imgStyle"></easy-loadimage>
  62. <view class="w-full mt-16 line1" :style="[productStyle]" v-if="checkboxInfo.includes(1)">
  63. <view class="inline fs-20 rd-4rpx mr-10 rd-4rpx" :style="[labelBg]">
  64. <text class="complete flex-center rd-4rpx" :style="[pinkNumStyle]">{{ item.people }}{{ $t(`人团`) }}</text>
  65. </view>
  66. <view class="inline fs-28 lh-40rpx" v-if="checkboxInfo.includes(0)">{{ item.title }}</view>
  67. </view>
  68. <view class="flex justify-between items-end mt-12">
  69. <view class="flex-col">
  70. <baseMoney :money="item.price" symbolSize="24" integerSize="36" decimalSize="36" weight :color="priceColor" v-if="checkboxInfo.includes(2)"></baseMoney>
  71. <text class="text-line fs-28 text--w111-999 Regular" v-if="checkboxInfo.includes(3)" :style="[otPriceColor]">{{ $t(`¥`) }}{{ item.product_price }}</text>
  72. </view>
  73. <view class="w-144 h-56 rd-30rpx flex-center fs-24 text--w111-fff bg--w111-E93323" v-if="!showBtn" :style="[btnBgColor]">{{ $t(`去拼团`) }}</view>
  74. </view>
  75. </view>
  76. </view>
  77. <!-- 三列 -->
  78. <view class="grid-column-3 grid-gap-18rpx pt-32 pr-20 pb-32 pl-20" :style="[boxContentStyle]" v-if="goodStyleConfig == 2">
  79. <view class="relative" v-for="(item, index) in combinationList" :key="index" @tap="goDetail(item)">
  80. <view class="abs-tag z-20" :style="[labelBg]" v-if="checkboxInfo.includes(1)">
  81. <text class="circle-tag flex-center fs-22" :style="[pinkNumStyle]">{{ item.people }}{{ $t(`人团`) }}</text>
  82. </view>
  83. <easy-loadimage :image-src="item.image" width="100%" height="212rpx" :borderRadius="imgStyle"></easy-loadimage>
  84. <view class="w-full line1 mt-16 fs-26" :style="[productStyle]" v-if="checkboxInfo.includes(0)">{{ item.title }}</view>
  85. <view class="flex items-baseline">
  86. <baseMoney :money="item.price" symbolSize="24" integerSize="36" decimalSize="36" weight :color="priceColor" v-if="checkboxInfo.includes(2)"></baseMoney>
  87. </view>
  88. <view class="text-line fs-24 text--w111-999 Regular lh-32rpx" :style="[otPriceColor]" v-if="checkboxInfo.includes(3)">{{ $t(`¥`) }}{{ item.product_price }}</view>
  89. </view>
  90. </view>
  91. <!-- 滑动 -->
  92. <scroll-view scroll-x="true" show-scrollbar="false" :style="[boxContentStyle]" class="white-nowrap vertical-middle w-full p-32" v-if="goodStyleConfig == 3">
  93. <view class="inline-block relative" :class="{ 'ml-20': index }" v-for="(item, index) in combinationList" :key="index" @tap="goDetail(item)">
  94. <view class="abs-tag z-20" :style="[labelBg]" v-if="checkboxInfo.includes(1)">
  95. <text class="circle-tag flex-center fs-22" :style="[pinkNumStyle]">{{ item.people }}{{ $t(`人团`) }}</text>
  96. </view>
  97. <easy-loadimage :image-src="item.image" width="224rpx" height="224rpx" :borderRadius="imgStyle"></easy-loadimage>
  98. <view class="w-222 line1 mt-16 fs-26" :style="[productStyle]" v-if="checkboxInfo.includes(0)">{{ item.title }}</view>
  99. <baseMoney class="mt-12" :money="item.price" symbolSize="24" integerSize="36" decimalSize="36" weight :color="priceColor" v-if="checkboxInfo.includes(2)"></baseMoney>
  100. <view class="text-line fs-24 Regular lh-32rpx" :style="[otPriceColor]" v-if="checkboxInfo.includes(3)">{{ $t(`¥`) }}{{ item.product_price }}</view>
  101. </view>
  102. </scroll-view>
  103. </view>
  104. </view>
  105. </view>
  106. </template>
  107. <script>
  108. import { openPinkSubscribe } from '@/utils/SubscribeMessage.js';
  109. import { pink } from '@/api/api.js';
  110. import { getCombinationList } from '@/api/activity.js';
  111. export default {
  112. name: 'combination',
  113. props: {
  114. dataConfig: {
  115. type: Object,
  116. default: () => {}
  117. },
  118. isSortType: {
  119. type: String | Number,
  120. default: 0
  121. }
  122. },
  123. data() {
  124. return {
  125. pinkInfo: '',
  126. combinationList: []
  127. };
  128. },
  129. computed: {
  130. titleStyle() {
  131. let titleText = this.dataConfig.titleText;
  132. return {
  133. fontStyle: !titleText.tabVal ? 'normal' : titleText.tabList[titleText.tabVal].style,
  134. fontWeight: !titleText.tabVal ? 'bold' : 'normal',
  135. color: this.dataConfig.titleColor.color[0].item,
  136. fontSize: this.dataConfig.titleNumber.val * 2 + 'rpx'
  137. };
  138. },
  139. boxStyle() {
  140. return {
  141. padding: `${this.dataConfig.topConfig.val * 2}rpx ${this.dataConfig.prConfig.val * 2}rpx ${this.dataConfig.bottomConfig.val * 2}rpx`,
  142. marginTop: `${this.dataConfig.mbConfig.val * 2}rpx`,
  143. background: this.dataConfig.bottomBgColor.color[0].item
  144. };
  145. },
  146. boxContentStyle() {
  147. let br = `${this.dataConfig.fillet.val * 2}rpx`;
  148. let borderRadius = `0 0 ${br} ${br}`;
  149. if (this.dataConfig.fillet.type) {
  150. borderRadius = `0 0 ${this.dataConfig.fillet.valList[3].val * 2}rpx ${this.dataConfig.fillet.valList[2].val * 2}rpx`;
  151. }
  152. return {
  153. borderRadius,
  154. background: `linear-gradient(90deg, ${this.dataConfig.moduleColor.color[0].item} 0%, ${this.dataConfig.moduleColor.color[1].item} 100%)`
  155. };
  156. },
  157. /*商品模板*/
  158. goodStyleConfig() {
  159. return this.dataConfig.goodStyleConfig.tabVal;
  160. },
  161. styleConfig() {
  162. return this.dataConfig.styleConfig.tabVal;
  163. },
  164. headerStyle() {
  165. let br = `${this.dataConfig.fillet.val * 2}rpx`,
  166. borderRadius = '',
  167. imgBgUrl = this.dataConfig.imgBgConfig.url;
  168. if (this.dataConfig.fillet.type) {
  169. borderRadius = `${this.dataConfig.fillet.valList[0].val * 2}rpx ${this.dataConfig.fillet.valList[1].val * 2}rpx 0 0`;
  170. } else {
  171. borderRadius = `${br} ${br} 0 0`;
  172. }
  173. return {
  174. backgroundImage: this.styleConfig
  175. ? 'url(' + imgBgUrl + ')'
  176. : `linear-gradient(90deg,${this.dataConfig.headerBgColor.color[0].item} 0%,${this.dataConfig.headerBgColor.color[1].item} 100%)`,
  177. borderRadius
  178. };
  179. },
  180. /*标题是文本还是图片*/
  181. titleConfig() {
  182. return this.dataConfig.titleConfig.tabVal;
  183. },
  184. /*标题文本*/
  185. titleTxtConfig() {
  186. return this.dataConfig.titleTxtConfig.value;
  187. },
  188. /*标题图片*/
  189. titleImg() {
  190. return this.styleConfig ? this.titleUrl : this.titleColorUrl;
  191. },
  192. titleColorUrl() {
  193. return this.dataConfig.imgColorConfig.url;
  194. },
  195. titleUrl() {
  196. return this.dataConfig.imgConfig.url;
  197. },
  198. /*标题提示文字*/
  199. tipsColor() {
  200. return {
  201. color: this.styleConfig ? this.dataConfig.tipsColor.color[0].item : this.dataConfig.tipsColor2.color[0].item
  202. };
  203. },
  204. /*分割线颜色*/
  205. dividerColor() {
  206. return {
  207. color: this.dataConfig.dividerColor.color[0].item
  208. };
  209. },
  210. /*头部按钮文本*/
  211. rightBntTxt() {
  212. return this.dataConfig.rightBntConfig.value;
  213. },
  214. /*头部按钮样式*/
  215. headerBntColor() {
  216. return {
  217. color: this.styleConfig ? this.dataConfig.headerBntColor.color[0].item : this.dataConfig.headerBntColor2.color[0].item,
  218. fontSize: `${this.dataConfig.bntNumber.val * 2}rpx`
  219. };
  220. },
  221. /*商品图片圆角样式*/
  222. imgStyle() {
  223. let borderRadius = `${this.dataConfig.filletImg.val * 2}rpx`;
  224. if (this.dataConfig.filletImg.type) {
  225. borderRadius = `${this.dataConfig.filletImg.valList[0].val * 2}rpx ${this.dataConfig.filletImg.valList[1].val * 2}rpx ${this.dataConfig.filletImg.valList[3].val * 2}rpx ${
  226. this.dataConfig.filletImg.valList[2].val * 2
  227. }rpx`;
  228. }
  229. return borderRadius;
  230. },
  231. /*商品名称样式*/
  232. productStyle() {
  233. return {
  234. color: this.dataConfig.goodsNameColor.color[0].item,
  235. fontWeight: this.dataConfig.goodsName.tabVal ? 'normal' : 'bold'
  236. };
  237. },
  238. /* 展示信息 */
  239. checkboxInfo() {
  240. return this.dataConfig.checkboxInfo.type;
  241. },
  242. pinkNumStyle() {
  243. return {
  244. color: this.dataConfig.toneConfig.tabVal ? this.dataConfig.labelColor.color[0].item : 'var(--view-theme)'
  245. // background: this.dataConfig.toneConfig.tabVal ? this.dataConfig.labelColor.color[0].item : 'var(--view-theme)'
  246. };
  247. },
  248. labelBg() {
  249. return {
  250. background: this.dataConfig.toneConfig.tabVal ? this.dataConfig.labelColor.color[0].item : 'var(--view-theme)',
  251. height: '32rpx'
  252. };
  253. },
  254. /* 价格颜色 */
  255. priceColor() {
  256. return this.dataConfig.toneConfig.tabVal ? this.dataConfig.pinkPriceColor.color[0].item : 'var(--view-theme)';
  257. },
  258. /* 划线价颜色 */
  259. otPriceColor() {
  260. return {
  261. color: this.dataConfig.goodsPriceColor.color[0].item
  262. };
  263. },
  264. showBtn() {
  265. return this.dataConfig.pinkConfig.tabVal;
  266. },
  267. /* 按钮颜色 */
  268. btnBgColor() {
  269. return {
  270. background: this.dataConfig.toneConfig.tabVal
  271. ? `linear-gradient(90deg,${this.dataConfig.goodsBntColor.color[1].item} 0%,${this.dataConfig.goodsBntColor.color[0].item} 100%)`
  272. : 'linear-gradient(90deg, var(--view-theme) 0%, var(--view-gradient) 100%)',
  273. color: this.dataConfig.goodsBntTxtColor.color[0].item
  274. };
  275. },
  276. /*商品数量*/
  277. numberConfig() {
  278. return this.dataConfig.numberConfig.val;
  279. }
  280. },
  281. mounted() {
  282. this.pink();
  283. this.getCombinationList();
  284. },
  285. methods: {
  286. goPage(url) {
  287. uni.navigateTo({
  288. url
  289. });
  290. },
  291. goDetail(item) {
  292. console.log(item);
  293. // #ifndef MP
  294. uni.navigateTo({
  295. url: `/pages/activity/goods_combination_details/index?id=${item.id}&type=3`
  296. });
  297. // #endif
  298. // #ifdef MP
  299. openPinkSubscribe().then((res) => {
  300. uni.navigateTo({
  301. url: `/pages/activity/goods_combination_details/index?id=${item.id}&type=3`
  302. });
  303. });
  304. // #endif
  305. },
  306. // 拼团列表
  307. getCombinationList: function () {
  308. let that = this;
  309. let limit = that.$config.LIMIT;
  310. let data = {
  311. page: 1,
  312. limit: this.numberConfig >= limit ? limit : this.numberConfig
  313. };
  314. getCombinationList(data)
  315. .then((res) => {
  316. that.combinationList = res.data;
  317. })
  318. .catch((res) => {
  319. return that.$util.Tips({
  320. title: res
  321. });
  322. });
  323. },
  324. // 拼团数据(拼团人数头部图片)
  325. pink: function () {
  326. pink().then((res) => {
  327. this.pinkInfo = res.data;
  328. });
  329. }
  330. }
  331. };
  332. </script>
  333. <style lang="scss">
  334. .Regular {
  335. font-family: 'Regular';
  336. }
  337. .bg-cover {
  338. background-size: cover;
  339. }
  340. .item ~ .item {
  341. margin-top: 32rpx;
  342. }
  343. .inline-flex {
  344. display: inline-flex;
  345. }
  346. .tuan-num {
  347. display: inline-flex;
  348. justify-content: center;
  349. align-items: center;
  350. padding: 0 8rpx;
  351. height: 32rpx;
  352. border-radius: 8rpx 0 0 8rpx;
  353. }
  354. .complete {
  355. display: inline-flex;
  356. justify-content: center;
  357. align-items: center;
  358. padding: 0 8rpx;
  359. height: 32rpx;
  360. line-height: 32rpx;
  361. border-radius: 0 8rpx 8rpx 0;
  362. background: rgba(255, 255, 255, 0.9);
  363. }
  364. .rd-4rpx {
  365. border-radius: 4rpx !important;
  366. }
  367. .avatar-group image {
  368. margin-right: -10rpx;
  369. }
  370. .abs-tag {
  371. position: absolute;
  372. left: 10rpx;
  373. top: 10rpx;
  374. width: 84rpx;
  375. height: 30rpx;
  376. border-radius: 20rpx;
  377. }
  378. .circle-tag {
  379. width: 84rpx;
  380. height: 30rpx;
  381. border-radius: 20rpx;
  382. background: rgba(255, 255, 255, 0.9);
  383. }
  384. scroll-view {
  385. box-sizing: border-box;
  386. }
  387. </style>