update @组合商品 一键领取校验 手输判断/授权逻辑

This commit is contained in:
huangzhen 2024-09-05 10:03:20 +08:00
parent 98f7f43cb0
commit 44518c4fea
5 changed files with 162 additions and 25 deletions

View File

@ -93,12 +93,13 @@ html {
display: none; display: none;
} }
/*页面加载*/ // 营销 H5 全局样式
// 页面加载
.pageNoneLoading_Vant { .pageNoneLoading_Vant {
margin-top: 200px; margin-top: 200px;
} }
/*点击遮罩loading*/ // 点击遮罩loading
.overlayLoadBody { .overlayLoadBody {
background-color: rgba(0, 0, 0, 0) !important; background-color: rgba(0, 0, 0, 0) !important;
display: flex; display: flex;
@ -120,4 +121,18 @@ html {
background: #e8eaec !important; background: #e8eaec !important;
} }
// 底部滑出输入框
.inputPopup {
display: flex;
flex-direction: column;
justify-content: space-around;
align-items: center;
.inputModalTitle {
}
.inputModalContent {
margin-bottom: 20px;
}
}

View File

@ -64,14 +64,15 @@
v-model:show="inputModalShow" v-model:show="inputModalShow"
closeable closeable
position="bottom" position="bottom"
:style="{ height: '30%' }" :style="{ height: '40%' }"
class="inputModal" class="inputPopup"
> >
<p class="inputModalTitle">标题</p> <p class="inputModalTitle"> {{ getModalTitle }} </p>
<van-cell-group class="inputModalContent" inset> <van-cell-group class="inputModalContent" inset>
<van-field v-model="inputVal" label="账号" placeholder="请输入手机号或QQ号" /> <van-field v-model="inputVal" label="账号" placeholder="请输入手机号" />
<van-field v-model="inputValAgain" label="再次输入" placeholder="请再次输入" /> <van-field v-model="inputValAgain" label="再次输入" placeholder="请再次输入" />
</van-cell-group> </van-cell-group>
<van-button @click="receiveAll('submit', selectedPro)" type="primary" block>块级元素</van-button>
</van-popup> </van-popup>
</div> </div>
</template> </template>
@ -84,8 +85,18 @@ export default {
props: {}, props: {},
data() { data() {
return { return {
loadingStatus: false, loadingStatus: false, // loading
overlayLoad: false, // loading
isWx: navigator.userAgent.toLowerCase().indexOf('micromessenger') !== -1,
wxAuthUrl: 'https://openapi.1688sup.com/wechat/oauth',
zfbAuthUrl: 'https://openapi.1688sup.com/alipay/oauth',
key: this.$route.query.key || localStorage.getItem("key"), key: this.$route.query.key || localStorage.getItem("key"),
// token: this.$route.query.token || localStorage.getItem("key"),
openid: this.$route.query.openid || localStorage.getItem("openid"), // id
alipayuserid: this.$route.query.alipayuserid || localStorage.getItem("alipayuserid"), // id
detailType: 0, // push type detailType: 0, // push type
showData: ['31', '32', '33', '2', '1'] as Array<any>, // showData: ['31', '32', '33', '2', '1'] as Array<any>, //
pageData: new Map([['31', []], ['32', []], ['33', []], ['2', []], ['1', []]]), pageData: new Map([['31', []], ['32', []], ['33', []], ['2', []], ['1', []]]),
@ -159,7 +170,7 @@ export default {
inputModalShow: false, inputModalShow: false,
inputVal: '', inputVal: '',
inputValAgain: '', inputValAgain: '',
overlayLoad: false, selectedPro: [], // +
orderData: [], // orderData: [], //
} }
}, },
@ -168,6 +179,25 @@ export default {
this.checkRoute(); this.checkRoute();
await this.getData(); await this.getData();
}, },
computed: {
getModalTitle() {
const obj = this.selectedPro[0];
if (this.selectedPro.length === 1) {
return obj.goods.name;
} else {
switch (obj.goods.type) {
case 1:
return "红包";
case 2:
return "直充/卡密";
case 3:
return obj.info.channel === 1 ? "支付宝立减金" : obj.info.channel === 2 ? '微信立减金' : '云闪付立减金';
default:
return ''
}
}
}
},
watch: { watch: {
'$route': { '$route': {
handler: 'checkRoute', handler: 'checkRoute',
@ -191,6 +221,8 @@ export default {
list.push(item); list.push(item);
this.pageData.set(index, list); this.pageData.set(index, list);
}) })
} else {
showToast('商品数据为空');
} }
} }
this.loadingStatus = false; this.loadingStatus = false;
@ -217,26 +249,81 @@ export default {
async receiveAll (type: string, list: any) { async receiveAll (type: string, list: any) {
if (this.detailType && type === 'top') return; if (this.detailType && type === 'top') return;
console.log(`---list-${type}---`, list); console.log(`---list-${type}---`, list);
if (type === 'one') { //
if (type === 'one') { //
let obj = list[0]; let obj = list[0];
if (obj.goods.err_code && obj.goods.reson) { if (obj.goods.err_code) {
return showToast(obj.goods.reson); return showToast(obj.goods.reson || '商品异常');
} }
} }
let ids: any = []; let ids: any = [], modes: any = [];
list.forEach((item: any) => { list.forEach((item: any) => {
if (item.goods.type === 1) { //
const str = item.cash.channel === 3 ? `${item.cash.channel}` : `${item.cash.channel}${item.cash.receive_mode}`;
modes.push(str)
} else if (item.goods.type === 2) { //
const str = item.degital.product_type === 1 ? `${item.degital.product_type}${item.degital.check_sms_code}` : `${item.degital.product_type}${item.degital.card_show}${item.degital.check_sms_code}`;
modes.push(str)
} else if (item.goods.type === 3) { //
const str = item.info.channel === 3 ? `${item.info.channel}` : `${item.info.channel}${item.info.receive_mode}`;
modes.push(str)
}
if (!item.goods.err_code) { if (!item.goods.err_code) {
ids.push(item.goods.id) ids.push(item.goods.id)
} }
}) })
if (new Set(modes).size !== 1) {
return showToast('不同类型或领取方式不支持一键领取');
}
if (!ids.length) { if (!ids.length) {
return showToast('暂无可领取商品'); return showToast('暂无可领取商品');
} }
// + /-/
this.selectedPro = [ ...list ];
let obj = this.selectedPro[0], account = '默认';
const boolHB = obj.goods.type === 1 && (((obj.cash.channel === 1) && (obj.cash.receive_mode === 2)) || (obj.cash.channel === 3));
const boolZC = obj.goods.type === 2 && !((obj.degital.product_type === 2) && (obj.degital.card_show === 2));
const boolLJJ = obj.goods.type === 3 && ((obj.info.channel === 1) && (obj.info.receive_mode === 2) || (obj.info.channel === 3));
if (boolHB || boolZC || boolLJJ) {
if (type !== 'submit') {
return this.inputModalShow = true;
}
if (!this.inputVal) {
return showToast('请输入账号');
} else {
if (!this.inputValAgain) {
return showToast('请再次输入账号');
}
if (this.inputValAgain !== this.inputVal) {
return showToast('两次输入不一致');
}
}
account = this.inputVal;
}
// /-/
if (obj.goods.type === 1) { //
if (obj.cash.channel === 1 && obj.cash.receive_mode === 1) { // -
account = this.alipayuserid;
}
if (this.info.channel === 2) { //
account = this.openid;
}
if (!account) return this.channelJudge(obj.cash.channel, obj.cash.receive_mode);
} else if (obj.goods.type === 3) {
if (obj.info.channel === 1 && obj.info.receive_mode === 1) { // -
account = this.alipayuserid;
}
if (obj.info.channel === 2) { //
account = this.openid;
}
if (!account) return this.channelJudge(obj.info.channel, obj.info.receive_mode);
}
// -
this.overlayLoad = true; this.overlayLoad = true;
const res = await EXCHANGE({ const res = await EXCHANGE({
key: this.key, key: this.key,
id: ids, id: ids,
account: 'account', account: account,
name: 'name', name: 'name',
}); });
if (res && res.code === 200) { if (res && res.code === 200) {
@ -263,6 +350,48 @@ export default {
} }
this.overlayLoad = false; this.overlayLoad = false;
}, },
// - +
channelJudge (channel: number, mode: number) {
// channel 1 2 3
// mode 1 2 1 2 3
if (channel === 1 && mode === 1) { // -
const backLink = encodeURIComponent(`${location.origin}/yxh5/cmsVoucher?key=${localStorage.getItem('key')}&id=${this.$route.query.id}`);
const url = `${this.zfbAuthUrl}?jump=${backLink}`;
//
const ua = navigator.userAgent.toLowerCase();
if (this.isWx || ua.indexOf("baiduboxapp") > -1 || ua.indexOf("firefox") > -1) {
showConfirmDialog({
confirmButtonText: '复制',
message: '请点击[复制]按钮,复制链接到浏览器打开',
})
.then(() => {
this.copyFn(url);
})
.catch(() => {})
} else {
//
location.replace(url);
}
} else if (channel === 2) { //
if (!this.isWx) { //
if (mode === 2) { //
const backLink = encodeURIComponent(`${location.origin}/yxh5/cmsVoucher?key=${localStorage.getItem('key')}&id=${this.$route.query.id}`);
const url = `${this.wxAuthUrl}?jump=${backLink}`;
showConfirmDialog({
confirmButtonText: '复制',
message: '请点击[复制]按钮,复制链接到微信打开',
})
.then(() => {
this.copyFn(url);
})
.catch(() => {})
} else { // +
// todo
location.replace('https://www.baidu.com/')
}
}
}
},
async orderPolling () { async orderPolling () {
const that = this; const that = this;
const res = await ORDER_QUERY({ const res = await ORDER_QUERY({
@ -540,13 +669,4 @@ export default {
} }
} }
} }
.inputModal {
display: flex;
flex-direction: column;
justify-content: space-around;
align-items: center;
.inputModalContent {
margin-bottom: 20px;
}
}
</style> </style>

View File

@ -11,7 +11,7 @@
</div> </div>
<p class="line"/> <p class="line"/>
<img class="defaultInputImg" v-if="!pageData" :src="cssData.defaultInputImg" alt=""> <img class="defaultInputImg" v-if="!pageData" :src="cssData.defaultInputImg" alt="">
<div v-if="!((pageData.degital.product_type === 2) && (pageData.degital.card_show === 2)) || (pageData.degital.check_sms_code === 1)" class="inputBox"> <div v-if="!((pageData.degital.product_type === 2) && (pageData.degital.card_show === 2))" class="inputBox">
<van-cell-group inset> <van-cell-group inset>
<van-field v-model="inputVal" label="账号" placeholder="请输入手机号" /> <van-field v-model="inputVal" label="账号" placeholder="请输入手机号" />
<van-field <van-field

View File

@ -1,7 +1,7 @@
<template> <template>
<van-loading class="pageNoneLoading_Vant" v-if="loadingStatus" size="24px" color="#0094ff" vertical>加载中...</van-loading> <van-loading class="pageNoneLoading_Vant" v-if="loadingStatus" size="24px" color="#0094ff" vertical>加载中...</van-loading>
<div v-else class="cmsListWrapper"> <div v-else class="cmsListWrapper">
<img @click="jumpBanner" class="bannerTop" :src="cssData.bannerTop[0].url" alt=""> <img @click="jumpBanner" class="bannerTop" :src="cssData.bannerTop.length ? cssData.bannerTop[0].url : 'https://lsxdmgoss.oss-cn-chengdu.aliyuncs.com/MarketingSystem/image/front/goodstop.png'" alt="">
<div class="content"> <div class="content">
<div v-if="cssData.contentType === 1" class="carouselBox"> <div v-if="cssData.contentType === 1" class="carouselBox">
<img v-if="!pageData" class="carouselImg" :src="cssData.carouselImg" alt=""> <img v-if="!pageData" class="carouselImg" :src="cssData.carouselImg" alt="">

View File

@ -269,7 +269,7 @@ export default {
account = this.openid; account = this.openid;
} }
// -/ // -/
if (!account ) return this.channelJudge(); if (!account) return this.channelJudge();
this.overlayLoad = true; this.overlayLoad = true;
const res = await EXCHANGE({ const res = await EXCHANGE({
key: this.key, key: this.key,
@ -306,6 +306,7 @@ export default {
.then(() => { .then(() => {
this.copyFn(url); this.copyFn(url);
}) })
.catch(() => {})
} else { } else {
// //
location.replace(url); location.replace(url);
@ -322,6 +323,7 @@ export default {
.then(() => { .then(() => {
this.copyFn(url); this.copyFn(url);
}) })
.catch(() => {})
} else { // + } else { // +
// todo // todo
location.replace('https://www.baidu.com/') location.replace('https://www.baidu.com/')