mirror of
https://gitee.com/ShopeX/ECShopX_mobile-frontend
synced 2026-08-14 17:41:45 +08:00
Merge branch 'pinjinjin' of git.ishopex.cn:onex/espier-taro-fenxiao into pinjinjin
This commit is contained in:
@@ -5,6 +5,7 @@ import { Loading, Price, BackToTop, SpHtmlContent } from '@/components'
|
||||
import api from '@/api'
|
||||
import { withBackToTop } from '@/hocs'
|
||||
import { styleNames, log } from '@/utils'
|
||||
import S from '@/spx'
|
||||
import GoodsBuyToolbar from './comps/buy-toolbar'
|
||||
|
||||
import './espier-detail.scss'
|
||||
@@ -106,9 +107,14 @@ export default class Detail extends Component {
|
||||
})
|
||||
}
|
||||
|
||||
handleBuyClick = (type) => {
|
||||
const { marketing } = this.state
|
||||
let url = `/pages/cart/checkout`
|
||||
handleBuyClick = async (type) => {
|
||||
const { marketing, info } = this.state
|
||||
let url = `/pages/cart/checkout?id=${info.item_id}`
|
||||
|
||||
const hasToken = !!S.getAuthToken()
|
||||
if (!hasToken) {
|
||||
return S.login(this, false)
|
||||
}
|
||||
|
||||
if (type === 'cart') {
|
||||
return Taro.navigateTo({
|
||||
|
||||
@@ -112,17 +112,22 @@ class Spx {
|
||||
} catch (e) {
|
||||
log.debug('[auth failed] redirect to login page: ', e)
|
||||
|
||||
const { fullPath } = getCurrentRoute(ctx.$router)
|
||||
const authUrl = process.env.TARO_ENV === 'weapp'
|
||||
? `/pages/auth/login?redirect=${fullPath}`
|
||||
: `/pages/auth/login?redirect=${fullPath}`
|
||||
|
||||
Taro.redirectTo({
|
||||
url: authUrl
|
||||
})
|
||||
this.goLogin(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
login (ctx, isRedirect = true) {
|
||||
const { fullPath } = getCurrentRoute(ctx.$router)
|
||||
|
||||
const authUrl = process.env.TARO_ENV === 'weapp'
|
||||
? `/pages/auth/login?redirect=${fullPath}`
|
||||
: `/pages/auth/login?redirect=${fullPath}`
|
||||
|
||||
Taro[isRedirect ? 'redirectTo' : 'navigateTo']({
|
||||
url: authUrl
|
||||
})
|
||||
}
|
||||
|
||||
logout () {
|
||||
Taro.removeStorageSync(TOKEN_IDENTIFIER)
|
||||
delete globalData[TOKEN_IDENTIFIER]
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { createReducer } from 'redux-create-reducer'
|
||||
|
||||
const initState = {
|
||||
list: []
|
||||
list: [],
|
||||
checkoutItem: null
|
||||
}
|
||||
|
||||
const cart = createReducer(initState, {
|
||||
@@ -12,6 +13,15 @@ const cart = createReducer(initState, {
|
||||
...state,
|
||||
list
|
||||
}
|
||||
},
|
||||
|
||||
['cart/checkout'](state, action) {
|
||||
const checkoutItem = action.payload
|
||||
|
||||
return {
|
||||
...state,
|
||||
checkoutItem
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user