分享优惠券更新

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) {
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) {
let item = this.popupadList[e];
if ( item.linkPath ) {
uni.navigateTo({
url: `${item.linkPath}`
uni.pro.navigateTo(item.linkPath, {
shopId: uni.cache.get('shopId'),
is_type: "me",
})
}
},

View File

@ -91,10 +91,6 @@
})
},
memberindex(url) {
// uni.pro.navigateTo("/pagesInviteFriends/index/index", {
// shopId: uni.cache.get('shopId'),
// type: 'index',
// })
uni.pro.navigateTo(url, {
shopId: uni.cache.get('shopId'),
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>
@ -481,6 +481,7 @@
duration: 0
});
if ( this.shopId ) {
this.productqueryShop();
this.productqueryProduct() //list
this.getShopUserInfo() //list
this.handlemessage() //websocket

View File

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

View File

@ -1,31 +1,31 @@
<template>
<view class="container">
<view class="me" v-if="status == 'me'">
<image class="topImg" mode="widthFix" src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/InviteFriends/index_bg.png"></image>
<view class="me" v-if="is_type == 'me'">
<image class="topImg" mode="widthFix" :src="InviteFriendsData.invitedImg"></image>
<view class="contentBox">
<view class="content">
<view class="title">邀请1人可得双方各得10元优惠券</view>
<view class="btn">邀请好友</view>
<view class="title">{{InviteFriendsData.title}}</view>
<button class="btn" open-type="share" @click="onShareAppMessage">邀请好友</button>
<view class="label o">新用户获得</view>
<view class="card">
<view class="card" v-for="(item,index) in InviteFriendsData.newCoupons">
<view class="left">
<view class="num"><text></text>10.00</view>
<view class="mnum">100.00可用</view>
<view class="num"><text></text>{{item.discountAmount}}</view>
<view class="mnum">{{item.fullAmount}}可用</view>
</view>
<view class="right">
<view class="rtitle">邀新10元优惠券×1</view>
<view class="time">领取后30天内有效</view>
<view class="rtitle">{{item.couponName}}</view>
<view class="time">{{item.useDetail}}</view>
</view>
</view>
<view class="label t">每邀请1个用户可获得</view>
<view class="card">
<view class="label t">每邀请{{InviteFriendsData.invitedNum}}个用户可获得</view>
<view class="card" v-for="(item,index) in InviteFriendsData.rewardCoupons">
<view class="left">
<view class="num"><text></text>10.00</view>
<view class="mnum">100.00可用</view>
<view class="num"><text></text>{{item.discountAmount}}</view>
<view class="mnum">{{item.fullAmount}}可用</view>
</view>
<view class="right">
<view class="rtitle">邀新10元优惠券×1</view>
<view class="time">领取后30天内有效</view>
<view class="rtitle">{{item.couponName}}</view>
<view class="time">{{item.useDetail}}</view>
</view>
</view>
</view>
@ -38,34 +38,37 @@
>{{item.label}}{{item.num||0}}</view>
</view>
<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="name">草莓大福</view>
<view class="status">草莓大福</view>
<view class="name">{{item.invitedName}}</view>
<view class="status" :style="{color: isSuccess ? '#333' : '#FF534B'}">{{
isSuccess ? '邀请成功' : '未邀请成功'
}}</view>
</view>
<view class="time">2023-22-33 17:33:99</view>
<view class="time">{{item.createTime}}</view>
</viwe>
</view>
</view>
</view>
</view>
<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="content">
<view class="title">此用户已死勿Call</view>
<view class="title">{{userInfo.nickName}}</view>
<view class="label">[邀请你领取新人专享优惠券]</view>
<view class="card">
<view class="card" v-for="(item,index) in shareOpenData.newCoupons">
<view class="left">
<view class="num"><text></text>10.00</view>
<view class="mnum">100.00可用</view>
<view class="num"><text></text>{{item.discountAmount}}</view>
<view class="mnum">{{item.fullAmount}}可用</view>
</view>
<view class="right">
<view class="rtitle">邀新10元优惠券×1</view>
<view class="time">领取后30天内有效</view>
<view class="rtitle">{{item.couponName}}</view>
<view class="time">{{item.useDetail}}</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>
@ -82,39 +85,129 @@
data() {
return {
show: false,
status: "he",
is_type: "",
tabList: [
{label: '已邀请', type: 1, num: 0},
{label: '无效' ,type: 2, num: 0}
],
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) {
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() {
},
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) {
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;
border-radius: 18rpx 18rpx 18rpx 18rpx;
border: 2rpx solid #333333;
margin-bottom: 32rpx;
.left{
border-right: 1rpx dashed #333;
padding-right: 34rpx;
margin-right: 46rpx;
flex-shrink: 0;
.num{
font-weight: 500;
font-size: 56rpx;
@ -216,6 +311,7 @@
background: #FFFFFF;
border-radius: 18rpx 18rpx 18rpx 18rpx;
padding: 32rpx 24rpx 32rpx 24rpx;
margin-top: 32rpx;
.tab{
background: #333333;
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"/>
<text class="title">桌台</text>
</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>
</view>
<!-- 打包外带 -->
@ -85,7 +85,7 @@
</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 class="favorable" v-else-if="item.type=='points'">
<view class="favorable" v-else-if="item.type=='points'&&calcUsablePointsData.usable">
<view class="favorable_left">
<image class="icon" :src="item.url" mode="aspectFill"/>
<text class="name"> {{ item.name }} </text>
@ -287,9 +287,9 @@
setPayAmount ( cartLists ) {
console.log(cartLists)
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 {
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.shopId) {params.shopId = this.shopId}
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.shopTableInfo = res.data.shopTableInfo;
this.storeInfo = res.data.storeInfo;
@ -438,22 +446,26 @@
return;
}
this.isSocket = true;
this.isPointsChecked = false;
this.listinfoid = msg.data.id
this.listinfo.details = msg.data.detailList;
this.setPayAmount(msg.data)
uni.$off('getMessage')
this.orderorderInfo(1)
this.getCalcUsablePoints()
}
break;
case 'addCart':
this.isSocket = true;
if ( this.eatModel == "dine-in" && this.tableCode ) {
this.isPointsChecked = false;
if (this.listinfoid) {
this.orderorderInfo()
} else {
this.listinfo.details = msg.data;
this.setPayAmount(msg)
}
this.getCalcUsablePoints()
}
break;
@ -466,12 +478,14 @@
}, 1000)
break;
case 'addcart':
this.isPointsChecked = false;
if (this.listinfoid) {
this.orderorderInfo()
} else {
this.listinfo.details = msg.data;
this.setPayAmount(msg)
}
this.getCalcUsablePoints()
this.isSocket = true;
break;
}
@ -618,7 +632,7 @@
"sendType": this.sendType,
"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;
}
let res = await this.api.creatOrder(params)