Commit 43f76188 authored by mqf_0707's avatar mqf_0707

授权逻辑更改

parent ea5c1696
This diff is collapsed.
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
"react": "^17.0.0", "react": "^17.0.0",
"react-dom": "^17.0.0", "react-dom": "^17.0.0",
"taro-ui": "^3.0.0-alpha.3", "taro-ui": "^3.0.0-alpha.3",
"tbcc-sdk-ts": "^1.0.7" "tbcc-sdk-ts": "^1.0.9"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.8.0", "@babel/core": "^7.8.0",
...@@ -74,4 +74,4 @@ ...@@ -74,4 +74,4 @@
"style-resources-loader": "^1.4.1", "style-resources-loader": "^1.4.1",
"stylelint": "9.3.0" "stylelint": "9.3.0"
} }
} }
\ No newline at end of file
import React, { useState } from 'react'
import { View, Text } from '@tarojs/components'
import Taro from '@tarojs/taro'
import classnames from 'classnames'
import './Auth.less'
const clspreFix = 'auth-page'
function Auth(props) {
const { clickAuthBtn = () => {} } = props
return (
<View className={`${clspreFix}`}>
<View className={`${clspreFix}__content`}>
<View className={`${clspreFix}__img`}></View>
<View className={`${clspreFix}__title`}>开启授权继续使用</View>
<Text className={`${clspreFix}__subTitle`}>{`申请获取你的淘宝昵称及头像\n用于会员身份的核实及认证`}</Text>
<View className={`${clspreFix}__btn`} onClick={clickAuthBtn}>立即授权</View>
<View className={`${clspreFix}__exct`} onClick={() => Taro.exit()}>退出程序</View>
</View>
</View>
)
}
export default Auth
\ No newline at end of file
.auth-page{
width: 100vw;
height: 100vh;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 20;
background-color: #eee; // f1ebdd
display: flex;
justify-content: center;
align-items: center;
&__content {
width: 520px;
margin: 0 auto;
}
&__img {
width: 168px;
height: 168px;
margin: 0 auto 75px;
background-image: url('https://yun.dui88.com/dbad8bde-b2d5-41a8-ba62-94a9d42d624c.png');
.image-property(cover, center center);
background-repeat: no-repeat;
}
&__title{
color: #111111;
font-size: 32px;
margin: 0 auto 24px;
text-align: center;
}
&__subTitle {
display: block;
line-height: 48px;
color: #757575;
font-size: 32px;
margin: 0 auto 70px;
text-align: center;
}
&__btn {
width: 496px;
height: 110px;
line-height: 110px;
border-radius: 60px;
color: #e1e1e1;
background-color: rgb(17, 17, 17);
text-align: center;
font-size: 28px;
}
&__exct {
width: 496px;
height: 110px;
line-height: 110px;
border-radius: 60px;
color: #e1e1e1;
background-color: rgb(17, 17, 17);
text-align: center;
font-size: 28px;
margin-top: 20px;
}
}
\ No newline at end of file
...@@ -6,7 +6,7 @@ import styles from './DoHelpModal.module.less' ...@@ -6,7 +6,7 @@ import styles from './DoHelpModal.module.less'
import API from '@/api' import API from '@/api'
import { useLoginInfoModel, useActivityInfoModel } from '@/store' import { useLoginInfoModel, useActivityInfoModel } from '@/store'
import { checkIsMember } from 'tbcc-sdk-ts/lib/utils' import { checkIsMember } from 'tbcc-sdk-ts/lib/utils'
import { commonToast } from 'tbcc-sdk-ts/lib/core/tb' import { showToast } from '@tarojs/taro'
import { HELP_MODAL_TYPE, HELP_CONFIG } from '@/config/help.config' import { HELP_MODAL_TYPE, HELP_CONFIG } from '@/config/help.config'
export default function DoHelpModal(props) { export default function DoHelpModal(props) {
...@@ -20,9 +20,9 @@ export default function DoHelpModal(props) { ...@@ -20,9 +20,9 @@ export default function DoHelpModal(props) {
const isVip = await checkIsMember() const isVip = await checkIsMember()
const helpRes = await API.completeTask({ key: HELP_CONFIG.KEY, inviteId, isVip }) const helpRes = await API.completeTask({ key: HELP_CONFIG.KEY, inviteId, isVip })
if (helpRes?.success) { if (helpRes?.success) {
commonToast('助力成功') showToast({ title: '助力成功'})
} else { } else {
commonToast(helpRes?.message) showToast({ title: helpRes?.message})
} }
onClose() onClose()
setMemberModalVisible(false) setMemberModalVisible(false)
...@@ -41,9 +41,9 @@ export default function DoHelpModal(props) { ...@@ -41,9 +41,9 @@ export default function DoHelpModal(props) {
const helpRes = await API.completeTask({ key: HELP_CONFIG.KEY, inviteId, isVip }) const helpRes = await API.completeTask({ key: HELP_CONFIG.KEY, inviteId, isVip })
if (helpRes?.success) { if (helpRes?.success) {
commonToast('助力成功') showToast({ title: '助力成功'})
} else { } else {
commonToast(helpRes?.message) showToast({ title: helpRes?.message})
} }
onClose() onClose()
} }
...@@ -51,7 +51,7 @@ export default function DoHelpModal(props) { ...@@ -51,7 +51,7 @@ export default function DoHelpModal(props) {
const isVip = await checkIsMember() const isVip = await checkIsMember()
// 已经是会员 // 已经是会员
if (isVip) { if (isVip) {
commonToast('新会员才能助力哦~') showToast({ title: '新会员才能助力哦~'})
} else { } else {
// 还不是会员,弹出会员弹窗 // 还不是会员,弹出会员弹窗
setMemberModalVisible(true) setMemberModalVisible(true)
......
import { getAuthUserInfo } from 'tbcc-sdk-ts/lib/core/tbFn' import { useEffect, useRef, useState } from 'react'
import { useEffect } from 'react' import Taro, { useDidShow, showToast } from '@tarojs/taro'
import { commonToast } from 'tbcc-sdk-ts/lib/core/tb' import { getSetting, openSetting, authorize, getAuthUserInfo } from 'tbcc-sdk-ts/lib/core/tb'
// 授权 // 授权
export function useAuth(callback = noopFn) { export function useAuth(authSuccess = () => {}) {
const [visible, setVisible ] = useState(false)
const goToOpenSetting = useRef(false)
// 获取授权信息
const getSettingFn = async () => {
const res = await getSetting()
if(!res.authSetting?.userInfo) {
const authResult = await authorize().catch(err => {
setVisible(true)
showToast({ title: '请先授权,授权成功后才可参与活动' })
})
if(authResult) {
authUserInfo()
}
}else {
authUserInfo()
}
}
// 打开授权设置
const openSettingFn = async () => {
goToOpenSetting.current = true
showToast({ title: '打开授权开关,授权成功后才可参与活动', duration: 1000, success: () => openSetting() })
}
// 获取用户授权信息
const authUserInfo = async() => { const authUserInfo = async() => {
const info = await getAuthUserInfo().catch(err => { const info = await getAuthUserInfo()
console.log('未授权成功', err)
commonToast('点击右上角,打开授权开关,重进活动即可参与')
})
if (info) { if (info) {
callback(info) authSuccess(info)
setVisible && setVisible(false)
} }
} }
useEffect(() => { useEffect(() => {
authUserInfo() getSettingFn()
}, []) }, [])
return {} useDidShow(() => {
if(goToOpenSetting.current) {
// 重新授权
getSettingFn()
goToOpenSetting.current = false
}
})
return {
visible,
getSettingFn,
openSettingFn
}
} }
\ No newline at end of file
...@@ -43,11 +43,11 @@ export function useLogin(callback = noopFn) { ...@@ -43,11 +43,11 @@ export function useLogin(callback = noopFn) {
callback(_loginInfo) callback(_loginInfo)
} }
} }
useAuth((authInfo) => { const authInfo = useAuth((authInfo) => {
console.warn('authInfo :>>'+authInfo) console.warn('authInfo :>>'+authInfo)
doLogin(authInfo) doLogin(authInfo)
}) })
return { isLogin } return { isLogin, authInfo }
} }
export function useLoginFromShare(callback = noopFn) { export function useLoginFromShare(callback = noopFn) {
......
import { useCallback } from 'react' import { useCallback } from 'react'
import { checkIsMember } from 'tbcc-sdk-ts/lib/utils' import { checkIsMember } from 'tbcc-sdk-ts/lib/utils'
import { commonToast } from 'tbcc-sdk-ts/lib/core/tb' import { showToast } from '@tarojs/taro'
import API from '@/api' import API from '@/api'
import {receiveEnamePrize, receiveMemberEname, receiveObjectPrize } from 'tbcc-sdk-ts/lib/request/capiFn' 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 } from '@/config/myPrize.config'
...@@ -16,7 +16,7 @@ const useReceive = (props) => { ...@@ -16,7 +16,7 @@ const useReceive = (props) => {
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) {
commonToast('需加入会员才能领取成功哦', 1000, ()=>{callbackObj.vipCallback && callbackObj.vipCallback()}) showToast({ title: '需加入会员才能领取成功哦', duration: 1000, success: ()=>{callbackObj.vipCallback && callbackObj.vipCallback()} })
return; return;
} }
} }
......
import API from '@/api' import API from '@/api'
import { useThrottle } from '@/hooks/useThrottle' import { useThrottle } from '@/hooks/useThrottle'
import { useState, useEffect, useRef } from 'react' import { useState, useEffect, useRef } from 'react'
import { useDidShow } from '@tarojs/taro' import { useDidShow, showToast } from '@tarojs/taro'
import { useLoginInfoModel } from '@/store' import { useLoginInfoModel } from '@/store'
import { checkIsMember } from 'tbcc-sdk-ts/lib/utils' import { checkIsMember } from 'tbcc-sdk-ts/lib/utils'
import { commonToast, navigateTo, favorShop, checkShopFavoredStatus, navigateToOutside, showSharePanel, navigateToTaobaoPage } from 'tbcc-sdk-ts/lib/core/tb' import { navigateTo, favorShop, checkShopFavoredStatus, navigateToOutside, showSharePanel, navigateToTaobaoPage } from 'tbcc-sdk-ts/lib/core/tb'
import { TASK_DATA } from '@/mock' import { TASK_DATA } from '@/mock'
import { SHOP_ID } from '@/const' import { SHOP_ID } from '@/const'
import config from '@/config/config' import config from '@/config/config'
...@@ -27,7 +27,7 @@ export function useTasks(props) { ...@@ -27,7 +27,7 @@ export function useTasks(props) {
doCompleteTaskHandle(currentTaskType) doCompleteTaskHandle(currentTaskType)
preBrowseTime.current = null preBrowseTime.current = null
} else if(preBrowseTime.current && ((Date.now() - preBrowseTime.current) / 1000) < browseTime) { } else if(preBrowseTime.current && ((Date.now() - preBrowseTime.current) / 1000) < browseTime) {
commonToast(`未达到${browseTime}秒~`) showToast({ title: `未达到${browseTime}秒~`})
preBrowseTime.current = null preBrowseTime.current = null
}else { }else {
fetchTaskList() fetchTaskList()
...@@ -68,7 +68,7 @@ export function useTasks(props) { ...@@ -68,7 +68,7 @@ export function useTasks(props) {
const { success, data } = await API.receiveTask({ key, rewardsKey: TASK_CONFIG.rewardsKey }) const { success, data } = await API.receiveTask({ key, rewardsKey: TASK_CONFIG.rewardsKey })
if (success && data) { if (success && data) {
const { rewards } = data const { rewards } = data
commonToast(`${successMsg}${rewards}`) showToast({ title: `${successMsg}${rewards}` })
fetchTaskList() fetchTaskList()
onUpdate && onUpdate() onUpdate && onUpdate()
} }
...@@ -149,7 +149,7 @@ export function useTasks(props) { ...@@ -149,7 +149,7 @@ export function useTasks(props) {
} }
// 完成任务接口调用 // 完成任务接口调用
const doCompleteTaskHandle = async(key,isVip) => { const doCompleteTaskHandle = async(key,isVip) => {
const { success } = await API.completeTask({ key, isVip }) const { success } = await API.completeTask({ key, taskType: key, isVip })
if (success) { if (success) {
await fetchTaskList() await fetchTaskList()
} }
......
import React, { useRef, useState, useEffect } from 'react' import React, { useRef, useState, useEffect } from 'react'
import { View, Image } from '@tarojs/components' import { View, Image } from '@tarojs/components'
import Taro, { useShareAppMessage, useDidShow, getApp } from '@tarojs/taro' import { useShareAppMessage, useDidShow, getApp, showToast } from '@tarojs/taro'
import classnames from 'classnames' import classnames from 'classnames'
import { SHARE_CONFIG } from '@/const.js' import { SHARE_CONFIG } from '@/const.js'
import { HELP_MODAL_TYPE } from '@/config/help.config' import { HELP_MODAL_TYPE } from '@/config/help.config'
...@@ -12,6 +12,7 @@ import RuleModal from '@/components/_tb_modal/RuleModal/RuleModal' ...@@ -12,6 +12,7 @@ import RuleModal from '@/components/_tb_modal/RuleModal/RuleModal'
import DoHelpModal from '@/components/_tb_modal/DoHelpModal/DoHelpModal' import DoHelpModal from '@/components/_tb_modal/DoHelpModal/DoHelpModal'
import TasksModal from '@/components/_tb_modal/TasksModal/TasksModal' import TasksModal from '@/components/_tb_modal/TasksModal/TasksModal'
import JackpotModal from '@/components/_tb_modal/JackpotModal' import JackpotModal from '@/components/_tb_modal/JackpotModal'
import Auth from '@/components/_tb_modal/Auth/Auth'
import styles from './index.module.less' import styles from './index.module.less'
import tbcc from 'tbcc-sdk-ts' import tbcc from 'tbcc-sdk-ts'
const { navigateTo, openDetail, showSharePanel } = tbcc.tb const { navigateTo, openDetail, showSharePanel } = tbcc.tb
...@@ -21,8 +22,6 @@ import {useAudio} from '@/hooks/useAudio' ...@@ -21,8 +22,6 @@ import {useAudio} from '@/hooks/useAudio'
import {CLOUD_OBJ, BGMUSIC_URL} from '@/const' import {CLOUD_OBJ, BGMUSIC_URL} from '@/const'
import { commonToast } from 'tbcc-sdk-ts/lib/core/tb'
const INDEX_CONFIG = { const INDEX_CONFIG = {
bg: '', // 背景 cloud://C4015B7CEC23CF013A78247E2852524F//火箭待机小球抖动.json bg: '', // 背景 cloud://C4015B7CEC23CF013A78247E2852524F//火箭待机小球抖动.json
ruleButton: '', // 规则按钮 ruleButton: '', // 规则按钮
...@@ -52,6 +51,8 @@ function Index() { ...@@ -52,6 +51,8 @@ function Index() {
const SHARE_IMG = useRef('') const SHARE_IMG = useRef('')
// 助力弹窗类型 // 助力弹窗类型
const [helpType,setHelpType] = useState(HELP_MODAL_TYPE.HELP) const [helpType,setHelpType] = useState(HELP_MODAL_TYPE.HELP)
// 助力弹窗类型
const [helpInfo,setHelpInfo] = useState({})
// 助力弹窗标识 // 助力弹窗标识
const showHelp = useRef(false) const showHelp = useRef(false)
...@@ -76,7 +77,7 @@ function Index() { ...@@ -76,7 +77,7 @@ function Index() {
// }) // })
},[]) },[])
// 授权登录完成 // 授权登录完成
useLogin(async (info) => { const { isLogin, authInfo } = useLogin(async (info) => {
handleVisibleModal(info) handleVisibleModal(info)
}) })
// 查看是否有助力信息 // 查看是否有助力信息
...@@ -145,7 +146,7 @@ function Index() { ...@@ -145,7 +146,7 @@ function Index() {
navigateTo('/pages/packagePrize/myPrize/myPrize') navigateTo('/pages/packagePrize/myPrize/myPrize')
}, },
'game': () => navigateTo('/pages/packageGame/game/game'), 'game': () => navigateTo('/pages/packageGame/game/game'),
'comps': () => { 'comps': async () => {
navigateTo('/pages/packageComs/comsTest/comsTest') navigateTo('/pages/packageComs/comsTest/comsTest')
} }
} }
...@@ -209,6 +210,7 @@ function Index() { ...@@ -209,6 +210,7 @@ function Index() {
/> />
} }
{<member-modal expend={memberVisible} onClose={onClose} onAuthFail={onAuthFail} onAuthSuccess={onAuthSuccess} />} {<member-modal expend={memberVisible} onClose={onClose} onAuthFail={onAuthFail} onAuthSuccess={onAuthSuccess} />}
{authInfo?.visible && <Auth clickAuthBtn={authInfo.openSettingFn} /> }
{false && <canvas-comp />} {false && <canvas-comp />}
</> </>
) )
......
import React, { useEffect, useState } from 'react' import React, { useEffect, useState } from 'react'
import { View } from '@tarojs/components' import { View } from '@tarojs/components'
import { useDidShow, useRouter, useDidHide, getApp } from '@tarojs/taro' import { useDidShow, useRouter, useDidHide, getApp, showToast } from '@tarojs/taro'
import API from '@/api' import API from '@/api'
import { useLogin, useLoginFromShare } from '@/hooks/useLogin' import { useLogin, useLoginFromShare } from '@/hooks/useLogin'
import { useActivityInfoModel, useLoginInfoModel } from '@/store' import { useActivityInfoModel, useLoginInfoModel } from '@/store'
import { import {
commonToast,
getSystemInfo, getSystemInfo,
navigateToOutside, navigateToOutside,
navigateBack, navigateBack,
...@@ -123,7 +122,6 @@ function GamePage(props) { ...@@ -123,7 +122,6 @@ function GamePage(props) {
setMemberVisible(true) setMemberVisible(true)
break; break;
} }
// commonToast(JSON.stringify(data))
setUpdateFlag(Math.floor(Math.random() * 1000)) setUpdateFlag(Math.floor(Math.random() * 1000))
setCanvasData(data) setCanvasData(data)
} else { } else {
......
...@@ -4,9 +4,8 @@ import ContainerFit from '@/components/_base/ContainerFit/ContainerFit' ...@@ -4,9 +4,8 @@ import ContainerFit from '@/components/_base/ContainerFit/ContainerFit'
import GoodsTitle from '@/components/_tb_comps/TitleImg/TitleImg' import GoodsTitle from '@/components/_tb_comps/TitleImg/TitleImg'
import GoodsList from '@/components/_tb_comps/GoodsList/GoodsList' import GoodsList from '@/components/_tb_comps/GoodsList/GoodsList'
import BrowserLoading from '@/components/_tb_comps/BrowserLoading/BrowserLoading' import BrowserLoading from '@/components/_tb_comps/BrowserLoading/BrowserLoading'
import { useDidShow, useRouter, useDidHide } from '@tarojs/taro' import { useDidShow, useRouter, useDidHide, showToast } from '@tarojs/taro'
import API from '@/api' import API from '@/api'
import { commonToast } from 'tbcc-sdk-ts/lib/core/tb'
import styles from './browseGoods.module.less' import styles from './browseGoods.module.less'
import { TASK_CONFIG, BROSE_GOOD_TYPE } from '@/config/task.config' import { TASK_CONFIG, BROSE_GOOD_TYPE } from '@/config/task.config'
import { BROWSE_CONFIG } from '@/config/browse.config' import { BROWSE_CONFIG } from '@/config/browse.config'
...@@ -37,7 +36,7 @@ function BrowseGoodsPage() { ...@@ -37,7 +36,7 @@ function BrowseGoodsPage() {
},[goodsList]) },[goodsList])
// 获取商品列表 // 获取商品列表
const getGoodsList = async () => { const getGoodsList = async () => {
const { success, data } = await API.getCollectGoods({ key: BROWSE_CONFIG.taskType, itemIds }) const { success, data } = await API.getCollectGoods({ key: BROWSE_CONFIG.taskType, itemIds, taskType: BROWSE_CONFIG.taskType })
if(success && !BROWSE_CONFIG.isMock ) { if(success && !BROWSE_CONFIG.isMock ) {
setGoodsList(data?.list || []) setGoodsList(data?.list || [])
} }
...@@ -54,7 +53,7 @@ function BrowseGoodsPage() { ...@@ -54,7 +53,7 @@ function BrowseGoodsPage() {
currentItemId.current = '' currentItemId.current = ''
preBrowseTime.current = null preBrowseTime.current = null
} else if(preBrowseTime.current) { } else if(preBrowseTime.current) {
commonToast(`未达到${browseTime}秒~`) showToast({ title: `未达到${browseTime}秒~`})
currentItemId.current = '' currentItemId.current = ''
preBrowseTime.current = null preBrowseTime.current = null
} }
...@@ -68,10 +67,10 @@ function BrowseGoodsPage() { ...@@ -68,10 +67,10 @@ function BrowseGoodsPage() {
}) })
// 浏览记录 // 浏览记录
const onCompleteTask = async(itemId) => { const onCompleteTask = async(itemId) => {
const { success } = await API.completeTask({ key: BROWSE_CONFIG.taskType, itemId: currentItemId.current }) const { success } = await API.completeTask({ key: BROWSE_CONFIG.taskType, itemId: currentItemId.current, taskType: BROWSE_CONFIG.taskType })
if (success) { if (success) {
getGoodsList() getGoodsList()
commonToast('浏览成功') showToast({ title: '浏览成功'})
} }
} }
// 点击商品 跳转时处理 // 点击商品 跳转时处理
...@@ -88,7 +87,7 @@ function BrowseGoodsPage() { ...@@ -88,7 +87,7 @@ function BrowseGoodsPage() {
}, },
[BROSE_GOOD_TYPE.DETAIL]: () => { [BROSE_GOOD_TYPE.DETAIL]: () => {
if(collected) { if(collected) {
commonToast('该商品已经浏览过了') showToast({ title: '该商品已经浏览过了'})
return; return;
} }
preBrowseTime.current = Date.now() preBrowseTime.current = Date.now()
......
...@@ -3,7 +3,7 @@ import { View } from '@tarojs/components' ...@@ -3,7 +3,7 @@ import { View } from '@tarojs/components'
import ContainerFit from '@/components/_base/ContainerFit/ContainerFit' import ContainerFit from '@/components/_base/ContainerFit/ContainerFit'
import TitleImg from '@/components/_tb_comps/TitleImg/TitleImg' import TitleImg from '@/components/_tb_comps/TitleImg/TitleImg'
import GoodsList from '@/components/_tb_comps/GoodsList/GoodsList' import GoodsList from '@/components/_tb_comps/GoodsList/GoodsList'
import { useRouter } from '@tarojs/taro' import { useRouter, showToast } from '@tarojs/taro'
import tbccTs from 'tbcc-sdk-ts' import tbccTs from 'tbcc-sdk-ts'
import API from '@/api' import API from '@/api'
import { useThrottle } from '@/hooks/useThrottle' import { useThrottle } from '@/hooks/useThrottle'
...@@ -11,7 +11,7 @@ import styles from './cartGoods.module.less' ...@@ -11,7 +11,7 @@ import styles from './cartGoods.module.less'
import { CART_CONFIG, CART_TYPE } from '@/config/cart.config' import { CART_CONFIG, CART_TYPE } from '@/config/cart.config'
import { GOOD_LIST } from '@/mock' import { GOOD_LIST } from '@/mock'
const { commonToast, showSkuModal } = tbccTs.tb const { showSkuModal } = tbccTs.tb
function CartGoodsPage() { function CartGoodsPage() {
const router = useRouter() const router = useRouter()
...@@ -25,26 +25,26 @@ function CartGoodsPage() { ...@@ -25,26 +25,26 @@ function CartGoodsPage() {
}, []) }, [])
const getGoodsList = async () => { const getGoodsList = async () => {
const { data } = await API.getCollectGoods({ key: CART_CONFIG.taskType, itemIds }) const { data } = await API.getCollectGoods({ key: CART_CONFIG.taskType, taskType: CART_CONFIG.taskType, itemIds })
data?.list && setGoodsList(data?.list || []) data?.list && setGoodsList(data?.list || [])
} }
// 加入购物车 // 对应itemId为 574141925233 skuId为4018047819826 数量为4 // 加入购物车 // 对应itemId为 574141925233 skuId为4018047819826 数量为4
const onCompleteTask = useThrottle(async (itemId, collected) => { const onCompleteTask = useThrottle(async (itemId, collected) => {
console.log(itemId) console.log(itemId)
if (collected && CART_CONFIG.type === CART_TYPE.ONE) { if (collected && CART_CONFIG.type === CART_TYPE.ONE) {
commonToast('您已加购过该商品了') showToast({ title: '您已加购过该商品了'})
return; return;
} }
if(collectflag.current && CART_CONFIG.type === CART_TYPE.ONE) { if(collectflag.current && CART_CONFIG.type === CART_TYPE.ONE) {
commonToast('该任务今天已完成,明天再来吧~') showToast({ title: '该任务今天已完成,明天再来吧~'})
} }
const { status, quantity } = await showSkuModal(String(itemId)) const { status, quantity } = await showSkuModal(String(itemId))
if (status == "addCartSuccess") { if (status == "addCartSuccess") {
const { success } = await API.completeTask({ key: CART_CONFIG.taskType, itemId, count: quantity }) const { success } = await API.completeTask({ key: CART_CONFIG.taskType, taskType: CART_CONFIG.taskType, itemId, count: quantity })
if (success) { if (success) {
collectflag.current = true collectflag.current = true
getGoodsList() getGoodsList()
commonToast('加购成功') showToast({ title: '加购成功'})
} }
} }
}, 2000); }, 2000);
......
...@@ -3,11 +3,11 @@ import { View } from '@tarojs/components' ...@@ -3,11 +3,11 @@ import { View } from '@tarojs/components'
import ContainerFit from '@/components/_base/ContainerFit/ContainerFit' import ContainerFit from '@/components/_base/ContainerFit/ContainerFit'
import TitleImg from '@/components/_tb_comps/TitleImg/TitleImg' import TitleImg from '@/components/_tb_comps/TitleImg/TitleImg'
import GoodsList from '@/components/_tb_comps/GoodsList/GoodsList' import GoodsList from '@/components/_tb_comps/GoodsList/GoodsList'
import { useRouter } from '@tarojs/taro' import { useRouter, showToast } from '@tarojs/taro'
import tbccTs from 'tbcc-sdk-ts' import tbccTs from 'tbcc-sdk-ts'
import API from '@/api' import API from '@/api'
import { useThrottle } from '@/hooks/useThrottle' import { useThrottle } from '@/hooks/useThrottle'
const { commonToast, checkGoodsCollectedStatus, collectGoods } = tbccTs.tb const { checkGoodsCollectedStatus, collectGoods } = tbccTs.tb
import styles from './collectGoods.module.less' import styles from './collectGoods.module.less'
import COLLECT_CONFIG from '@/config/collect.config' import COLLECT_CONFIG from '@/config/collect.config'
import { GOOD_LIST } from '@/mock' import { GOOD_LIST } from '@/mock'
...@@ -24,26 +24,26 @@ function CollectGoodsPage() { ...@@ -24,26 +24,26 @@ function CollectGoodsPage() {
}, []) }, [])
const getGoodsList = async () => { const getGoodsList = async () => {
const { data } = await API.getCollectGoods({ key: COLLECT_CONFIG.taskType, itemIds }) const { data } = await API.getCollectGoods({ key: COLLECT_CONFIG.taskType, itemIds, taskType: COLLECT_CONFIG.taskType })
data?.list && setGoodsList(data?.list || []) data?.list && setGoodsList(data?.list || [])
} }
const onCompleteTask = useThrottle(async(itemId,collected) => { const onCompleteTask = useThrottle(async(itemId,collected) => {
const collectFn = async () => { const collectFn = async () => {
const { success } = await API.completeTask({ key: COLLECT_CONFIG.taskType, itemId }) const { success } = await API.completeTask({ key: COLLECT_CONFIG.taskType, itemId, taskType: COLLECT_CONFIG.taskType })
if (success) { if (success) {
collectFlag.current = true collectFlag.current = true
getGoodsList() getGoodsList()
commonToast('收藏成功') showToast({ title: '收藏成功'})
} }
} }
// 今日是否已收藏过 // 今日是否已收藏过
if(collectFlag.current) { if(collectFlag.current) {
commonToast('任务已完成,请明日再来') showToast({title: '任务已完成,请明日再来'})
return; return;
} }
if (collected) { if (collected) {
commonToast('您已收藏过该商品了') showToast({ title:'您已收藏过该商品了'})
return; return;
} }
// 判断是否活动外已收藏商品 // 判断是否活动外已收藏商品
......
...@@ -12,7 +12,7 @@ import ORDER_CONFIG from '@/config/order.config' ...@@ -12,7 +12,7 @@ import ORDER_CONFIG from '@/config/order.config'
function OrderGoodsPage() { function OrderGoodsPage() {
const router = useRouter() const router = useRouter()
const { itemIds } = router?.params const { itemIds } = router?.params
const { data } = useRequest(API.getCollectGoods, { key: ORDER_CONFIG.taskType, itemIds }) const { data } = useRequest(API.getCollectGoods, { key: ORDER_CONFIG.taskType, itemIds, taskType: ORDER_CONFIG.taskType })
return ( return (
<ContainerFit bg={ORDER_CONFIG.bg}> <ContainerFit bg={ORDER_CONFIG.bg}>
......
...@@ -8,7 +8,7 @@ import tbccTs from 'tbcc-sdk-ts' ...@@ -8,7 +8,7 @@ import tbccTs from 'tbcc-sdk-ts'
import { useThrottle } from '@/hooks/useThrottle' import { useThrottle } from '@/hooks/useThrottle'
import { dateFormatter } from '@/utils/date' import { dateFormatter } from '@/utils/date'
import styles from './myPrize.module.less' import styles from './myPrize.module.less'
import { useDidHide, useDidShow, getApp } from '@tarojs/taro' import { showToast, useDidShow, getApp } from '@tarojs/taro'
import useReceive from '@/hooks/useReceive' import useReceive from '@/hooks/useReceive'
import { PRIZE_CONFIG, DRAW_STATUS, PRIZE_TYPE } from '@/config/myPrize.config' import { PRIZE_CONFIG, DRAW_STATUS, PRIZE_TYPE } from '@/config/myPrize.config'
...@@ -16,7 +16,7 @@ const { objectStatus: _objectStatus, enameStatus: _enameStatus, orderStatus, com ...@@ -16,7 +16,7 @@ const { objectStatus: _objectStatus, enameStatus: _enameStatus, orderStatus, com
const objectStatus = { ..._objectStatus, ...commonStatus } const objectStatus = { ..._objectStatus, ...commonStatus }
const enameStatus = { ..._enameStatus, ...commonStatus } const enameStatus = { ..._enameStatus, ...commonStatus }
const { commonToast, navigateToOutside, setClipboard, openDetail } = tbccTs.tb const { navigateToOutside, setClipboard, openDetail } = tbccTs.tb
function Empty(blankTxt) { function Empty(blankTxt) {
return <View className={styles['my-prize-item__empty']}>{blankTxt}</View> return <View className={styles['my-prize-item__empty']}>{blankTxt}</View>
...@@ -55,7 +55,7 @@ function MyPrizeList() { ...@@ -55,7 +55,7 @@ function MyPrizeList() {
// 复制编码 // 复制编码
const handleCopyId = async(text) => { const handleCopyId = async(text) => {
await setClipboard(text) await setClipboard(text)
commonToast('复制成功') showToast({ title: '复制成功' })
} }
// 领取奖品 // 领取奖品
const handleClick = useThrottle(async (item) => { const handleClick = useThrottle(async (item) => {
...@@ -110,8 +110,8 @@ function MyPrizeList() { ...@@ -110,8 +110,8 @@ function MyPrizeList() {
const { type, itemId, drawStatus, useUrl = '' } = itm const { type, itemId, drawStatus, useUrl = '' } = itm
if(itemId && hasGoodPrize) return orderStatus[drawStatus] if(itemId && hasGoodPrize) return orderStatus[drawStatus]
if(type === PRIZE_TYPE.OBJECT) return objectStatus[drawStatus] if(type === PRIZE_TYPE.OBJECT) return objectStatus[drawStatus]
if(type === PRIZE_TYPE.ENAME && drawStatus === DRAW_STATUS.SUCCESS && !useUrl) return PRIZE_CONFIG.receiveBtn if(type !== PRIZE_TYPE.OBJECT && drawStatus === DRAW_STATUS.SUCCESS && !useUrl) return PRIZE_CONFIG.receiveBtn
if(type === PRIZE_TYPE.ENAME) return enameStatus[drawStatus] if(type !== PRIZE_TYPE.OBJECT) return enameStatus[drawStatus]
} }
return ( return (
......
...@@ -6,7 +6,7 @@ export const noopFn = () => { } ...@@ -6,7 +6,7 @@ export const noopFn = () => { }
// 领取实物 // 领取实物
const getUerAddressParam = async () => { const getUerAddressParam = async () => {
const userAddress = await getUserAddress().catch(err => { const userAddress = await getUserAddress().catch(err => {
commonToast(err.errorMessage); commonToast({ content: err.errorMessage});
}); });
if(!userAddress) return false if(!userAddress) return false
const { name, telNumber, provinceName, cityName, cityCode, countyName, detailInfo, streetName } = userAddress || {}; const { name, telNumber, provinceName, cityName, cityCode, countyName, detailInfo, streetName } = userAddress || {};
...@@ -58,10 +58,10 @@ export const receiveObjectPrize = async (data) => { ...@@ -58,10 +58,10 @@ export const receiveObjectPrize = async (data) => {
} }
const { success, data, message } = await API.receiveObjectPrize({ ...params, ..._params }) const { success, data, message } = await API.receiveObjectPrize({ ...params, ..._params })
if (success) { if (success) {
commonToast(successMsg) commonToast({ content: successMsg})
resolve(true) resolve(true)
}else { }else {
commonToast(errorMsg || message) commonToast({content: errorMsg || message})
resolve(false) resolve(false)
} }
}) })
...@@ -71,14 +71,14 @@ export const receiveEnamePrize = async (data) => { ...@@ -71,14 +71,14 @@ export const receiveEnamePrize = async (data) => {
const { params, successMsg, errorMsg } = data const { params, successMsg, errorMsg } = data
return new Promise(async (resolve,reject) => { return new Promise(async (resolve,reject) => {
const { success, data, message } = await API.receiveEnamePrize(params).catch(res => { const { success, data, message } = await API.receiveEnamePrize(params).catch(res => {
commonToast(successMsg || res.message) commonToast({ content: successMsg || res.message})
resolve(false) resolve(false)
}); });
if (success) { if (success) {
commonToast(successMsg) commonToast({ content: successMsg})
resolve(true) resolve(true)
}else { }else {
commonToast(errorMsg || message) commonToast({ content: errorMsg || message})
resolve(false) resolve(false)
} }
}) })
...@@ -113,14 +113,14 @@ export const receiveMemberEname = async(data) => { ...@@ -113,14 +113,14 @@ export const receiveMemberEname = async(data) => {
if(result.businessSuccess) { if(result.businessSuccess) {
const { success, data, message } = await API.updateEnamePrizeReceived({ ...ext }) const { success, data, message } = await API.updateEnamePrizeReceived({ ...ext })
if(success) { if(success) {
commonToast(successMsg || '奖品发放成功,请前往我的奖品处进行使用') commonToast({ content: successMsg || '奖品发放成功,请前往我的奖品处进行使用'})
resolve(true) resolve(true)
}else { }else {
commonToast(errorMsg || message) commonToast({ content: errorMsg || message})
resolve(false) resolve(false)
} }
}else{ }else{
commonToast(result.errorMsg) commonToast({ content: result.errorMsg})
resolve(false) resolve(false)
} }
}) })
...@@ -129,7 +129,7 @@ export const receiveMemberEname = async(data) => { ...@@ -129,7 +129,7 @@ export const receiveMemberEname = async(data) => {
export const addStat = async(activityId, type)=> { export const addStat = async(activityId, type)=> {
return new Promise(async (resolve,reject) => { return new Promise(async (resolve,reject) => {
const result = await API.addStat({ activityId, type }).catch(res => { const result = await API.addStat({ activityId, type }).catch(res => {
commonToast(res && res.message); commonToast({ content: res && res.message});
}); });
if (result && result.success) { if (result && result.success) {
resolve(true) resolve(true)
......
...@@ -13894,10 +13894,10 @@ taro-ui@^3.0.0-alpha.3: ...@@ -13894,10 +13894,10 @@ taro-ui@^3.0.0-alpha.3:
lodash "^4.17.10" lodash "^4.17.10"
prop-types "^15.7.2" prop-types "^15.7.2"
tbcc-sdk-ts@^1.0.7: tbcc-sdk-ts@^1.0.9:
version "1.0.7" version "1.0.9"
resolved "https://registry.yarnpkg.com/tbcc-sdk-ts/-/tbcc-sdk-ts-1.0.7.tgz#17da833f4de75d01898485c2634623108e1519cd" resolved "https://registry.yarnpkg.com/tbcc-sdk-ts/-/tbcc-sdk-ts-1.0.9.tgz#36eedaa5f2d164c5e431cfe027dd8241d7622576"
integrity sha512-bPoL2BEBhx45+4u+zjhCz9otAK5KjLEcu9RoyoRhfr5lxLUohU8Cy6d/JEvg4+E/ArmWEc1fs5/Z0LNKtzPt/w== integrity sha512-g4Rr6thIurH+fWlgaF4y8/aXu0ViVYoAzrZG7Rji5CguzDuZ2L8lH/uXCAzYtNXBmnB7IvtkR2i11xxe1YI8Dw==
optionalDependencies: optionalDependencies:
"@types/lodash" "^4.14.160" "@types/lodash" "^4.14.160"
"@types/node" "^14.6.0" "@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