combination.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  1. <template>
  2. <!-- 拼团活动 -->
  3. <view v-show="!isSortType">
  4. <common-wrapper v-if="combinationList.length" :config="configData">
  5. <view class="combination" v-if="combinationList.length">
  6. <view>
  7. <!-- 拼团头部 -->
  8. <view
  9. class="w-full h-96 px-24 flex-between-center bg-cover"
  10. :style="[headerStyle]"
  11. >
  12. <view class="flex-y-center">
  13. <text
  14. class="fs-32 lh-44rpx fw-500"
  15. :style="[titleStyle]"
  16. v-if="titleConfig"
  17. >{{ titleTxtConfig }}</text
  18. >
  19. <image :src="titleImg" class="w-140 h-32" v-else></image>
  20. <text class="fs-28 text--w111-ccc px-20" :style="[dividerColor]"
  21. >|</text
  22. >
  23. <view
  24. class="avatar-group flex-y-center mr-20"
  25. v-if="pinkInfo.avatars && pinkInfo.avatars.length"
  26. >
  27. <image
  28. v-for="(item, index) in pinkInfo.avatars"
  29. :key="index"
  30. :src="item"
  31. mode=""
  32. class="w-36 h-36 rd-50-p111-"
  33. ></image>
  34. </view>
  35. <text class="fs-26 text--w111-999 lh-36rpx" :style="[tipsColor]"
  36. >{{ pinkInfo.pink_count }}{{ $t(`人参与拼团`) }}</text
  37. >
  38. </view>
  39. <view
  40. class="flex-y-center fs-24 text--w111-999"
  41. :style="[headerBntColor]"
  42. @tap="goPage('/pages/activity/goods_combination/index')"
  43. >
  44. <text>{{ rightBntTxt }}</text>
  45. <text
  46. class="iconfont icon-ic_rightarrow fs-24"
  47. :style="[headerBntColor]"
  48. ></text>
  49. </view>
  50. </view>
  51. <!-- 拼团列表 -->
  52. <!-- 单列 -->
  53. <view
  54. class="pt-32 pr-20 pb-32 pl-20"
  55. :style="[boxContentStyle]"
  56. v-if="goodStyleConfig == 0"
  57. >
  58. <view
  59. class="w-full flex justify-between item"
  60. v-for="(item, index) in combinationList"
  61. :key="index"
  62. @tap="goDetail(item)"
  63. >
  64. <easy-loadimage
  65. :image-src="item.image"
  66. width="240rpx"
  67. height="240rpx"
  68. :borderRadius="imgStyle"
  69. ></easy-loadimage>
  70. <view class="flex-1 flex-col justify-between pl-20 h-240">
  71. <view class="w-full">
  72. <view
  73. class="w-full fs-28 h-80 lh-40rpx line2"
  74. :style="[productStyle]"
  75. v-if="checkboxInfo.includes(0)"
  76. >{{ item.title }}</view
  77. >
  78. <view class="flex mt-14" v-if="checkboxInfo.includes(1)">
  79. <view class="flex fs-20 rd-8rpx" :style="[labelBg]">
  80. <text
  81. class="tuan-num text--w111-fff flex-center"
  82. v-if="checkboxInfo.includes(1)"
  83. >{{ item.people }}{{ $t(`人团`) }}</text
  84. >
  85. <text class="complete flex-center" :style="[pinkNumStyle]"
  86. >已拼{{ item.pink_count || 0 }}份</text
  87. >
  88. </view>
  89. </view>
  90. </view>
  91. <view class="flex justify-between items-end">
  92. <view class="flex-col">
  93. <baseMoney
  94. :money="item.price"
  95. symbolSize="24"
  96. integerSize="36"
  97. decimalSize="36"
  98. weight
  99. :color="priceColor"
  100. preFix="拼团价"
  101. preFixSize="24"
  102. :textColor="priceColor"
  103. v-if="checkboxInfo.includes(2)"
  104. ></baseMoney>
  105. <text
  106. class="text-line fs-28 text--w111-999 pt-14 Regular"
  107. v-if="checkboxInfo.includes(3)"
  108. :style="[otPriceColor]"
  109. >{{ $t(`¥`) }}{{ item.product_price }}</text
  110. >
  111. </view>
  112. <view
  113. class="w-144 h-56 rd-30rpx flex-center fs-24 text--w111-fff"
  114. v-if="!showBtn"
  115. :style="[btnBgColor]"
  116. >{{ $t(`去拼团`) }}</view
  117. >
  118. </view>
  119. </view>
  120. </view>
  121. </view>
  122. <!-- 两列 -->
  123. <view
  124. class="grid-column-2 grid-gap-22rpx pt-32 pr-20 pb-32 pl-20"
  125. :style="[boxContentStyle]"
  126. v-if="goodStyleConfig == 1"
  127. >
  128. <view
  129. v-for="(item, index) in combinationList"
  130. :key="index"
  131. @tap="goDetail(item)"
  132. >
  133. <easy-loadimage
  134. :image-src="item.image"
  135. width="100%"
  136. height="324rpx"
  137. :borderRadius="imgStyle"
  138. ></easy-loadimage>
  139. <view
  140. class="w-full mt-16 line1"
  141. :style="[productStyle]"
  142. v-if="checkboxInfo.includes(1)"
  143. >
  144. <view
  145. class="inline fs-20 rd-4rpx mr-10 rd-4rpx"
  146. :style="[labelBg]"
  147. >
  148. <text
  149. class="complete flex-center rd-4rpx"
  150. :style="[pinkNumStyle]"
  151. >{{ item.people }}{{ $t(`人团`) }}</text
  152. >
  153. </view>
  154. <view
  155. class="inline fs-28 lh-40rpx"
  156. v-if="checkboxInfo.includes(0)"
  157. >{{ item.title }}</view
  158. >
  159. </view>
  160. <view class="flex justify-between items-end mt-12">
  161. <view class="flex-col">
  162. <baseMoney
  163. :money="item.price"
  164. symbolSize="24"
  165. integerSize="36"
  166. decimalSize="36"
  167. weight
  168. :color="priceColor"
  169. v-if="checkboxInfo.includes(2)"
  170. ></baseMoney>
  171. <text
  172. class="text-line fs-28 text--w111-999 Regular"
  173. v-if="checkboxInfo.includes(3)"
  174. :style="[otPriceColor]"
  175. >{{ $t(`¥`) }}{{ item.product_price }}</text
  176. >
  177. </view>
  178. <view
  179. class="w-144 h-56 rd-30rpx flex-center fs-24 text--w111-fff bg--w111-E93323"
  180. v-if="!showBtn"
  181. :style="[btnBgColor]"
  182. >{{ $t(`去拼团`) }}</view
  183. >
  184. </view>
  185. </view>
  186. </view>
  187. <!-- 三列 -->
  188. <view
  189. class="grid-column-3 grid-gap-18rpx pt-32 pr-20 pb-32 pl-20"
  190. :style="[boxContentStyle]"
  191. v-if="goodStyleConfig == 2"
  192. >
  193. <view
  194. class="relative"
  195. v-for="(item, index) in combinationList"
  196. :key="index"
  197. @tap="goDetail(item)"
  198. >
  199. <view
  200. class="abs-tag z-20"
  201. :style="[labelBg]"
  202. v-if="checkboxInfo.includes(1)"
  203. >
  204. <text
  205. class="circle-tag flex-center fs-22"
  206. :style="[pinkNumStyle]"
  207. >{{ item.people }}{{ $t(`人团`) }}</text
  208. >
  209. </view>
  210. <easy-loadimage
  211. :image-src="item.image"
  212. width="100%"
  213. height="212rpx"
  214. :borderRadius="imgStyle"
  215. ></easy-loadimage>
  216. <view
  217. class="w-full line1 mt-16 fs-26"
  218. :style="[productStyle]"
  219. v-if="checkboxInfo.includes(0)"
  220. >{{ item.title }}</view
  221. >
  222. <view class="flex items-baseline">
  223. <baseMoney
  224. :money="item.price"
  225. symbolSize="24"
  226. integerSize="36"
  227. decimalSize="36"
  228. weight
  229. :color="priceColor"
  230. v-if="checkboxInfo.includes(2)"
  231. ></baseMoney>
  232. </view>
  233. <view
  234. class="text-line fs-24 text--w111-999 Regular lh-32rpx"
  235. :style="[otPriceColor]"
  236. v-if="checkboxInfo.includes(3)"
  237. >{{ $t(`¥`) }}{{ item.product_price }}</view
  238. >
  239. </view>
  240. </view>
  241. <!-- 滑动 -->
  242. <scroll-view
  243. scroll-x="true"
  244. show-scrollbar="false"
  245. :style="[boxContentStyle]"
  246. class="white-nowrap vertical-middle w-full p-32"
  247. v-if="goodStyleConfig == 3"
  248. >
  249. <view
  250. class="inline-block relative"
  251. :class="{ 'ml-20': index }"
  252. v-for="(item, index) in combinationList"
  253. :key="index"
  254. @tap="goDetail(item)"
  255. >
  256. <view
  257. class="abs-tag z-20"
  258. :style="[labelBg]"
  259. v-if="checkboxInfo.includes(1)"
  260. >
  261. <text
  262. class="circle-tag flex-center fs-22"
  263. :style="[pinkNumStyle]"
  264. >{{ item.people }}{{ $t(`人团`) }}</text
  265. >
  266. </view>
  267. <easy-loadimage
  268. :image-src="item.image"
  269. width="224rpx"
  270. height="224rpx"
  271. :borderRadius="imgStyle"
  272. ></easy-loadimage>
  273. <view
  274. class="w-222 line1 mt-16 fs-26"
  275. :style="[productStyle]"
  276. v-if="checkboxInfo.includes(0)"
  277. >{{ item.title }}</view
  278. >
  279. <baseMoney
  280. class="mt-12"
  281. :money="item.price"
  282. symbolSize="24"
  283. integerSize="36"
  284. decimalSize="36"
  285. weight
  286. :color="priceColor"
  287. v-if="checkboxInfo.includes(2)"
  288. ></baseMoney>
  289. <view
  290. class="text-line fs-24 Regular lh-32rpx"
  291. :style="[otPriceColor]"
  292. v-if="checkboxInfo.includes(3)"
  293. >{{ $t(`¥`) }}{{ item.product_price }}</view
  294. >
  295. </view>
  296. </scroll-view>
  297. </view>
  298. </view>
  299. </common-wrapper>
  300. </view>
  301. </template>
  302. <script>
  303. import commonWrapper from "./commonWrapper.vue";
  304. import { openPinkSubscribe } from "@/utils/SubscribeMessage.js";
  305. import { pink } from "@/api/api.js";
  306. import { getCombinationList } from "@/api/activity.js";
  307. export default {
  308. components: { commonWrapper },
  309. name: "combination",
  310. props: {
  311. dataConfig: {
  312. type: Object,
  313. default: () => {},
  314. },
  315. isSortType: {
  316. type: String | Number,
  317. default: 0,
  318. },
  319. },
  320. data() {
  321. return {
  322. pinkInfo: "",
  323. combinationList: [],
  324. };
  325. },
  326. computed: {
  327. titleStyle() {
  328. let titleText = this.dataConfig.titleText;
  329. return {
  330. fontStyle: !titleText.tabVal
  331. ? "normal"
  332. : titleText.tabList[titleText.tabVal].style,
  333. fontWeight: !titleText.tabVal ? "bold" : "normal",
  334. color: this.dataConfig.titleColor.color[0].item,
  335. fontSize: this.dataConfig.titleNumber.val * 2 + "rpx",
  336. };
  337. },
  338. configData() {
  339. return {
  340. ...this.dataConfig,
  341. paddingConfig: this.dataConfig.paddingConfig || {
  342. isAll: false,
  343. valList: [
  344. {
  345. val: this.dataConfig.topConfig
  346. ? this.dataConfig.topConfig.val
  347. : 0,
  348. },
  349. {
  350. val: this.dataConfig.prConfig ? this.dataConfig.prConfig.val : 0,
  351. },
  352. {
  353. val: this.dataConfig.bottomConfig
  354. ? this.dataConfig.bottomConfig.val
  355. : 0,
  356. },
  357. {
  358. val: this.dataConfig.prConfig ? this.dataConfig.prConfig.val : 0,
  359. },
  360. ],
  361. },
  362. marginConfig: this.dataConfig.marginConfig || {
  363. isAll: false,
  364. valList: [
  365. {
  366. val: this.dataConfig.mbConfig ? this.dataConfig.mbConfig.val : 0,
  367. },
  368. {
  369. val: 0,
  370. },
  371. {
  372. val: 0,
  373. },
  374. {
  375. val: 0,
  376. },
  377. ],
  378. },
  379. };
  380. },
  381. boxContentStyle() {
  382. let br = `${this.dataConfig.fillet.val * 2}rpx`;
  383. let borderRadius = `0 0 ${br} ${br}`;
  384. if (this.dataConfig.fillet.type) {
  385. borderRadius = `0 0 ${this.dataConfig.fillet.valList[3].val * 2}rpx ${
  386. this.dataConfig.fillet.valList[2].val * 2
  387. }rpx`;
  388. }
  389. return {
  390. borderRadius,
  391. background: `linear-gradient(90deg, ${this.dataConfig.moduleColor.color[0].item} 0%, ${this.dataConfig.moduleColor.color[1].item} 100%)`,
  392. };
  393. },
  394. /*商品模板*/
  395. goodStyleConfig() {
  396. return this.dataConfig.goodStyleConfig.tabVal;
  397. },
  398. styleConfig() {
  399. return this.dataConfig.styleConfig.tabVal;
  400. },
  401. headerStyle() {
  402. let br = `${this.dataConfig.fillet.val * 2}rpx`,
  403. borderRadius = "",
  404. imgBgUrl = this.dataConfig.imgBgConfig.url;
  405. if (this.dataConfig.fillet.type) {
  406. borderRadius = `${this.dataConfig.fillet.valList[0].val * 2}rpx ${
  407. this.dataConfig.fillet.valList[1].val * 2
  408. }rpx 0 0`;
  409. } else {
  410. borderRadius = `${br} ${br} 0 0`;
  411. }
  412. return {
  413. backgroundImage: this.styleConfig
  414. ? "url(" + imgBgUrl + ")"
  415. : `linear-gradient(90deg,${this.dataConfig.headerBgColor.color[0].item} 0%,${this.dataConfig.headerBgColor.color[1].item} 100%)`,
  416. borderRadius,
  417. };
  418. },
  419. /*标题是文本还是图片*/
  420. titleConfig() {
  421. return this.dataConfig.titleConfig.tabVal;
  422. },
  423. /*标题文本*/
  424. titleTxtConfig() {
  425. return this.dataConfig.titleTxtConfig.value;
  426. },
  427. /*标题图片*/
  428. titleImg() {
  429. return this.styleConfig ? this.titleUrl : this.titleColorUrl;
  430. },
  431. titleColorUrl() {
  432. return this.dataConfig.imgColorConfig.url;
  433. },
  434. titleUrl() {
  435. return this.dataConfig.imgConfig.url;
  436. },
  437. /*标题提示文字*/
  438. tipsColor() {
  439. return {
  440. color: this.styleConfig
  441. ? this.dataConfig.tipsColor.color[0].item
  442. : this.dataConfig.tipsColor2.color[0].item,
  443. };
  444. },
  445. /*分割线颜色*/
  446. dividerColor() {
  447. return {
  448. color: this.dataConfig.dividerColor.color[0].item,
  449. };
  450. },
  451. /*头部按钮文本*/
  452. rightBntTxt() {
  453. return this.dataConfig.rightBntConfig.value;
  454. },
  455. /*头部按钮样式*/
  456. headerBntColor() {
  457. return {
  458. color: this.styleConfig
  459. ? this.dataConfig.headerBntColor.color[0].item
  460. : this.dataConfig.headerBntColor2.color[0].item,
  461. fontSize: `${this.dataConfig.bntNumber.val * 2}rpx`,
  462. };
  463. },
  464. /*商品图片圆角样式*/
  465. imgStyle() {
  466. let borderRadius = `${this.dataConfig.filletImg.val * 2}rpx`;
  467. if (this.dataConfig.filletImg.type) {
  468. borderRadius = `${this.dataConfig.filletImg.valList[0].val * 2}rpx ${
  469. this.dataConfig.filletImg.valList[1].val * 2
  470. }rpx ${this.dataConfig.filletImg.valList[3].val * 2}rpx ${
  471. this.dataConfig.filletImg.valList[2].val * 2
  472. }rpx`;
  473. }
  474. return borderRadius;
  475. },
  476. /*商品名称样式*/
  477. productStyle() {
  478. return {
  479. color: this.dataConfig.goodsNameColor.color[0].item,
  480. fontWeight: this.dataConfig.goodsName.tabVal ? "normal" : "bold",
  481. };
  482. },
  483. /* 展示信息 */
  484. checkboxInfo() {
  485. return this.dataConfig.checkboxInfo.type;
  486. },
  487. pinkNumStyle() {
  488. return {
  489. color: this.dataConfig.toneConfig.tabVal
  490. ? this.dataConfig.labelColor.color[0].item
  491. : "var(--view-theme)",
  492. // background: this.dataConfig.toneConfig.tabVal ? this.dataConfig.labelColor.color[0].item : 'var(--view-theme)'
  493. };
  494. },
  495. labelBg() {
  496. return {
  497. background: this.dataConfig.toneConfig.tabVal
  498. ? this.dataConfig.labelColor.color[0].item
  499. : "var(--view-theme)",
  500. height: "32rpx",
  501. };
  502. },
  503. /* 价格颜色 */
  504. priceColor() {
  505. return this.dataConfig.toneConfig.tabVal
  506. ? this.dataConfig.pinkPriceColor.color[0].item
  507. : "var(--view-theme)";
  508. },
  509. /* 划线价颜色 */
  510. otPriceColor() {
  511. return {
  512. color: this.dataConfig.goodsPriceColor.color[0].item,
  513. };
  514. },
  515. showBtn() {
  516. return this.dataConfig.pinkConfig.tabVal;
  517. },
  518. /* 按钮颜色 */
  519. btnBgColor() {
  520. return {
  521. background: this.dataConfig.toneConfig.tabVal
  522. ? `linear-gradient(90deg,${this.dataConfig.goodsBntColor.color[1].item} 0%,${this.dataConfig.goodsBntColor.color[0].item} 100%)`
  523. : "linear-gradient(90deg, var(--view-theme) 0%, var(--view-gradient) 100%)",
  524. color: this.dataConfig.goodsBntTxtColor.color[0].item,
  525. };
  526. },
  527. /*商品数量*/
  528. numberConfig() {
  529. return this.dataConfig.numberConfig.val;
  530. },
  531. },
  532. mounted() {
  533. this.pink();
  534. this.getCombinationList();
  535. },
  536. methods: {
  537. goPage(url) {
  538. uni.navigateTo({
  539. url,
  540. });
  541. },
  542. goDetail(item) {
  543. // #ifndef MP
  544. uni.navigateTo({
  545. url: `/pages/activity/goods_combination_details/index?id=${item.id}&type=3`,
  546. });
  547. // #endif
  548. // #ifdef MP
  549. openPinkSubscribe().then((res) => {
  550. uni.navigateTo({
  551. url: `/pages/activity/goods_combination_details/index?id=${item.id}&type=3`,
  552. });
  553. });
  554. // #endif
  555. },
  556. // 拼团列表
  557. getCombinationList: function () {
  558. let that = this;
  559. let limit = that.$config.LIMIT;
  560. let data = {
  561. page: 1,
  562. limit: this.numberConfig >= limit ? limit : this.numberConfig,
  563. };
  564. getCombinationList(data)
  565. .then((res) => {
  566. that.combinationList = res.data;
  567. })
  568. .catch((res) => {
  569. return that.$util.Tips({
  570. title: res,
  571. });
  572. });
  573. },
  574. // 拼团数据(拼团人数头部图片)
  575. pink: function () {
  576. pink().then((res) => {
  577. this.pinkInfo = res.data;
  578. });
  579. },
  580. },
  581. };
  582. </script>
  583. <style lang="scss">
  584. .Regular {
  585. font-family: "Regular";
  586. }
  587. .bg-cover {
  588. background-repeat: no-repeat;
  589. background-size: 100% 100%;
  590. }
  591. .item ~ .item {
  592. margin-top: 32rpx;
  593. }
  594. .inline-flex {
  595. display: inline-flex;
  596. }
  597. .tuan-num {
  598. display: inline-flex;
  599. justify-content: center;
  600. align-items: center;
  601. padding: 0 8rpx;
  602. height: 32rpx;
  603. border-radius: 8rpx 0 0 8rpx;
  604. }
  605. .complete {
  606. display: inline-flex;
  607. justify-content: center;
  608. align-items: center;
  609. padding: 0 8rpx;
  610. height: 32rpx;
  611. line-height: 32rpx;
  612. border-radius: 0 8rpx 8rpx 0;
  613. background: rgba(255, 255, 255, 0.9);
  614. }
  615. .rd-4rpx {
  616. border-radius: 4rpx !important;
  617. }
  618. .avatar-group image {
  619. margin-right: -10rpx;
  620. }
  621. .abs-tag {
  622. position: absolute;
  623. left: 10rpx;
  624. top: 10rpx;
  625. width: 84rpx;
  626. height: 30rpx;
  627. border-radius: 20rpx;
  628. }
  629. .circle-tag {
  630. width: 84rpx;
  631. height: 30rpx;
  632. border-radius: 20rpx;
  633. background: rgba(255, 255, 255, 0.9);
  634. }
  635. scroll-view {
  636. box-sizing: border-box;
  637. }
  638. </style>