123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- Page({
- data: {
- inviteCode: '',
- inviteLink: '',
- inviteRewards: {
- directInvite: '50.00',
- teamInvite: '200.00'
- },
- invitedFriends: [],
- inviteStats: {
- totalInvited: 0,
- activeInvited: 0,
- totalReward: '0.00'
- }
- },
- onLoad() {
- this.generateInviteCode()
- this.getInviteStats()
- this.getInvitedFriendsList()
- },
- // 生成邀请码
- generateInviteCode() {
- // 生成一个唯一的邀请码
- const code = 'INV' + Math.random().toString(36).substr(2, 6).toUpperCase()
- const link = `https://yourapp.com/invite?code=${code}`
- this.setData({
- inviteCode: code,
- inviteLink: link
- })
- },
- // 获取邀请统计数据
- getInviteStats() {
- // TODO: 调用后端API获取邀请统计
- this.setData({
- inviteStats: {
- totalInvited: 15,
- activeInvited: 8,
- totalReward: '1280.50'
- }
- })
- },
- // 获取邀请好友列表
- getInvitedFriendsList() {
- // TODO: 调用后端API获取邀请好友列表
- this.setData({
- invitedFriends: [
- {
- id: '1',
- avatarUrl: '/static/images/avatar1.png',
- nickName: '小明',
- registerTime: '2023-09-15',
- status: '已激活',
- reward: '50.00'
- },
- {
- id: '2',
- avatarUrl: '/static/images/avatar2.png',
- nickName: '小红',
- registerTime: '2023-09-16',
- status: '未激活',
- reward: '0.00'
- }
- ]
- })
- },
- // 复制邀请码
- copyInviteCode() {
- wx.setClipboardData({
- data: this.data.inviteCode,
- success: () => {
- wx.showToast({
- title: '邀请码已复制',
- icon: 'success'
- })
- }
- })
- },
- // 复制邀请链接
- copyInviteLink() {
- wx.setClipboardData({
- data: this.data.inviteLink,
- success: () => {
- wx.showToast({
- title: '邀请链接已复制',
- icon: 'success'
- })
- }
- })
- },
- // 分享邀请
- onShareAppMessage() {
- return {
- title: '快来加入我的分销团队,一起赚钱!',
- path: `/pages/index/index?inviteCode=${this.data.inviteCode}`,
- imageUrl: '/static/images/share.jpg'
- }
- },
- // 查看邀请奖励规则
- viewInviteRules() {
- wx.navigateTo({
- url: '/pages/distribution/rules'
- })
- }
- })
|