123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- <template>
- <view @click="route" class="reduce dir-left-nowrap main-between cross-center" :class="sign === 'gift' ? theme + '-full ' : theme + '-m-back-full ' + theme">
- <view :class="sign === 'gift' ? theme + '-color' : theme+'-m-text bd-name ' + theme">满减优惠</view>
- <view class="dir-left-nowrap cross-center">
- <view class="bd-item" v-if="full_reduce.rule_type === 2">
- <text :class="theme+'-m-back ' + theme" class="text" >
- 每满{{full_reduce.rule.min_money}}减{{full_reduce.rule.cut}}
- </text>
- </view>
- <view :class="!opacity ? 'bd-opacity-0' : 'bd-opacity-1'" v-else-if="full_reduce.rule_type === 1" class="bd-item u-line-1 dir-left-nowrap cross-center">
- <text :class="[sign === 'gift' ? theme + '-background ' : theme+'-m-back ' + theme]"
- :id="'bd-'+index + '-text'"
- class="text " v-for="(item, index) in list" :key="index">
- 满{{item.min_money}}{{item.discount_type === '1' ? '减' + item.cut : '打' + item.discount + '折'}}
- </text>
- </view>
- <view class="arrow"></view>
- </view>
- </view>
- </template>
- <script>
- export default {
- name: "app-goods-full-reduce",
- props: {
- theme: String,
- full_reduce: Object,
- sign: String
- },
- data() {
- return {
- textWidth: 0,
- resultWidth: 0,
- list: [],
- opacity: false
- }
- },
- methods: {
- route() {
- uni.navigateTo({
- url: '/pages/full_reduce/index/index'
- })
- },
- initSize: function () {
- let query = [];
- for (let i = 0; i < this.list.length; i++) {
- query.push(
- new Promise(resolve => {
- let query = uni.createSelectorQuery().in(this);
- query.select(`#bd-${i}-text`).boundingClientRect().exec(ret => {
- if (ret[0]) {
- this.textWidth += (ret[0].width + uni.upx2px(10));
- }
- resolve();
- });
- })
- )
- }
- Promise.all(query).then(() => {
- this.resultWidth = this.textWidth;
- });
- }
- },
- watch: {
- 'full_reduce.rule' : {
- immediate: true,
- handler(newVal) {
- this.list = newVal;
- this.textWidth = 0;
- setTimeout(() => {
- this.initSize();
- }, 500);
- },
- deep: true
- },
- resultWidth: {
- handler(newVal) {
- if (newVal > uni.upx2px(552)) {
- this.list = this.list.slice(0, this.list.length - 1);
- this.textWidth = 0;
- this.$nextTick(() => {
- this.initSize();
- });
- } else {
- this.opacity = true;
- }
- }
- }
- },
- mounted() {
- setTimeout(() => {
- this.list = this.full_reduce.rule;
- this.textWidth = 0;
- setTimeout(() => {
- this.initSize();
- }, 500);
- }, 500);
- }
- }
- </script>
- <style lang="scss" scoped>
- @import '../../../static/css/gift.scss';
- .reduce {
- width: 750upx;
- padding: 20upx 24upx;
- }
- .arrow {
- background-size: 100% 100%;
- background-repeat: no-repeat;
- width: 12upx;
- height: 22upx;
- background-image: url("../../../static/image/icon/arrow-right.png");
- }
- .text {
- padding: 5rpx 10rpx;
- border-radius: 15rpx;
- font-size: 21upx;
- color: #ffffff;
- margin-right: 10rpx;
- }
- .bd-name {
- font-size: 28rpx;
- width: 150rpx;
- }
- .bd-item {
- width: 552upx;
- }
- .a.a-m-back-full {
- background: #ffecec;
- }
- .b.b-m-back-full {
- background: #fff9e5;
- }
- .c.c-m-back-full {
- background: #ffeef2;
- }
- .d.d-m-back-full {
- background: #fcf8ef;
- }
- .e.e-m-back-full {
- background: #f1f2fd;
- }
- .f.f-m-back-full {
- background: #ffecec;
- }
- .g.g-m-back-full{
- background: #eff8f1;
- }
- .h.h-m-back-full {
- background: #edf4fc;
- }
- .i.i-m-back-full {
- background: #eaeaea;
- }
- .j.j-m-back-full {
- background: #ffecec;
- }
- .streamer-gold-gift-full {
- background: #fcf6ec;
- }
- .romantic-powder-gift-full {
- background: #ffeef2;
- }
- .taste-red-gift-full {
- background: #ffecec;
- }
- .elegant-purple-gift-full {
- background: #f1f2fd;
- }
- .fresh-green-gift-full {
- background: #eff8f1;
- }
- .business-blue-gift-full {
- background: #edf4fc;
- }
- .bd-opacity-0 {
- opacity: 0;
- }
- .bd-opacity-1 {
- opacity: 1;
- }
- </style>
|