bargain.vue 16 KB

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