Commit 46995013 authored by mqf_0707's avatar mqf_0707

wnf

parent 73fe85be
...@@ -37,7 +37,6 @@ export default function Modal(props) { ...@@ -37,7 +37,6 @@ export default function Modal(props) {
{!hideCloseButton && <View className={closeBtnClass} onTap={onCloseModal} />} {!hideCloseButton && <View className={closeBtnClass} onTap={onCloseModal} />}
{props.children} {props.children}
</View> </View>
</View> </View>
) )
} }
.overlay { .overlay {
.cover(); .cover();
z-index: 21; z-index: 21;
opacity: 0;
background-color: rgba(0, 0, 0, 0.7); background-color: rgba(0, 0, 0, 0.7);
} }
import React, { useState } from 'react'
import { View, Image, ScrollView } from '@tarojs/components'
import Taro, { useShareAppMessage, useDidShow } from '@tarojs/taro'
import classnames from 'classnames'
import styles from './Swiper.module.less'
function Swiper(props) {
return (
<>
</>
)
}
export default Swiper
\ No newline at end of file
import React from 'react' import React from 'react'
import { View, Image } from '@tarojs/components' import { View, Image } from '@tarojs/components'
import './DeliveryModal.less' import styles from './DeliveryModal.module.less'
export default function DeliveryModal(props) { export default function DeliveryModal(props) {
const { prizeItem, task, onClose = () => {} } = props const { prizeItem, task, onClose = () => {} } = props
return ( return (
<View className='logistics-modal-container'> <View className={styles['container']}>
<View <View
className='logistics-modal-container__content' className={styles['content']}
style={prizeItem.shipStatus === 3 style={prizeItem.shipStatus === 3
? `background: url(${task.shipped}) no-repeat;background-size: 100% 100%;` ? `background: url(${task.shipped}) no-repeat;background-size: 100% 100%;`
: `background: url(${task.notShipped}) no-repeat;background-size: 100% 100%;`} : `background: url(${task.notShipped}) no-repeat;background-size: 100% 100%;`}
> >
<View className='logistics-modal-container__close' onTap={onClose} /> <View className={styles['container__close']} onTap={onClose} />
<View className='logistics-modal-container__content-item'> <View className={styles['content-item']}>
<View className='logistics-modal-container__content-left'> <View className={styles['content-left']}>
<Image mode='scaleToFill' src={prizeItem.image} /> <Image mode='scaleToFill' src={prizeItem.image} />
</View> </View>
<View className='logistics-modal-container__content-right'> <View className={styles['content-right']}>
<View className='logistics-modal-container__content-name'>{prizeItem.name}</View> <View className={styles['content-name']}>{prizeItem.name}</View>
<View className='logistics-modal-container__content-copy'> <View className={styles['content-copy']}>
<View className='logistics-modal-container__content-copy__code'>奖品编码:{prizeItem._id}</View> <View className={styles['content-copy__code']}>奖品编码:{prizeItem._id}</View>
<View className='logistics-modal-container__content-copy__img' onTap='copyPrizeId' /> <View className={styles['content-copy__img']} onTap='copyPrizeId' />
</View> </View>
<View className='logistics-modal-container__content-desc'>{prizeItem.shipStatus === 3 ? '发货状态:已发货' : '发货状态:未发货'}</View> <View className={styles['content-desc']}>{prizeItem.shipStatus === 3 ? '发货状态:已发货' : '发货状态:未发货'}</View>
{prizeItem.shipStatus === 2 && <View className='logistics-modal-container__content-desc'>温馨提示:奖品将在活动结束7天内陆续发出</View>} {prizeItem.shipStatus === 2 && <View className={styles['content-desc']}>温馨提示:奖品将在活动结束7天内陆续发出</View>}
{ {
prizeItem.shipStatus !== 2 && prizeItem.shipStatus !== 2 &&
<View className='logistics-modal-container__content-copy'> <View className={styles['content-copy']}>
<View className='logistics-modal-container__content-copy__code'>{'物流单号:' + prizeItem.shipNum}</View> <View className={styles['content-copy__code']}>{'物流单号:' + prizeItem.shipNum}</View>
<View className='logistics-modal-container__content-copy__img' style={`background: url(${task.copyIcon}) no-repeat;background-size: 100% 100%;`} onTap={onClose} /> <View className={styles['content-copy__img']} style={`background: url(${task.copyIcon}) no-repeat;background-size: 100% 100%;`} onTap={onClose} />
</View> </View>
} }
</View> </View>
...@@ -37,4 +37,4 @@ export default function DeliveryModal(props) { ...@@ -37,4 +37,4 @@ export default function DeliveryModal(props) {
</View> </View>
</View> </View>
) )
} }
\ No newline at end of file
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
} }
} }
.logistics-modal-container { .container {
position: fixed; position: fixed;
top: 0; top: 0;
left: 0; left: 0;
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
} }
} }
.logistics-modal-container__content { .content {
width: 646px; width: 646px;
height: 244px; height: 244px;
padding: 0 46px; padding: 0 46px;
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
animation: containerAnimation 0.3s forwards; animation: containerAnimation 0.3s forwards;
} }
.logistics-modal-container__close { .container__close {
position: absolute; position: absolute;
right: -10px; right: -10px;
top: -70px; top: -70px;
...@@ -49,23 +49,23 @@ ...@@ -49,23 +49,23 @@
background-size: 100% 100%; background-size: 100% 100%;
} }
.logistics-modal-container__content-item { .content-item {
border-radius: 10px; border-radius: 10px;
display: flex; display: flex;
} }
.logistics-modal-container__content-left { .content-left {
width: 144px; width: 144px;
height: 144px; height: 144px;
background: rgba(244, 244, 244, 1); background: rgba(244, 244, 244, 1);
} }
.logistics-modal-container__content-left image { .content-left image {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
.logistics-modal-container__content-right { .content-right {
height: 144px; height: 144px;
margin-left: 24px; margin-left: 24px;
display: flex; display: flex;
...@@ -78,30 +78,30 @@ ...@@ -78,30 +78,30 @@
white-space: nowrap; white-space: nowrap;
} }
.logistics-modal-container__content-name { .content-name {
font-size: 28px; font-size: 28px;
color: rgba(51, 51, 51, 1); color: rgba(51, 51, 51, 1);
} }
.logistics-modal-container__content-desc { .content-desc {
font-size: 20px; font-size: 20px;
} }
.logistics-modal-container__content-ids { .content-ids {
margin-bottom: 20px; margin-bottom: 20px;
} }
.logistics-modal-container__content-copy { .content-copy {
display: flex; display: flex;
align-items: center; align-items: center;
height: 30px; height: 30px;
} }
.logistics-modal-container__content-copy__code { .content-copy__code {
font-size: 20px; font-size: 20px;
} }
.logistics-modal-container__content-copy__img { .content-copy__img {
width: 20px; width: 20px;
height: 20px; height: 20px;
background-size: 100% 100%; background-size: 100% 100%;
......
...@@ -6,9 +6,8 @@ import styles from './PrizeModal.module.less' ...@@ -6,9 +6,8 @@ import styles from './PrizeModal.module.less'
import { BENEFIT_TYPE, PRIZE_TYPE } from '@/const' import { BENEFIT_TYPE, PRIZE_TYPE } from '@/const'
import { checkIsMember } from 'tbcc-sdk-ts/lib/utils' import { checkIsMember } from 'tbcc-sdk-ts/lib/utils'
import { commonToast, navigateToOutside } from 'tbcc-sdk-ts/lib/core/tb' import { commonToast, navigateToOutside } from 'tbcc-sdk-ts/lib/core/tb'
import { receiveEnamePrize, receiveObjectPrize, applyActivity } from '@/utils/util' import { receiveEnamePrize, receiveObjectPrize, receiveMemberEname } from '@/utils/util'
import config from '@/config' import config from '@/config'
import API from '@/api'
export default function PrizeModal(props) { export default function PrizeModal(props) {
const { prizeData = {}, onClose = () => {}, } = props const { prizeData = {}, onClose = () => {}, } = props
...@@ -19,6 +18,8 @@ export default function PrizeModal(props) { ...@@ -19,6 +18,8 @@ export default function PrizeModal(props) {
const onRecivePrize = useThrottle(async () => { const onRecivePrize = useThrottle(async () => {
const { activityId } = app const { activityId } = app
const successMsg = '奖品发放成功,请前往我的奖品处进行使用'
const errorMsg = '奖品发放失败,请前往我的奖品处进行处理'
if(type === PRIZE_TYPE.CREDITS || (type === PRIZE_TYPE.ENAME && benefitType === BENEFIT_TYPE.MEMBER)) { if(type === PRIZE_TYPE.CREDITS || (type === PRIZE_TYPE.ENAME && benefitType === BENEFIT_TYPE.MEMBER)) {
const isVip = await checkIsMember() const isVip = await checkIsMember()
if(!isVip) { if(!isVip) {
...@@ -27,43 +28,25 @@ export default function PrizeModal(props) { ...@@ -27,43 +28,25 @@ export default function PrizeModal(props) {
return; return;
} }
} }
if(type === PRIZE_TYPE.ENAME && benefitType === BENEFIT_TYPE.MEMBER) { const receiveFn = {
// receiveMemberEname() [PRIZE_TYPE.ENAME]: async () => {
navigateToOutside(ename) if(benefitType === BENEFIT_TYPE.MEMBER) {
onClose() await receiveMemberEname({params: { sellerId: config.sellerId, ename, id }, successMsg, errorMsg })
return; }else {
} await receiveEnamePrize({params: { activityId, id }, successMsg, errorMsg })
const result = type === PRIZE_TYPE.OBJECT ? (await receiveObjectPrize({ activityId, id })) : (await receiveEnamePrize({ activityId, id })) }
if(result.success && result.status == 1) { },
commonToast('奖品发放成功,请前往我的奖品处进行使用') [PRIZE_TYPE.OBJECT]: async () => {
onClose() await receiveObjectPrize({params: { activityId, id }, successMsg, errorMsg })
}else if(!result.success && result.status == 2) { },
commonToast('奖品发放失败,请前往我的奖品处进行处理') [PRIZE_TYPE.CREDITS]: async () => {
onClose() await receiveEnamePrize({params: { activityId, id }, successMsg, errorMsg })
} }
},2000)
// 领取会员权益
const receiveMemberEname = async () => {
if(!ename) {
onClose()
return;
}
const result = await applyActivity(config.sellerId,ename)
if(result.businessSuccess) {
const { success, data } = await API.updateEnamePrizeReceived({ id })
if(success) {
commonToast('奖品发放成功,请前往我的奖品处进行使用')
onClose()
}else {
commonToast('奖品发放失败,请前往我的奖品处进行处理')
onClose()
} }
}else { await receiveFn[type]()
commonToast('奖品发放失败,请前往我的奖品处进行处理')
onClose() onClose()
} },2000)
} // 入会弹窗
const onAuthSuccess = async() => { const onAuthSuccess = async() => {
setMemberModalVisible(false) setMemberModalVisible(false)
onRecivePrize() onRecivePrize()
......
...@@ -2,23 +2,45 @@ import { View, Image, Text } from '@tarojs/components' ...@@ -2,23 +2,45 @@ import { View, Image, Text } from '@tarojs/components'
import React from 'react' import React from 'react'
import Modal from '@/components/_base/Modal/Modal' import Modal from '@/components/_base/Modal/Modal'
import { useThrottle } from '@/hooks/useThrottle' import { useThrottle } from '@/hooks/useThrottle'
import styles from './PrizeNoModal.module.less' import classnames from 'classnames'
import styles from './ThanksModal.module.less'
export default function PrizeNoModal(props) { const thanksText = {
const { onHandle = () => {}, type = 1 } = props 1: {
title: '很遗憾,未抽中奖品\n再接再厉',
btnTxt: '再抽一次',
icon: '//yun.duiba.com.cn/taobaomini/provideBeauty/close_btn.png',
desc: '奖品可在我的奖品中查看'
},
2: {
title: '很遗憾,未抽中奖品\n再接再厉',
btnTxt: '再抽一次',
icon: '//yun.duiba.com.cn/taobaomini/provideBeauty/close_btn.png',
desc: '奖品可在我的奖品中查看'
}
}
export default function ThanksModal(props) {
const { onHandle = () => {}, type = 1, hasClose = false, hasDesc = false } = props
const getContainerStyle = classnames(styles['thanks-container'],{
[`${styles['thanks-container-02']}`]: type === 2
})
// 标题样式
const getTitleStyle = classnames(styles['thanks-title'],{
[`${styles['thanks-title-02']}`]: type === 2
})
// 按钮样式
const getBtnStyle = classnames(styles['thanks-btn'],{
[`${styles['thanks-btn-02']}`]: type === 2
})
return ( return (
<Modal hideCloseButton={true} top={'50%'}> <Modal hideCloseButton={true} top={'50%'}>
{type === 1 && <View className={styles['prize-container']}> <View className={getContainerStyle}>
<Text className={styles['prize-info']}>{'很遗憾,未抽中奖品\n再接再厉'}</Text> <Text className={getTitleStyle}>{thanksText[type].title}</Text>
<View className={styles['prize-btn']} onClick={()=> onHandle(type)}>再抽一次</View> <View className={getBtnStyle} onClick={()=> onHandle(type)}>{thanksText[type].btnTxt}</View>
<Image className={styles['prize-close']} onClick={()=> onHandle(2)} src={'//yun.duiba.com.cn/taobaomini/provideBeauty/close_btn.png'} /> {hasClose && <Image className={styles['thanks-close']} onClick={()=> onHandle(2)} src={thanksText[type].icon} />}
</View>} {hasDesc && <View className={styles['thanks-desc']}>{thanksText[type].desc}</View>}
{type === 2 && <View className={styles['prize-container-02']}> </View>
<Text className={styles['prize-info-02']}>{'很遗憾,感谢参与\n更多福利活动等着你'}</Text>
<View className={styles['prize-btn-02']} onClick={()=> onHandle(type)}>我知道了</View>
<View className={styles['prize-desc']}>奖品可在我的奖品中查看</View>
</View>}
</Modal> </Modal>
) )
} }
\ No newline at end of file
.prize-container { .thanks-container {
.wh(450px,305px); .wh(450px,305px);
position: relative; position: relative;
.image('//yun.dui88.com/taobaomini/provideBeauty/prize/prize_bg_02.png'); .image('//yun.dui88.com/taobaomini/provideBeauty/prize/prize_bg_02.png');
} }
.thanks-container-02 {
.wh(570px,398px);
position: relative;
.image('//yun.dui88.com/taobaomini/provideBeauty/prize/prize_bg_01.png');
}
.pos-row-center() { .pos-row-center() {
position: absolute; position: absolute;
left: 50%; left: 50%;
transform: translate(-50%,0); transform: translate(-50%,0);
} }
.prize-btn { .thanks-title {
.wh(162px,37px);
.pos-row-center();
bottom: 38px;
background: linear-gradient(0deg, #FFBC6E, #FFDFB4);
border-radius: 18px;
.flex-row-center();
font-size: 31px;
font-family: FZLTHProGlobal;
font-weight: 400;
color: #1C1C1C;
}
.prize-info {
width: 300px; width: 300px;
.pos-row-center(); .pos-row-center();
bottom: 30px; bottom: 30px;
...@@ -31,23 +24,7 @@ ...@@ -31,23 +24,7 @@
color: #1C1C1C; color: #1C1C1C;
text-align: center; text-align: center;
} }
.prize-desc{ .thanks-title-02 {
position: absolute;
left: 160px;
bottom: 55px;
font-size: 20px;
font-family: FZLTHProGlobal;
font-weight: 400;
color: #1C1C1C;
text-align: center;
}
.prize-container-02 {
.wh(570px,398px);
position: relative;
.image('//yun.dui88.com/taobaomini/provideBeauty/prize/prize_bg_01.png');
}
.prize-info-02 {
width: 442px; width: 442px;
position: absolute; position: absolute;
left: 41px; left: 41px;
...@@ -60,7 +37,19 @@ ...@@ -60,7 +37,19 @@
color: #1C1C1C; color: #1C1C1C;
text-align: center; text-align: center;
} }
.prize-btn-02 { .thanks-btn {
.wh(162px,37px);
.pos-row-center();
bottom: 38px;
background: linear-gradient(0deg, #FFBC6E, #FFDFB4);
border-radius: 18px;
.flex-row-center();
font-size: 31px;
font-family: FZLTHProGlobal;
font-weight: 400;
color: #1C1C1C;
}
.thanks-btn-02 {
width: 172px; width: 172px;
height: 36px; height: 36px;
background: #F6F6F6; background: #F6F6F6;
...@@ -75,8 +64,18 @@ ...@@ -75,8 +64,18 @@
.flex-row-center(); .flex-row-center();
margin-right: 30px; margin-right: 30px;
} }
.prize-close { .thanks-close {
.wh(38px,38px); .wh(38px,38px);
.pos-row-center(); .pos-row-center();
bottom: -60px; bottom: -60px;
}
.thanks-desc{
position: absolute;
left: 160px;
bottom: 55px;
font-size: 20px;
font-family: FZLTHProGlobal;
font-weight: 400;
color: #1C1C1C;
text-align: center;
} }
\ No newline at end of file
...@@ -9,7 +9,8 @@ import { checkIsMember } from 'tbcc-sdk-ts/lib/utils' ...@@ -9,7 +9,8 @@ import { checkIsMember } from 'tbcc-sdk-ts/lib/utils'
import { dateFormatter } from '@/utils/date' import { dateFormatter } from '@/utils/date'
import styles from './myPrize.module.less' import styles from './myPrize.module.less'
import { getApp } from '@tarojs/taro' import { getApp } from '@tarojs/taro'
import { applyActivity } from '@/utils/util' import { receiveEnamePrize, receiveObjectPrize, receiveMemberEname } from '@/utils/util'
import config from '@/config'
const { commonToast, getUserAddress, navigateToOutside, setClipboard } = tbccTs.tb const { commonToast, getUserAddress, navigateToOutside, setClipboard } = tbccTs.tb
const { getMyPrizeList } = API const { getMyPrizeList } = API
...@@ -76,118 +77,56 @@ function MyPrizeList() { ...@@ -76,118 +77,56 @@ function MyPrizeList() {
await setClipboard(text) await setClipboard(text)
commonToast('复制成功') commonToast('复制成功')
} }
// 领取会员权益 // 新领取方式
const receiveMemberEname = async (id,ename) => { const handleClick = useThrottle(async (item) => {
if(!ename) { const { activityId } = app
return; const { type, drawStatus, useUrl = '', id, _id, ename = '', benefitType } = item
} // 领取前验证
const result = await applyActivity(config.sellerId,ename) if (drawStatus === DRAW_STATUS.SUCCESS) {
if(result.businessSuccess) { if (type === PRIZE_TYPE.OBJECT && prizeConfig.hasLogistic) {
const { success, data } = await API.updateEnamePrizeReceived({ id }).catch(res => { setCurrentPrize(item)
commonToast(res.message) setDeliveryModalVisible(true)
}) return
if(success) { }
commonToast('领取成功') if (type !== PRIZE_TYPE.OBJECT && useUrl) {
fetchMyPriceList() navigateToOutside(useUrl)
} return
}else {
commonToast(result.errorMsg)
}
}
// 优惠券
async function handleGetEquity(id) {
const { activityId } = app
const result = await API.Fn.receiveEnamePrize({ id, activityId })
if (result) {
commonToast('领取成功')
}
fetchMyPriceList()
}
// 领取实物
async function handleReceiveObjectPrize(id) {
const { activityId } = app
const result = await API.Fn.receiveObjectPrize({ id, activityId })
if (result) {
commonToast('领取成功')
}
fetchMyPriceList()
}
// 积分
async function handleGetCredits(id) {
// 判断是否为会员
const isVip = await checkIsMember()
if (!isVip) {
commonToast('需加入会员才能领取成功哦', 2000, () => { setMemberVisible(true) })
return
}
handleGetEquity(id)
}
// 领取实物前询问
async function handleChooseAddress(id) {
const userAddress = await getUserAddress().catch(err => {
commonToast(err && err.errorMessage)
})
if (!userAddress) return
const { name, telNumber, provinceName, cityName, cityCode, countyName, detailInfo, streetName } = userAddress || {}
const params = {
name,
phone: telNumber,
addressDetail: detailInfo,
cityCode,
city: cityName,
province: provinceName,
area: countyName,
streetName,
id
}
my.confirm({
title: '提示',
content: '确认使用该收货地址:' + name + telNumber + userAddress.duibaAddress.address,
confirmButtonText: '确定',
cancelButtonText: '取消',
success: (result) => {
console.log(result)
const { confirm } = result
if (confirm) {
handleReceiveObjectPrize(params)
} }
} }
}) if (!(drawStatus === DRAW_STATUS.RETRY || drawStatus === DRAW_STATUS.WAITAWARD)) {
}
const handleClick = useThrottle(async(item) => {
const { type, drawStatus, useUrl = '', id, _id, ename = '', benefitType } = item
if (drawStatus === DRAW_STATUS.SUCCESS) {
if (type === PRIZE_TYPE.OBJECT && prizeConfig.hasLogistic) {
setCurrentPrize(item)
setDeliveryModalVisible(true)
return return
} }
if (type !== PRIZE_TYPE.OBJECT && useUrl) { // 执行奖品领取
navigateToOutside(useUrl) const successMsg = '领取成功'
return if(type === PRIZE_TYPE.CREDITS || (type === PRIZE_TYPE.ENAME && benefitType === BENEFIT_TYPE.MEMBER)) {
const isVip = await checkIsMember()
if(!isVip) {
commonToast('需加入会员才能领取成功哦', 2000, () => { setMemberVisible(true) })
return;
}
} }
} const receiveFn = {
if (!(drawStatus === DRAW_STATUS.RETRY || drawStatus === DRAW_STATUS.WAITAWARD)) { [PRIZE_TYPE.ENAME]: async () => {
return if(benefitType === BENEFIT_TYPE.MEMBER) {
} return await receiveMemberEname({params: { sellerId: config.sellerId, ename, id }, successMsg })
}else {
// 领取权益 return await receiveEnamePrize({params: { activityId, id }, successMsg })
const prizeId = id || _id }
if (type === PRIZE_TYPE.ENAME && (benefitType === BENEFIT_TYPE.ENAME || !benefitType)) return handleGetEquity(prizeId) },
// 领取会员 [PRIZE_TYPE.OBJECT]: async () => {
if (type === PRIZE_TYPE.ENAME && benefitType === BENEFIT_TYPE.MEMBER) return receiveMemberEname(prizeId,ename) return await receiveObjectPrize({params: { activityId, id }, successMsg })
// 领取实物 },
if (type === PRIZE_TYPE.OBJECT) return handleChooseAddress(prizeId) [PRIZE_TYPE.CREDITS]: async () => {
// 领取积分 return await receiveEnamePrize({params: { activityId, id }, successMsg })
if (type === PRIZE_TYPE.CREDITS) return handleGetCredits(prizeId) }
}, 2000) }
const result = await receiveFn[type]()
result && fetchMyPriceList()
},2000)
// 入会插件
const onClose = () => { const onClose = () => {
setMemberVisible(false) setMemberVisible(false)
} }
const onAuthSuccess = () => { const onAuthSuccess = () => {
setMemberVisible(false) setMemberVisible(false)
} }
...@@ -251,5 +190,4 @@ function MyPrizeList() { ...@@ -251,5 +190,4 @@ function MyPrizeList() {
</View> </View>
) )
} }
export default MyPrizeList
export default MyPrizeList \ No newline at end of file
...@@ -33,39 +33,95 @@ const confirmAddress = async (address) => { ...@@ -33,39 +33,95 @@ const confirmAddress = async (address) => {
success: (res) => { success: (res) => {
if(res.confirm) { if(res.confirm) {
resolve(true) resolve(true)
}else {
resolve(false)
} }
resolve(false)
}, },
}); });
}) })
} }
export const receiveObjectPrize = async (_params) => { export const receiveObjectPrize = async (data) => {
const { params, successMsg, errorMsg } = data
return new Promise(async (resolve,reject) => { return new Promise(async (resolve,reject) => {
const userInfo = await getUerAddressParam() const userInfo = await getUerAddressParam()
if(!userInfo) resolve({ success: false, status: 3, message: '未领取' }) if(!userInfo) {
resolve(false)
return;
}
const { params: _params, duibaAddress } = userInfo const { params: _params, duibaAddress } = userInfo
const { name, phone } = _params const { name, phone } = _params
const address = name + phone + duibaAddress const address = name + phone + duibaAddress
const canPass = await confirmAddress(address) const canPass = await confirmAddress(address)
if(!canPass) resolve({ success: false, status: 3, message: '未领取' }) if(!canPass) {
const { success, data } = await API.receiveObjectPrize({ ...params, ..._params }) resolve(false)
return;
}
const { success, data, message } = await API.receiveObjectPrize({ ...params, ..._params })
if (success) { if (success) {
resolve({ success: true, status: 1, message: '领取成功'}) commonToast(successMsg)
resolve(true)
}else { }else {
resolve({ success: false, status: 2, message: '领取失败' }) commonToast(errorMsg || message)
resolve(false)
} }
}) })
} }
// 领取权益 // 领取权益
export const receiveEnamePrize = async (params) => { export const receiveEnamePrize = async (data) => {
const { params, successMsg, errorMsg } = data
return new Promise(async (resolve,reject) => { return new Promise(async (resolve,reject) => {
const { success, data } = await API.receiveEnamePrize(params).catch(res => { const { success, data, message } = await API.receiveEnamePrize(params).catch(res => {
resolve({ success: false, status: 2 }) commonToast(successMsg || res.message)
resolve(false)
}); });
if (success) { if (success) {
resolve({ success: true, status: 1 }) commonToast(successMsg)
resolve(true)
}else { }else {
resolve({ success: false, status: 2 }) commonToast(errorMsg || message)
resolve(false)
}
})
}
// 领取会员优惠券
const applyActivity = (sellerId, activityId) => {
const memberBenefitPlugin = requirePlugin("memberBenefit")
if(!memberBenefitPlugin) return false
return new Promise(async (resolve,reject) => {
memberBenefitPlugin.applyActivity({
data: {
sellerId,
activityId,
},
success: (result) => {
resolve(result)
},
fail: (error) => {
console.warn('领取商家权益失败'+JSON.stringify(error.data))
resolve(error.data)
}
});
})
}
export const receiveMemberEname = async(data) => {
const { params, successMsg, errorMsg } = data
const { sellerId, ename, ...ext } = params
if(!ename) return false
return new Promise(async (resolve,reject) => {
const result = await applyActivity(sellerId,ename)
if(!result) resolve(false)
if(result.businessSuccess) {
const { success, data, message } = await API.updateEnamePrizeReceived({ ...ext })
if(success) {
commonToast(successMsg || '奖品发放成功,请前往我的奖品处进行使用')
resolve(true)
}else {
commonToast(errorMsg || message)
resolve(false)
}
}else{
commonToast(result.errorMsg)
resolve(false)
} }
}) })
} }
...@@ -110,26 +166,6 @@ export const getActivity = (sellerId) => { ...@@ -110,26 +166,6 @@ export const getActivity = (sellerId) => {
}); });
}) })
} }
// 领取商家权益
export const applyActivity = (sellerId, activityId) => {
const memberBenefitPlugin = requirePlugin("memberBenefit")
if(!memberBenefitPlugin) return []
return new Promise(async (resolve,reject) => {
memberBenefitPlugin.applyActivity({
data: {
sellerId,
activityId,
},
success: (result) => {
resolve(result)
},
fail: (error) => {
console.warn('领取商家权益失败'+JSON.stringify(error.data))
resolve(error.data)
}
});
})
}
// 查询商家会员等级 // 查询商家会员等级
export const getGrade = (sellerId) => { export const getGrade = (sellerId) => {
const memberBenefitPlugin = requirePlugin("memberBenefit") const memberBenefitPlugin = requirePlugin("memberBenefit")
......
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