本次修改: 1. 新增分销绑定 API 接口与路由 2. 老用户不再自动绑定推荐人,需手动输入邀请码绑定 3. 新增绑定推荐人 UI 弹层与展示组件 4. 新增防环校验与关系补全逻辑 5. 调整邀请码存储逻辑,仅未登录用户自动存储
258 行
5.8 KiB
Vue
258 行
5.8 KiB
Vue
<script>
|
||
export default {
|
||
onLaunch: function (options) {
|
||
console.log('App Launch', options)
|
||
this.captureInvite(options)
|
||
},
|
||
onShow: function (options) {
|
||
console.log('App Show', options)
|
||
this.captureInvite(options)
|
||
},
|
||
onHide: function () {
|
||
console.log('App Hide')
|
||
},
|
||
methods: {
|
||
/**
|
||
* 捕获并解析邀请分销参数(仅供未注册新用户首次登录建档使用,老用户须手动输入邀请码补绑)
|
||
* @param {Object} options 小程序启动或页面入参
|
||
*/
|
||
captureInvite(options) {
|
||
// 已登录老用户不自动捕获或自动补绑,须在分销中心手动填写邀请码绑定
|
||
if (uni.getStorageSync('fc_token')) {
|
||
return
|
||
}
|
||
const query = (options && options.query) || {}
|
||
let ic = query.ic || query.inviteCode || query.invite_code
|
||
let inviterId = query.inviterId || query.inviter_id
|
||
|
||
// 解析微信小程序码携带的 scene 场景值(如 scene=ic_ABCD 或 scene=ABCD 或 scene=ic=ABCD)
|
||
if (!ic && query.scene) {
|
||
try {
|
||
const sceneStr = decodeURIComponent(query.scene)
|
||
if (sceneStr.indexOf('ic_') === 0) {
|
||
ic = sceneStr.slice(3)
|
||
} else if (sceneStr.indexOf('ic=') === 0) {
|
||
ic = sceneStr.slice(3)
|
||
} else if (sceneStr.indexOf('uid_') === 0) {
|
||
inviterId = sceneStr.slice(4)
|
||
} else if (sceneStr.indexOf('uid=') === 0) {
|
||
inviterId = sceneStr.slice(4)
|
||
} else if (/^id_\d+_u_(\d+)$/.test(sceneStr)) {
|
||
const m = sceneStr.match(/^id_\d+_u_(\d+)$/)
|
||
if (m && m[1]) inviterId = m[1]
|
||
} else if (/^[A-Za-z0-9]{4,16}$/.test(sceneStr)) {
|
||
ic = sceneStr
|
||
}
|
||
} catch (e) {}
|
||
}
|
||
|
||
if (ic) {
|
||
uni.setStorageSync('fc_invite_code', String(ic))
|
||
}
|
||
if (inviterId) {
|
||
uni.setStorageSync('fc_inviter_id', Number(inviterId))
|
||
}
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style>
|
||
/* ============================================================
|
||
* 全局基础样式 · 生态绿(Eco Green)
|
||
* ========================================================== */
|
||
page {
|
||
--fc-primary: #00e070;
|
||
--fc-primary-ink: #04301e;
|
||
--fc-primary-light: #5cf3a6;
|
||
--fc-primary-lighter: #e4fdf0;
|
||
--fc-bg: #f2fef7;
|
||
--fc-text: #04291c;
|
||
--fc-text-secondary: #3f6b57;
|
||
--fc-border: #d6f3e3;
|
||
--fc-price: #e0891b;
|
||
|
||
background-color: var(--fc-bg);
|
||
color: var(--fc-text);
|
||
font-size: 28rpx;
|
||
font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
||
-webkit-font-smoothing: antialiased;
|
||
}
|
||
|
||
view,
|
||
text,
|
||
scroll-view,
|
||
swiper,
|
||
image,
|
||
button {
|
||
box-sizing: border-box;
|
||
-webkit-tap-highlight-color: transparent;
|
||
}
|
||
|
||
/* 通用容器 */
|
||
.fc-page {
|
||
min-height: 100vh;
|
||
background: var(--fc-bg);
|
||
padding-bottom: 120rpx;
|
||
}
|
||
|
||
.fc-card {
|
||
background: #ffffff;
|
||
border-radius: 24rpx;
|
||
padding: 30rpx;
|
||
margin: 24rpx;
|
||
box-shadow: 0 6rpx 24rpx rgba(4, 48, 30, 0.08);
|
||
}
|
||
|
||
/* 主按钮 */
|
||
.fc-btn {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
height: 88rpx;
|
||
border-radius: 999rpx;
|
||
font-size: 30rpx;
|
||
font-weight: 600;
|
||
color: var(--fc-primary-ink);
|
||
background: linear-gradient(135deg, #00e070 0%, #00c860 55%, #00b85c 100%);
|
||
box-shadow: 0 8rpx 24rpx rgba(0, 168, 85, 0.28);
|
||
}
|
||
.fc-btn--ghost {
|
||
background: #ffffff;
|
||
color: var(--fc-primary-text);
|
||
border: 2rpx solid var(--fc-primary);
|
||
box-shadow: none;
|
||
}
|
||
.fc-btn--disabled {
|
||
background: #d6f3e3;
|
||
color: #ffffff;
|
||
box-shadow: none;
|
||
}
|
||
|
||
/* 标签 */
|
||
.fc-tag {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
padding: 4rpx 14rpx;
|
||
border-radius: 999rpx;
|
||
font-size: 22rpx;
|
||
background: var(--fc-primary-lighter);
|
||
color: var(--fc-primary-text);
|
||
}
|
||
|
||
/* 价格 */
|
||
.fc-price {
|
||
color: var(--fc-price);
|
||
font-weight: 700;
|
||
}
|
||
.fc-price__symbol {
|
||
font-size: 24rpx;
|
||
}
|
||
|
||
/* 渐变占位图(无外链图片时使用) */
|
||
.fc-thumb {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
border-radius: 20rpx;
|
||
background: linear-gradient(135deg, #d9fbe9 0%, #b6f3d4 50%, #8fecbd 100%);
|
||
font-size: 56rpx;
|
||
color: #ffffff;
|
||
}
|
||
|
||
.fc-safe-bottom {
|
||
height: constant(safe-area-inset-bottom);
|
||
height: env(safe-area-inset-bottom);
|
||
}
|
||
|
||
/* 文本截断 */
|
||
.fc-ellipsis {
|
||
overflow: hidden;
|
||
white-space: nowrap;
|
||
text-overflow: ellipsis;
|
||
}
|
||
.fc-ellipsis-2 {
|
||
display: -webkit-box;
|
||
-webkit-line-clamp: 2;
|
||
-webkit-box-orient: vertical;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.fc-empty {
|
||
padding: 120rpx 0;
|
||
text-align: center;
|
||
color: var(--fc-text-secondary);
|
||
font-size: 26rpx;
|
||
}
|
||
|
||
@keyframes fc-shimmer {
|
||
0% { opacity: 0.55; }
|
||
50% { opacity: 1; }
|
||
100% { opacity: 0.55; }
|
||
}
|
||
.fc-skeleton {
|
||
animation: fc-shimmer 1.2s ease-in-out infinite;
|
||
background: #e6fbf1;
|
||
border-radius: 16rpx;
|
||
}
|
||
|
||
/* ============================================================
|
||
* 图标(图片)与 LOGO
|
||
* 所有图标均为 static/icons/ 下的图片,可在后台
|
||
* 「系统设置 → LOGO 与图标」中替换。
|
||
* ========================================================== */
|
||
.fc-icon {
|
||
display: block;
|
||
width: 40rpx;
|
||
height: 40rpx;
|
||
flex-shrink: 0;
|
||
}
|
||
.fc-icon--xs { width: 30rpx; height: 30rpx; }
|
||
.fc-icon--sm { width: 36rpx; height: 36rpx; }
|
||
.fc-icon--md { width: 48rpx; height: 48rpx; }
|
||
.fc-icon--lg { width: 64rpx; height: 64rpx; }
|
||
.fc-icon--xl { width: 88rpx; height: 88rpx; }
|
||
|
||
/* 徽章图标(图片自带圆角底色) */
|
||
.fc-icon--badge {
|
||
width: 96rpx;
|
||
height: 96rpx;
|
||
border-radius: 28rpx;
|
||
}
|
||
.fc-icon--badge-sm {
|
||
width: 76rpx;
|
||
height: 76rpx;
|
||
border-radius: 22rpx;
|
||
}
|
||
|
||
/* LOGO(图片自带 21.9% 圆角,CSS 圆角与之对齐避免裁切) */
|
||
.fc-logo {
|
||
display: block;
|
||
}
|
||
.fc-logo--sm {
|
||
width: 60rpx;
|
||
height: 60rpx;
|
||
border-radius: 13rpx;
|
||
}
|
||
.fc-logo--md {
|
||
width: 96rpx;
|
||
height: 96rpx;
|
||
border-radius: 21rpx;
|
||
}
|
||
.fc-logo--lg {
|
||
width: 140rpx;
|
||
height: 140rpx;
|
||
border-radius: 31rpx;
|
||
box-shadow: 0 10rpx 30rpx rgba(0, 0, 0, 0.12);
|
||
}
|
||
|
||
/* 图标 + 文字 的行内组合 */
|
||
.fc-inline {
|
||
display: flex;
|
||
align-items: center;
|
||
}
|
||
.fc-inline__text {
|
||
margin-left: 10rpx;
|
||
}
|
||
</style>
|