58 lines
1.5 KiB
TypeScript
58 lines
1.5 KiB
TypeScript
import { FC } from 'react'
|
|
import ContextBlueTooth from "@/use/contextBlueTooth"
|
|
import { Provider } from 'react-redux'
|
|
import configStore from './store'
|
|
import './app.scss'
|
|
import Taro, { useDidShow} from '@tarojs/taro'
|
|
import { analysisShortCodeApi } from './common/shortCode'
|
|
import { IMG_CND_Prefix } from './common/constant'
|
|
|
|
const store = configStore()
|
|
const App:FC = (params) => {
|
|
|
|
Taro.showShareMenu({
|
|
withShareTicket: true
|
|
})
|
|
|
|
useDidShow(() => {
|
|
console.log('params:',params)
|
|
})
|
|
|
|
const page = Taro.getCurrentInstance().page
|
|
console.log('res:::', page)
|
|
if(page && page.onShareAppMessage) {
|
|
//当有分享参数时,绑定上下级
|
|
if(page.options?.share) {
|
|
analysisShortCodeApi(page.options.share)
|
|
}
|
|
page.onShareAppMessage = (res) => {
|
|
let path = ''
|
|
let title = ''
|
|
let imageUrl = ''
|
|
let sortCode = Taro.getStorageSync('sort_code')?JSON.parse(Taro.getStorageSync('sort_code')):''
|
|
if(res.from === 'button') {
|
|
path = `/pages/details/index?share=${sortCode.shareShortDetail.code}`
|
|
title = sortCode.shareShortDetail.title
|
|
} else {
|
|
path = `/pages/index/index?share=${sortCode.shareShortPage.code}`
|
|
title = sortCode.shareShortPage.title
|
|
imageUrl = IMG_CND_Prefix + '/mall/share_img_01.png'
|
|
}
|
|
return {
|
|
title,
|
|
path,
|
|
imageUrl,
|
|
}
|
|
}
|
|
}
|
|
|
|
return (
|
|
<ContextBlueTooth>
|
|
<Provider store={store}>
|
|
{params.children}
|
|
</Provider>
|
|
</ContextBlueTooth>
|
|
)
|
|
}
|
|
|
|
export default App |