Commit 940d97d2 authored by 王能飞's avatar 王能飞

Merge branch 'c_client_taro-pack' into 'c_client_taro'

集合页任务优化

See merge request !45
parents c18c539a 66cb3c56
......@@ -441,9 +441,9 @@
"optional": true
},
"@types/node": {
"version": "14.17.15",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.15.tgz",
"integrity": "sha512-D1sdW0EcSCmNdLKBGMYb38YsHUS6JcM7yQ6sLQ9KuZ35ck7LYCKE7kYFHOO59ayFOY3zobWVZxf4KXhYHcHYFA==",
"version": "14.17.16",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.16.tgz",
"integrity": "sha512-WiFf2izl01P1CpeY8WqFAeKWwByMueBEkND38EcN8N68qb0aDG3oIS1P5MhAX5kUdr469qRyqsY/MjanLjsFbQ==",
"optional": true
},
"@types/prop-types": {
......@@ -5345,9 +5345,9 @@
}
},
"tbcc-sdk-ts": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/tbcc-sdk-ts/-/tbcc-sdk-ts-1.0.10.tgz",
"integrity": "sha512-z+6/SVclywLnlbIqndPzUDFuVj1NEbojFm9vQAqx1hiXvpJbBcf5Ioo9J7k0rjymXgk0+at+QsnjhwuWEq3o/g==",
"version": "1.0.13",
"resolved": "https://registry.npmjs.org/tbcc-sdk-ts/-/tbcc-sdk-ts-1.0.13.tgz",
"integrity": "sha512-dupA8ug1zz1/tfVw2ifOoNBlI6te9EXbtSHlsxycNDQxrykCSMP8objFujLeWUajrqNXbUoJlmV2JqbwU626mQ==",
"requires": {
"@types/lodash": "^4.14.160",
"@types/node": "^14.6.0",
......
......@@ -51,7 +51,7 @@
"react": "^17.0.0",
"react-dom": "^17.0.0",
"taro-ui": "^3.0.0-alpha.3",
"tbcc-sdk-ts": "^1.0.10"
"tbcc-sdk-ts": "^1.0.13"
},
"devDependencies": {
"@babel/core": "^7.8.0",
......
......@@ -19,6 +19,7 @@ class App extends Component {
app.cloud = cloud
app.tornadoAPI = tornadoAPI
app.activityId = activityId || defaultActivityId
app.isOnlineAct = !!activityId
}
// 页面后台切前台
componentDidShow () {}
......
import { View } from '@tarojs/components'
import React from 'react'
import { useEffect, useState } from 'react'
import styles from './ContainerFit.module.less'
import { getSystemInfo } from 'tbcc-sdk-ts/lib/core/tb'
export default function ContainerFit(props) {
const { bg = '', hasFitPsd = false } = props
const { bg = '', hasFitPsd = false, fullScreenFit = false } = props
const [ system, setSystem ] = useState(false)
const [statusBarHeight, setStatusBarHeight ] = useState(24)
useEffect(() => {
fullScreenFit && getSystemInfo().then(res => {
const { system, statusBarHeight } = res
setSystem(system)
setStatusBarHeight(statusBarHeight)
})
}, [])
const FitContainerStyle = (flag) => {
return flag ? {
background: `url(${bg}) no-repeat`,
backgroundSize: '100% 100%',
paddingTop: (system === 'iOS' && fullScreenFit) && (statusBarHeight / 100 + 'rem')
} : {}
}
return (
<View className={styles['page-container']}>
<View className={styles['page-psd-container']} style={{ background: `url(${bg}) no-repeat`, backgroundSize: '7.5rem 16.24rem' }}>
{!hasFitPsd && <View className={styles['page-content']}>
<View className={styles['page-container']} style={FitContainerStyle(!hasFitPsd)}>
{hasFitPsd && <View className={styles['page-psd-container']} style={FitContainerStyle(hasFitPsd)}>
{props.children}
</View>}
{hasFitPsd && props.children}
</View>
</View>}
{!hasFitPsd && props.children}
</View>
)
}
\ No newline at end of file
......@@ -6,6 +6,7 @@
width: 100vw;
height: 100vh;
min-height: 100vh;
box-sizing: border-box;
overflow: hidden;
}
.page-psd-container {
......@@ -16,13 +17,4 @@
right: 0;
top: 50%;
transform: translate(0,-50%);
}
.page-content {
position: absolute;
width: 100vw;
height: 100vh;
left: 0;
right: 0;
top: 50%;
transform: translate(0,-50%);
}
\ No newline at end of file
......@@ -3,10 +3,16 @@ import { View, Image, ScrollView } from '@tarojs/components'
import classnames from 'classnames'
import styles from './TitleImg.module.less'
const posConfig = {
bottom: 'flex-end',
top: 'flex-start',
center: 'center'
}
function TitleImg(props) {
const { config } = props
const { config, position = 'center' } = props
return (
<View className={styles['title-box']}>
<View className={styles['title-box']} style={{ alignItems: posConfig[position] }}>
<Image src={config.image} mode="widthFix" style={{width: config.width / 100 + 'rem', height: config.height / 100 + 'rem' }} />
</View>
)
......
......@@ -24,7 +24,7 @@ export default function DeliveryModal(props) {
<View className={styles['content-copy__img']} onTap='copyPrizeId' />
</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={styles['content-desc']}>{task.shipDesc}</View>}
{
prizeItem.shipStatus !== 2 &&
<View className={styles['content-copy']}>
......
......@@ -7,7 +7,7 @@ import API from '@/api'
import { useLoginInfoModel, useActivityInfoModel } from '@/store'
import { checkIsMember } from 'tbcc-sdk-ts/lib/utils'
import { showToast } from '@tarojs/taro'
import { HELP_MODAL_TYPE, HELP_CONFIG } from '@/config/help.config'
import { HELP_MODAL_TYPE, HELP_CONFIG, RECEIVE_REWARD } from '@/config/help.config'
export default function DoHelpModal(props) {
const { activityInfo } = useActivityInfoModel()
......@@ -59,10 +59,10 @@ export default function DoHelpModal(props) {
},
[HELP_MODAL_TYPE.FAIL]: async () => onClose(type),
[HELP_MODAL_TYPE.REWARDS]: async () => {
const { success, data } = await API.receiveTask({ key: HELP_CONFIG.KEY })
if(success && data) {
onClose(type)
if(RECEIVE_REWARD) {
await API.receiveTask({ key: HELP_CONFIG.KEY, taskType: HELP_MODAL_TYPE.KEY })
}
onClose && onClose(type)
}
}
helpFn[type]()
......
......@@ -9,6 +9,8 @@ export const HELP_MODAL_SHOW = {
SHOW: 1, // 已弹
NOT_SHOW: 2, // 未弹
}
// 助力弹窗是否已弹
export const RECEIVE_REWARD = true // true | 直接领取 false | 任务弹窗领取
// 助力配置
export const HELP_CONFIG = {
KEY: 'invite',
......
......@@ -61,6 +61,7 @@ export const PRIZE_CONFIG = {
},
contentTop: '208rpx',
blankTxt: '暂无奖品',
shipDesc: '温馨提示:奖品将在活动结束7天内陆续发出',
hasLogistic: false, // 是否展示物流信息
isShowPirzeId: false, // 是否显示奖品编号
hasGoodPrize: false, // 是否含有专属商品
......
......@@ -37,7 +37,8 @@ export const TASK_CONFIG = {
collect: '//yun.duiba.com.cn/baicaoweiFarmer/orderGoods.png',
sign: '//yun.duiba.com.cn/baicaoweiFarmer/orderGoods.png',
exchange: '//yun.duiba.com.cn/baicaoweiFarmer/orderGoods.png',
share: '//yun.duiba.com.cn/baicaoweiFarmer/orderGoods.png'
share: '//yun.duiba.com.cn/baicaoweiFarmer/orderGoods.png',
addCart: '//yun.duiba.com.cn/baicaoweiFarmer/orderGoods.png'
},
commonTxt: {
1: '去完成',
......
......@@ -3,7 +3,7 @@ import { checkIsMember } from 'tbcc-sdk-ts/lib/utils'
import { showToast } from '@tarojs/taro'
import API from '@/api'
import {receiveEnamePrize, receiveMemberEname, receiveObjectPrize } from 'tbcc-sdk-ts/lib/request/capiFn'
import { PRIZE_TYPE, BENEFIT_TYPE } from '@/config/myPrize.config'
import { PRIZE_TYPE, BENEFIT_TYPE, DRAW_STATUS } from '@/config/myPrize.config'
import config from '@/config/config'
const useReceive = (props) => {
......@@ -23,16 +23,16 @@ const useReceive = (props) => {
const receiveFn = {
[PRIZE_TYPE.ENAME]: async () => {
if(benefitType === BENEFIT_TYPE.MEMBER) {
await receiveMemberEname(API.receiveMemberEname,{params: { sellerId: config.sellerId, ename, id }, successMsg, errorMsg })
await receiveMemberEname(API.receiveMemberEname,{params: { sellerId: config.sellerId, ename, id, status: DRAW_STATUS.SUCCESS }, successMsg, errorMsg })
}else {
await receiveEnamePrize(API.receiveEnamePrize, {params: { activityId, id }, successMsg, errorMsg })
await receiveEnamePrize(API.receiveEnamePrize, {params: { id }, successMsg, errorMsg })
}
},
[PRIZE_TYPE.OBJECT]: async () => {
await receiveObjectPrize(API.receiveObjectPrize, {params: { activityId, id }, successMsg, errorMsg })
await receiveObjectPrize(API.receiveObjectPrize, {params: { id }, successMsg, errorMsg })
},
[PRIZE_TYPE.CREDITS]: async () => {
await receiveEnamePrize(API.receiveEnamePrize, {params: { activityId, id }, successMsg, errorMsg })
await receiveEnamePrize(API.receiveEnamePrize, {params: { id }, successMsg, errorMsg })
}
}
await receiveFn[type]()
......
......@@ -79,7 +79,7 @@ export function useTasks(props) {
})
// 完成任务处理
const completeTask = async(item, callbackFn = () => {}) => {
const { key, url, itemIds, keepTime } = item
const { key, url, itemIds, keepTime, todayCompleteTimes, rateType, times, completeTimes } = item
setCurrentTaskType(key)
const completeFn = {
member: async () => {
......@@ -131,11 +131,13 @@ export function useTasks(props) {
},
collect: async() => {
app.isFlashTask = true
navigateTo(`/pages/packageGood/collectGoods/collectGoods?itemIds=${itemIds}`)
const _itm = { itemIds, todayCompleteTimes, rateType, times, completeTimes }
navigateTo(`/pages/packageGood/collectGoods/collectGoods?item=${JSON.stringify(_itm)}`)
},
addCart: async() => {
app.isFlashTask = true
navigateTo(`/pages/packageGood/cartGoods/cartGoods?itemIds=${itemIds}`)
const _itm = { itemIds, todayCompleteTimes, rateType, times, completeTimes }
navigateTo(`/pages/packageGood/cartGoods/cartGoods?item=${JSON.stringify(_itm)}`)
},
sign: () => doCompleteTaskHandle(key),
share: () => {
......
......@@ -63,6 +63,7 @@ function Index() {
setActivityInfoAndStatus({
startTime, endTime, rule
})
// 判断活动未开始 且 app.isOnlineAct = false
}
}
// 获取用户信息
......
......@@ -113,9 +113,9 @@ function BrowseGoodsPage() {
}, 1000)
}
return (
<ContainerFit bg={BROWSE_CONFIG.bg}>
<ContainerFit bg={BROWSE_CONFIG.bg} fullScreenFit>
<View className={styles['page-content__title']}>
<GoodsTitle config={BROWSE_CONFIG.head}/>
<GoodsTitle config={BROWSE_CONFIG.head} position={'bottom'} />
</View>
<View className={styles['page-content__list']}>
<GoodsList goodsList={goodsList} task={BROWSE_CONFIG} onOpenDetail={(itemId,collected) => onOpenDetail(itemId,collected)} />
......
......@@ -9,6 +9,7 @@ import API from '@/api'
import { useThrottle } from '@/hooks/useThrottle'
import styles from './cartGoods.module.less'
import { CART_CONFIG, CART_TYPE } from '@/config/cart.config'
import { TASK_RATE_TYPE } from '@/config/task.config'
import { GOOD_LIST } from '@/mock'
const { showSkuModal } = tbccTs.tb
......@@ -16,10 +17,10 @@ const { showSkuModal } = tbccTs.tb
function CartGoodsPage() {
const router = useRouter()
const [goodsList, setGoodsList] = useState([])
const { itemIds } = router?.params
// 收藏状态
const collectflag = useRef(false)
const { item } = router?.params
const { itemIds, todayCompleteTimes = 0, rateType, times, completeTimes = 0 } = JSON.parse(item)
// 加购状态
const collectFlag = useRef(rateType === TASK_RATE_TYPE.EVERYDAY? +todayCompleteTimes : +completeTimes)
useEffect(() => {
getGoodsList()
}, [])
......@@ -30,29 +31,29 @@ function CartGoodsPage() {
}
// 加入购物车 // 对应itemId为 574141925233 skuId为4018047819826 数量为4
const onCompleteTask = useThrottle(async (itemId, collected) => {
console.log(itemId)
if (collected && CART_CONFIG.type === CART_TYPE.ONE) {
showToast({ title: '您已加购过该商品了'})
return;
}
if(collectflag.current && CART_CONFIG.type === CART_TYPE.ONE) {
if(rateType !== TASK_RATE_TYPE.FOREVER && collectFlag.current >= times && CART_TYPE.ONE) {
showToast({ title: '该任务今天已完成,明天再来吧~'})
return;
}
const { status, quantity } = await showSkuModal(String(itemId))
if (status == "addCartSuccess") {
const { success } = await API.completeTask({ key: CART_CONFIG.taskType, taskType: CART_CONFIG.taskType, itemId, count: quantity })
if (success) {
collectflag.current = true
collectflag.current += 1
getGoodsList()
showToast({ title: '加购成功'})
// showToast({ title: '加购成功'})
}
}
}, 2000);
return (
<ContainerFit bg={CART_CONFIG.bg}>
<ContainerFit bg={CART_CONFIG.bg} fullScreenFit>
<View className={styles['page-content__title']}>
<TitleImg config={CART_CONFIG.head}/>
<TitleImg config={CART_CONFIG.head} position={'bottom'} />
</View>
<View className={styles['page-content__list']}>
<GoodsList goodsList={goodsList} task={CART_CONFIG} onCompleteTask={(itemId,collected) => onCompleteTask(itemId,collected)} />
......
......@@ -7,22 +7,23 @@ import { useRouter, showToast } from '@tarojs/taro'
import tbccTs from 'tbcc-sdk-ts'
import API from '@/api'
import { useThrottle } from '@/hooks/useThrottle'
const { checkGoodsCollectedStatus, collectGoods } = tbccTs.tb
const { checkGoodsCollectedStatus, collectGoods, getSystemInfo } = tbccTs.tb
import styles from './collectGoods.module.less'
import COLLECT_CONFIG from '@/config/collect.config'
import { TASK_RATE_TYPE } from '@/config/task.config'
import { GOOD_LIST } from '@/mock'
function CollectGoodsPage() {
const router = useRouter()
const [goodsList, setGoodsList] = useState([])
const { itemIds } = router?.params
// 收藏状态
const collectFlag = useRef(false)
const [goodsList, setGoodsList] = useState(GOOD_LIST)
const { item } = router?.params
const { itemIds, todayCompleteTimes = 0, rateType, times, completeTimes = 0 } = JSON.parse(item)
// 加购状态
const collectFlag = useRef(rateType === TASK_RATE_TYPE.EVERYDAY? +todayCompleteTimes : +completeTimes)
useEffect(() => {
getGoodsList()
}, [])
const getGoodsList = async () => {
const { data } = await API.getCollectGoods({ key: COLLECT_CONFIG.taskType, itemIds, taskType: COLLECT_CONFIG.taskType })
data?.list && setGoodsList(data?.list || [])
......@@ -32,13 +33,13 @@ function CollectGoodsPage() {
const collectFn = async () => {
const { success } = await API.completeTask({ key: COLLECT_CONFIG.taskType, itemId, taskType: COLLECT_CONFIG.taskType })
if (success) {
collectFlag.current = true
collectFlag.current += 1
getGoodsList()
showToast({ title: '收藏成功'})
}
}
// 今日是否已收藏过
if(collectFlag.current) {
if(rateType !== TASK_RATE_TYPE.FOREVER && collectFlag.current >= times) {
showToast({title: '任务已完成,请明日再来'})
return;
}
......@@ -60,9 +61,9 @@ function CollectGoodsPage() {
})
return (
<ContainerFit bg={COLLECT_CONFIG.bg}>
<View className={styles['page-content__title']}>
<TitleImg config={COLLECT_CONFIG.head}/>
<ContainerFit bg={COLLECT_CONFIG.bg} fullScreenFit>
<View className={styles['page-content__title']} style={{}}>
<TitleImg config={COLLECT_CONFIG.head} position={'bottom'} />
</View>
<View className={styles['page-content__list']}>
<GoodsList goodsList={goodsList} task={COLLECT_CONFIG} onCompleteTask={(itemId,collected) => onCompleteTask(itemId,collected)} />
......
......@@ -15,9 +15,9 @@ function OrderGoodsPage() {
const { data } = useRequest(API.getCollectGoods, { key: ORDER_CONFIG.taskType, itemIds, taskType: ORDER_CONFIG.taskType })
return (
<ContainerFit bg={ORDER_CONFIG.bg}>
<ContainerFit bg={ORDER_CONFIG.bg} fullScreenFit>
<View className={styles['page-content__title']}>
<TitleImg config={ORDER_CONFIG.head}/>
<TitleImg config={ORDER_CONFIG.head} position={'bottom'} />
</View>
<View className={styles['page-content__list']}>
<GoodsList goodsList={data?.list || []} task={ORDER_CONFIG} />
......
......@@ -116,9 +116,9 @@ function MyPrizeList() {
return (
<>
<ContainerFit bg={PRIZE_CONFIG.bg}>
<ContainerFit bg={PRIZE_CONFIG.bg} fullScreenFit>
<View className={styles['my-prize-label']}>
<TitleImg config={PRIZE_CONFIG.head}></TitleImg>
<TitleImg config={PRIZE_CONFIG.head} position={'bottom'}></TitleImg>
</View>
<View className={styles['my-prize-content']} style={{ top: PRIZE_CONFIG.contentTop }}>
<ScrollView scrollY className={styles['my-prize-content__scroll']}>
......
......@@ -8,11 +8,13 @@
top: 363px;
bottom: 0;
width: 100%;
padding: 40px 0;
box-sizing: border-box;
}
.my-prize-content__scroll {
width: 100%;
height: 100%;
padding-top: 30px;
margin-top: 30px;
}
.my-prize-list {
width: 100%;
......
......@@ -13894,10 +13894,10 @@ taro-ui@^3.0.0-alpha.3:
lodash "^4.17.10"
prop-types "^15.7.2"
tbcc-sdk-ts@^1.0.10:
version "1.0.10"
resolved "https://registry.yarnpkg.com/tbcc-sdk-ts/-/tbcc-sdk-ts-1.0.10.tgz#8e1489176c843a43f95931aae3e04a5b6c1f8305"
integrity sha512-z+6/SVclywLnlbIqndPzUDFuVj1NEbojFm9vQAqx1hiXvpJbBcf5Ioo9J7k0rjymXgk0+at+QsnjhwuWEq3o/g==
tbcc-sdk-ts@^1.0.13:
version "1.0.13"
resolved "https://registry.yarnpkg.com/tbcc-sdk-ts/-/tbcc-sdk-ts-1.0.13.tgz#179c6c7f8529a4b146c73a651f529aa56345b6fa"
integrity sha512-dupA8ug1zz1/tfVw2ifOoNBlI6te9EXbtSHlsxycNDQxrykCSMP8objFujLeWUajrqNXbUoJlmV2JqbwU626mQ==
optionalDependencies:
"@types/lodash" "^4.14.160"
"@types/node" "^14.6.0"
......
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