123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- <template>
- <view class="detail-discount">
- <view class="top dir-left-nowrap main-between">
- <view class="text">
- <template v-if="activeIndex === 0 && ladder_rules.length === 1">
- <view>
- 再抢购{{ladder_rules[0].num-sales}}件
- </view>
- <view>
- 可享
- <text>{{ladder_rules[0].discount}}</text>
- 折优惠
- </view>
- </template>
- <template v-if="activeIndex === 0 && ladder_rules.length > 1">
- <view>
- 再抢购{{ladder_rules[0].num-sales}}件
- </view>
- <view>
- 可享
- <text>{{ladder_rules[0].discount}}</text>
- 折优惠
- </view>
- </template>
- <template v-if="activeIndex > 0">
- <view>
- 当前{{ladder_rules[activeIndex-1].discount}}折,再抢购{{ladder_rules[activeIndex].num-sales}}件
- </view>
- <view>
- 可享
- <text>{{ladder_rules[activeIndex].discount}}</text>
- 折优惠
- </view>
- </template>
- <template v-if="activeIndex === -1">
- <view >已满足抢购条件</view>
- 可享
- <text>{{ladder_rules[ladder_rules.length - 1].discount}}</text>
- 折优惠
- </template>
- </view>
- <view class="button" >
- <app-jump-button form open_type="share">邀请好友购买</app-jump-button>
- </view>
- </view>
- <view class="bottom">
- <view :scroll-x="true" class="textss" v-if="ladder_rules.length === 1">
- <view class="scroll-empty"></view>
- <view class="content-d border-radius-right border-radius-left" style="width:702rpx;">
- <view class="content-d-d-d border-radius-left border-radius-right" :style="{width: `${ activeIndex === -1 ? '702' : (702/Number(ladder_rules[0].num)) * sales}rpx`}"></view>
- <text class="content-text-o">满{{ladder_rules[0].num}}件,享{{Number(ladder_rules[0].discount)}}折</text>
- </view>
- <view class="scroll-empty after"></view>
- </view>
- <scroll-view :scroll-x="true" class="textss" v-if="ladder_rules.length !== 1" >
- <view class="scroll-empty"></view>
- <view class="content-d" v-for="(item, index) in ladder_rules" :key="index" :class="{'border-radius-left': index === 0, 'border-radius-right': index === ladder_rules.length - 1}">
- <view class="content-d-d-d" :style="{width: `${getNum(item, index)}rpx`}" :class="{'border-radius-left': index === 0, 'border-radius-right': index === ladder_rules.length - 1}"></view>
- <text class="content-text">满{{item.num}}件,享{{item.discount}}折</text>
- <view class="yuan-default" :class="{'yuan' : activeIndex > index || activeIndex === -1}" ></view>
- </view>
- <view class="scroll-empty after"></view>
- </scroll-view>
- </view>
- </view>
- </template>
- <script>
- export default {
- name: "detail-discount",
- data() {
- return {
- shareShow: false,
- x: 0,
- y: 0,
- old: {
- x: 0,
- y: 0
- }
- }
- },
- props: {
- url: String,
- ladder_rules: Array,
- sales: Number,
- },
- computed: {
- activeIndex() {
- let index = 0;
- for (let i = 0; i < this.ladder_rules.length; i++) {
- if (this.ladder_rules[i].num > this.sales) {
- return i;
- } else {
- index += 1;
- }
- }
- if (index === this.ladder_rules.length) {
- return -1;
- }
- }
- },
- methods: {
- open_share() {
- this.shareShow = true;
- },
- onChange: function(e) {
- this.old.x = e.detail.x;
- },
- getNum(item, index) {
- if (this.activeIndex > index) {
- return 320;
- } else if (this.activeIndex === index) {
- if (index === 0) {
- return 320/Number(item.num) * this.sales;
- } else {
- return 320/(Number(item.num)-Number(this.ladder_rules[index-1].num)) * (this.sales-Number(this.ladder_rules[index-1].num));
- }
- } else if (this.activeIndex === -1) {
- return 320;
- } else if (this.activeIndex < index) {
- return 0;
- }
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .detail-discount {
- width: #{702rpx};
- background:linear-gradient(45deg,#ff8c40, #ff6d40);
- height: #{210rpx};
- border-radius: 15upx;
- margin: 24upx 24upx 0 24upx;
- .top {
- color: #ffffff;
- padding: #{ 30rpx 24rpx 0 24rpx};
- .text {
- font-size: #{26rpx};
- text {
- font-size: #{32rpx};
- }
- }
- .button {
- margin-top: #{8rpx};
- width: #{213rpx};
- height: #{56rpx};
- line-height: #{54rpx};
- font-size: #{26rpx};
- color: #ffffff;
- border-radius: #{30rpx};
- text-align: center;
- border: #{1rpx} solid #ffffff;
- }
- }
- .bottom {
- height: #{100rpx};
- width: #{702rpx};
- }
- }
- .textss {
- height: #{100rpx};
- white-space: nowrap;
- }
- .content {
- height: #{10rpx};
- width: #{702rpx};
- background-color: #b24c2d;
- border-radius: #{5rpx};
- position: relative;
- .content-nei {
- height: #{10rpx};
- border-radius: #{5rpx};
- background-color: #ffffff;
- }
- .content-text {
- position: absolute;
- font-size: #{24rpx};
- color: #ffffff;
- margin-top: #{16rpx};
- right: 0;
- }
- }
- .content-d {
- display: inline-block;
- width: #{320rpx};
- height: #{10rpx};
- position: relative;
- margin-top: #{5rpx};
- background-color: rgba(204, 94, 51, .8);
- .content-text {
- position: absolute;
- font-size: #{24rpx};
- color: #ffffff;
- margin-top: #{16rpx};
- right: 0;
- transform: translateX(50%);
- }
- .content-text-o {
- position: absolute;
- font-size: #{24rpx};
- color: #ffffff;
- margin-top: #{16rpx};
- right: 0;
- }
- }
- .content-d-d {
- height: #{10rpx};
- border-radius: #{5rpx};
- }
- .content-d-d-d {
- height: #{10rpx};
- background-color: #f7f7f7;
- }
- .yuan {
- background-color: #ff8c40 !important;
- border: #{5rpx} solid #ffffff !important;
- }
- .scroll-empty {
- height: #{10upx};
- width: #{25upx};
- display: inline-block;
- }
- .after {
- width: #{125upx};
- }
- .yuan-default {
- border-radius: 50%;
- position: absolute;
- z-index: 1400;
- top: 50%;
- transform: translateY(-50%);
- right: 0;
- width: #{20rpx};
- height: #{20rpx};
- background-color: rgba(204, 94, 51, .8);
- border: #{5rpx} solid rgba(204, 94, 51, .8) ;
- }
- .border-radius-left {
- border-top-left-radius: #{5rpx};
- border-bottom-left-radius: #{5rpx};
- }
- .border-radius-right {
- border-top-right-radius: #{5rpx};
- border-bottom-right-radius: #{5rpx};
- }
- </style>
|