seckill.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. <template>
  2. <!-- 秒杀列表 -->
  3. <view :style="[boxStyle]" v-if="spikeList.length > 0">
  4. <view>
  5. <!-- 秒杀头部 -->
  6. <view class="w-full h-96 px-24 flex-between-center bg-cover" :style="[headerStyle]">
  7. <view class="flex-y-center">
  8. <text class="fs-32 lh-44rpx fw-500" :style="[titleStyle]" v-if="titleConfig">{{titleTxtConfig}}</text>
  9. <image :src="titleImg" class="w-140 h-32" v-else></image>
  10. <text class="fs-26 text--w111-999 lh-36rpx pl-20" :style="[tipsColor]">{{ $t(`距离结束`) }}</text>
  11. <countDown
  12. :is-day="false"
  13. tip-text=" "
  14. day-text=" "
  15. hour-text=":"
  16. minute-text=":"
  17. second-text=" "
  18. :datatime="datatime"
  19. :bgColor="numberBgColor"
  20. :colors="numberColor"
  21. :dotColor="dotColor"></countDown>
  22. </view>
  23. <view class="flex-y-center fs-24 text--w111-999" :style="[headerBntColor]"
  24. @tap="goPage('/pages/activity/goods_seckill/index')">
  25. <text>{{rightBntTxt}}</text>
  26. <text class="iconfont icon-ic_rightarrow fs-24" :style="[headerBntColor]"></text>
  27. </view>
  28. </view>
  29. <!-- 单列 -->
  30. <view class="pt-32 pr-20 pb-32 pl-20 bg--w111-fff" :style="[boxContentStyle]"
  31. v-if="goodStyleConfig == 0">
  32. <view class="w-full flex justify-between item"
  33. v-for="(item,index) in spikeList" :key="index"
  34. @tap="goDetails(item)">
  35. <easy-loadimage
  36. :image-src="item.image"
  37. :border-src="item.activity_image"
  38. width="240rpx"
  39. height="240rpx"
  40. :borderRadius="imgStyle"></easy-loadimage>
  41. <view class="flex-1 flex-col justify-between pl-20 h-240">
  42. <view>
  43. <view class="w-full fs-28 h-80 lh-40rpx line2" :style="[productStyle]"
  44. v-if="checkboxInfo.includes(0)">{{item.title}}</view>
  45. <view class="w-full flex-y-center mt-20" v-if="checkboxInfo.includes(1)">
  46. <view class="progress relative">
  47. <view class="active" :style="{'width': item.percent +'%',background:progressBgColor}">
  48. <!-- <image src="@/static/images/lightning.png" class="lightning"></image> -->
  49. </view>
  50. <image src="@/static/images/lightning.png" class="lightning"
  51. :style="{left: item.percent +'%',transform:item.percent==100?'translateX(-100%)':'translateX(0)'}"></image>
  52. </view>
  53. <text class="fs-22 lh-30rpx pl-12" :style="{color: priceColor}">已抢{{item.percent +'%'}}</text>
  54. </view>
  55. </view>
  56. <view class="flex justify-between items-end">
  57. <view class="flex-col">
  58. <baseMoney
  59. :money="item.price"
  60. symbolSize="24"
  61. integerSize="36"
  62. decimalSize="36" weight
  63. :color="priceColor"
  64. preFix="秒杀价"
  65. preFixSize="24"
  66. :textColor="priceColor"
  67. v-if="checkboxInfo.includes(2)"></baseMoney>
  68. <text class="text-line fs-28 text--w111-999 pt-10 mb-10 Regular"
  69. v-if="checkboxInfo.includes(3)"
  70. :style="[otPriceColor]">{{ $t(`¥`) }}{{item.product_price.toString().split('.')[1] ? item.product_price : item.product_price + '.00'}}</text>
  71. </view>
  72. <view class='w-144 h-56 rd-30rpx flex-center fs-24 text--w111-fff'
  73. v-if="!showBtn" :style="[btnBgColor]">{{ $t(`去抢购`) }}</view>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. <!-- 两列 -->
  79. <view class="grid-column-2 grid-gap-22rpx pt-32 pr-20 pb-32 pl-20" :style="[boxContentStyle]" v-if="goodStyleConfig == 1">
  80. <view v-for="(item,index) in spikeList" :key="index"
  81. @tap="goDetails(item)">
  82. <easy-loadimage
  83. :image-src="item.image"
  84. :border-src="item.activity_image"
  85. width="100%"
  86. height="324rpx"
  87. :borderRadius="imgStyle"></easy-loadimage>
  88. <view class="w-full line2 mt-16 fs-28 lh-40rpx"
  89. :style="[productStyle]" v-if="checkboxInfo.includes(0)">{{item.title}}</view>
  90. <view class="flex justify-between items-end mt-10">
  91. <view class="flex-col">
  92. <baseMoney
  93. :money="item.price"
  94. symbolSize="24"
  95. integerSize="36"
  96. decimalSize="36"
  97. weight
  98. :color="priceColor"
  99. v-if="checkboxInfo.includes(2)"></baseMoney>
  100. <text class="text-line fs-28 text--w111-999 pt-14 Regular"
  101. v-if="checkboxInfo.includes(3)" :style="[otPriceColor]"
  102. >{{ $t(`¥`) }}{{item.product_price.toString().split('.')[1] ? item.product_price : item.product_price + '.00'}}</text>
  103. </view>
  104. <view class='w-144 h-56 rd-30rpx flex-center fs-24 text--w111-fff bg--w111-E93323'
  105. v-if="!showBtn" :style="[btnBgColor]">{{ $t(`去抢购`) }}</view>
  106. </view>
  107. </view>
  108. </view>
  109. <!-- 三列 -->
  110. <view class="grid-column-3 grid-gap-18rpx pt-32 pr-20 pb-32 pl-20" :style="[boxContentStyle]" v-if="goodStyleConfig == 2">
  111. <view v-for="(item,index) in spikeList" :key="index"
  112. @tap="goDetails(item)">
  113. <easy-loadimage
  114. :image-src="item.image"
  115. :border-src="item.activity_image"
  116. width="100%"
  117. height="212rpx"
  118. :borderRadius="imgStyle"></easy-loadimage>
  119. <view class="w-full line1 mt-16 fs-26" :style="[productStyle]"
  120. v-if="checkboxInfo.includes(0)">{{item.title}}</view>
  121. <view class="price-box flex-center relative" :style="[tagBag]" v-if="checkboxInfo.includes(2)">
  122. <baseMoney :money="item.price"
  123. symbolSize="24"
  124. integerSize="30"
  125. decimalSize="30"
  126. weight
  127. :color="bargainPriceColor"
  128. ></baseMoney>
  129. <image src="@/static/images/shandian.png" class="shandian"></image>
  130. </view>
  131. <view class="text-line fs-24 text--w111-999 Regular lh-32rpx mt-10"
  132. :style="[otPriceColor]" v-if="checkboxInfo.includes(3)"
  133. >{{ $t(`¥`) }}{{item.product_price.toString().split('.')[1] ? item.product_price : item.product_price + '.00'}}</view>
  134. </view>
  135. </view>
  136. <!-- 滑动 -->
  137. <scroll-view scroll-x="true" show-scrollbar="false"
  138. class="white-nowrap vertical-middle w-full p-32"
  139. :style="[boxContentStyle]"
  140. v-if="goodStyleConfig == 3">
  141. <view class="inline-block" :class="{ 'ml-20': index }" v-for="(item,index) in spikeList" :key="index"
  142. @tap="goDetails(item)">
  143. <easy-loadimage
  144. :image-src="item.image"
  145. :border-src="item.activity_image"
  146. width="224rpx"
  147. height="224rpx"
  148. :borderRadius="imgStyle"></easy-loadimage>
  149. <view class="w-222 line1 mt-16 fs-26 lh-26rpx" :style="[productStyle]"
  150. v-if="checkboxInfo.includes(0)">{{item.title}}</view>
  151. <view class="flex justify-between items-end mt-16">
  152. <view>
  153. <baseMoney :money="item.price"
  154. symbolSize="24"
  155. integerSize="36"
  156. decimalSize="36"
  157. weight
  158. :color="priceColor"
  159. v-if="checkboxInfo.includes(2)"></baseMoney>
  160. <view class="text-line fs-24 text--w111-999 Regular lh-32rpx"
  161. :style="[otPriceColor]" v-if="checkboxInfo.includes(3)"
  162. >{{ $t(`¥`) }}{{item.product_price.toString().split('.')[1] ? item.product_price : item.product_price + '.00'}}</view>
  163. </view>
  164. <view class="qiang flex-center fs-24 text--w111-fff"
  165. v-if="!showBtn" :style="[btnBgColor]">{{ $t(`抢`) }}</view>
  166. </view>
  167. </view>
  168. </scroll-view>
  169. </view>
  170. </view>
  171. </template>
  172. <script>
  173. import countDown from '@/components/countDown';
  174. import {
  175. getSeckillIndexTime,
  176. getSeckillList
  177. } from '@/api/activity.js';
  178. export default {
  179. options: {
  180. styleIsolation: 'shared' ,
  181. },
  182. name: 'seckill',
  183. components:{
  184. countDown
  185. },
  186. props: {
  187. dataConfig: {
  188. type: Object,
  189. default: () => {}
  190. },
  191. isSortType:{
  192. type: String | Number,
  193. default:0
  194. }
  195. },
  196. data() {
  197. return {
  198. datatime:'',
  199. spikeList: [],
  200. seckillTimeIndex:0,
  201. seckillTime: [],
  202. };
  203. },
  204. computed:{
  205. titleStyle(){
  206. let titleText = this.dataConfig.titleText
  207. return {
  208. fontStyle: !titleText.tabVal?'normal':titleText.tabList[titleText.tabVal].style,
  209. fontWeight: !titleText.tabVal?'bold':'normal',
  210. color: this.dataConfig.titleColor.color[0].item,
  211. fontSize: this.dataConfig.titleNumber.val*2+'rpx'
  212. }
  213. },
  214. boxStyle(){
  215. return {
  216. padding: `${this.dataConfig.topConfig.val * 2}rpx ${this.dataConfig.prConfig.val * 2}rpx ${this.dataConfig.bottomConfig.val * 2}rpx`,
  217. marginTop: `${this.dataConfig.mbConfig.val * 2}rpx`,
  218. background: this.dataConfig.bottomBgColor.color[0].item,
  219. }
  220. },
  221. tagBag(){
  222. return {
  223. color: this.dataConfig.toneConfig.tabVal ? this.dataConfig.goodsBntTxtColor.color[0].item : '#fff',
  224. background: this.dataConfig.toneConfig.tabVal
  225. ? `linear-gradient(270deg,${this.dataConfig.goodsBntColor.color[1].item} 0%,${this.dataConfig.goodsBntColor.color[0].item} 100%)`
  226. : 'var(--view-theme)',
  227. }
  228. },
  229. bargainPriceColor(){
  230. return this.dataConfig.toneConfig.tabVal ? this.dataConfig.seckillPriceColor2.color[0].item : 'var(--view-theme)'
  231. },
  232. boxContentStyle() {
  233. let br = `${this.dataConfig.fillet.val * 2}rpx`;
  234. let borderRadius = `0 0 ${br} ${br}`;
  235. if (this.dataConfig.fillet.type) {
  236. borderRadius =
  237. `0 0 ${this.dataConfig.fillet.valList[3].val * 2}rpx ${this.dataConfig.fillet.valList[2].val * 2}rpx`;
  238. }
  239. return {
  240. borderRadius,
  241. background: `linear-gradient(90deg, ${this.dataConfig.moduleColor.color[0].item} 0%, ${this.dataConfig.moduleColor.color[1].item} 100%)`,
  242. };
  243. },
  244. /*商品模板*/
  245. goodStyleConfig(){
  246. return this.dataConfig.goodStyleConfig.tabVal
  247. },
  248. styleConfig(){
  249. return this.dataConfig.styleConfig.tabVal
  250. },
  251. headerStyle(){
  252. let br = `${this.dataConfig.fillet.val * 2}rpx`,
  253. borderRadius= '',
  254. imgBgUrl = this.dataConfig.imgBgConfig.url;
  255. if (this.dataConfig.fillet.type){
  256. borderRadius = `${this.dataConfig.fillet.valList[0].val * 2}rpx ${this.dataConfig.fillet.valList[1].val * 2}rpx 0 0`
  257. }else{
  258. borderRadius = `${br} ${br} 0 0`
  259. }
  260. return {
  261. backgroundImage: this.styleConfig ? 'url(' + imgBgUrl + ')' : `linear-gradient(90deg,${this.dataConfig.headerBgColor.color[0].item} 0%,${this.dataConfig.headerBgColor.color[1].item} 100%)`,
  262. borderRadius,
  263. }
  264. },
  265. /*标题是文本还是图片*/
  266. titleConfig(){
  267. return this.dataConfig.titleConfig.tabVal
  268. },
  269. /*标题文本*/
  270. titleTxtConfig(){
  271. return this.dataConfig.titleTxtConfig.value
  272. },
  273. /*标题图片*/
  274. titleImg(){
  275. return this.styleConfig ? this.titleUrl : this.titleColorUrl
  276. },
  277. titleColorUrl(){
  278. return this.dataConfig.imgColorConfig.url
  279. },
  280. titleUrl(){
  281. return this.dataConfig.imgConfig.url
  282. },
  283. /*标题提示文字*/
  284. tipsColor(){
  285. return {
  286. color: this.styleConfig ? this.dataConfig.tipsColor.color[0].item : this.dataConfig.tipsColor2.color[0].item
  287. }
  288. },
  289. /*头部按钮文本*/
  290. rightBntTxt(){
  291. return this.dataConfig.rightBntConfig.value
  292. },
  293. /*头部按钮样式*/
  294. headerBntColor(){
  295. return {
  296. color: this.styleConfig ? this.dataConfig.headerBntColor.color[0].item : this.dataConfig.headerBntColor2.color[0].item,
  297. fontSize: `${this.dataConfig.bntNumber.val * 2}rpx`
  298. }
  299. },
  300. /*商品图片圆角样式*/
  301. imgStyle(){
  302. let borderRadius = `${this.dataConfig.filletImg.val * 2}rpx`;
  303. if (this.dataConfig.filletImg.type) {
  304. borderRadius =
  305. `${this.dataConfig.filletImg.valList[0].val * 2}rpx ${this.dataConfig.filletImg.valList[1].val * 2}rpx ${this.dataConfig.filletImg.valList[3].val * 2}rpx ${this.dataConfig.filletImg.valList[2].val * 2}rpx`;
  306. }
  307. return borderRadius
  308. },
  309. /*商品名称样式*/
  310. productStyle(){
  311. return {
  312. color: this.dataConfig.goodsNameColor.color[0].item,
  313. fontWeight: this.dataConfig.goodsName.tabVal ? 'normal' : 'bold'
  314. }
  315. },
  316. /* 展示信息 */
  317. checkboxInfo(){
  318. return this.dataConfig.checkboxInfo.type
  319. },
  320. /* 价格颜色 */
  321. priceColor(){
  322. return this.dataConfig.toneConfig.tabVal ? this.dataConfig.progressTxtColor.color[0].item : 'var(--view-theme)'
  323. },
  324. /* 划线价颜色 */
  325. otPriceColor(){
  326. return {
  327. color: this.dataConfig.goodsPriceColor.color[0].item
  328. }
  329. },
  330. showBtn(){
  331. return this.dataConfig.seckillConfig.tabVal
  332. },
  333. /* 按钮颜色 */
  334. btnBgColor(){
  335. return {
  336. 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-gradient) 0%, var(--view-theme) 100%)',
  337. color: this.dataConfig.goodsBntTxtColor.color[0].item
  338. }
  339. },
  340. progressBgColor(){
  341. return this.dataConfig.toneConfig.tabVal ? `linear-gradient(90deg,${this.dataConfig.progressColor.color[0].item} 0%,${this.dataConfig.progressColor.color[1].item} 100%)`: 'linear-gradient(45deg, var(--view-gradient) 0%, var(--view-theme) 100%)'
  342. },
  343. /*倒计时背景色*/
  344. numberBgColor(){
  345. return this.styleConfig ? `linear-gradient(90deg, ${this.dataConfig.numberBgColor.color[0].item} 0%, ${this.dataConfig.numberBgColor.color[1].item} 100%)` : `linear-gradient(90deg, ${this.dataConfig.numberBgColor2.color[0].item} 0%, ${this.dataConfig.numberBgColor2.color[1].item} 100%)`
  346. },
  347. numberColor(){
  348. return this.styleConfig ? this.dataConfig.numberColor.color[0].item : this.dataConfig.numberColor2.color[0].item
  349. },
  350. dotColor(){
  351. return this.styleConfig ? this.dataConfig.numberBgColor.color[0].item : this.dataConfig.numberBgColor2.color[0].item
  352. },
  353. /*商品数量*/
  354. numberConfig(){
  355. return this.dataConfig.numberConfig.val
  356. }
  357. },
  358. mounted() {
  359. this.getSeckillIndexTime();
  360. },
  361. methods: {
  362. goPage(url){
  363. uni.navigateTo({
  364. url
  365. })
  366. },
  367. goDetails(item){
  368. uni.navigateTo({
  369. url: '/pages/activity/goods_seckill_details/index?id=' + item.id + '&type=1&time_id=' + this.timeList[this.active].id
  370. })
  371. },
  372. getSeckillIndexTime() {
  373. let limit = this.$config.LIMIT;
  374. let params = {
  375. page: 1,
  376. limit: this.numberConfig>=limit?limit:this.numberConfig,
  377. type: 'index'
  378. }
  379. getSeckillIndexTime().then(res => {
  380. this.timeList = res.data.seckillTime;
  381. this.active = res.data.seckillTimeIndex;
  382. if (res.data.seckillTimeIndex === -1) {
  383. return;
  384. }
  385. this.datatime = res.data.seckillTime[res.data.seckillTimeIndex].stop
  386. let id = res.data.seckillTime[res.data.seckillTimeIndex].id
  387. getSeckillList(id, params).then(({data}) => {
  388. this.spikeList = data
  389. })
  390. })
  391. },
  392. }
  393. }
  394. </script>
  395. <style lang="scss" scoped>
  396. .Regular{
  397. font-family: 'Regular';
  398. }
  399. ::v-deep .styleAll{
  400. padding: 0 8rpx;
  401. border-radius: 4rpx;
  402. font-size: 24rpx;
  403. line-height: 40rpx;
  404. }
  405. .bg-cover{
  406. background-size: cover;
  407. }
  408. .item ~ .item{
  409. margin-top: 32rpx;
  410. }
  411. .progress{
  412. width:240rpx;
  413. height: 24rpx;
  414. border-radius: 12rpx;
  415. background-color: rgba(253, 240, 237, 1);
  416. overflow: hidden;
  417. .active{
  418. height: 24rpx;
  419. border-radius: 12rpx;
  420. background: linear-gradient(45deg, #FF7931 0%, #E93323 100%);
  421. }
  422. .lightning{
  423. position: absolute;
  424. top: -2rpx;
  425. width: 28rpx;
  426. height: 28rpx;
  427. }
  428. }
  429. .price-box{
  430. width: 150rpx;
  431. height: 44rpx;
  432. background: linear-gradient(45deg, var(--view-gradient) 0%, var(--view-theme) 100%);
  433. border-radius: 0px 8rpx 8rpx 0px;
  434. margin: 20rpx 0 0 10rpx;
  435. .shandian{
  436. position: absolute;
  437. width: 24rpx;
  438. height: 44rpx;
  439. top: 0;
  440. left: -10rpx;
  441. }
  442. }
  443. .qiang{
  444. width: 66rpx;
  445. height: 40rpx;
  446. background: linear-gradient(45deg, #FF7931 0%, #E93323 100%);
  447. border-radius: 0px 22rpx 22rpx 0px;
  448. position: relative;
  449. &:before{
  450. content:'';
  451. position: absolute;
  452. top: 0;
  453. left: -10rpx;
  454. width: 24rpx;
  455. height: 40rpx;
  456. background-image: url('@/static/images/shandian.png');
  457. background-size: cover;
  458. }
  459. }
  460. scroll-view {
  461. box-sizing: border-box;
  462. }
  463. </style>