消息推送授权

master
yujialong 3 days ago
parent 4f95620906
commit 58214fffc6
  1. 19
      src/components/getPhoneModal/index.tsx
  2. 3
      src/pages/Home/index.tsx
  3. 22
      src/pages/UserHome/index.tsx

@ -40,6 +40,23 @@ export default function GetPhoneNumber({ onClose, scene = null, modalVisible, on
}, 0)
};
// 消息推送授权
const publicNotice = () => {
Taro.requestSubscribeMessage({
tmplIds: ['F5kG9ryTuf3U09liOVIqqZDDEwNwiuWbLPPdoVpKPWI', 'cnMggWGwr0_cVw7Hf_fg3u74EDJdA0b4e56Ioy-Vr_Q'],
success (res) {
},
fail (err) {
Taro.showToast({
title: err,
duration: 2000,
icon: 'error'
});
}
})
}
const handleGetUserPhone = (e: any) => {
console.log('注册接口:',e.detail, Taro.getStorageSync('othersInviteCode'))
@ -63,6 +80,8 @@ export default function GetPhoneNumber({ onClose, scene = null, modalVisible, on
Taro.setStorageSync('UserToken', res.data.token)
Taro.removeStorageSync('othersInviteCode')
publicNotice()
if(scene){
Taro.request({
url: 'https://interapi.jm-kid.com/api/product/exchange',

@ -299,8 +299,7 @@ export default function Home() {
else{
//已订阅,跳转详情页
Taro.navigateTo({
url: index ? '/pages/CollectionDetail/index?id=' + item.prdt_id : '/pages/Share/index'
// url: '/pages/Share/index'
url: '/pages/Share/index'
})
}
}

@ -168,6 +168,25 @@ export default function UserHome() {
// }
// })
// 消息推送授权
const publicNotice = (url) => {
Taro.requestSubscribeMessage({
tmplIds: ['F5kG9ryTuf3U09liOVIqqZDDEwNwiuWbLPPdoVpKPWI', 'cnMggWGwr0_cVw7Hf_fg3u74EDJdA0b4e56Ioy-Vr_Q'],
success (res) {
Taro.navigateTo({
url: url,
})
},
fail (err) {
Taro.showToast({
title: err,
duration: 2000,
icon: 'error'
});
}
})
}
const handlePush = (index: number,url: string) => {
if(!Taro.getStorageSync('UserToken')){
setisLoginOpen(true)
@ -178,6 +197,9 @@ export default function UserHome() {
} else if (index === 2) {
// 兑换码
setisUserExchangeModalOpen(true)
} else if (index === 4) {
// 联系客服
publicNotice(url)
} else {
Taro.navigateTo({
url: url,

Loading…
Cancel
Save