修改了一个小问题,增加了不同平台分享邀请的功能(未测试)
This commit is contained in:
parent
6f7207da2d
commit
de1a80cc13
@ -66,7 +66,7 @@ defineExpose({ revealResults, reset })
|
||||
|
||||
<style lang="scss" scoped>
|
||||
/* ============================================
|
||||
奇盒潮玩 - 翻牌动画组件
|
||||
柯大鸭潮玩 - 翻牌动画组件
|
||||
采用暖橙色调的开箱效果
|
||||
============================================ */
|
||||
|
||||
|
||||
@ -135,7 +135,7 @@ function handleConfirm() {
|
||||
|
||||
<style lang="scss" scoped>
|
||||
/* ============================================
|
||||
奇盒潮玩 - 支付弹窗组件
|
||||
柯大鸭潮玩 - 支付弹窗组件
|
||||
采用暖橙色调的底部弹窗设计
|
||||
============================================ */
|
||||
|
||||
|
||||
@ -292,7 +292,7 @@ async function onPaymentConfirm(paymentData) {
|
||||
|
||||
<style lang="scss" scoped>
|
||||
/* ============================================
|
||||
奇盒潮玩 - 选号组件 (适配高级卡片布局)
|
||||
柯大鸭潮玩 - 选号组件 (适配高级卡片布局)
|
||||
============================================ */
|
||||
|
||||
/* 容器 - 去除背景,融入父级卡片 */
|
||||
|
||||
@ -123,7 +123,7 @@ import { onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
|
||||
onShareAppMessage(() => {
|
||||
const inviteCode = uni.getStorageSync('invite_code') || (uni.getStorageSync('user_info') || {}).invite_code || ''
|
||||
return {
|
||||
title: `${title.value || '精彩活动'} - 奇盒潮玩`,
|
||||
title: `${title.value || '精彩活动'} - 柯大鸭潮玩`,
|
||||
path: `/pages/index/index?invite_code=${inviteCode}`,
|
||||
imageUrl: '/static/logo.png'
|
||||
}
|
||||
@ -132,7 +132,7 @@ onShareAppMessage(() => {
|
||||
onShareTimeline(() => {
|
||||
const inviteCode = uni.getStorageSync('invite_code') || (uni.getStorageSync('user_info') || {}).invite_code || ''
|
||||
return {
|
||||
title: `${title.value || '精彩活动'} - 奇盒潮玩`,
|
||||
title: `${title.value || '精彩活动'} - 柯大鸭潮玩`,
|
||||
query: `invite_code=${inviteCode}`,
|
||||
imageUrl: '/static/logo.png'
|
||||
}
|
||||
|
||||
@ -411,7 +411,7 @@ function closeFlip() { showFlip.value = false }
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
/* 奇盒潮玩 - 无限赏活动页面 */
|
||||
/* 柯大鸭潮玩 - 无限赏活动页面 */
|
||||
.page {
|
||||
min-height: 100vh;
|
||||
padding-bottom: calc(200rpx + env(safe-area-inset-bottom));
|
||||
|
||||
@ -150,7 +150,7 @@ onLoad((opts) => {
|
||||
|
||||
<style lang="scss" scoped>
|
||||
/* ============================================
|
||||
奇盒潮玩 - 地址编辑页面
|
||||
柯大鸭潮玩 - 地址编辑页面
|
||||
采用暖橙色调的表单设计
|
||||
============================================ */
|
||||
|
||||
|
||||
@ -115,7 +115,7 @@ onLoad(() => {
|
||||
|
||||
<style lang="scss" scoped>
|
||||
/* ============================================
|
||||
奇盒潮玩 - 地址管理页面
|
||||
柯大鸭潮玩 - 地址管理页面
|
||||
采用暖橙色调的卡片列表设计
|
||||
============================================ */
|
||||
|
||||
|
||||
@ -682,7 +682,7 @@ async function onShip() {
|
||||
|
||||
<style lang="scss" scoped>
|
||||
/* ============================================
|
||||
奇盒潮玩 - 货柜页面
|
||||
柯大鸭潮玩 - 货柜页面
|
||||
采用现代卡片式布局,统一设计语言
|
||||
============================================ */
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
<!-- 顶部导航栏 (搜索) -->
|
||||
<view class="nav-header">
|
||||
<view class="brand-logo">
|
||||
<text class="brand-text">奇盒潮玩</text>
|
||||
<text class="brand-text">柯大鸭潮玩</text>
|
||||
<view class="brand-star">✨</view>
|
||||
</view>
|
||||
<view class="search-bar">
|
||||
@ -24,7 +24,7 @@
|
||||
<swiper-item v-for="b in displayBanners" :key="b.id">
|
||||
<image v-if="b.image" class="banner-image" :src="b.image" mode="aspectFill" @tap="onBannerTap(b)" />
|
||||
<view v-else class="banner-fallback">
|
||||
<text class="banner-fallback-text">{{ b.title || '奇盒潮玩 V6.0' }}</text>
|
||||
<text class="banner-fallback-text">{{ b.title || '柯大鸭潮玩 V6.0' }}</text>
|
||||
<text class="banner-tag">功能更新UI优化全面来袭</text>
|
||||
</view>
|
||||
</swiper-item>
|
||||
@ -322,7 +322,7 @@ export default {
|
||||
onShareAppMessage() {
|
||||
const inviteCode = uni.getStorageSync('invite_code') || (uni.getStorageSync('user_info') || {}).invite_code || ''
|
||||
return {
|
||||
title: '奇盒潮玩 - 开箱惊喜等你来',
|
||||
title: '柯大鸭潮玩 - 开箱惊喜等你来',
|
||||
path: `/pages/index/index?invite_code=${inviteCode}`,
|
||||
imageUrl: '/static/logo.png'
|
||||
}
|
||||
@ -331,7 +331,7 @@ export default {
|
||||
onShareTimeline() {
|
||||
const inviteCode = uni.getStorageSync('invite_code') || (uni.getStorageSync('user_info') || {}).invite_code || ''
|
||||
return {
|
||||
title: '奇盒潮玩 - 开箱惊喜等你来',
|
||||
title: '柯大鸭潮玩 - 开箱惊喜等你来',
|
||||
query: `invite_code=${inviteCode}`,
|
||||
imageUrl: '/static/logo.png'
|
||||
}
|
||||
@ -341,7 +341,7 @@ export default {
|
||||
|
||||
<style lang="scss">
|
||||
/* ============================================
|
||||
奇盒潮玩 - 首页样式 (V6.0 Pro Refined)
|
||||
柯大鸭潮玩 - 首页样式 (V6.0 Pro Refined)
|
||||
============================================ */
|
||||
|
||||
.page {
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
<view class="logo-box">
|
||||
<image class="logo" src="/static/logo.png" mode="widthFix"></image>
|
||||
</view>
|
||||
<view class="app-name">奇盒潮玩</view>
|
||||
<view class="app-name">柯大鸭潮玩</view>
|
||||
<view class="welcome-text">开启欧气之旅 ✨</view>
|
||||
</view>
|
||||
|
||||
|
||||
@ -47,7 +47,27 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 邀请Banner -->
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<view class="invite-banner glass-card">
|
||||
<view class="invite-content">
|
||||
<view class="invite-text-group">
|
||||
<view class="invite-title-row">
|
||||
<text class="invite-tag">好礼相送</text>
|
||||
<text class="invite-title">邀请好友送好礼</text>
|
||||
</view>
|
||||
<text class="invite-desc">全新版本等你来玩,奖励拿到手软</text>
|
||||
</view>
|
||||
<button class="invite-action-btn invite-share-btn" open-type="share">
|
||||
<image class="invite-share-icon" src="/static/logo.png" mode="aspectFit"></image>
|
||||
<text>立即邀请</text>
|
||||
<text class="invite-arrow">›</text>
|
||||
</button>
|
||||
</view>
|
||||
<image class="invite-bg-icon" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI2NCIgaGVpZ2h0PSI2NCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiNGRjZCMDAiIHN0cm9rZS13aWR0aD0iMSIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIj48cGF0aCBkPSJNMjEgMTF2OGEyIDIgMCAwIDEtMiAySDVhMiAyIDAgMCAwIDEtMiAyVjdsOS02IDkgNnoiIC8+PC9zdmc+" mode="aspectFit"></image>
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
|
||||
<!-- #ifndef MP-WEIXIN -->
|
||||
<view class="invite-banner glass-card" @click="handleInvite">
|
||||
<view class="invite-content">
|
||||
<view class="invite-text-group">
|
||||
@ -64,6 +84,7 @@
|
||||
</view>
|
||||
<image class="invite-bg-icon" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI2NCIgaGVpZ2h0PSI2NCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiNGRjZCMDAiIHN0cm9rZS13aWR0aD0iMSIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIj48cGF0aCBkPSJNMjEgMTF2OGEyIDIgMCAwIDEtMiAySDVhMiAyIDAgMCAwIDEtMiAyVjdsOS02IDkgNnoiIC8+PC9zdmc+" mode="aspectFit"></image>
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
|
||||
<!-- 我的订单 -->
|
||||
<view class="section-card glass-card">
|
||||
@ -446,10 +467,54 @@ export default {
|
||||
invitesLoading: false
|
||||
}
|
||||
},
|
||||
onLoad(opts) {
|
||||
const code = (opts && (opts.invite_code || opts.inviteCode)) || ''
|
||||
const v = String(code || '').trim()
|
||||
if (v) {
|
||||
try { uni.setStorageSync('inviter_code', v) } catch (_) {}
|
||||
const token = uni.getStorageSync('token')
|
||||
if (!token) {
|
||||
uni.navigateTo({ url: `/pages/register/register?invite_code=${encodeURIComponent(v)}` })
|
||||
}
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
this.loadUserInfo()
|
||||
},
|
||||
onShareAppMessage() {
|
||||
const inviteCode = uni.getStorageSync('invite_code') || (uni.getStorageSync('user_info') || {}).invite_code || ''
|
||||
return {
|
||||
title: '给你一个宝藏应用,快来!',
|
||||
path: inviteCode ? `/pages/register/register?invite_code=${inviteCode}` : '/pages/register/register',
|
||||
imageUrl: '/static/logo.png'
|
||||
}
|
||||
},
|
||||
onShareTimeline() {
|
||||
const inviteCode = uni.getStorageSync('invite_code') || (uni.getStorageSync('user_info') || {}).invite_code || ''
|
||||
return {
|
||||
title: '给你一个宝藏应用,快来!',
|
||||
query: inviteCode ? `invite_code=${inviteCode}` : '',
|
||||
imageUrl: '/static/logo.png'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getInviteCode() {
|
||||
const v = this.inviteCode || uni.getStorageSync('invite_code') || (uni.getStorageSync('user_info') || {}).invite_code || ''
|
||||
return String(v || '').trim()
|
||||
},
|
||||
getInviteSharePath() {
|
||||
const code = this.getInviteCode()
|
||||
return code ? `/pages/register/register?invite_code=${encodeURIComponent(code)}` : '/pages/register/register'
|
||||
},
|
||||
normalizePointsBalance(v) {
|
||||
if (v && typeof v === 'object') {
|
||||
const nested = v.balance ?? v.points_balance ?? v.value
|
||||
const n1 = Number(nested)
|
||||
return Number.isFinite(n1) ? n1 : 0
|
||||
}
|
||||
const n2 = Number(v)
|
||||
return Number.isFinite(n2) ? n2 : 0
|
||||
},
|
||||
async loadUserInfo() {
|
||||
const token = uni.getStorageSync('token')
|
||||
if (!token) {
|
||||
@ -466,36 +531,25 @@ export default {
|
||||
this.nickname = cachedUser.nickname
|
||||
this.avatar = cachedUser.avatar
|
||||
this.inviteCode = cachedUser.invite_code
|
||||
this.pointsBalance = cachedUser.points_balance || 0
|
||||
this.pointsBalance = this.normalizePointsBalance(cachedUser.points_balance)
|
||||
} else if (cachedUserId) {
|
||||
this.userId = cachedUserId
|
||||
}
|
||||
|
||||
if (this.userId) {
|
||||
// 刷新积分余额
|
||||
const balance = await getUserPoints(this.userId, 1, 1).then(res => {
|
||||
// 如果 getUserPoints 返回列表,这里可能拿不到余额,尝试 getPointsBalance
|
||||
// 查看 api/appUser.js, getPointsBalance 存在
|
||||
return getUserPoints(this.userId) // 这里先占位,下面会单独调用
|
||||
}).catch(() => null)
|
||||
|
||||
// 正确获取积分余额
|
||||
try {
|
||||
const balanceRes = await getPointsBalance(this.userId)
|
||||
if (balanceRes !== undefined) {
|
||||
this.pointsBalance = balanceRes
|
||||
}
|
||||
} catch (e) { console.error('Get points balance failed', e) }
|
||||
|
||||
// 刷新统计数据
|
||||
const s = await getUserStats(this.userId)
|
||||
if(s) this.stats = { ...this.stats, ...s }
|
||||
|
||||
// 更新缓存中的积分
|
||||
if (cachedUser) {
|
||||
try {
|
||||
const balanceRes = await getPointsBalance(this.userId)
|
||||
if (balanceRes !== undefined) {
|
||||
this.pointsBalance = this.normalizePointsBalance(balanceRes)
|
||||
if (cachedUser) {
|
||||
cachedUser.points_balance = this.pointsBalance
|
||||
uni.setStorageSync('user_info', cachedUser)
|
||||
}
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
const s = await getUserStats(this.userId)
|
||||
if (s) this.stats = { ...this.stats, ...s }
|
||||
} else {
|
||||
// 如果没有 userId,尝试调用 getUserInfo (即使可能失败)
|
||||
const res = await getUserInfo()
|
||||
@ -504,7 +558,7 @@ export default {
|
||||
this.nickname = res.nickname
|
||||
this.avatar = res.avatar
|
||||
this.inviteCode = res.invite_code
|
||||
this.pointsBalance = res.points_balance || 0
|
||||
this.pointsBalance = this.normalizePointsBalance(res.points_balance)
|
||||
uni.setStorageSync('user_info', res)
|
||||
uni.setStorageSync('user_id', res.id)
|
||||
|
||||
@ -538,18 +592,64 @@ export default {
|
||||
uni.showToast({ title: '功能开发中', icon: 'none' })
|
||||
},
|
||||
handleInvite() {
|
||||
// Show share menu or copy code
|
||||
const code = this.inviteCode || '无'
|
||||
const code = this.getInviteCode()
|
||||
const path = this.getInviteSharePath()
|
||||
|
||||
try { if (code) uni.setStorageSync('inviter_code', code) } catch (_) {}
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
try { uni.showShareMenu({ withShareTicket: true }) } catch (_) {}
|
||||
uni.showModal({
|
||||
title: '邀请好友',
|
||||
content: `您的邀请码是:${code}\n快去分享给好友吧!`,
|
||||
confirmText: '复制邀请码',
|
||||
content: '请点击「立即邀请」进行分享。',
|
||||
showCancel: true,
|
||||
cancelText: '复制链接',
|
||||
confirmText: '知道了',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
uni.setClipboardData({ data: code })
|
||||
if (res.cancel) {
|
||||
const data = path
|
||||
uni.setClipboardData({ data })
|
||||
}
|
||||
}
|
||||
})
|
||||
return
|
||||
// #endif
|
||||
|
||||
// #ifdef APP-PLUS
|
||||
if (typeof uni.share === 'function') {
|
||||
const summary = code ? `给你一个宝藏应用,快来!邀请码:${code}` : '给你一个宝藏应用,快来!'
|
||||
uni.share({
|
||||
provider: 'weixin',
|
||||
scene: 'WXSceneSession',
|
||||
type: 1,
|
||||
summary,
|
||||
fail: () => {
|
||||
uni.setClipboardData({ data: path })
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
// #endif
|
||||
|
||||
// #ifdef H5
|
||||
const url = `${location.origin}${location.pathname}#${path}`
|
||||
const text = '给你一个宝藏应用,快来!'
|
||||
if (typeof navigator !== 'undefined' && navigator.share) {
|
||||
navigator.share({ title: text, text, url }).catch(() => {
|
||||
uni.setClipboardData({ data: url })
|
||||
})
|
||||
} else {
|
||||
uni.setClipboardData({ data: url })
|
||||
}
|
||||
// #endif
|
||||
|
||||
// #ifndef MP-WEIXIN
|
||||
// #ifndef APP-PLUS
|
||||
// #ifndef H5
|
||||
uni.setClipboardData({ data: path })
|
||||
// #endif
|
||||
// #endif
|
||||
// #endif
|
||||
},
|
||||
|
||||
// --- Points Logic ---
|
||||
@ -954,6 +1054,17 @@ export default {
|
||||
display: flex; align-items: center;
|
||||
box-shadow: 0 4rpx 12rpx rgba($brand-primary, 0.2);
|
||||
}
|
||||
.invite-share-btn {
|
||||
line-height: 1;
|
||||
margin: 0;
|
||||
}
|
||||
.invite-share-btn::after { border: none; }
|
||||
.invite-share-icon {
|
||||
width: 30rpx;
|
||||
height: 30rpx;
|
||||
margin-right: 10rpx;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
.invite-arrow { font-size: 28rpx; margin-left: 4rpx; line-height: 1; }
|
||||
.invite-bg-icon {
|
||||
position: absolute; right: -20rpx; bottom: -20rpx;
|
||||
|
||||
@ -176,7 +176,7 @@ onReachBottom(() => {
|
||||
|
||||
<style lang="scss" scoped>
|
||||
/* ============================================
|
||||
奇盒潮玩 - 订单页面
|
||||
柯大鸭潮玩 - 订单页面
|
||||
采用暖橙色调的订单列表设计
|
||||
============================================ */
|
||||
|
||||
|
||||
@ -4,6 +4,11 @@
|
||||
<view class="title">注册新账号</view>
|
||||
|
||||
<view class="form">
|
||||
<view class="input-row">
|
||||
<text class="label">邀请码</text>
|
||||
<input type="text" v-model="inviteCode" class="input-field" placeholder="请输入邀请码" />
|
||||
</view>
|
||||
|
||||
<view class="input-row">
|
||||
<text class="label">账号</text>
|
||||
<input type="text" v-model="account" class="input-field" placeholder="请输入账号" />
|
||||
@ -32,13 +37,24 @@
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
|
||||
const account = ref('')
|
||||
const password = ref('')
|
||||
const confirmPassword = ref('')
|
||||
const inviteCode = ref('')
|
||||
const loading = ref(false)
|
||||
const error = ref('')
|
||||
|
||||
onLoad((opts) => {
|
||||
const code = (opts && (opts.invite_code || opts.inviteCode)) || ''
|
||||
const v = String(code || uni.getStorageSync('inviter_code') || '').trim()
|
||||
if (v) {
|
||||
inviteCode.value = v
|
||||
try { uni.setStorageSync('inviter_code', v) } catch (_) {}
|
||||
}
|
||||
})
|
||||
|
||||
function goLogin() {
|
||||
uni.navigateBack()
|
||||
}
|
||||
@ -59,7 +75,7 @@ function onRegister() {
|
||||
|
||||
<style scoped>
|
||||
/* ============================================
|
||||
奇盒潮玩 - 注册页面
|
||||
柯大鸭潮玩 - 注册页面
|
||||
============================================ */
|
||||
|
||||
.container {
|
||||
|
||||
@ -51,7 +51,7 @@ onLoad((opts) => {
|
||||
|
||||
<style lang="scss" scoped>
|
||||
/* ============================================
|
||||
奇盒潮玩 - 商品详情页
|
||||
柯大鸭潮玩 - 商品详情页
|
||||
============================================ */
|
||||
|
||||
.page {
|
||||
|
||||
@ -212,7 +212,7 @@ import { onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
|
||||
onShareAppMessage(() => {
|
||||
const inviteCode = uni.getStorageSync('invite_code') || (uni.getStorageSync('user_info') || {}).invite_code || ''
|
||||
return {
|
||||
title: '奇盒潮玩商城 - 好物等你来兑',
|
||||
title: '柯大鸭潮玩商城 - 好物等你来兑',
|
||||
path: `/pages/index/index?invite_code=${inviteCode}`,
|
||||
imageUrl: '/static/logo.png'
|
||||
}
|
||||
@ -221,7 +221,7 @@ onShareAppMessage(() => {
|
||||
onShareTimeline(() => {
|
||||
const inviteCode = uni.getStorageSync('invite_code') || (uni.getStorageSync('user_info') || {}).invite_code || ''
|
||||
return {
|
||||
title: '奇盒潮玩商城 - 好物等你来兑',
|
||||
title: '柯大鸭潮玩商城 - 好物等你来兑',
|
||||
query: `invite_code=${inviteCode}`,
|
||||
imageUrl: '/static/logo.png'
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user