chore(组件): 组件尽量使用异步导入模式
This commit is contained in:
@@ -6,7 +6,8 @@
|
||||
</view>
|
||||
<view class="banner-container">
|
||||
<view class="memberInfo">
|
||||
<image :src="$util.img(memberInfo.headimg)" v-if="memberInfo.headimg" @error="headimgError" mode="aspectFill"/>
|
||||
<image :src="$util.img(memberInfo.headimg)" v-if="memberInfo.headimg" @error="headimgError"
|
||||
mode="aspectFill" />
|
||||
<image :src="$util.getDefaultImage().head" v-else mode="aspectFill"></image>
|
||||
<view class="member-desc">
|
||||
<view class="font-size-toolbar">{{ memberInfo.nickname }}</view>
|
||||
@@ -22,26 +23,27 @@
|
||||
:circular="swiperConfig.circular" :previous-margin="swiperConfig.previousMargin"
|
||||
:next-margin="swiperConfig.nextMargin" @change="swiperChange" @animationfinish="animationfinish"
|
||||
:current="curIndex">
|
||||
<swiper-item :class="levelList.length == 1 ? 'image-container-box' : ''" v-for="(item, i) in levelList" :key="i">
|
||||
<swiper-item :class="levelList.length == 1 ? 'image-container-box' : ''"
|
||||
v-for="(item, i) in levelList" :key="i">
|
||||
<view class="image-container" :class="[
|
||||
curIndex === 0
|
||||
? i === listLen - 1
|
||||
? 'item-left'
|
||||
: i === 1
|
||||
curIndex === 0
|
||||
? i === listLen - 1
|
||||
? 'item-left'
|
||||
: i === 1
|
||||
? 'item-right'
|
||||
: 'item-center'
|
||||
: curIndex === listLen - 1
|
||||
: curIndex === listLen - 1
|
||||
? i === 0
|
||||
? 'item-right'
|
||||
: i === listLen - 2
|
||||
? 'item-left'
|
||||
: 'item-center'
|
||||
? 'item-left'
|
||||
: 'item-center'
|
||||
: i === curIndex - 1
|
||||
? 'item-left'
|
||||
: i === curIndex + 1
|
||||
? 'item-right'
|
||||
: 'item-center'
|
||||
]">
|
||||
? 'item-left'
|
||||
: i === curIndex + 1
|
||||
? 'item-right'
|
||||
: 'item-center'
|
||||
]">
|
||||
<view class="slide-image" style="background-size: 100% 100%;background-repeat:no-repeat"
|
||||
:style="{
|
||||
transform: curIndex === i ? 'scale(' + scaleX + ',' + scaleY + ')' : 'scale(1,1)',
|
||||
@@ -50,14 +52,19 @@
|
||||
}">
|
||||
<view class="bg-border"></view>
|
||||
|
||||
<image v-if="levelList[curIndex] && levelList[curIndex]['level_picture']" :src="$util.img(levelList[curIndex]['level_picture'])"/>
|
||||
<image v-else :style="{backgroundColor:levelList[curIndex]['bg_color']}"/>
|
||||
<image v-if="levelList[curIndex] && levelList[curIndex]['level_picture']"
|
||||
:src="$util.img(levelList[curIndex]['level_picture'])" />
|
||||
<image v-else :style="{ backgroundColor: levelList[curIndex]['bg_color'] }" />
|
||||
|
||||
<view class="info">
|
||||
<view class="level-detail" :style="{color:levelList[curIndex]['level_text_color']}">{{ levelList[curIndex].level_name }}</view>
|
||||
<view class="growr-name" :style="{color:levelList[curIndex]['level_text_color']}">{{ levelList[curIndex].level_name }}可享受消费折扣和</view>
|
||||
<view class="growr-value" :style="{color:levelList[curIndex]['level_text_color']}">会员大礼包等权益</view>
|
||||
<view class="growth-rules font-size-tag" @click="openExplainPopup" v-if="levelList[curIndex].remark != ''">
|
||||
<view class="level-detail" :style="{ color: levelList[curIndex]['level_text_color'] }">
|
||||
{{ levelList[curIndex].level_name }}</view>
|
||||
<view class="growr-name" :style="{ color: levelList[curIndex]['level_text_color'] }">{{
|
||||
levelList[curIndex].level_name }}可享受消费折扣和</view>
|
||||
<view class="growr-value" :style="{ color: levelList[curIndex]['level_text_color'] }">
|
||||
会员大礼包等权益</view>
|
||||
<view class="growth-rules font-size-tag" @click="openExplainPopup"
|
||||
v-if="levelList[curIndex].remark != ''">
|
||||
<text class="iconfont icon-wenhao font-size-tag"></text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -78,8 +85,10 @@
|
||||
<view class="clear"></view>
|
||||
</view>
|
||||
<view class="card-time-list">
|
||||
<view class="card-item-box" :class="{ small: currCard.charge_rule_arr.length == 4 }" v-for="(item, index) in currCard.charge_rule_arr" :key="index">
|
||||
<view class="card-time-item" :class="{ active: choiceIndex == index }" @click="choice(index)">
|
||||
<view class="card-item-box" :class="{ small: currCard.charge_rule_arr.length == 4 }"
|
||||
v-for="(item, index) in currCard.charge_rule_arr" :key="index">
|
||||
<view class="card-time-item" :class="{ active: choiceIndex == index }"
|
||||
@click="choice(index)">
|
||||
<image :src="$util.img('public/uniapp/level/card-icon.png')" mode="widthFix"></image>
|
||||
<view class="time-name">{{ cardType[item.key].name }}</view>
|
||||
<view class="time-price">
|
||||
@@ -172,7 +181,8 @@
|
||||
</view>
|
||||
<view class="agreement" v-if="agreement">
|
||||
购买既视为同意
|
||||
<text @click="$util.redirectTo('/pages_tool/member/card_agreement')">《{{ agreement.title }}》</text>
|
||||
<text @click="$util.redirectTo('/pages_tool/member/card_agreement')">《{{ agreement.title
|
||||
}}》</text>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
@@ -198,7 +208,8 @@
|
||||
</uni-popup>
|
||||
</view>
|
||||
|
||||
<ns-payment ref="choosePaymentPopup" :payMoney="currCard.charge_rule_arr[choiceIndex].value" @confirm="toPay" v-if="currCard.charge_rule_arr.length"></ns-payment>
|
||||
<ns-payment ref="choosePaymentPopup" :payMoney="currCard.charge_rule_arr[choiceIndex].value"
|
||||
@confirm="toPay" v-if="currCard.charge_rule_arr.length"></ns-payment>
|
||||
</block>
|
||||
<block v-else><ns-empty text="暂无可开会员卡" :isIndex="false"></ns-empty></block>
|
||||
|
||||
@@ -209,221 +220,216 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import scroll from '@/common/js/scroll-view.js';
|
||||
import uniPopup from '@/components/uni-popup/uni-popup.vue';
|
||||
import nsEmpty from '@/components/ns-empty/ns-empty.vue';
|
||||
import nsLogin from '@/components/ns-login/ns-login.vue';
|
||||
import loadingCover from '@/components/loading-cover/loading-cover.vue';
|
||||
import nsPayment from '@/components/ns-payment/ns-payment.vue';
|
||||
import scroll from '@/common/js/scroll-view.js';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
uniPopup,
|
||||
nsEmpty,
|
||||
nsLogin,
|
||||
loadingCover,
|
||||
nsPayment
|
||||
},
|
||||
mixins: [scroll],
|
||||
data() {
|
||||
return {
|
||||
isSub: false, // 是否已提交
|
||||
isIphoneX: false,
|
||||
couponPopList: [],
|
||||
curIndex: 0,
|
||||
isDescAnimating: false,
|
||||
scaleX: (634 / 540).toFixed(4),
|
||||
scaleY: (378 / 330).toFixed(4),
|
||||
swiperConfig: {
|
||||
indicatorDots: false,
|
||||
indicatorColor: 'rgba(255, 255, 255, .4)',
|
||||
indicatorActiveColor: 'rgba(255, 255, 255, 1)',
|
||||
interval: 3000,
|
||||
duration: 300,
|
||||
circular: false,
|
||||
previousMargin: '58rpx',
|
||||
nextMargin: '58rpx'
|
||||
export default {
|
||||
components: {
|
||||
uniPopup: () => import('@/components/uni-popup/uni-popup.vue'),
|
||||
nsEmpty: () => import('@/components/ns-empty/ns-empty.vue'),
|
||||
nsLogin: () => import('@/components/ns-login/ns-login.vue'),
|
||||
loadingCover: () => import('@/components/loading-cover/loading-cover.vue'),
|
||||
nsPayment: () => import('@/components/ns-payment/ns-payment.vue')
|
||||
},
|
||||
mixins: [scroll],
|
||||
data() {
|
||||
return {
|
||||
isSub: false, // 是否已提交
|
||||
isIphoneX: false,
|
||||
couponPopList: [],
|
||||
curIndex: 0,
|
||||
isDescAnimating: false,
|
||||
scaleX: (634 / 540).toFixed(4),
|
||||
scaleY: (378 / 330).toFixed(4),
|
||||
swiperConfig: {
|
||||
indicatorDots: false,
|
||||
indicatorColor: 'rgba(255, 255, 255, .4)',
|
||||
indicatorActiveColor: 'rgba(255, 255, 255, 1)',
|
||||
interval: 3000,
|
||||
duration: 300,
|
||||
circular: false,
|
||||
previousMargin: '58rpx',
|
||||
nextMargin: '58rpx'
|
||||
},
|
||||
levelList: [],
|
||||
levelId: 0,
|
||||
cardType: {
|
||||
week: {
|
||||
name: '周卡',
|
||||
unit: '周'
|
||||
},
|
||||
levelList: [],
|
||||
levelId: 0,
|
||||
cardType: {
|
||||
week: {
|
||||
name: '周卡',
|
||||
unit: '周'
|
||||
},
|
||||
month: {
|
||||
name: '月卡',
|
||||
unit: '月'
|
||||
},
|
||||
quarter: {
|
||||
name: '季卡',
|
||||
unit: '季'
|
||||
},
|
||||
year: {
|
||||
name: '年卡',
|
||||
unit: '年'
|
||||
}
|
||||
month: {
|
||||
name: '月卡',
|
||||
unit: '月'
|
||||
},
|
||||
choiceIndex: 0,
|
||||
outTradeNo: '',
|
||||
agreement: null
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
listLen() {
|
||||
return this.levelList.length;
|
||||
quarter: {
|
||||
name: '季卡',
|
||||
unit: '季'
|
||||
},
|
||||
year: {
|
||||
name: '年卡',
|
||||
unit: '年'
|
||||
}
|
||||
},
|
||||
currCard() {
|
||||
if (this.levelList[this.curIndex]) {
|
||||
let card = this.levelList[this.curIndex];
|
||||
let charge_rule = card.charge_rule ? JSON.parse(card.charge_rule) : {};
|
||||
card.charge_rule_arr = [];
|
||||
Object.keys(charge_rule).forEach(key => {
|
||||
card.charge_rule_arr.push({
|
||||
key: key,
|
||||
value: charge_rule[key]
|
||||
});
|
||||
choiceIndex: 0,
|
||||
outTradeNo: '',
|
||||
agreement: null
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
listLen() {
|
||||
return this.levelList.length;
|
||||
},
|
||||
currCard() {
|
||||
if (this.levelList[this.curIndex]) {
|
||||
let card = this.levelList[this.curIndex];
|
||||
let charge_rule = card.charge_rule ? JSON.parse(card.charge_rule) : {};
|
||||
card.charge_rule_arr = [];
|
||||
Object.keys(charge_rule).forEach(key => {
|
||||
card.charge_rule_arr.push({
|
||||
key: key,
|
||||
value: charge_rule[key]
|
||||
});
|
||||
return card;
|
||||
}
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
//会员卡
|
||||
this.isIphoneX = this.$util.uniappIsIPhoneX();
|
||||
|
||||
if (this.storeToken) {
|
||||
this.getCardList();
|
||||
} else {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.login.open('/pages_tool/member/card_buy');
|
||||
});
|
||||
return card;
|
||||
}
|
||||
this.getAgreement();
|
||||
},
|
||||
onShow() {},
|
||||
watch: {
|
||||
storeToken: function(nVal, oVal) {
|
||||
if (nVal) {
|
||||
this.getCardList();
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
swiperChange(e) {
|
||||
this.curIndex = e.detail.current;
|
||||
this.choiceIndex = 0;
|
||||
this.isDescAnimating = true;
|
||||
},
|
||||
animationfinish(e) {
|
||||
this.isDescAnimating = false;
|
||||
},
|
||||
getCardList() {
|
||||
this.$api.sendRequest({
|
||||
url: '/supermember/api/membercard/lists',
|
||||
success: res => {
|
||||
if (res.code == 0 && res.data) {
|
||||
this.levelList = res.data;
|
||||
this.levelId = this.memberInfo.member_level;
|
||||
for (let i = 0; i < this.levelList.length; i++) {
|
||||
if (this.levelList[i].level_id == this.levelId) {
|
||||
this.curIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.$util.showToast({
|
||||
title: res.message
|
||||
});
|
||||
}
|
||||
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
|
||||
}
|
||||
});
|
||||
},
|
||||
choice(index) {
|
||||
this.choiceIndex = index;
|
||||
},
|
||||
/**
|
||||
* 创建
|
||||
*/
|
||||
create() {
|
||||
if (this.memberInfo.member_level_type && this.memberInfo.member_level != this.currCard.level_id) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '您有尚未过期的会员卡,再次购卡会覆盖掉之前的卡,是否继续?',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
this.$refs.choosePaymentPopup.open();
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.$refs.choosePaymentPopup.open();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 提交
|
||||
*/
|
||||
toPay() {
|
||||
if (this.isSub) return;
|
||||
this.isSub = true;
|
||||
|
||||
this.$api.sendRequest({
|
||||
url: '/supermember/api/ordercreate/create',
|
||||
data: {
|
||||
level_id: this.currCard.level_id,
|
||||
period_unit: this.currCard.charge_rule_arr[this.choiceIndex].key
|
||||
},
|
||||
success: res => {
|
||||
if (res.data && res.code == 0) {
|
||||
this.outTradeNo = res.data.out_trade_no;
|
||||
uni.setStorageSync('paySource', 'membercard');
|
||||
this.$refs.choosePaymentPopup.getPayInfo(this.outTradeNo);
|
||||
} else {
|
||||
this.isSub = false;
|
||||
this.$util.showToast({
|
||||
title: res.message
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
headimgError() {
|
||||
this.memberInfo.headimg = this.$util.getDefaultImage().head;
|
||||
},
|
||||
/**
|
||||
* 打开说明弹出层
|
||||
*/
|
||||
openExplainPopup() {
|
||||
this.$refs.explainPopup.open();
|
||||
},
|
||||
/**
|
||||
* 打开说明弹出层
|
||||
*/
|
||||
closeExplainPopup() {
|
||||
this.$refs.explainPopup.close();
|
||||
},
|
||||
getAgreement() {
|
||||
this.$api.sendRequest({
|
||||
url: '/supermember/api/membercard/agreement',
|
||||
success: res => {
|
||||
if (res.code == 0 && res.data && res.data.title != '' && res.data.content != '') {
|
||||
this.agreement = res.data;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
onBackPress(options) {
|
||||
if (options.from === 'navigateBack') {
|
||||
return false;
|
||||
}
|
||||
this.$util.redirectTo('/pages/member/index');
|
||||
return true;
|
||||
}
|
||||
};
|
||||
},
|
||||
onLoad() {
|
||||
//会员卡
|
||||
this.isIphoneX = this.$util.uniappIsIPhoneX();
|
||||
|
||||
if (this.storeToken) {
|
||||
this.getCardList();
|
||||
} else {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.login.open('/pages_tool/member/card_buy');
|
||||
});
|
||||
}
|
||||
this.getAgreement();
|
||||
},
|
||||
onShow() { },
|
||||
watch: {
|
||||
storeToken: function (nVal, oVal) {
|
||||
if (nVal) {
|
||||
this.getCardList();
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
swiperChange(e) {
|
||||
this.curIndex = e.detail.current;
|
||||
this.choiceIndex = 0;
|
||||
this.isDescAnimating = true;
|
||||
},
|
||||
animationfinish(e) {
|
||||
this.isDescAnimating = false;
|
||||
},
|
||||
getCardList() {
|
||||
this.$api.sendRequest({
|
||||
url: '/supermember/api/membercard/lists',
|
||||
success: res => {
|
||||
if (res.code == 0 && res.data) {
|
||||
this.levelList = res.data;
|
||||
this.levelId = this.memberInfo.member_level;
|
||||
for (let i = 0; i < this.levelList.length; i++) {
|
||||
if (this.levelList[i].level_id == this.levelId) {
|
||||
this.curIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.$util.showToast({
|
||||
title: res.message
|
||||
});
|
||||
}
|
||||
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
|
||||
}
|
||||
});
|
||||
},
|
||||
choice(index) {
|
||||
this.choiceIndex = index;
|
||||
},
|
||||
/**
|
||||
* 创建
|
||||
*/
|
||||
create() {
|
||||
if (this.memberInfo.member_level_type && this.memberInfo.member_level != this.currCard.level_id) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '您有尚未过期的会员卡,再次购卡会覆盖掉之前的卡,是否继续?',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
this.$refs.choosePaymentPopup.open();
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.$refs.choosePaymentPopup.open();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 提交
|
||||
*/
|
||||
toPay() {
|
||||
if (this.isSub) return;
|
||||
this.isSub = true;
|
||||
|
||||
this.$api.sendRequest({
|
||||
url: '/supermember/api/ordercreate/create',
|
||||
data: {
|
||||
level_id: this.currCard.level_id,
|
||||
period_unit: this.currCard.charge_rule_arr[this.choiceIndex].key
|
||||
},
|
||||
success: res => {
|
||||
if (res.data && res.code == 0) {
|
||||
this.outTradeNo = res.data.out_trade_no;
|
||||
uni.setStorageSync('paySource', 'membercard');
|
||||
this.$refs.choosePaymentPopup.getPayInfo(this.outTradeNo);
|
||||
} else {
|
||||
this.isSub = false;
|
||||
this.$util.showToast({
|
||||
title: res.message
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
headimgError() {
|
||||
this.memberInfo.headimg = this.$util.getDefaultImage().head;
|
||||
},
|
||||
/**
|
||||
* 打开说明弹出层
|
||||
*/
|
||||
openExplainPopup() {
|
||||
this.$refs.explainPopup.open();
|
||||
},
|
||||
/**
|
||||
* 打开说明弹出层
|
||||
*/
|
||||
closeExplainPopup() {
|
||||
this.$refs.explainPopup.close();
|
||||
},
|
||||
getAgreement() {
|
||||
this.$api.sendRequest({
|
||||
url: '/supermember/api/membercard/agreement',
|
||||
success: res => {
|
||||
if (res.code == 0 && res.data && res.data.title != '' && res.data.content != '') {
|
||||
this.agreement = res.data;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
onBackPress(options) {
|
||||
if (options.from === 'navigateBack') {
|
||||
return false;
|
||||
}
|
||||
this.$util.redirectTo('/pages/member/index');
|
||||
return true;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
@import './public/css/card.scss';
|
||||
@import './public/css/card.scss';
|
||||
</style>
|
||||
Reference in New Issue
Block a user