Commit 793441f5 by songbingqi

完成我的页面优惠券开发

parent 937143d1
...@@ -49,7 +49,7 @@ export default { ...@@ -49,7 +49,7 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
.big { .big {
height: 68rpx; height: 82rpx;
display: flex; display: flex;
align-items: center; align-items: center;
padding-top: 3rpx; padding-top: 3rpx;
...@@ -64,8 +64,8 @@ export default { ...@@ -64,8 +64,8 @@ export default {
.textAction{ .textAction{
width: 100%; width: 100%;
text-align: center; text-align: center;
margin-bottom: 12rpx; margin-bottom: 18rpx;
font-size: 24rpx; font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC; font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500; font-weight: 500;
color: #333333; color: #333333;
...@@ -74,8 +74,8 @@ export default { ...@@ -74,8 +74,8 @@ export default {
.textDefault{ .textDefault{
width: 100%; width: 100%;
text-align: center; text-align: center;
margin-bottom: 12rpx; margin-bottom: 18rpx;
font-size: 24rpx; font-size: 28rpx;
font-family: PingFangSC-Regular, PingFang SC; font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400; font-weight: 400;
color: #666666; color: #666666;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<view class="right_top"> <view class="right_top">
<view class="info"> <view class="info">
<view :style="[titleColor]" class="title">{{info.title}}</view> <view :style="[titleColor]" class="title">{{info.title}}</view>
<view :style="[timeColor]" class="time">有效期至{{info.time[0]}}</view> <view :style="[timeColor]" class="time">{{info.time[0]?info.time[0]+'-'+info.time[1]:'有效期至'+info.time[1]}}</view>
</view> </view>
<view class="action"> <view class="action">
<view v-if="type==='use'"> <view v-if="type==='use'">
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
</view> </view>
<view v-else> <view v-else>
<view v-if="info.status===0"> <view v-if="info.status===0">
<button class="gouse">去使用</button> <button class="gouse" @click="goMenu">去使用</button>
</view> </view>
</view> </view>
</view> </view>
...@@ -160,6 +160,9 @@ export default { ...@@ -160,6 +160,9 @@ export default {
selected(info) { selected(info) {
if(info.status!==0)return if(info.status!==0)return
this.$emit("updata",info.id) this.$emit("updata",info.id)
},
goMenu() {
uni.switchTab({ url: '/pages/menu/menu' });
} }
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<scroll-view class="nav-left" :style="[heightStyle]" :class="[shopCarFlag||shopState===0?'shopCarcss':'' ]" scroll-y :scroll-top="scrollLeftTop" scroll-with-animation> <scroll-view class="nav-left" :style="[heightStyle]" :class="[shopCarFlag||shopState===0?'shopCarcss':'' ]" scroll-y :scroll-top="scrollLeftTop" scroll-with-animation>
<view class="nav-left-item" v-for="(item,index) in classifyData" @click="categoryClickMain(item.id)" :key="item.id" <view class="nav-left-item" v-for="(item,index) in classifyData" @click="categoryClickMain(item.id)" :key="item.id"
:class="item.id == categoryId ? 'active' : ''"> :class="item.id == categoryId ? 'active' : ''">
<view class="imgbox" v-if="item.src"><image :style="{'height':sizeList[index].height+'rpx','width':sizeList[index].width+'rpx'}" :src="item.src"/></view> <view class="imgbox" v-if="item.src&&sizeList[index].width"><image :style="{'height':sizeList[index].height+'rpx','width':sizeList[index].width+'rpx'}" :src="item.src"/></view>
<view :style="{'margin-top':'10rpx'}"><span>{{ item.name }}</span></view> <view :style="{'margin-top':'10rpx'}"><span>{{ item.name }}</span></view>
<!-- <view :class="item.id == categoryId ? 'active-line' : ''"></view> --> <!-- <view :class="item.id == categoryId ? 'active-line' : ''"></view> -->
</view> </view>
...@@ -115,9 +115,9 @@ export default { ...@@ -115,9 +115,9 @@ export default {
this.categoryPostion = data this.categoryPostion = data
}).exec(); }).exec();
}) })
categorys[0]?categorys[0].src = 'http://fakeimg.pl/43x42/':'' // categorys[0]?categorys[0].src = 'http://fakeimg.pl/43x42/':''
categorys[1]?categorys[1].src = 'http://fakeimg.pl/54x34/':'' // categorys[1]?categorys[1].src = 'http://fakeimg.pl/54x34/':''
categorys[2]?categorys[2].src = 'http://fakeimg.pl/32x30/':'' // categorys[2]?categorys[2].src = 'http://fakeimg.pl/32x30/':''
categorys.map(item=>{ categorys.map(item=>{
this.imagesHeight(item.src) this.imagesHeight(item.src)
}) })
...@@ -142,11 +142,13 @@ export default { ...@@ -142,11 +142,13 @@ export default {
const val = await uni.getImageInfo({ const val = await uni.getImageInfo({
src src
}) })
console.log(val[1].width) console.log(val)
this.sizeList.push({ if(val.length==2){
width:val[1].width, this.sizeList.push({
height:val[1].height width:val[1].width,
}) height:val[1].height
})
}
}, },
getSku(data) { getSku(data) {
const { skus } = data; const { skus } = data;
......
...@@ -105,7 +105,7 @@ export default { ...@@ -105,7 +105,7 @@ export default {
padding: 12rpx 32rpx; padding: 12rpx 32rpx;
align-items: center; align-items: center;
.text{ .text{
font-size: 26rpx; font-size: 28rpx;
font-family: PingFangSC-Semibold, PingFang SC; font-family: PingFangSC-Semibold, PingFang SC;
font-weight: 600; font-weight: 600;
color: #000000; color: #000000;
......
...@@ -4,13 +4,19 @@ ...@@ -4,13 +4,19 @@
<view> <view>
<swiper :current="current" class="swiper" @change="swiperChange"> <swiper :current="current" class="swiper" @change="swiperChange">
<swiper-item> <swiper-item>
<view class="list"> <view class="list" v-if="canuse.length!=0">
<Ticket/> <Ticket v-for="(item,index) in canuse" :key="index" :info="item"/>
</view>
<view class="emty" v-else>
<view class="text">暂无可用优惠券</view>
</view> </view>
</swiper-item> </swiper-item>
<swiper-item> <swiper-item>
<view class="list"> <view class="list" v-if="cantuse.length!=0">
<Ticket v-for="(item,index) in nouserList" :key="index" :info="item" /> <Ticket v-for="(item,index) in cantuse" :key="index" :info="item" />
</view>
<view class="emty" v-else>
<view class="text">暂无可用优惠券</view>
</view> </view>
</swiper-item> </swiper-item>
</swiper> </swiper>
...@@ -21,6 +27,7 @@ ...@@ -21,6 +27,7 @@
<script> <script>
import Ticket from '@/components/Ticket/index.vue' import Ticket from '@/components/Ticket/index.vue'
import Tabs from '@/components/Tabs/index.vue' import Tabs from '@/components/Tabs/index.vue'
import Mine from '@/request/mine'
export default { export default {
components: {Ticket,Tabs}, components: {Ticket,Tabs},
data() { data() {
...@@ -35,9 +42,19 @@ export default { ...@@ -35,9 +42,19 @@ export default {
], ],
nouserList:[], nouserList:[],
current: 0, current: 0,
actionIndx:0 actionIndx:0,
canuse:[],
cantuse:[]
}; };
}, },
watch:{
current(val) {
console.log(val,'val')
if(val===1&&this.cantuse.length===0){
this.getTickList(false)
}
}
},
mounted(){ mounted(){
for(let i=0;i<2;i++){ for(let i=0;i<2;i++){
this.nouserList.push({ this.nouserList.push({
...@@ -59,8 +76,48 @@ export default { ...@@ -59,8 +76,48 @@ export default {
reson:'不可与已勾选券叠加使用' // 不可使用原因 reson:'不可与已勾选券叠加使用' // 不可使用原因
}) })
} }
this.getTickList(true)
}, },
methods: { methods: {
async getTickList(val) {
const {data} = await Mine.getUserList(val)
const {rows} = data
console.log(data)
const canuse = rows.map(item=>{
let timeStart = ''
let timeEnd = ''
if(item.useStartTime){
timeStart = item.useStartTime.slice(0,11).replace('-', '.')
}
if(item.useEndTime){
timeEnd = item.useEndTime.slice(0,11).replace('-', '.')
}
return {
id: item.id,
status: item.state===0?0:item.state===1?2:3,
couponType: item.type,
typeDesc: item.categoryName,
price: item.priceDiscount,
priceDesc: item.ruleDesc,
checkStatus: false,
title: item.name,
time: [timeStart,timeEnd],
shopList: [item.areaLimitDesc],
goodList: [item.goodLimitDesc],
useScence: ['小程序下单可用'],
useDesc: ['*不可与其他优惠券同时使用','*不可与门店优惠共享','*订单完成后选择退款,只退回实际支付金额,优惠券不予退回'],
zkRule: item.type===1?'抵扣后实付金额无法小于0':item.type===2?'整单最高抵扣50元':'可享受规定范围内饮品免单',
reson: item.notFitableDesc,
couponAmount:item.couponAmount,
fitItem:item
}
})
if(val){
this.canuse = canuse
}else{
this.cantuse = canuse
}
},
changeTab(current) { changeTab(current) {
this.current = current; this.current = current;
}, },
...@@ -81,6 +138,18 @@ export default { ...@@ -81,6 +138,18 @@ export default {
padding: 0rpx 32rpx; padding: 0rpx 32rpx;
overflow-y: scroll; overflow-y: scroll;
} }
.emty{
.text{
text-align: center;
margin-top: 322rpx;
font-size: 28rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #999999;
line-height: 40rpx;
letter-spacing: 1rpx;
}
}
} }
} }
</style> </style>
...@@ -4,20 +4,27 @@ ...@@ -4,20 +4,27 @@
<view class="ticketList"> <view class="ticketList">
<swiper :current="current" class="swiper" @change="swiperChange"> <swiper :current="current" class="swiper" @change="swiperChange">
<swiper-item> <swiper-item>
<view class="list"> <view class="list" v-if="canuse.length!=0">
<Ticket v-for="(item,index) in canuse" :key="index" :info="item" type="use" @updata="updata"/> <Ticket v-for="(item,index) in canuse" :key="index" :info="item" type="use" @updata="updata"/>
</view> </view>
<view class="emty" v-else>
<view class="text">暂无可用优惠券</view>
</view>
</swiper-item> </swiper-item>
<swiper-item> <swiper-item>
<view class="list"> <view class="list" v-if="cantuse.length!=0">
<Ticket v-for="(item,index) in cantuse" :key="index" :info="item" type="use"/> <Ticket v-for="(item,index) in cantuse" :key="index" :info="item" type="use"/>
</view> </view>
<view class="emty" v-else>
<view class="text">暂无不可用优惠券</view>
</view>
</swiper-item> </swiper-item>
</swiper> </swiper>
</view> </view>
<view class="usebtn" v-if="price!=0"> <view class="usebtn" v-if="canuse.length!=0&&current===0">
<view class="content"> <view class="content">
<view class="text">已选1张HOOLOO卷,可优惠<span class="money">{{price}}</span></view> <view class="text" v-if="price!=0">已选1张HOOLOO卷,可优惠<span class="money">{{price}}</span></view>
<view class="text" v-else>暂未选择HOOLOO优惠卷</view>
<view> <view>
<view class="btnView" @click="setTickcet">确认</view> <view class="btnView" @click="setTickcet">确认</view>
</view> </view>
...@@ -51,7 +58,6 @@ export default { ...@@ -51,7 +58,6 @@ export default {
}, },
watch:{ watch:{
canuse(val){ canuse(val){
console.log(val,123)
const vals = val.filter((item)=>{return item.checkStatus})||[] const vals = val.filter((item)=>{return item.checkStatus})||[]
this.price = vals[0]?.couponAmount||0 this.price = vals[0]?.couponAmount||0
} }
...@@ -136,6 +142,18 @@ export default { ...@@ -136,6 +142,18 @@ export default {
padding: 0rpx 32rpx; padding: 0rpx 32rpx;
overflow-y: scroll; overflow-y: scroll;
} }
.emty{
.text{
text-align: center;
margin-top: 322rpx;
font-size: 28rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #999999;
line-height: 40rpx;
letter-spacing: 1rpx;
}
}
} }
} }
......
...@@ -43,7 +43,8 @@ ...@@ -43,7 +43,8 @@
<div :class="[ticketNum>0?'num-action':'num']"> <div :class="[ticketNum>0?'num-action':'num']">
<span v-if="selectPrice" class="price">-¥{{selectPrice}}</span> <span v-if="selectPrice" class="price">-¥{{selectPrice}}</span>
<span v-else>{{ticketNum>0?ticketNum+'张可用':'暂无可用优惠'}}</span> <span v-else>{{ticketNum>0?ticketNum+'张可用':'暂无可用优惠'}}</span>
<!-- <image class="arrow-right-select" :src="'../../../static/imgs/jiantouhei.png'" /> --> <image v-if="!ticketNum>0" class="arrow-right-select" :src="'../../../static/imgs/jiantouhei.png'" />
<image v-else class="arrow-right-select" :src="'../../../static/imgs/jiantoufen.jpg'" />
</div> </div>
</div> </div>
...@@ -300,12 +301,10 @@ export default { ...@@ -300,12 +301,10 @@ export default {
const {data} = list const {data} = list
this.ticketList = data this.ticketList = data
this.$store.commit('setTickerList',this.ticketList) this.$store.commit('setTickerList',this.ticketList)
console.log(this.ticketList,'list')
} }
if(num.code==200){ if(num.code==200){
const {data} = num const {data} = num
this.ticketNum = data this.ticketNum = data
console.log(this.ticketNum,'num')
} }
} }
}, },
......
...@@ -30,5 +30,16 @@ export default { ...@@ -30,5 +30,16 @@ export default {
.catch((err) => { .catch((err) => {
context.showToast({ title: '服务器错误', icon: 'none' }); context.showToast({ title: '服务器错误', icon: 'none' });
}); });
},
// 获取用户优惠卷列表
getUserList(data) {
return uni.$u.http
.get(`/app/coupon/list/${data}`, {})
.then((res) => {
return res;
})
.catch((err) => {
context.showToast({ title: '服务器错误', icon: 'none' });
});
} }
}; };
...@@ -14,6 +14,14 @@ const order = { ...@@ -14,6 +14,14 @@ const order = {
setTickerList(state, data) { setTickerList(state, data) {
console.log(data) console.log(data)
const canuse = data.fitable.map(item=>{ const canuse = data.fitable.map(item=>{
let timeStart = ''
let timeEnd = ''
if(item.useStartTime){
timeStart = item.useStartTime.slice(0,11).replace('-', '.')
}
if(item.useEndTime){
timeEnd = item.useEndTime.slice(0,11).replace('-', '.')
}
return { return {
id: item.id, id: item.id,
status: 0, status: 0,
...@@ -23,7 +31,7 @@ const order = { ...@@ -23,7 +31,7 @@ const order = {
priceDesc: item.ruleDesc, priceDesc: item.ruleDesc,
checkStatus: false, checkStatus: false,
title: item.name, title: item.name,
time: [item.useStartTime,item.useEndTime], time: [timeStart,timeEnd],
shopList: [item.areaLimitDesc], shopList: [item.areaLimitDesc],
goodList: [item.goodLimitDesc], goodList: [item.goodLimitDesc],
useScence: ['小程序下单可用'], useScence: ['小程序下单可用'],
...@@ -38,6 +46,14 @@ const order = { ...@@ -38,6 +46,14 @@ const order = {
}) })
if(canuse.length!=0)canuse[0].checkStatus = true if(canuse.length!=0)canuse[0].checkStatus = true
const cantUse = data.notfitable.map(item=>{ const cantUse = data.notfitable.map(item=>{
let timeStart = ''
let timeEnd = ''
if(item.useStartTime){
timeStart = item.useStartTime.slice(0,11).replace('-', '.')
}
if(item.useEndTime){
timeEnd = item.useEndTime.slice(0,11).replace('-', '.')
}
return { return {
id: item.id, id: item.id,
status: 1, status: 1,
...@@ -47,7 +63,7 @@ const order = { ...@@ -47,7 +63,7 @@ const order = {
priceDesc: item.ruleDesc, priceDesc: item.ruleDesc,
checkStatus: false, checkStatus: false,
title: item.name, title: item.name,
time: [item.useStartTime,item.useEndTime], time: [timeStart,timeEnd],
shopList: [item.areaLimitDesc], shopList: [item.areaLimitDesc],
goodList: [item.goodLimitDesc], goodList: [item.goodLimitDesc],
useScence: ['小程序下单可用'], useScence: ['小程序下单可用'],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment