Commit 46995013 authored by mqf_0707's avatar mqf_0707

wnf

parent 73fe85be
......@@ -37,7 +37,6 @@ export default function Modal(props) {
{!hideCloseButton && <View className={closeBtnClass} onTap={onCloseModal} />}
{props.children}
</View>
</View>
)
}
.overlay {
.cover();
z-index: 21;
opacity: 0;
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 { View, Image } from '@tarojs/components'
import './DeliveryModal.less'
import styles from './DeliveryModal.module.less'
export default function DeliveryModal(props) {
const { prizeItem, task, onClose = () => {} } = props
return (
<View className='logistics-modal-container'>
<View className={styles['container']}>
<View
className='logistics-modal-container__content'
className={styles['content']}
style={prizeItem.shipStatus === 3
? `background: url(${task.shipped}) 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='logistics-modal-container__content-item'>
<View className='logistics-modal-container__content-left'>
<View className={styles['container__close']} onTap={onClose} />
<View className={styles['content-item']}>
<View className={styles['content-left']}>
<Image mode='scaleToFill' src={prizeItem.image} />
</View>
<View className='logistics-modal-container__content-right'>
<View className='logistics-modal-container__content-name'>{prizeItem.name}</View>
<View className='logistics-modal-container__content-copy'>
<View className='logistics-modal-container__content-copy__code'>奖品编码:{prizeItem._id}</View>
<View className='logistics-modal-container__content-copy__img' onTap='copyPrizeId' />
<View className={styles['content-right']}>
<View className={styles['content-name']}>{prizeItem.name}</View>
<View className={styles['content-copy']}>
<View className={styles['content-copy__code']}>奖品编码:{prizeItem._id}</View>
<View className={styles['content-copy__img']} onTap='copyPrizeId' />
</View>
<View className='logistics-modal-container__content-desc'>{prizeItem.shipStatus === 3 ? '发货状态:已发货' : '发货状态:未发货'}</View>
{prizeItem.shipStatus === 2 && <View className='logistics-modal-container__content-desc'>温馨提示:奖品将在活动结束7天内陆续发出</View>}
<View className={styles['content-desc']}>{prizeItem.shipStatus === 3 ? '发货状态:已发货' : '发货状态:未发货'}</View>
{prizeItem.shipStatus === 2 && <View className={styles['content-desc']}>温馨提示:奖品将在活动结束7天内陆续发出</View>}
{
prizeItem.shipStatus !== 2 &&
<View className='logistics-modal-container__content-copy'>
<View className='logistics-modal-container__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']}>
<View className={styles['content-copy__code']}>{'物流单号:' + prizeItem.shipNum}</View>
<View className={styles['content-copy__img']} style={`background: url(${task.copyIcon}) no-repeat;background-size: 100% 100%;`} onTap={onClose} />
</View>
}
</View>
......@@ -37,4 +37,4 @@ export default function DeliveryModal(props) {
</View>
</View>
)
}
}
\ No newline at end of file
......@@ -4,7 +4,7 @@
}
}
.logistics-modal-container {
.container {
position: fixed;
top: 0;
left: 0;
......@@ -22,7 +22,7 @@
}
}
.logistics-modal-container__content {
.content {
width: 646px;
height: 244px;
padding: 0 46px;
......@@ -38,7 +38,7 @@
animation: containerAnimation 0.3s forwards;
}
.logistics-modal-container__close {
.container__close {
position: absolute;
right: -10px;
top: -70px;
......@@ -49,23 +49,23 @@
background-size: 100% 100%;
}
.logistics-modal-container__content-item {
.content-item {
border-radius: 10px;
display: flex;
}
.logistics-modal-container__content-left {
.content-left {
width: 144px;
height: 144px;
background: rgba(244, 244, 244, 1);
}
.logistics-modal-container__content-left image {
.content-left image {
width: 100%;
height: 100%;
}
.logistics-modal-container__content-right {
.content-right {
height: 144px;
margin-left: 24px;
display: flex;
......@@ -78,30 +78,30 @@
white-space: nowrap;
}
.logistics-modal-container__content-name {
.content-name {
font-size: 28px;
color: rgba(51, 51, 51, 1);
}
.logistics-modal-container__content-desc {
.content-desc {
font-size: 20px;
}
.logistics-modal-container__content-ids {
.content-ids {
margin-bottom: 20px;
}
.logistics-modal-container__content-copy {
.content-copy {
display: flex;
align-items: center;
height: 30px;
}
.logistics-modal-container__content-copy__code {
.content-copy__code {
font-size: 20px;
}
.logistics-modal-container__content-copy__img {
.content-copy__img {
width: 20px;
height: 20px;
background-size: 100% 100%;
......
......@@ -6,9 +6,8 @@ import styles from './PrizeModal.module.less'
import { BENEFIT_TYPE, PRIZE_TYPE } from '@/const'
import { checkIsMember } from 'tbcc-sdk-ts/lib/utils'
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 API from '@/api'
export default function PrizeModal(props) {
const { prizeData = {}, onClose = () => {}, } = props
......@@ -19,6 +18,8 @@ export default function PrizeModal(props) {
const onRecivePrize = useThrottle(async () => {
const { activityId } = app
const successMsg = '奖品发放成功,请前往我的奖品处进行使用'
const errorMsg = '奖品发放失败,请前往我的奖品处进行处理'
if(type === PRIZE_TYPE.CREDITS || (type === PRIZE_TYPE.ENAME && benefitType === BENEFIT_TYPE.MEMBER)) {
const isVip = await checkIsMember()
if(!isVip) {
......@@ -27,43 +28,25 @@ export default function PrizeModal(props) {
return;
}
}
if(type === PRIZE_TYPE.ENAME && benefitType === BENEFIT_TYPE.MEMBER) {
// receiveMemberEname()
navigateToOutside(ename)
onClose()
return;
}
const result = type === PRIZE_TYPE.OBJECT ? (await receiveObjectPrize({ activityId, id })) : (await receiveEnamePrize({ activityId, id }))
if(result.success && result.status == 1) {
commonToast('奖品发放成功,请前往我的奖品处进行使用')
onClose()
}else if(!result.success && result.status == 2) {
commonToast('奖品发放失败,请前往我的奖品处进行处理')
onClose()
}
},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()
const receiveFn = {
[PRIZE_TYPE.ENAME]: async () => {
if(benefitType === BENEFIT_TYPE.MEMBER) {
await receiveMemberEname({params: { sellerId: config.sellerId, ename, id }, successMsg, errorMsg })
}else {
await receiveEnamePrize({params: { activityId, id }, successMsg, errorMsg })
}
},
[PRIZE_TYPE.OBJECT]: async () => {
await receiveObjectPrize({params: { activityId, id }, successMsg, errorMsg })
},
[PRIZE_TYPE.CREDITS]: async () => {
await receiveEnamePrize({params: { activityId, id }, successMsg, errorMsg })
}
}
}else {
commonToast('奖品发放失败,请前往我的奖品处进行处理')
await receiveFn[type]()
onClose()
}
}
},2000)
// 入会弹窗
const onAuthSuccess = async() => {
setMemberModalVisible(false)
onRecivePrize()
......
......@@ -2,23 +2,45 @@ import { View, Image, Text } from '@tarojs/components'
import React from 'react'
import Modal from '@/components/_base/Modal/Modal'
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 { onHandle = () => {}, type = 1 } = props
const thanksText = {
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 (
<Modal hideCloseButton={true} top={'50%'}>
{type === 1 && <View className={styles['prize-container']}>
<Text className={styles['prize-info']}>{'很遗憾,未抽中奖品\n再接再厉'}</Text>
<View className={styles['prize-btn']} onClick={()=> onHandle(type)}>再抽一次</View>
<Image className={styles['prize-close']} onClick={()=> onHandle(2)} src={'//yun.duiba.com.cn/taobaomini/provideBeauty/close_btn.png'} />
</View>}
{type === 2 && <View className={styles['prize-container-02']}>
<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>}
<View className={getContainerStyle}>
<Text className={getTitleStyle}>{thanksText[type].title}</Text>
<View className={getBtnStyle} onClick={()=> onHandle(type)}>{thanksText[type].btnTxt}</View>
{hasClose && <Image className={styles['thanks-close']} onClick={()=> onHandle(2)} src={thanksText[type].icon} />}
{hasDesc && <View className={styles['thanks-desc']}>{thanksText[type].desc}</View>}
</View>
</Modal>
)
}
\ No newline at end of file
.prize-container {
.thanks-container {
.wh(450px,305px);
position: relative;
.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() {
position: absolute;
left: 50%;
transform: translate(-50%,0);
}
.prize-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;
}
.prize-info {
.thanks-title {
width: 300px;
.pos-row-center();
bottom: 30px;
......@@ -31,23 +24,7 @@
color: #1C1C1C;
text-align: center;
}
.prize-desc{
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 {
.thanks-title-02 {
width: 442px;
position: absolute;
left: 41px;
......@@ -60,7 +37,19 @@
color: #1C1C1C;
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;
height: 36px;
background: #F6F6F6;
......@@ -75,8 +64,18 @@
.flex-row-center();
margin-right: 30px;
}
.prize-close {
.thanks-close {
.wh(38px,38px);
.pos-row-center();
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'
import { dateFormatter } from '@/utils/date'
import styles from './myPrize.module.less'
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 { getMyPrizeList } = API
......@@ -76,118 +77,56 @@ function MyPrizeList() {
await setClipboard(text)
commonToast('复制成功')
}
// 领取会员权益
const receiveMemberEname = async (id,ename) => {
if(!ename) {
return;
}
const result = await applyActivity(config.sellerId,ename)
if(result.businessSuccess) {
const { success, data } = await API.updateEnamePrizeReceived({ id }).catch(res => {
commonToast(res.message)
})
if(success) {
commonToast('领取成功')
fetchMyPriceList()
}
}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)
// 新领取方式
const handleClick = useThrottle(async (item) => {
const { activityId } = app
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
}
if (type !== PRIZE_TYPE.OBJECT && useUrl) {
navigateToOutside(useUrl)
return
}
}
})
}
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)
if (!(drawStatus === DRAW_STATUS.RETRY || drawStatus === DRAW_STATUS.WAITAWARD)) {
return
}
if (type !== PRIZE_TYPE.OBJECT && useUrl) {
navigateToOutside(useUrl)
return
// 执行奖品领取
const successMsg = '领取成功'
if(type === PRIZE_TYPE.CREDITS || (type === PRIZE_TYPE.ENAME && benefitType === BENEFIT_TYPE.MEMBER)) {
const isVip = await checkIsMember()
if(!isVip) {
commonToast('需加入会员才能领取成功哦', 2000, () => { setMemberVisible(true) })
return;
}
}
}
if (!(drawStatus === DRAW_STATUS.RETRY || drawStatus === DRAW_STATUS.WAITAWARD)) {
return
}
// 领取权益
const prizeId = id || _id
if (type === PRIZE_TYPE.ENAME && (benefitType === BENEFIT_TYPE.ENAME || !benefitType)) return handleGetEquity(prizeId)
// 领取会员
if (type === PRIZE_TYPE.ENAME && benefitType === BENEFIT_TYPE.MEMBER) return receiveMemberEname(prizeId,ename)
// 领取实物
if (type === PRIZE_TYPE.OBJECT) return handleChooseAddress(prizeId)
// 领取积分
if (type === PRIZE_TYPE.CREDITS) return handleGetCredits(prizeId)
}, 2000)
const receiveFn = {
[PRIZE_TYPE.ENAME]: async () => {
if(benefitType === BENEFIT_TYPE.MEMBER) {
return await receiveMemberEname({params: { sellerId: config.sellerId, ename, id }, successMsg })
}else {
return await receiveEnamePrize({params: { activityId, id }, successMsg })
}
},
[PRIZE_TYPE.OBJECT]: async () => {
return await receiveObjectPrize({params: { activityId, id }, successMsg })
},
[PRIZE_TYPE.CREDITS]: async () => {
return await receiveEnamePrize({params: { activityId, id }, successMsg })
}
}
const result = await receiveFn[type]()
result && fetchMyPriceList()
},2000)
// 入会插件
const onClose = () => {
setMemberVisible(false)
}
const onAuthSuccess = () => {
setMemberVisible(false)
}
......@@ -251,5 +190,4 @@ function MyPrizeList() {
</View>
)
}
export default MyPrizeList
export default MyPrizeList
\ No newline at end of file
......@@ -33,39 +33,95 @@ const confirmAddress = async (address) => {
success: (res) => {
if(res.confirm) {
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) => {
const userInfo = await getUerAddressParam()
if(!userInfo) resolve({ success: false, status: 3, message: '未领取' })
if(!userInfo) {
resolve(false)
return;
}
const { params: _params, duibaAddress } = userInfo
const { name, phone } = _params
const address = name + phone + duibaAddress
const canPass = await confirmAddress(address)
if(!canPass) resolve({ success: false, status: 3, message: '未领取' })
const { success, data } = await API.receiveObjectPrize({ ...params, ..._params })
if(!canPass) {
resolve(false)
return;
}
const { success, data, message } = await API.receiveObjectPrize({ ...params, ..._params })
if (success) {
resolve({ success: true, status: 1, message: '领取成功'})
commonToast(successMsg)
resolve(true)
}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) => {
const { success, data } = await API.receiveEnamePrize(params).catch(res => {
resolve({ success: false, status: 2 })
const { success, data, message } = await API.receiveEnamePrize(params).catch(res => {
commonToast(successMsg || res.message)
resolve(false)
});
if (success) {
resolve({ success: true, status: 1 })
commonToast(successMsg)
resolve(true)
}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) => {
});
})
}
// 领取商家权益
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) => {
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