You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

786 lines
19 KiB

3 months ago
  1. <!-- 拼团 -->
  2. <template>
  3. <view class="groupBox" v-if="groupProductList.length" :style="[...boxPadding]">
  4. <view class="group" :style="[...boxStyle]">
  5. <view class="group-top acea-row row-middle row-between" :style="[bgImgStyle]">
  6. <view class="group-top-left acea-row">
  7. <image v-if="selectStyle == 0" :src="logoUrl" alt="" class="logo">
  8. <view v-else class="titleFont" :style="[...headerTitleConfig]">{{ titleConfig }}</view>
  9. <view v-if="groupInfo.totalPeople" class="interval" :style="[lineColor]"></view>
  10. <view class="avater-box" v-if="groupInfo.avatarList&&groupInfo.avatarList.length">
  11. <image class="avater1" :src="groupInfo.avatarList[0]"></image>
  12. <image class="avater2" v-if="groupInfo.avatarList.length>1" :src="groupInfo.avatarList[1]"></image>
  13. <image class="avater3" v-if="groupInfo.avatarList.length>2" :src="groupInfo.avatarList[2]"></image>
  14. </view>
  15. <view v-if="groupInfo.totalPeople" class="num ml-num" :class="groupInfo.avatarList.length==1?'num1':groupInfo.avatarList.length==2?'num2':groupInfo.avatarList.length==3?'num3':''" :style="[titleColor]">{{groupInfo.totalPeople}}人拼团成功</view>
  16. </view>
  17. <view class="group-top-right" :style="[headerBtnColor]" @click="toMore">
  18. 更多
  19. <text class="iconfont icon-you" :style="[headerBtnColor]"></text>
  20. </view>
  21. </view>
  22. <!-- 样式一 -->
  23. <view v-if="listStyle == 0" :style="[...boxBgStyle]" class="group-bottom">
  24. <view v-for="(item, index) in groupProductList" :key="index" :style="[contentConfig]" >
  25. <view class=" acea-row row-between" @click="toGroupDetail(item.id)">
  26. <view class="group-bottom-left">
  27. <view class="img acea-row row-center row-middle" >
  28. <easy-loadimage :image-src="item.image" width="250rpx"
  29. height="250rpx" :radius="dataConfig.contentStyle.val"></easy-loadimage>
  30. </view>
  31. </view>
  32. <view class="group-bottom-right acea-row row-column row-between">
  33. <view class="right-top">
  34. <view class="title line2" v-if="typeShow.includes(0)" :style="[nameColor]">
  35. {{item.title}}
  36. </view>
  37. <view class="pink acea-row" v-if="typeShow.includes(1)">
  38. <view class="people-box acea-row" :style="[groupTitleColor]">
  39. <view class="people" :style="[groupTitleColor]">{{item.people}}人团</view>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="right-bottom acea-row row-between">
  44. <view class="price">
  45. <view class="pinkNum" v-if="typeShow.includes(2)" :style="[priceColor]"><text
  46. class="pinkNum-title">拼团价</text><text class="pinkNum-icon"></text><text
  47. class="pinkNum-num semiBold">{{item.price}}</text>
  48. </view>
  49. <view class="num" v-if="typeShow.includes(3)" :style="[originalColor]"><text
  50. class="num-title">单买价</text><text class="num-icon"></text><text
  51. class="icon-num regular">{{item.otPrice}}</text>
  52. </view>
  53. </view>
  54. <view class="btnBox" v-if="groupBtnShow">
  55. <view class="btn" :style="[...btnColor]">去拼团</view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. <!-- 样式二 -->
  63. <view class="group-bottom two acea-row row-between grid-list" v-if="listStyle == 1"
  64. :style="[...boxBgStyle]">
  65. <view v-for="(item, index) in groupProductList" :key="index" @click="toGroupDetail(item.id)">
  66. <view class="group-bottom-left">
  67. <view class="img acea-row row-center row-middle big-img">
  68. <easy-loadimage :image-src="item.image" width="324rpx"
  69. height="324rpx" :radius="dataConfig.contentStyle.val"></easy-loadimage>
  70. </view>
  71. </view>
  72. <view class="two-item">
  73. <view class="title acea-row">
  74. <view :style="[groupTitleColor]" class="numPink-box">
  75. <view class="numPink" v-if="typeShow.includes(1)" :style="[groupTitleFontColor]">{{item.people}}人团</view>
  76. </view>
  77. <text class="line1" v-if="typeShow.includes(0)" :style="[nameColor]">
  78. {{item.title}}
  79. </text>
  80. </view>
  81. <view class="two-item-bottom acea-row row-between">
  82. <view class="price">
  83. <view class="pinkNum" v-if="typeShow.includes(2)" :style="[priceColor]">
  84. <text class="num-icon"></text><text
  85. class="num semiBold" >{{item.price}}</text>
  86. </view>
  87. <view class="otNum regular" v-if="typeShow.includes(3)" :style="[originalColor]">
  88. {{item.otPrice}}
  89. </view>
  90. </view>
  91. <view class="btnBox" v-if="groupBtnShow">
  92. <view class="btn" :style="[...btnColor]">去拼团</view>
  93. </view>
  94. </view>
  95. </view>
  96. </view>
  97. </view>
  98. <!-- 样式三 -->
  99. <view class="group-bottom three acea-row grid-three" v-if="listStyle == 2" :style="[...boxBgStyle]">
  100. <view v-for="(item, index) in groupProductList" :key="index" class="three-box" @click="toGroupDetail(item.id)">
  101. <view class="group-bottom-left">
  102. <view class="img acea-row row-center row-middle three-img">
  103. <easy-loadimage width="100%" class="loadimage"
  104. height="100%" :image-src="item.image" :radius="dataConfig.contentStyle.val"></easy-loadimage>
  105. </view>
  106. </view>
  107. <view class="two-item">
  108. <view class="title acea-row">
  109. <view :style="[groupTitleColor]" class="numPink-box numPink-box-special">
  110. <view class="numPink" v-if="typeShow.includes(1)" :style="[groupTitleFontColor]">{{item.people}}人团</view>
  111. </view>
  112. <text class="line1" v-if="typeShow.includes(0)" :style="[nameColor]">
  113. {{item.title}}
  114. </text>
  115. </view>
  116. <view class="two-item-bottom">
  117. <view class="price">
  118. <view class="pinkNum" v-if="typeShow.includes(2)" :style="[priceColor]">
  119. <text class="num-icon"></text><text
  120. class="num semiBold">{{item.price}}</text>
  121. </view>
  122. <view class="otNum regular" v-if="typeShow.includes(3)" :style="[originalColor]">
  123. {{item.otPrice}}
  124. </view>
  125. </view>
  126. </view>
  127. </view>
  128. </view>
  129. </view>
  130. <!-- 样式四 -->
  131. <view class="group-bottom four acea-row " v-if="listStyle == 3" :style="[...boxBgStyle]">
  132. <scroll-view scroll-x="true" class="scroll_view">
  133. <view v-for="(item, index) in groupProductList" :key="index" class="four-item" :style="[fourStyle]" @click="toGroupDetail(item.id)">
  134. <view class="group-bottom-left">
  135. <view class="img acea-row row-center row-middle four-img">
  136. <easy-loadimage :image-src="item.image" width="240rpx"
  137. height="240rpx" :radius="dataConfig.contentStyle.val"></easy-loadimage>
  138. </view>
  139. </view>
  140. <view class="two-item">
  141. <view class="title acea-row" v-if="typeShow.includes(0)" :style="[nameColor]">
  142. <view :style="[groupTitleColor]" class="numPink-box numPink-box-special">
  143. <view class="numPink" v-if="typeShow.includes(1)" :style="[groupTitleFontColor]">{{item.people}}人团</view>
  144. </view>
  145. <text class="line1">
  146. {{item.title}}
  147. </text>
  148. </view>
  149. <view class="two-item-bottom">
  150. <view class="price">
  151. <view class="pinkNum" v-if="typeShow.includes(2)" :style="[priceColor]">
  152. <text class="num-icon"></text><text
  153. class="num semiBold">{{item.price}}</text>
  154. </view>
  155. <view class="otNum regular" v-if="typeShow.includes(3)" :style="[originalColor]">
  156. {{item.otPrice}}
  157. </view>
  158. </view>
  159. </view>
  160. </view>
  161. </view>
  162. </scroll-view>
  163. </view>
  164. <emptyPage :mTop="'0'" v-if="groupProductList.length==0" title="暂无拼团商品,去看看其他商品吧~~" :imgSrc="urlDomain+'crmebimage/presets/noActivity.png'"></emptyPage>
  165. </view>
  166. </view>
  167. </template>
  168. <script>
  169. import {getCombinationIndexApi} from '@/api/activity.js';
  170. import easyLoadimage from '@/components/base/easy-loadimage.vue';
  171. import emptyPage from '@/components/emptyPage.vue'
  172. let app = getApp();
  173. export default {
  174. name: 'homeGroup',
  175. components: {
  176. easyLoadimage,
  177. emptyPage
  178. },
  179. props: {
  180. dataConfig: {
  181. type: Object,
  182. default: () => {}
  183. },
  184. },
  185. data() {
  186. return {
  187. urlDomain: this.$Cache.get("imgHost"),
  188. listStyle: 0,
  189. logoUrl: null,
  190. typeShow: [0, 1, 2, 3],
  191. groupBtnShow: true,
  192. selectStyle: '',
  193. titleConfig: '',
  194. selectBgImg: '',
  195. bgImgUrl: '',
  196. headerTitleStyle: 0,
  197. old: {
  198. scrollTop: 0
  199. },
  200. groupInfo: {},
  201. groupProductList: [],
  202. themeColor:this.$options.filters.filterTheme(app.globalData.theme)
  203. }
  204. },
  205. computed: {
  206. //容器样式
  207. //最外层盒子的样式
  208. boxStyle() {
  209. return [{
  210. 'border-radius': this.dataConfig.bgStyle.val ? 2 * this.dataConfig.bgStyle.val + 'rpx' : '0'
  211. },
  212. {
  213. margin: 0 + ' ' + 2 * this.dataConfig.lrConfig.val + 'rpx' + ' ' + 0
  214. },
  215. {
  216. background: `linear-gradient(to right,${this.dataConfig.bgColor.color[0].item}, ${this.dataConfig.bgColor.color[1].item})`,
  217. },
  218. ];
  219. },
  220. //边距
  221. boxPadding() {
  222. return [{
  223. padding: 2 * this.dataConfig.upConfig.val + 'rpx' + ' ' + '0rpx' + ' ' + 2 * this.dataConfig
  224. .downConfig.val + 'rpx',
  225. },
  226. {
  227. margin: 2 * this.dataConfig.mbConfig.val + 'rpx' + ' ' + 0 + ' ' + 0
  228. },
  229. ]
  230. },
  231. //背景颜色
  232. boxBgStyle() {
  233. return [{
  234. gap: this.listStyle != 3 ? `${2*this.dataConfig.contentConfig.val}rpx` : ''
  235. },
  236. {
  237. background: `linear-gradient(to right,${this.dataConfig.contentBgColor.color[0].item}, ${this.dataConfig.contentBgColor.color[1].item})`,
  238. },
  239. ];
  240. },
  241. fourStyle() {
  242. return {
  243. 'margin-right': this.listStyle == 3 ? `${2*this.dataConfig.contentConfig.val}rpx` : ''
  244. }
  245. },
  246. //标题颜色
  247. titleColor() {
  248. return {
  249. color: this.dataConfig.titleColor.color[0].item,
  250. };
  251. },
  252. //头部按钮颜色
  253. headerBtnColor() {
  254. return {
  255. color: this.dataConfig.headerBtnColor.color[0].item,
  256. };
  257. },
  258. //商品名称颜色
  259. nameColor() {
  260. return {
  261. color: this.dataConfig.nameColor.color[0].item,
  262. };
  263. },
  264. //商品原价颜色
  265. originalColor() {
  266. return {
  267. color: this.dataConfig.originalColor.color[0].item,
  268. };
  269. },
  270. //拼团价格颜色
  271. priceColor() {
  272. return {
  273. color: this.dataConfig.themeStyleConfig.tabVal?this.dataConfig.priceColor.color[0].item:this.themeColor,
  274. };
  275. },
  276. //标签颜色
  277. groupTitleColor() {
  278. return {
  279. background: this.dataConfig.themeStyleConfig.tabVal?this.dataConfig.groupTitleColor.color[0].item:this.themeColor,
  280. };
  281. },
  282. //已拼颜色
  283. groupTitleFontColor() {
  284. return {
  285. color: this.dataConfig.themeStyleConfig.tabVal?this.dataConfig.groupTitleColor.color[0].item:this.themeColor,
  286. }
  287. },
  288. //分割线颜色
  289. lineColor() {
  290. return {
  291. border: `1rpx solid ${this.dataConfig.lineColor.color[0].item}`,
  292. };
  293. },
  294. //按钮颜色
  295. btnColor() {
  296. return [{
  297. background: `linear-gradient(to right,${this.dataConfig.themeStyleConfig.tabVal?this.dataConfig.btnColor.color[0].item:'#FF7931'}, ${this.dataConfig.themeStyleConfig.tabVal?this.dataConfig.btnColor.color[1].item:this.themeColor})`,
  298. },
  299. {
  300. color: this.dataConfig.btnFontColor.color[0].item,
  301. }
  302. ];
  303. },
  304. //样式一内容边距
  305. contentConfig() {
  306. return {
  307. 'paddingBottom': 2 * this.dataConfig.contentConfig.val + 'rpx',
  308. };
  309. },
  310. //背景图片
  311. bgImgStyle() {
  312. return {
  313. 'background': this.selectBgImg == 0 ? `url(${this.bgImgUrl})` :
  314. `linear-gradient(to right,${this.dataConfig.bgColor.color[0].item}, ${this.dataConfig.bgColor.color[1].item})`,
  315. };
  316. },
  317. //标题文字格式
  318. headerTitleConfig() {
  319. return [{
  320. 'font-weight': this.headerTitleStyle == 0 ? 600 : ''
  321. },
  322. {
  323. 'font-style': this.headerTitleStyle == 2 ? 'italic' : 'normal'
  324. },
  325. {
  326. color: this.dataConfig.headerTitleColor.color[0].item,
  327. }
  328. ]
  329. }
  330. },
  331. created() {
  332. this.setConfig()
  333. this.getInfo()
  334. },
  335. methods: {
  336. //去拼团
  337. toGroupDetail(id){
  338. uni.navigateTo({
  339. url:`/pages/activity/goods_combination_details/index?id=${id}`
  340. })
  341. },
  342. getInfo() {
  343. let that = this;
  344. getCombinationIndexApi().then(function(res) {
  345. that.groupProductList = res.data.productList;
  346. that.groupInfo = {totalPeople:res.data.totalPeople,avatarList:res.data.avatarList}
  347. }).catch((res) => {
  348. return that.$util.Tips({
  349. title: res
  350. });
  351. })
  352. },
  353. scroll: function(e) {
  354. this.old.scrollTop = e.detail.scrollTop
  355. },
  356. // 更多
  357. toMore() {
  358. uni.navigateTo({
  359. url: '/pages/activity/goods_combination/index'
  360. })
  361. },
  362. setConfig() {
  363. this.listStyle = this.dataConfig.tabConfig.tabVal;
  364. this.logoUrl = this.dataConfig.logoConfig.url;
  365. this.typeShow = this.dataConfig.typeConfig.activeValue;
  366. this.groupBtnShow = this.dataConfig.groupBtnConfig.tabVal == 0 ? true : false;
  367. this.selectStyle = this.dataConfig.selectStyle.tabVal;
  368. this.titleConfig = this.dataConfig.titleConfig.val;
  369. this.selectBgImg = this.dataConfig.selectBgImg.tabVal;
  370. this.bgImgUrl = this.dataConfig.bgImg.url;
  371. this.headerTitleStyle = this.dataConfig.headerTitleStyle.tabVal;
  372. },
  373. }
  374. }
  375. </script>
  376. <style lang="scss" scoped>
  377. .groupBox {
  378. overflow: hidden;
  379. .group {
  380. overflow: hidden;
  381. .group-top {
  382. width: 100%;
  383. height: 100rpx;
  384. padding: 0 24rpx;
  385. background-size: cover !important;
  386. .group-top-left {
  387. align-items: center;
  388. .ml10{
  389. margin-top: 4rpx;
  390. }
  391. .logo {
  392. width: 154rpx;
  393. height: 32rpx;
  394. object-fit: contain;
  395. }
  396. .interval {
  397. width: 0rpx;
  398. height: 28rpx;
  399. margin-left: 20rpx;
  400. margin-top: 4rpx;
  401. opacity: 0.6;
  402. }
  403. .pinkHead {
  404. width: 108rpx;
  405. height: 36rpx;
  406. }
  407. .num {
  408. height: 32rpx;
  409. line-height: 32rpx;
  410. font-size: 26rpx;
  411. margin-left: 16rpx;
  412. color: #FFFFFF;
  413. margin-top: 6rpx;
  414. }
  415. .num1{
  416. margin-left: 12rpx;
  417. }
  418. .num2{
  419. margin-left: 41rpx;
  420. }
  421. .num3{
  422. margin-left: 76rpx;
  423. }
  424. }
  425. .group-top-right {
  426. height: 32rpx;
  427. line-height: 32rpx;
  428. font-size: 24rpx;
  429. .icon-xiangyou {
  430. font-size: 24rpx;
  431. }
  432. }
  433. }
  434. .group-bottom {
  435. width: 100%;
  436. padding: 20rpx;
  437. .img {
  438. width: 240rpx;
  439. // height: 240rpx;
  440. // background: #F3F9FF;
  441. }
  442. .big-img.img {
  443. width: 100%;
  444. height: 324rpx;
  445. }
  446. .three-img.img {
  447. width: 100%;
  448. height: 210rpx;
  449. }
  450. .loadimage{
  451. width: 100%;
  452. height: 100%;
  453. }
  454. .four-img {
  455. width: 240rpx;
  456. height: 240rpx;
  457. }
  458. .group-bottom-right {
  459. flex: 1;
  460. margin-left: 20rpx;
  461. .right-top {
  462. .title {
  463. font-size: 28rpx;
  464. color: #333333;
  465. }
  466. .people-box {
  467. border-radius: 8rpx;
  468. }
  469. .pink {
  470. margin-top: 16rpx;
  471. font-size: 22rpx;
  472. border-radius: 8rpx;
  473. .people {
  474. color: #fff;
  475. padding: 4rpx 16rpx;
  476. border-radius: 8rpx;
  477. }
  478. .groupNum {
  479. background-color: rgba(255, 255, 255, 0.9);
  480. padding: 4rpx 12rpx;
  481. border-radius: 0 6rpx 6rpx 0;
  482. margin-left: 2rpx;
  483. }
  484. }
  485. }
  486. .right-bottom {
  487. .price {
  488. .pinkNum {
  489. .pinkNum-num {
  490. font-size: 36rpx;
  491. }
  492. }
  493. .num {
  494. color: #999999;
  495. }
  496. }
  497. .btnBox {
  498. // margin-top: 16rpx;
  499. font-size: 22rpx;
  500. display: flex;
  501. align-items: end;
  502. .btn {
  503. padding: 12rpx 20rpx;
  504. border-radius: 50rpx;
  505. }
  506. }
  507. }
  508. }
  509. }
  510. .group-bottom.two {
  511. .two-item {
  512. width: 100%;
  513. .title {
  514. margin-top: 20rpx;
  515. .numPink {
  516. color: #ffffff;
  517. padding: 6rpx 12rpx;
  518. border-radius: 4rpx;
  519. font-size: 22rpx;
  520. }
  521. .line1 {
  522. width: 210rpx;
  523. margin-left: 10rpx;
  524. }
  525. }
  526. .two-item-bottom {
  527. margin-top: 10rpx;
  528. .pinkNum {
  529. .num {
  530. font-size: 36rpx;
  531. }
  532. }
  533. .otNum {
  534. font-size: 26rpx;
  535. color: #999999;
  536. text-decoration: line-through;
  537. }
  538. .btnBox {
  539. margin-top: 16rpx;
  540. font-size: 22rpx;
  541. .btn {
  542. padding: 12rpx 24rpx;
  543. border-radius: 50rpx;
  544. }
  545. }
  546. }
  547. }
  548. }
  549. .group-bottom.three {
  550. .three-box{
  551. position: relative;
  552. }
  553. .numPink {
  554. color: #ffffff;
  555. padding: 4rpx 12rpx;
  556. border-radius: 16rpx;
  557. font-size: 22rpx;
  558. // z-index: 9;
  559. }
  560. .two-item {
  561. width: 100%;
  562. .title {
  563. margin-top: 18rpx;
  564. // width: 100%;
  565. .numPink {
  566. color: #ffffff;
  567. padding: 4rpx 12rpx;
  568. border-radius: 8rpx;
  569. font-size: 22rpx;
  570. }
  571. .line1 {
  572. width: 180rpx;
  573. margin-left: 5px;
  574. }
  575. }
  576. .two-item-bottom {
  577. margin-top: 10rpx;
  578. .pinkNum {
  579. .num {
  580. font-size: 36rpx;
  581. }
  582. }
  583. .otNum {
  584. font-size: 26rpx;
  585. color: #999999;
  586. text-decoration: line-through;
  587. }
  588. .btnBox {
  589. margin-top: 16rpx;
  590. font-size: 22rpx;
  591. .btn {
  592. padding: 12rpx 24rpx;
  593. border-radius: 50rpx;
  594. }
  595. }
  596. }
  597. }
  598. }
  599. .group-bottom.four {
  600. overflow: hidden;
  601. flex-wrap: nowrap;
  602. position: relative;
  603. .four-item{
  604. position: relative;
  605. }
  606. .numPink {
  607. color: #ffffff;
  608. padding: 6rpx 12rpx;
  609. border-radius: 32rpx;
  610. font-size: 22rpx;
  611. z-index: 9;
  612. }
  613. .two-item {
  614. width: 210rpx;
  615. .title {
  616. margin-top: 18rpx;
  617. .numPink {
  618. color: #ffffff;
  619. padding: 6rpx 12rpx;
  620. border-radius: 32rpx;
  621. font-size: 22rpx;
  622. }
  623. .line1 {
  624. width: 210rpx;
  625. }
  626. }
  627. .two-item-bottom {
  628. margin-top: 10rpx;
  629. .pinkNum {
  630. .num {
  631. font-size: 36rpx;
  632. }
  633. }
  634. .otNum {
  635. font-size: 26rpx;
  636. text-decoration: line-through;
  637. }
  638. .btnBox {
  639. margin-top: 16rpx;
  640. font-size: 22rpx;
  641. .btn {
  642. padding: 12rpx 24rpx;
  643. border-radius: 50rpx;
  644. }
  645. }
  646. }
  647. }
  648. }
  649. }
  650. .price {
  651. display: flex;
  652. flex-direction: column;
  653. justify-content: flex-end;
  654. }
  655. .grid-list {
  656. display: grid !important;
  657. grid-template-columns: repeat(2, 1fr);
  658. grid-template-rows: auto;
  659. width: 100%;
  660. }
  661. .grid-three {
  662. width: 100%;
  663. display: grid !important;
  664. grid-template-columns: repeat(3, 1fr);
  665. grid-template-rows: auto;
  666. }
  667. }
  668. .titleFont {
  669. font-size: 16px;
  670. }
  671. .scroll_view {
  672. white-space: nowrap;
  673. .four-item {
  674. display: inline-block;
  675. color: #999999;
  676. }
  677. }
  678. .num-icon {
  679. font-weight: 500 !important;
  680. }
  681. .numPink {
  682. background-color: rgba(255, 255, 255, 0.9);
  683. }
  684. .numPink-box {
  685. border-radius: 8rpx;
  686. }
  687. .numPink-box-special {
  688. position: absolute;
  689. left: 10rpx;
  690. top: 10rpx;
  691. border-radius: 32rpx;
  692. }
  693. .avater-box{
  694. position: relative;
  695. display: flex;
  696. align-items: end;
  697. margin-top: 4rpx;
  698. image{
  699. width: 36rpx;
  700. height: 36rpx;
  701. border-radius: 18rpx;
  702. }
  703. .avater1{
  704. margin-left: 20rpx;
  705. }
  706. .avater2{
  707. position: absolute;
  708. margin-left: 48rpx;
  709. }
  710. .avater3{
  711. position: absolute;
  712. left: 78rpx;
  713. }
  714. }
  715. .regular{
  716. line-height: 34rpx !important;
  717. font-weight: 400 !important;
  718. }
  719. .icon-you{
  720. font-size: 24rpx;
  721. }
  722. </style>