Feat:优惠券对接
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
<template>
|
||||
<view class="pkg-user-coupons">
|
||||
<SubSection :current="current" :can-use="canUse" :not-use="notUse" @change="changeNav"/>
|
||||
|
||||
<Coupons class="coupons" :data="item" v-for="(item,index) in list" :key="index"/>
|
||||
|
||||
<image class="zero-coupons" :src="webUrl+'/20231201201733142658.png'" mode="scaleToFill" v-if="list.length===0"/>
|
||||
<!-- <view>-->
|
||||
<!-- <button @tap="startRecord">开始录音</button>-->
|
||||
<!-- <button @tap="endRecord">停止录音</button>-->
|
||||
<!-- <button @tap="playVoice">播放录音</button>-->
|
||||
<!-- </view>-->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import SubSection from "@/components/SubSection.vue";
|
||||
import Coupons from "@/components/Coupons.vue";
|
||||
import {getCouponsUser} from "@/api/user";
|
||||
|
||||
const recorderManager = uni.getRecorderManager();
|
||||
const innerAudioContext = uni.createInnerAudioContext();
|
||||
|
||||
innerAudioContext.autoplay = true;
|
||||
|
||||
export default {
|
||||
name: "myCoupons",
|
||||
components: {SubSection, Coupons},
|
||||
data() {
|
||||
return {
|
||||
webUrl: this.$VUE_APP_RESOURCES_URL,
|
||||
voicePath: '',
|
||||
current: 0,
|
||||
canUse: 0,
|
||||
notUse: 0,
|
||||
list: []
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
// let self = this;
|
||||
// recorderManager.onStop(function (res) {
|
||||
// console.log('recorder stop' + JSON.stringify(res));
|
||||
// self.voicePath = res.tempFilePath;
|
||||
// });
|
||||
|
||||
this.fetchList(1)
|
||||
this.fetchList(2)
|
||||
},
|
||||
methods: {
|
||||
startRecord() {
|
||||
console.log('开始录音');
|
||||
|
||||
recorderManager.start();
|
||||
},
|
||||
endRecord() {
|
||||
console.log('录音结束');
|
||||
recorderManager.stop();
|
||||
},
|
||||
playVoice() {
|
||||
console.log('播放录音');
|
||||
|
||||
if (this.voicePath) {
|
||||
innerAudioContext.src = this.voicePath;
|
||||
innerAudioContext.play();
|
||||
}
|
||||
},
|
||||
|
||||
changeNav(index) {
|
||||
this.current = index
|
||||
this.fetchList(index + 1)
|
||||
},
|
||||
fetchList(type) {
|
||||
// type 1-可使用,2-已到期
|
||||
getCouponsUser(type).then(({data}) => {
|
||||
if (this.current + 1 === type) this.list = data
|
||||
this.list?.forEach(item => {
|
||||
item.isOpen = false
|
||||
})
|
||||
if (type === 1) this.canUse = data.length
|
||||
if (type === 2) this.notUse = data.length
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.pkg-user-coupons {
|
||||
padding: 40rpx 32rpx;
|
||||
|
||||
/deep/ .components-coupons {
|
||||
margin-top: 32rpx;
|
||||
}
|
||||
|
||||
.zero-coupons {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%,-50%);
|
||||
width: 400rpx;
|
||||
height: 366rpx;
|
||||
vertical-align: middle;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user