bargain.vue 12 KB

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