Files
ruo-shan-cloud-redirect/miniprogram/pages/index/index.ts
T

36 lines
886 B
TypeScript

// index.ts
import { BASE_URL, appId } from '../../env'
Component({
data: {
showPopup: false,
showToast: false,
},
methods: {
preventTouchMove() {},
onOverlayTap() {
wx.request({
url: `${BASE_URL}/api/ad/ww-join-fans/result/${appId}`,
method: 'GET',
success: (res: any) => {
const data = res.data
if (data.data.url || data.data) {
// @ts-ignore
wx.openOfficialAccountArticle({
url: data.data.url || data.data,
fail: () => {
wx.showToast({ title: '打开失败', icon: 'none' })
},
})
} else {
wx.showToast({ title: '未获取到链接', icon: 'none' })
}
},
fail: () => {
wx.showToast({ title: '请求失败', icon: 'none' })
},
})
},
},
})