yurong/pages/h5/bridge.vue

57 lines
1.4 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="page">
<web-view :src="src"></web-view>
</view>
</template>
<script>
export default {
data() {
return {
activityHomeUrl: 'http://point.agrimedia.cn/affiliate-activity/pages/index/index',
src: '',
from: ''
}
},
onLoad(options) {
this.initBridgeEntryUrl()
if (options && options.from) {
this.from = decodeURIComponent(options.from)
}
},
onUnload() {
if (this.from) {
this.$tools.setPromotionBridgeSkip(this.from)
}
},
methods: {
// 进入 bridge 页后统一跳到活动首页:
// 1. 已登录时在活动首页后拼上 exuiduid 数字段固定补足到 7 位。
// 2. 未登录时直接进入活动首页,不带 exuid。
initBridgeEntryUrl() {
const localUid = String(uni.getStorageSync('uid') || '')
if (!localUid) {
this.src = this.activityHomeUrl
return
}
const promotionUid = this.buildPromotionUidValue(localUid)
this.src = `${this.activityHomeUrl}?exuid=${promotionUid}`
console.log(this.src)
},
// 推广相关的 uid 数字段始终保持 7 位,不足时在末尾补 0。
buildPromotionUidValue(localUid) {
const uidValue = String(localUid || '')
const padCount = Math.max(7 - uidValue.length, 0)
return `${uidValue}${'0'.repeat(padCount)}`
}
}
}
</script>
<style>
.page {
width: 100%;
height: 100%;
}
</style>