bargain.vue 12 KB

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