分享优惠券更新

This commit is contained in:
GaoHao 2024-11-08 17:32:35 +08:00
parent 7b81e2ffb0
commit 7167c2604f
7 changed files with 211 additions and 72 deletions

View File

@ -356,5 +356,36 @@ export default {
calcUsablePoints(param) { calcUsablePoints(param) {
return uni.api.get("/api/points/member-points/calc-usable-points", param); return uni.api.get("/api/points/member-points/calc-usable-points", param);
}, },
/**
* 分享-获取邀请页数据
* @param {Object} param
*/
getByShopId(param) {
return uni.api.get("/tbShopShare/getByShopId", param);
},
/**
* 分享-邀请记录
* @param {Object} param
*/
shareRecord(param) {
return uni.api.get("/tbShopShare/record", param);
},
/**
* 分享-被邀请人进入页面时使用
* @param {Object} param
*/
shareHeOpen(param) {
return uni.api.post("/tbShopShare/open", param);
},
/**
* 分享-被邀请人领取优惠券时使用
* @param {Object} param
*/
shareReceive(param) {
return uni.api.post("/tbShopShare/receive", param);
},
} }

View File

@ -76,8 +76,9 @@
swiperClick (e) { swiperClick (e) {
let item = this.popupadList[e]; let item = this.popupadList[e];
if ( item.linkPath ) { if ( item.linkPath ) {
uni.navigateTo({ uni.pro.navigateTo(item.linkPath, {
url: `${item.linkPath}` shopId: uni.cache.get('shopId'),
is_type: "me",
}) })
} }
}, },

View File

@ -91,10 +91,6 @@
}) })
}, },
memberindex(url) { memberindex(url) {
// uni.pro.navigateTo("/pagesInviteFriends/index/index", {
// shopId: uni.cache.get('shopId'),
// type: 'index',
// })
uni.pro.navigateTo(url, { uni.pro.navigateTo(url, {
shopId: uni.cache.get('shopId'), shopId: uni.cache.get('shopId'),
type: 'index', type: 'index',

View File

@ -238,10 +238,10 @@
<!-- 购物车 --> <!-- 购物车 -->
<shoppingCart v-if="tableCode&&shopId" ref="shoppingCart" :shopId="shopId" :tableCode="tableCode" :cartLists_count="cartLists_count" :cartLists="cartLists" :showCart="showCart" @addCart="addCart" @close="close"></shoppingCart> <shoppingCart v-if="tableCode||shopId" ref="shoppingCart" :shopId="shopId" :tableCode="tableCode" :cartLists_count="cartLists_count" :cartLists="cartLists" :showCart="showCart" @addCart="addCart" @close="close"></shoppingCart>
<!-- 购物车结算 --> <!-- 购物车结算 -->
<shoppingCartBilling v-if="tableCode&&shopId" ref="shoppingCartBilling" :cartListsdatashow="cartListsdatashow" :shopId="shopId" :tableCode="tableCode" :storeInfo="shopInfo.storeInfo" :cartLists_count="cartLists_count" :cartLists="cartLists" :showCart="showCart" @isOpen="isOpen"></shoppingCartBilling> <shoppingCartBilling v-if="tableCode||shopId" ref="shoppingCartBilling" :cartListsdatashow="cartListsdatashow" :shopId="shopId" :tableCode="tableCode" :storeInfo="shopInfo.storeInfo" :cartLists_count="cartLists_count" :cartLists="cartLists" :showCart="showCart" @isOpen="isOpen"></shoppingCartBilling>
<view class="placedOrderTip" @click="placedOrder" v-if="tableCode&&shopInfo.shopTableInfo&&shopInfo.shopTableInfo.orderId&&shopInfo.storeInfo.registerType == 'restaurant'"><u-avatar :src="src" shape="circle"></u-avatar><view style="margin-left: 8rpx;">已下单菜品</view></view> <view class="placedOrderTip" @click="placedOrder" v-if="tableCode&&shopInfo.shopTableInfo&&shopInfo.shopTableInfo.orderId&&shopInfo.storeInfo.registerType == 'restaurant'"><u-avatar :src="src" shape="circle"></u-avatar><view style="margin-left: 8rpx;">已下单菜品</view></view>
@ -481,6 +481,7 @@
duration: 0 duration: 0
}); });
if ( this.shopId ) { if ( this.shopId ) {
this.productqueryShop();
this.productqueryProduct() //list this.productqueryProduct() //list
this.getShopUserInfo() //list this.getShopUserInfo() //list
this.handlemessage() //websocket this.handlemessage() //websocket

View File

@ -17,22 +17,22 @@
<view class="containertopbox"> <view class="containertopbox">
<view class="containertopboxitem flex-start" v-for="(item,index) in list" :key="index"> <view class="containertopboxitem flex-start" v-for="(item,index) in list" :key="index">
<view class="containertopboxitemleft flex-colum" <view class="containertopboxitemleft flex-colum"
:class="{'containertopboxitemleft_vip': item.type == 2,'containertopboxitemlefts': item.status != 0,}" v-if="item.type == 2"> :class="{'containertopboxitemleft_vip': item.type == 2,'containertopboxitemlefts': status != 1,}" >
<view class="containertopboxitemleft_one" <view class="containertopboxitemleft_one"
:class="item.status == 0?'':'containertopboxitemleft_ones'"> :class="status == 1?'':'containertopboxitemleft_ones'">
<block v-if="item.type == 2"> <block v-if="item.type == 2">
<text>{{item.num || 0}}</text> <text>{{item.num || 0}}</text>
<text style="font-size: 28rpx;margin-left: 6rpx;"></text> <text style="font-size: 28rpx;margin-left: 6rpx;"></text>
</block> </block>
<block v-else > <block v-else >
<text style="font-size: 28rpx;margin-right: 6rpx;"></text> <text style="font-size: 28rpx;margin-right: 6rpx;"></text>
<text>{{item.couponsAmount || 0}}</text> <text>{{item.discountAmount || 0}}</text>
</block> </block>
</view> </view>
<view class="containertopboxitemleft_tow" <view class="containertopboxitemleft_tow"
:class="{ :class="{
'containertopboxitemleft_tows': item.status != 0, 'containertopboxitemleft_tows': status != 1,
'containertopboxitemleft_nameVip': item.type == 2, 'containertopboxitemleft_nameVip': item.type == 2,
}"> }">
{{ item.type == 2 ? item.detail : '优惠券(元)'}} {{ item.type == 2 ? item.detail : '优惠券(元)'}}
@ -42,8 +42,9 @@
<view class="containertopboxitemright"> <view class="containertopboxitemright">
<view class="containertopboxitemright_one"> <view class="containertopboxitemright_one">
<view class="flex-start"> <view class="flex-start">
<image class="icon" src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/user/coupon_icon.png" mode="aspectFill"> <image class="icon" v-if="item.type == 2 " src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/user/coupon_icon.png" mode="aspectFill">
<text class="title">{{ item.shopName }}</text> <text class="title" v-if="item.type == 2 ">{{ item.shopName }}</text>
<text class="title" v-if="item.type == 1 ">{{ item.name }}</text>
</view> </view>
<text>无门槛使用</text> <text>无门槛使用</text>
</view> </view>
@ -51,13 +52,13 @@
<view> {{ item.type == 2 ? '会员商品券' : '通用红包券'}}</view> <view> {{ item.type == 2 ? '会员商品券' : '通用红包券'}}</view>
<view <view
@click="navigatorGo(item)" @click="navigatorGo(item)"
:class="item.status == 0?'containertopboxitemright_four containertopboxitemright_btn':'containertopboxitemright_fours containertopboxitemright_btn'"> :class="status == 1?'containertopboxitemright_four containertopboxitemright_btn':'containertopboxitemright_fours containertopboxitemright_btn'">
{{item.status == 0 ? '去使用':'已使用'}} {{status == 1 ? '去使用':'已使用'}}
</view> </view>
</view> </view>
<!-- <view class="containertopboxitemright_there"> <view class="containertopboxitemright_there" v-if="item.type == 1 ">
有效期至{{$u.timeFormat(item.endTime, 'yyyy/mm/dd') || '0'}} 有效期至{{$u.timeFormat(item.endTime, 'yyyy/mm/dd') || '0'}}
</view> --> </view>
</view> </view>
</view> </view>
@ -133,11 +134,10 @@
* 去使用优惠券 * 去使用优惠券
*/ */
navigatorGo ( item ) { navigatorGo ( item ) {
if ( item.type == 2 ) { uni.cache.set('shopId',item.shopId)
uni.pro.navigateTo('/pages/order_food/order_food', { uni.pro.navigateTo('/pages/order_food/order_food', {
shopId: item.shopId shopId: item.shopId
}) })
}
}, },
} }
}; };

View File

@ -1,31 +1,31 @@
<template> <template>
<view class="container"> <view class="container">
<view class="me" v-if="status == 'me'"> <view class="me" v-if="is_type == 'me'">
<image class="topImg" mode="widthFix" src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/InviteFriends/index_bg.png"></image> <image class="topImg" mode="widthFix" :src="InviteFriendsData.invitedImg"></image>
<view class="contentBox"> <view class="contentBox">
<view class="content"> <view class="content">
<view class="title">邀请1人可得双方各得10元优惠券</view> <view class="title">{{InviteFriendsData.title}}</view>
<view class="btn">邀请好友</view> <button class="btn" open-type="share" @click="onShareAppMessage">邀请好友</button>
<view class="label o">新用户获得</view> <view class="label o">新用户获得</view>
<view class="card"> <view class="card" v-for="(item,index) in InviteFriendsData.newCoupons">
<view class="left"> <view class="left">
<view class="num"><text></text>10.00</view> <view class="num"><text></text>{{item.discountAmount}}</view>
<view class="mnum">100.00可用</view> <view class="mnum">{{item.fullAmount}}可用</view>
</view> </view>
<view class="right"> <view class="right">
<view class="rtitle">邀新10元优惠券×1</view> <view class="rtitle">{{item.couponName}}</view>
<view class="time">领取后30天内有效</view> <view class="time">{{item.useDetail}}</view>
</view> </view>
</view> </view>
<view class="label t">每邀请1个用户可获得</view> <view class="label t">每邀请{{InviteFriendsData.invitedNum}}个用户可获得</view>
<view class="card"> <view class="card" v-for="(item,index) in InviteFriendsData.rewardCoupons">
<view class="left"> <view class="left">
<view class="num"><text></text>10.00</view> <view class="num"><text></text>{{item.discountAmount}}</view>
<view class="mnum">100.00可用</view> <view class="mnum">{{item.fullAmount}}可用</view>
</view> </view>
<view class="right"> <view class="right">
<view class="rtitle">邀新10元优惠券×1</view> <view class="rtitle">{{item.couponName}}</view>
<view class="time">领取后30天内有效</view> <view class="time">{{item.useDetail}}</view>
</view> </view>
</view> </view>
</view> </view>
@ -38,34 +38,37 @@
>{{item.label}}{{item.num||0}}</view> >{{item.label}}{{item.num||0}}</view>
</view> </view>
<view class="tabContent"> <view class="tabContent">
<viwe class="tabContent_item"> <viwe class="tabContent_item" v-for="(item,index) in shareRecordData.list" :key="index">
<view class="top"> <view class="top">
<view class="name">草莓大福</view> <view class="name">{{item.invitedName}}</view>
<view class="status">草莓大福</view> <view class="status" :style="{color: isSuccess ? '#333' : '#FF534B'}">{{
isSuccess ? '邀请成功' : '未邀请成功'
}}</view>
</view> </view>
<view class="time">2023-22-33 17:33:99</view> <view class="time">{{item.createTime}}</view>
</viwe> </viwe>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
<view class="he" v-else> <view class="he" v-else>
<image class="topImg" mode="widthFix" src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/InviteFriends/draw_bg.png"></image> <image class="topImg" mode="widthFix" :src="InviteFriendsData.beInvitedImg"></image>
<view class="contentBox"> <view class="contentBox">
<view class="content"> <view class="content">
<view class="title">此用户已死勿Call</view> <view class="title">{{userInfo.nickName}}</view>
<view class="label">[邀请你领取新人专享优惠券]</view> <view class="label">[邀请你领取新人专享优惠券]</view>
<view class="card"> <view class="card" v-for="(item,index) in shareOpenData.newCoupons">
<view class="left"> <view class="left">
<view class="num"><text></text>10.00</view> <view class="num"><text></text>{{item.discountAmount}}</view>
<view class="mnum">100.00可用</view> <view class="mnum">{{item.fullAmount}}可用</view>
</view> </view>
<view class="right"> <view class="right">
<view class="rtitle">邀新10元优惠券×1</view> <view class="rtitle">{{item.couponName}}</view>
<view class="time">领取后30天内有效</view> <view class="time">{{item.useDetail}}</view>
</view> </view>
</view> </view>
<view class="btn">领券</view> <view class="btn" v-if="shareOpenData.status == 1" @click="shareReceive">领券</view>
<view class="btn" v-else style="background-color: #999;">领券</view>
</view> </view>
@ -82,39 +85,129 @@
data() { data() {
return { return {
show: false, show: false,
status: "he", is_type: "",
tabList: [ tabList: [
{label: '已邀请', type: 1, num: 0}, {label: '已邀请', type: 1, num: 0},
{label: '无效' ,type: 2, num: 0} {label: '无效' ,type: 2, num: 0}
], ],
tabAcitve: 1, tabAcitve: 1,
userInfo: uni.cache.get('userInfo'),
shopId: null,
shareId: null,
invitedId: null,
InviteFriendsData: null,
shareRecordData: null,
shareOpenData: null,
isSuccess: true,
share: {
title: "",
path: "",
imageUrl: ""
}
}; };
}, },
onLoad(options) { onLoad(options) {
console.log(options)
if ( options.shopId ) { this.shopId = options.shopId; }
if ( options.is_type ) { this.is_type = options.is_type; }
if ( options.shareId ) { this.shareId = options.shareId; }
if ( options.invitedId ) { this.invitedId = options.invitedId; }
this.is_type = 'he'
this.invitedId = "113"
this.shareId = "1"
this.shopId = "11"
if ( this.is_type == 'he') {
this.shareHeOpen()
}
this.getByShopId();
}, },
onShow() { onShow() {
}, },
methods: { methods: {
onShareAppMessage(res) {
if (res.from === 'button') {//
console.log(res.target)
}
return this.share
},
async getByShopId() {
let params = {
shopId : this.shopId
}
let res = await this.api.getByShopId(params)
if ( res.code == 0 ) {
this.InviteFriendsData = res.data;
this.share.title = res.data.title
this.share.path = `/pagesInviteFriends/index/index?shopId=${this.shopId}&is_type=he&shareId=${this.InviteFriendsData.id}&invitedId=${uni.cache.get('userInfo').id}`
this.share.imageUrl = res.data.shareImg
this.shareRecord();
}
},
/**
* 邀请记录
*/
async shareRecord() {
let params = {
shareId : this.InviteFriendsData.id,
invitedId : uni.cache.get('userInfo').id,
shopId : this.shopId,
isSuccess : this.isSuccess,
}
let res = await this.api.shareRecord(params)
if ( res.code == 0 ) {
this.shareRecordData = res.data;
this.tabList[0].num = res.data.isSuccess;
this.tabList[1].num = res.data.isFail;
}
},
/**
* 被邀请人进入页面调用接口
*/
async shareHeOpen() {
let params = {
shareId : this.shareId,
invitedId : this.invitedId,
// beInvitedId : uni.cache.get('userInfo').id,
beInvitedId : 119,
shopId : this.shopId,
}
let res = await this.api.shareHeOpen(params)
if ( res.code == 0 ) {
this.shareOpenData = res.data;
}
},
/**
* 领取优惠券
*/
async shareReceive() {
let params = {
shareId : this.shareId,
invitedId : this.invitedId,
beInvitedId : uni.cache.get('userInfo').id,
shopId : this.shopId,
}
let res = await this.api.shareReceive(params)
if ( res.code == 0 ) {
uni.showToast({
title: "领取成功",
icon: "none",
})
setTimeout(()=>{
uni.pro.redirectTo('/pages/user/coupon', {
type: 1
})
},1000)
}
},
tabClick(item) { tabClick(item) {
this.tabAcitve = item.type; this.tabAcitve = item.type;
}, },
/**
* 解码
* @param {Object} url
* @param {Object} name
*/
getQueryString(url, name) {
var reg = new RegExp('(^|&|/?)' + name + '=([^&|/?]*)(&|/?|$)', 'i')
var r = url.substr(1).match(reg)
if (r != null) {
return r[2]
}
return null;
},
} }
@ -174,10 +267,12 @@
background: #FCF9F4; background: #FCF9F4;
border-radius: 18rpx 18rpx 18rpx 18rpx; border-radius: 18rpx 18rpx 18rpx 18rpx;
border: 2rpx solid #333333; border: 2rpx solid #333333;
margin-bottom: 32rpx;
.left{ .left{
border-right: 1rpx dashed #333; border-right: 1rpx dashed #333;
padding-right: 34rpx; padding-right: 34rpx;
margin-right: 46rpx; margin-right: 46rpx;
flex-shrink: 0;
.num{ .num{
font-weight: 500; font-weight: 500;
font-size: 56rpx; font-size: 56rpx;
@ -216,6 +311,7 @@
background: #FFFFFF; background: #FFFFFF;
border-radius: 18rpx 18rpx 18rpx 18rpx; border-radius: 18rpx 18rpx 18rpx 18rpx;
padding: 32rpx 24rpx 32rpx 24rpx; padding: 32rpx 24rpx 32rpx 24rpx;
margin-top: 32rpx;
.tab{ .tab{
background: #333333; background: #333333;
border-radius: 12rpx 12rpx 12rpx 12rpx; border-radius: 12rpx 12rpx 12rpx 12rpx;

View File

@ -22,7 +22,7 @@
<image class="icon" src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/confirmOrder/table.png" mode="aspectFill"/> <image class="icon" src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/confirmOrder/table.png" mode="aspectFill"/>
<text class="title">桌台</text> <text class="title">桌台</text>
</view> </view>
<view class="value" v-if="tableCode"> {{ shopTableInfo.name }} </view> <view class="value" v-if="tableCode"> {{ shopTableInfo.name || '' }} </view>
<u-icon v-else @click="scan" name="scan" size="60"></u-icon> <u-icon v-else @click="scan" name="scan" size="60"></u-icon>
</view> </view>
<!-- 打包外带 --> <!-- 打包外带 -->
@ -85,7 +85,7 @@
</view> </view>
<view class="favorable_right" ><text class="favorable_right_text"></text> <u-icon name="arrow-right" color="#575B66" size="28"></u-icon></view> <view class="favorable_right" ><text class="favorable_right_text"></text> <u-icon name="arrow-right" color="#575B66" size="28"></u-icon></view>
</view> </view>
<view class="favorable" v-else-if="item.type=='points'"> <view class="favorable" v-else-if="item.type=='points'&&calcUsablePointsData.usable">
<view class="favorable_left"> <view class="favorable_left">
<image class="icon" :src="item.url" mode="aspectFill"/> <image class="icon" :src="item.url" mode="aspectFill"/>
<text class="name"> {{ item.name }} </text> <text class="name"> {{ item.name }} </text>
@ -287,9 +287,9 @@
setPayAmount ( cartLists ) { setPayAmount ( cartLists ) {
console.log(cartLists) console.log(cartLists)
if ( this.amountVIP.isVip == 1 && cartLists.memberAmount > 0 ) { if ( this.amountVIP.isVip == 1 && cartLists.memberAmount > 0 ) {
this.listinfo.payAmount = (cartLists.memberAmount+(this.shopTableInfo.seatNum*this.storeInfo.tableFee)).toFixed(2) this.listinfo.payAmount = (cartLists.memberAmount+(this.shopTableInfo?(this.shopTableInfo.seatNum*this.storeInfo.tableFee):0)).toFixed(2)
} else { } else {
this.listinfo.payAmount = (cartLists.amount+(this.shopTableInfo.seatNum*this.storeInfo.tableFee)).toFixed(2) this.listinfo.payAmount = (cartLists.amount+(this.shopTableInfo?(this.shopTableInfo.seatNum*this.storeInfo.tableFee):0)).toFixed(2)
} }
}, },
/** /**
@ -382,6 +382,14 @@
if (this.tableCode) {params.code = this.tableCode} if (this.tableCode) {params.code = this.tableCode}
if (this.shopId) {params.shopId = this.shopId} if (this.shopId) {params.shopId = this.shopId}
let res = await this.api.productqueryShop(params) let res = await this.api.productqueryShop(params)
if ( res.data.shopTableInfo && !res.data.shopTableInfo.choseCount&&this.orderAMeal) {
this.orderAMeal = false;
uni.pro.navigateTo('/pagesOrder/orderAMeal/index', {
tableCode: this.tableCode,
shopId: res.data.storeInfo.id,
})
return;
}
this.freeDingConfig = res.data.freeDingConfig; this.freeDingConfig = res.data.freeDingConfig;
this.shopTableInfo = res.data.shopTableInfo; this.shopTableInfo = res.data.shopTableInfo;
this.storeInfo = res.data.storeInfo; this.storeInfo = res.data.storeInfo;
@ -438,22 +446,26 @@
return; return;
} }
this.isSocket = true; this.isSocket = true;
this.isPointsChecked = false;
this.listinfoid = msg.data.id this.listinfoid = msg.data.id
this.listinfo.details = msg.data.detailList; this.listinfo.details = msg.data.detailList;
this.setPayAmount(msg.data) this.setPayAmount(msg.data)
uni.$off('getMessage') uni.$off('getMessage')
this.orderorderInfo(1) this.orderorderInfo(1)
this.getCalcUsablePoints()
} }
break; break;
case 'addCart': case 'addCart':
this.isSocket = true; this.isSocket = true;
if ( this.eatModel == "dine-in" && this.tableCode ) { if ( this.eatModel == "dine-in" && this.tableCode ) {
this.isPointsChecked = false;
if (this.listinfoid) { if (this.listinfoid) {
this.orderorderInfo() this.orderorderInfo()
} else { } else {
this.listinfo.details = msg.data; this.listinfo.details = msg.data;
this.setPayAmount(msg) this.setPayAmount(msg)
} }
this.getCalcUsablePoints()
} }
break; break;
@ -466,12 +478,14 @@
}, 1000) }, 1000)
break; break;
case 'addcart': case 'addcart':
this.isPointsChecked = false;
if (this.listinfoid) { if (this.listinfoid) {
this.orderorderInfo() this.orderorderInfo()
} else { } else {
this.listinfo.details = msg.data; this.listinfo.details = msg.data;
this.setPayAmount(msg) this.setPayAmount(msg)
} }
this.getCalcUsablePoints()
this.isSocket = true; this.isSocket = true;
break; break;
} }
@ -618,7 +632,7 @@
"sendType": this.sendType, "sendType": this.sendType,
"remark": this.remark, "remark": this.remark,
} }
if ( this.calcUsablePointsData.pointsNum && this.calcUsablePointsData.pointsNum > 0) { if ( this.isPointsChecked && this.calcUsablePointsData.pointsNum && this.calcUsablePointsData.pointsNum > 0) {
params.pointsNum = this.calcUsablePointsData.pointsNum; params.pointsNum = this.calcUsablePointsData.pointsNum;
} }
let res = await this.api.creatOrder(params) let res = await this.api.creatOrder(params)