|
|
@@ -6,7 +6,7 @@
|
|
|
<text class="loading-text">加载中...</text>
|
|
|
</view>
|
|
|
|
|
|
- <!-- 邀请信息卡片 -->
|
|
|
+ <!-- 邀请信息卡片(仅用于展示,不做交互) -->
|
|
|
<view class="invite-card" v-if="!loading && inviteInfo">
|
|
|
<view class="invite-header">
|
|
|
<view class="invite-icon">🏠</view>
|
|
|
@@ -28,79 +28,16 @@
|
|
|
</text>
|
|
|
</view>
|
|
|
|
|
|
- <!-- 未登录:显示登录按钮 -->
|
|
|
- <view class="action-area" v-if="!isLoggedIn">
|
|
|
- <button class="btn btn-primary" @tap="handleWechatLogin" :disabled="loginLoading">
|
|
|
- <text v-if="!loginLoading">微信一键登录并加入家庭</text>
|
|
|
- <text v-else>登录中...</text>
|
|
|
+ <view class="action-area">
|
|
|
+ <text class="tip-text">{{ tipText }}</text>
|
|
|
+ <button class="btn btn-primary" @tap="goNext" :disabled="redirecting">
|
|
|
+ <text v-if="!redirecting">{{ btnText }}</text>
|
|
|
+ <text v-else>跳转中...</text>
|
|
|
</button>
|
|
|
- <text class="tip-text">登录后即可申请加入此家庭</text>
|
|
|
- </view>
|
|
|
-
|
|
|
- <!-- 已登录:显示关系选择 -->
|
|
|
- <view class="action-area" v-if="isLoggedIn && !accepted && !requestSubmitted">
|
|
|
- <!-- 已有家庭时显示合并选项 -->
|
|
|
- <view class="family-warning" v-if="familyStatus && familyStatus.inFamily">
|
|
|
- <text class="warning-icon">⚠️</text>
|
|
|
- <text class="warning-text">
|
|
|
- 您当前已加入「{{ familyStatus.familyName }}」家庭,加入新家庭可选择合并(成员将一起迁移)或拒绝
|
|
|
- </text>
|
|
|
- </view>
|
|
|
-
|
|
|
- <!-- 关系选择 -->
|
|
|
- <view class="form-group">
|
|
|
- <text class="form-label">您在家庭中的身份</text>
|
|
|
- <picker @change="onFamilyRoleChange" :value="familyRoleIndex" :range="familyRoleOptions">
|
|
|
- <view class="picker-select">
|
|
|
- <text>{{ familyRoleOptions[familyRoleIndex] || '请选择您的身份' }}</text>
|
|
|
- <text class="picker-arrow">›</text>
|
|
|
- </view>
|
|
|
- </picker>
|
|
|
- </view>
|
|
|
-
|
|
|
- <!-- 已有家庭时显示合并勾选框 -->
|
|
|
- <view class="form-group" v-if="familyStatus && familyStatus.inFamily">
|
|
|
- <label class="checkbox-label" @tap="toggleMerge">
|
|
|
- <view class="checkbox" :class="{ checked: mergeFamily }">
|
|
|
- <text v-if="mergeFamily">✓</text>
|
|
|
- </view>
|
|
|
- <text>合并家庭(我的家庭成员将一起迁入新家庭)</text>
|
|
|
- </label>
|
|
|
- </view>
|
|
|
-
|
|
|
- <button class="btn btn-primary" @tap="handleSubmitRequest" :disabled="acceptLoading">
|
|
|
- <text v-if="!acceptLoading">提交申请</text>
|
|
|
- <text v-else>提交中...</text>
|
|
|
- </button>
|
|
|
- </view>
|
|
|
-
|
|
|
- <!-- 已提交申请,等待审批 -->
|
|
|
- <view class="pending-card" v-if="requestSubmitted && !accepted">
|
|
|
- <view class="pending-icon">🕐</view>
|
|
|
- <text class="pending-title">申请已提交</text>
|
|
|
- <text class="pending-text">等待邀请人确认</text>
|
|
|
- <text class="pending-hint">通常几分钟内会有回复</text>
|
|
|
- <button class="btn btn-outline btn-cancel-request" @tap="onCancelRequest">取消申请</button>
|
|
|
- </view>
|
|
|
-
|
|
|
- <!-- 申请被拒绝 -->
|
|
|
- <view class="error-area" v-if="requestSubmitted && requestStatus === 'rejected'">
|
|
|
- <view class="error-icon">❌</view>
|
|
|
- <text class="error-text-main">申请已被拒绝</text>
|
|
|
- <text class="error-text-sub" v-if="rejectMessage">{{ rejectMessage }}</text>
|
|
|
- <button class="btn btn-outline" @tap="goHome">返回首页</button>
|
|
|
- </view>
|
|
|
-
|
|
|
- <!-- 加入成功 -->
|
|
|
- <view class="success-area" v-if="accepted">
|
|
|
- <view class="success-icon">✅</view>
|
|
|
- <text class="success-text">加入成功!</text>
|
|
|
- <text class="success-sub">欢迎加入「{{ inviteInfo.familyName }}」</text>
|
|
|
- <button class="btn btn-primary" @tap="goHome">进入首页</button>
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
- <!-- 推广码绑定卡片 -->
|
|
|
+ <!-- 推广码绑定卡片(兼容旧链接) -->
|
|
|
<view class="invite-card" v-if="!loading && refCode && !bindDone">
|
|
|
<view class="invite-header">
|
|
|
<view class="invite-icon">🤝</view>
|
|
|
@@ -117,7 +54,7 @@
|
|
|
<text class="tip-text">绑定后该推荐人后续消费时记入其家庭公共账户</text>
|
|
|
</view>
|
|
|
<view class="action-area" v-else>
|
|
|
- <button class="btn btn-primary" @tap="handleWechatLogin" :disabled="loginLoading">
|
|
|
+ <button class="btn btn-primary" @tap="goLoginWithRef" :disabled="loginLoading">
|
|
|
<text v-if="!loginLoading">微信一键登录</text>
|
|
|
<text v-else>登录中...</text>
|
|
|
</button>
|
|
|
@@ -145,341 +82,197 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { validateInvitation, checkUserFamily, bindReferral, requestJoinByCode, getMyPendingRequest, cancelMyJoinRequest } from '@/utils/api.js'
|
|
|
+import { validateInvitation, validateFamilyCode, checkUserFamily, bindReferral } from '@/utils/api.js'
|
|
|
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
- token: '',
|
|
|
+ // 家庭邀请码(单一参数)
|
|
|
+ familyInviteCode: '',
|
|
|
+ // 推广码(兼容)
|
|
|
refCode: '',
|
|
|
bindLoading: false,
|
|
|
bindDone: false,
|
|
|
loading: true,
|
|
|
loginLoading: false,
|
|
|
- acceptLoading: false,
|
|
|
+ redirecting: false,
|
|
|
isLoggedIn: false,
|
|
|
inviteInfo: null,
|
|
|
familyStatus: null,
|
|
|
- familyRoleIndex: 0,
|
|
|
- mergeFamily: false,
|
|
|
- accepted: false,
|
|
|
- requestSubmitted: false,
|
|
|
- requestStatus: '',
|
|
|
- requestId: null,
|
|
|
- requestTimer: null,
|
|
|
- rejectMessage: '',
|
|
|
error: '',
|
|
|
- familyRoleOptions: ['爸爸', '妈妈', '爷爷', '奶奶', '姥爷', '姥姥', '其他']
|
|
|
+ // 动态文案
|
|
|
+ tipText: '',
|
|
|
+ btnText: ''
|
|
|
}
|
|
|
},
|
|
|
onLoad(query) {
|
|
|
- // 邀请码(推荐人)统一解析:query.inviteCode / query.refCode / 场景值 ref=xxx
|
|
|
- // 分享链接用 inviteCode,落地页内部用 refCode,二维码场景值用 ref= 前缀
|
|
|
- var refCode = query.refCode || query.inviteCode || ''
|
|
|
- if (!refCode && query.scene) {
|
|
|
- var refScene = decodeURIComponent(query.scene)
|
|
|
- if (refScene.indexOf('ref=') === 0) {
|
|
|
- refCode = refScene.substring(4)
|
|
|
+ query = query || {}
|
|
|
+
|
|
|
+ // 1. 解析家庭邀请码(单一参数,兼容 inviteCode/familyInviteCode)
|
|
|
+ var familyInviteCode = query.familyInviteCode || query.inviteCode || ''
|
|
|
+ if (!familyInviteCode && query.scene) {
|
|
|
+ var sceneDecoded = decodeURIComponent(query.scene)
|
|
|
+ // 支持 scene=fam_xxx 或 ref=xxx 格式
|
|
|
+ if (sceneDecoded.indexOf('fam_') === 0) {
|
|
|
+ familyInviteCode = sceneDecoded
|
|
|
+ } else if (sceneDecoded.indexOf('ref=') === 0) {
|
|
|
+ // ref=xxx 归为推广码
|
|
|
+ } else if (sceneDecoded.length >= 6) {
|
|
|
+ // 兜底:长度>=6 视为家庭邀请码
|
|
|
+ familyInviteCode = familyInviteCode || sceneDecoded
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // token(家庭邀请):优先从 query 参数,其次从场景值
|
|
|
- var token = query.token || query.inviteToken || ''
|
|
|
- if (!token) {
|
|
|
- var scene = query.scene
|
|
|
- if (scene) {
|
|
|
- var sceneDecoded = decodeURIComponent(scene)
|
|
|
- // 新格式:JSON 场景值 {"t":"TOKEN"}
|
|
|
- if (sceneDecoded.indexOf('{') === 0) {
|
|
|
- try {
|
|
|
- var sceneObj = JSON.parse(sceneDecoded)
|
|
|
- token = sceneObj.t || sceneObj.token || ''
|
|
|
- } catch (e) {
|
|
|
- token = ''
|
|
|
- }
|
|
|
- } else if (sceneDecoded.indexOf('invite=') === 0) {
|
|
|
- // 旧格式兼容
|
|
|
- token = sceneDecoded.substring(7)
|
|
|
- } else if (sceneDecoded.indexOf('ref=') === 0) {
|
|
|
- // 推广码场景值(ref=xxx),已在上方解析为 refCode,不作为 token
|
|
|
- token = ''
|
|
|
- } else if (sceneDecoded.length === 6) {
|
|
|
- // 裸邀请码场景值(InviteController 生成的二维码 scene=referralCode,6位)
|
|
|
- // 归为推广码,不作为家庭 token
|
|
|
- refCode = refCode || sceneDecoded
|
|
|
- token = ''
|
|
|
- } else {
|
|
|
- token = sceneDecoded
|
|
|
- }
|
|
|
+ // 2. 解析推广码(兼容旧链接)
|
|
|
+ var refCode = query.refCode || ''
|
|
|
+ if (!refCode && query.scene) {
|
|
|
+ var sceneDecoded = decodeURIComponent(query.scene)
|
|
|
+ if (sceneDecoded.indexOf('ref=') === 0) {
|
|
|
+ refCode = sceneDecoded.substring(4)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (!token && !refCode) {
|
|
|
- // 兼容旧分享链接(promotion/index.vue 旧版 onShareAppMessage 不带参数)
|
|
|
- // 无有效邀请信息时跳转首页,不显示"邀请链接无效"死页面
|
|
|
+ // 3. 无任何有效参数 -> 首页
|
|
|
+ if (!familyInviteCode && !refCode) {
|
|
|
uni.reLaunch({ url: '/pages/index-home/index' })
|
|
|
return
|
|
|
}
|
|
|
- if (refCode) {
|
|
|
- // 推广码模式:仅存储 refCode,无需校验邀请
|
|
|
- this.refCode = refCode
|
|
|
- this.loading = false
|
|
|
- this.checkLoginStatus()
|
|
|
+
|
|
|
+ // 4. 有家庭邀请码 -> 存储并校验
|
|
|
+ if (familyInviteCode) {
|
|
|
+ this.familyInviteCode = familyInviteCode
|
|
|
+ // 存入本地,供登录页/个人信息页使用
|
|
|
+ uni.setStorageSync('pendingFamilyInviteCode', familyInviteCode)
|
|
|
+ this.validateFamilyInvite(familyInviteCode)
|
|
|
return
|
|
|
}
|
|
|
- this.token = token
|
|
|
+
|
|
|
+ // 5. 仅有推广码 -> 走原有推广绑定流程
|
|
|
+ this.refCode = refCode
|
|
|
+ this.loading = false
|
|
|
this.checkLoginStatus()
|
|
|
- this.validateToken()
|
|
|
},
|
|
|
onShow() {
|
|
|
- // 从登录页返回时重新检查登录状态
|
|
|
- if (this.token) {
|
|
|
+ // 从登录页返回,重新检查
|
|
|
+ if (this.familyInviteCode) {
|
|
|
this.checkLoginStatus()
|
|
|
if (!this.inviteInfo) {
|
|
|
- this.validateToken()
|
|
|
+ this.validateFamilyInvite(this.familyInviteCode)
|
|
|
}
|
|
|
- }
|
|
|
- },
|
|
|
- onUnload() {
|
|
|
- if (this.requestTimer) {
|
|
|
- clearInterval(this.requestTimer)
|
|
|
- this.requestTimer = null
|
|
|
+ } else if (this.refCode) {
|
|
|
+ this.checkLoginStatus()
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
checkLoginStatus() {
|
|
|
var token = uni.getStorageSync('token')
|
|
|
this.isLoggedIn = !!token
|
|
|
- if (this.isLoggedIn) {
|
|
|
- this.checkFamily()
|
|
|
- }
|
|
|
},
|
|
|
- async validateToken() {
|
|
|
+
|
|
|
+ // 校验家庭邀请码有效性(仅获取家庭信息用于展示)
|
|
|
+ async validateFamilyInvite(code) {
|
|
|
this.loading = true
|
|
|
try {
|
|
|
- var res = await validateInvitation(this.token)
|
|
|
- if (res && res.data) {
|
|
|
+ var res = await validateFamilyCode(code)
|
|
|
+ if (res && res.code === 200) {
|
|
|
this.inviteInfo = res.data
|
|
|
- // 已登录用户进入落地页:回显已有的待确认申请(避免重复显示提交表单)
|
|
|
+ // 已登录用户:检查是否已在目标家庭
|
|
|
if (this.isLoggedIn) {
|
|
|
- this.checkExistingRequest()
|
|
|
+ await this.checkFamilyAndRedirect()
|
|
|
+ } else {
|
|
|
+ // 未登录:设置文案引导去登录
|
|
|
+ this.setRedirectInfo(false)
|
|
|
+ this.loading = false
|
|
|
}
|
|
|
} else {
|
|
|
this.error = '邀请已失效'
|
|
|
+ this.loading = false
|
|
|
}
|
|
|
} catch (e) {
|
|
|
this.error = e.message || '邀请验证失败'
|
|
|
+ this.loading = false
|
|
|
}
|
|
|
- this.loading = false
|
|
|
},
|
|
|
- async checkFamily() {
|
|
|
+
|
|
|
+ // 检查家庭状态并决定跳转
|
|
|
+ async checkFamilyAndRedirect() {
|
|
|
try {
|
|
|
var res = await checkUserFamily()
|
|
|
if (res && res.data) {
|
|
|
this.familyStatus = res.data
|
|
|
- // 已在家庭内:同步 familyId 到 store(hasFamily getter 依赖)
|
|
|
+ // 同步 familyId
|
|
|
if (res.data.inFamily && res.data.familyId) {
|
|
|
this.$store && this.$store.commit('setFamilyId', res.data.familyId)
|
|
|
uni.setStorageSync('familyId', res.data.familyId)
|
|
|
}
|
|
|
- // 如果已经在目标家庭,直接显示成功
|
|
|
- if (this.inviteInfo && this.familyStatus.inFamily && this.familyStatus.familyId === this.inviteInfo.familyId) {
|
|
|
- this.accepted = true
|
|
|
- } else if (!this.familyStatus.inFamily && this.inviteInfo) {
|
|
|
- // 已登录且不在目标家庭:回显已有申请状态,避免重复显示提交表单
|
|
|
- this.checkExistingRequest()
|
|
|
+ // 已在目标家庭 -> 直接进首页
|
|
|
+ if (this.inviteInfo && this.familyStatus.inFamily &&
|
|
|
+ this.familyStatus.familyId === this.inviteInfo.familyId) {
|
|
|
+ this.setRedirectInfo(true)
|
|
|
+ this.loading = false
|
|
|
+ // 延迟跳转,让用户看到成功提示
|
|
|
+ setTimeout(() => this.goHome(), 1000)
|
|
|
+ return
|
|
|
}
|
|
|
+ // 不在目标家庭 -> 去完善个人信息页提交申请
|
|
|
+ this.setRedirectInfo(false)
|
|
|
+ this.loading = false
|
|
|
+ } else {
|
|
|
+ this.setRedirectInfo(false)
|
|
|
+ this.loading = false
|
|
|
}
|
|
|
} catch (e) {
|
|
|
console.log('检查家庭状态失败', e)
|
|
|
+ this.setRedirectInfo(false)
|
|
|
+ this.loading = false
|
|
|
}
|
|
|
},
|
|
|
- async handleWechatLogin() {
|
|
|
- this.loginLoading = true
|
|
|
- try {
|
|
|
- var that = this
|
|
|
- // 微信登录
|
|
|
- var loginRes = await new Promise(function(resolve, reject) {
|
|
|
- uni.login({
|
|
|
- provider: 'weixin',
|
|
|
- success: function(res) {
|
|
|
- resolve(res)
|
|
|
- },
|
|
|
- fail: function(err) {
|
|
|
- reject(err)
|
|
|
- }
|
|
|
- })
|
|
|
- })
|
|
|
-
|
|
|
- var code = loginRes.code
|
|
|
- if (!code) {
|
|
|
- uni.showToast({ title: '登录失败', icon: 'none' })
|
|
|
- this.loginLoading = false
|
|
|
- return
|
|
|
- }
|
|
|
|
|
|
- // 调起微信登录
|
|
|
- var { wechatLogin } = require('@/utils/api.js')
|
|
|
- var res = await wechatLogin(code, {})
|
|
|
- if (res && res.data) {
|
|
|
- // 保存登录信息
|
|
|
- var data = res.data
|
|
|
- uni.setStorageSync('token', data.token)
|
|
|
- uni.setStorageSync('userId', data.userId)
|
|
|
- uni.setStorageSync('role', data.role)
|
|
|
- uni.setStorageSync('currentRole', data.role)
|
|
|
- uni.setStorageSync('isSwitchedChild', false)
|
|
|
- uni.setStorageSync('isSwitchedTeacher', false)
|
|
|
- if (data.openid) {
|
|
|
- uni.setStorageSync('openid', data.openid)
|
|
|
- }
|
|
|
- that.$store && that.$store.commit('setToken', data.token)
|
|
|
- that.$store && that.$store.commit('setFamilyId', data.familyId)
|
|
|
-
|
|
|
- this.isLoggedIn = true
|
|
|
- uni.showToast({ title: '登录成功', icon: 'success' })
|
|
|
- // 兼容旧分享链接:登录成功后自动绑定推广码(与 login.vue 流程一致)
|
|
|
- if (this.refCode && !this.bindDone) {
|
|
|
- await this.bindRef()
|
|
|
- }
|
|
|
- // 重新检查家庭状态
|
|
|
- await this.checkFamily()
|
|
|
- }
|
|
|
- } catch (e) {
|
|
|
- uni.showToast({ title: '登录失败', icon: 'none' })
|
|
|
- console.log('微信登录失败', e)
|
|
|
+ setRedirectInfo(isInTargetFamily) {
|
|
|
+ if (isInTargetFamily) {
|
|
|
+ this.tipText = '您已是该家庭成员'
|
|
|
+ this.btnText = '进入首页'
|
|
|
+ } else {
|
|
|
+ this.tipText = '完善个人信息后将自动提交加入申请'
|
|
|
+ this.btnText = '去完善信息'
|
|
|
}
|
|
|
- this.loginLoading = false
|
|
|
- },
|
|
|
- onFamilyRoleChange(e) {
|
|
|
- this.familyRoleIndex = e.detail.value
|
|
|
- },
|
|
|
- toggleMerge() {
|
|
|
- this.mergeFamily = !this.mergeFamily
|
|
|
},
|
|
|
- async handleSubmitRequest() {
|
|
|
- var familyRole = this.familyRoleOptions[this.familyRoleIndex] || ''
|
|
|
- if (!familyRole) {
|
|
|
- uni.showToast({ title: '请选择您在家庭中的身份', icon: 'none' })
|
|
|
- return
|
|
|
- }
|
|
|
|
|
|
- this.acceptLoading = true
|
|
|
- try {
|
|
|
- var res = await requestJoinByCode(this.token, familyRole)
|
|
|
- if (res && res.code === 200) {
|
|
|
- this.requestSubmitted = true
|
|
|
- this.requestStatus = 'pending'
|
|
|
- this.requestId = (res.data && res.data.id) || null
|
|
|
- this.acceptLoading = false
|
|
|
- uni.showToast({ title: '申请已提交,等待邀请人确认', icon: 'success' })
|
|
|
- this.startPolling()
|
|
|
- } else {
|
|
|
- this.acceptLoading = false
|
|
|
- uni.showToast({ title: res.message || '提交失败', icon: 'none' })
|
|
|
- }
|
|
|
- } catch (e) {
|
|
|
- this.acceptLoading = false
|
|
|
- uni.showToast({ title: e.message || '提交失败', icon: 'none' })
|
|
|
- }
|
|
|
- },
|
|
|
- startPolling() {
|
|
|
- var self = this
|
|
|
- if (this.requestTimer) {
|
|
|
- clearInterval(this.requestTimer)
|
|
|
- }
|
|
|
- this.requestTimer = setInterval(function() {
|
|
|
- if (self.accepted || self.requestStatus === 'rejected') {
|
|
|
- clearInterval(self.requestTimer)
|
|
|
- self.requestTimer = null
|
|
|
- return
|
|
|
- }
|
|
|
- self.checkRequestStatus()
|
|
|
- }, 5000)
|
|
|
- },
|
|
|
- async checkRequestStatus() {
|
|
|
- try {
|
|
|
- var res = await getMyPendingRequest()
|
|
|
- if (res && res.code === 200 && res.data) {
|
|
|
- var requestData = res.data
|
|
|
- this.requestId = requestData.id || this.requestId
|
|
|
- this.requestStatus = requestData.status || 'pending'
|
|
|
- if (this.requestStatus === 'approved') {
|
|
|
- clearInterval(this.requestTimer)
|
|
|
- this.requestTimer = null
|
|
|
- this.accepted = true
|
|
|
- uni.setStorageSync('familyId', this.inviteInfo.familyId)
|
|
|
- uni.setStorageSync('currentFamilyId', this.inviteInfo.familyId)
|
|
|
- // 审批通过后同步 familyId 到 store(hasFamily getter 依赖)
|
|
|
- this.$store && this.$store.commit('setFamilyId', this.inviteInfo.familyId)
|
|
|
- uni.showToast({ title: '加入家庭成功', icon: 'success' })
|
|
|
- } else if (this.requestStatus === 'rejected') {
|
|
|
- clearInterval(this.requestTimer)
|
|
|
- this.requestTimer = null
|
|
|
- this.rejectMessage = requestData.adminComment || ''
|
|
|
- uni.showToast({ title: '申请已被拒绝', icon: 'none' })
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (e) {
|
|
|
- console.log('轮询请求状态失败', e)
|
|
|
+ // 统一跳转逻辑
|
|
|
+ goNext() {
|
|
|
+ if (this.redirecting) return
|
|
|
+ this.redirecting = true
|
|
|
+
|
|
|
+ if (this.inviteInfo && this.familyStatus && this.familyStatus.inFamily &&
|
|
|
+ this.familyStatus.familyId === this.inviteInfo.familyId) {
|
|
|
+ this.goHome()
|
|
|
+ } else {
|
|
|
+ // 跳转个人信息完善页,带上邀请码参数
|
|
|
+ uni.navigateTo({
|
|
|
+ url: '/pages/user-edit/user-edit?familyInviteCode=' + this.familyInviteCode
|
|
|
+ })
|
|
|
}
|
|
|
},
|
|
|
- async checkExistingRequest() {
|
|
|
- // 回显守卫:仅在已登录、未提交、未成功且不在目标家庭时查询
|
|
|
- if (!this.inviteInfo || this.requestSubmitted || this.accepted) return
|
|
|
- if (this.familyStatus && this.familyStatus.inFamily && this.familyStatus.familyId === this.inviteInfo.familyId) return
|
|
|
- try {
|
|
|
- var res = await getMyPendingRequest()
|
|
|
- if (res && res.code === 200 && res.data && res.data.status === 'pending') {
|
|
|
- var requestData = res.data
|
|
|
- if (requestData.targetFamilyId && requestData.targetFamilyId !== this.inviteInfo.familyId) return
|
|
|
- this.requestId = requestData.id || null
|
|
|
- this.requestSubmitted = true
|
|
|
- this.requestStatus = 'pending'
|
|
|
- this.startPolling()
|
|
|
- }
|
|
|
- } catch (e) {
|
|
|
- console.log('回显加入申请状态失败', e)
|
|
|
- }
|
|
|
+
|
|
|
+ goHome() {
|
|
|
+ uni.reLaunch({ url: '/pages/index-home/index' })
|
|
|
},
|
|
|
- onCancelRequest() {
|
|
|
- var self = this
|
|
|
- uni.showModal({
|
|
|
- title: '取消申请',
|
|
|
- content: '确定取消本次加入申请吗?',
|
|
|
- success: function(mr) {
|
|
|
- if (mr.confirm) {
|
|
|
- self.doCancelRequest()
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
+ // 登录页跳转(带上邀请码)
|
|
|
+ goLogin() {
|
|
|
+ uni.navigateTo({
|
|
|
+ url: '/pages/login/login?familyInviteCode=' + this.familyInviteCode
|
|
|
})
|
|
|
},
|
|
|
- async doCancelRequest() {
|
|
|
- if (!this.requestId) {
|
|
|
- uni.showToast({ title: '未找到申请记录', icon: 'none' })
|
|
|
- return
|
|
|
- }
|
|
|
- try {
|
|
|
- var res = await cancelMyJoinRequest(this.requestId)
|
|
|
- if (res && res.code === 200) {
|
|
|
- if (this.requestTimer) {
|
|
|
- clearInterval(this.requestTimer)
|
|
|
- this.requestTimer = null
|
|
|
- }
|
|
|
- this.requestSubmitted = false
|
|
|
- this.requestStatus = ''
|
|
|
- this.requestId = null
|
|
|
- uni.showToast({ title: '已取消申请', icon: 'success' })
|
|
|
- } else {
|
|
|
- uni.showToast({ title: (res && res.message) || '取消失败', icon: 'none' })
|
|
|
- }
|
|
|
- } catch (e) {
|
|
|
- uni.showToast({ title: e.message || '取消失败', icon: 'none' })
|
|
|
- }
|
|
|
- },
|
|
|
- goHome() {
|
|
|
- uni.reLaunch({ url: '/pages/index-home/index' })
|
|
|
+
|
|
|
+ // 推广码场景:去登录
|
|
|
+ goLoginWithRef() {
|
|
|
+ uni.navigateTo({
|
|
|
+ url: '/pages/login/login?refCode=' + this.refCode
|
|
|
+ })
|
|
|
},
|
|
|
+
|
|
|
+ // 推广码绑定
|
|
|
async bindRef() {
|
|
|
if (!this.refCode) {
|
|
|
uni.showToast({ title: '推广码为空', icon: 'none' })
|
|
|
@@ -537,7 +330,7 @@ export default {
|
|
|
background: #FFFFFF;
|
|
|
border-radius: 24rpx;
|
|
|
padding: 40rpx;
|
|
|
- box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.08);
|
|
|
+ box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 008);
|
|
|
margin-top: 10vh;
|
|
|
}
|
|
|
|
|
|
@@ -599,82 +392,13 @@ export default {
|
|
|
display: flex;
|
|
|
flex-direction: column;
|
|
|
gap: 16rpx;
|
|
|
+ width: 100%;
|
|
|
}
|
|
|
|
|
|
-.family-warning {
|
|
|
- display: flex;
|
|
|
- align-items: flex-start;
|
|
|
- padding: 20rpx;
|
|
|
- background: #FEF3C7;
|
|
|
- border-radius: 12rpx;
|
|
|
- gap: 12rpx;
|
|
|
-}
|
|
|
-
|
|
|
-.warning-icon {
|
|
|
- font-size: 32rpx;
|
|
|
- flex-shrink: 0;
|
|
|
-}
|
|
|
-
|
|
|
-.warning-text {
|
|
|
- font-size: 24rpx;
|
|
|
- color: #92400E;
|
|
|
- line-height: 1.5;
|
|
|
-}
|
|
|
-
|
|
|
-.form-group {
|
|
|
- margin-bottom: 20rpx;
|
|
|
-}
|
|
|
-
|
|
|
-.form-label {
|
|
|
- display: block;
|
|
|
- font-size: 28rpx;
|
|
|
- color: #374151;
|
|
|
- margin-bottom: 12rpx;
|
|
|
- font-weight: 500;
|
|
|
-}
|
|
|
-
|
|
|
-.picker-select {
|
|
|
- display: flex;
|
|
|
- justify-content: space-between;
|
|
|
- align-items: center;
|
|
|
- padding: 24rpx 28rpx;
|
|
|
- background: #F9FAFB;
|
|
|
- border: 2rpx solid #E5E7EB;
|
|
|
- border-radius: 16rpx;
|
|
|
- font-size: 28rpx;
|
|
|
- color: #1E293B;
|
|
|
-}
|
|
|
-
|
|
|
-.picker-arrow {
|
|
|
- font-size: 36rpx;
|
|
|
- color: #9CA3AF;
|
|
|
-}
|
|
|
-
|
|
|
-.checkbox-label {
|
|
|
- display: flex;
|
|
|
- align-items: center;
|
|
|
- gap: 12rpx;
|
|
|
- font-size: 26rpx;
|
|
|
- color: #4B5563;
|
|
|
-}
|
|
|
-
|
|
|
-.checkbox {
|
|
|
- width: 36rpx;
|
|
|
- height: 36rpx;
|
|
|
- border: 2rpx solid #D1D5DB;
|
|
|
- border-radius: 8rpx;
|
|
|
- display: flex;
|
|
|
- align-items: center;
|
|
|
- justify-content: center;
|
|
|
- flex-shrink: 0;
|
|
|
-}
|
|
|
-
|
|
|
-.checkbox.checked {
|
|
|
- background: #F97316;
|
|
|
- border-color: #F97316;
|
|
|
- color: #FFFFFF;
|
|
|
+.tip-text {
|
|
|
font-size: 24rpx;
|
|
|
- font-weight: 700;
|
|
|
+ color: #94A3B8;
|
|
|
+ text-align: center;
|
|
|
}
|
|
|
|
|
|
.btn {
|
|
|
@@ -693,7 +417,7 @@ export default {
|
|
|
}
|
|
|
|
|
|
.btn-primary:disabled {
|
|
|
- opacity: 0.6;
|
|
|
+ opacity: 06;
|
|
|
}
|
|
|
|
|
|
.btn-outline {
|
|
|
@@ -702,12 +426,6 @@ export default {
|
|
|
border: 2rpx solid #F97316;
|
|
|
}
|
|
|
|
|
|
-.tip-text {
|
|
|
- font-size: 24rpx;
|
|
|
- color: #94A3B8;
|
|
|
- text-align: center;
|
|
|
-}
|
|
|
-
|
|
|
.success-area {
|
|
|
display: flex;
|
|
|
flex-direction: column;
|
|
|
@@ -753,58 +471,4 @@ export default {
|
|
|
color: #6B7280;
|
|
|
text-align: center;
|
|
|
}
|
|
|
-
|
|
|
-.pending-card {
|
|
|
- display: flex;
|
|
|
- flex-direction: column;
|
|
|
- align-items: center;
|
|
|
- gap: 12rpx;
|
|
|
- padding: 40rpx;
|
|
|
- background: #FEF3C7;
|
|
|
- border-radius: 20rpx;
|
|
|
- margin-top: 20rpx;
|
|
|
-}
|
|
|
-
|
|
|
-.pending-icon {
|
|
|
- font-size: 72rpx;
|
|
|
-}
|
|
|
-
|
|
|
-.pending-title {
|
|
|
- font-size: 32rpx;
|
|
|
- font-weight: 700;
|
|
|
- color: #92400E;
|
|
|
-}
|
|
|
-
|
|
|
-.pending-text {
|
|
|
- font-size: 28rpx;
|
|
|
- color: #78350F;
|
|
|
-}
|
|
|
-
|
|
|
-.pending-hint {
|
|
|
- font-size: 24rpx;
|
|
|
- color: #A16207;
|
|
|
-}
|
|
|
-
|
|
|
-.error-area {
|
|
|
- display: flex;
|
|
|
- flex-direction: column;
|
|
|
- align-items: center;
|
|
|
- gap: 12rpx;
|
|
|
- padding: 40rpx;
|
|
|
- background: #FEF2F2;
|
|
|
- border-radius: 20rpx;
|
|
|
- margin-top: 20rpx;
|
|
|
-}
|
|
|
-
|
|
|
-.error-text-main {
|
|
|
- font-size: 32rpx;
|
|
|
- font-weight: 700;
|
|
|
- color: #DC2626;
|
|
|
-}
|
|
|
-
|
|
|
-.error-text-sub {
|
|
|
- font-size: 26rpx;
|
|
|
- color: #991B1B;
|
|
|
- margin-bottom: 20rpx;
|
|
|
-}
|
|
|
-</style>
|
|
|
+</style>
|