| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <template>
- <view class="bind-page">
- <view class="form-card">
- <text class="form-title">输入推荐人邀请码</text>
- <text class="form-desc">由好友分享给你的专属邀请码(6 位字母数字),可在好友的海报页复制</text>
- <input
- class="code-input"
- v-model="referralCode"
- placeholder="请输入邀请码"
- placeholder-class="code-placeholder"
- maxlength="16"
- :disabled="binding"
- />
- <button class="bind-btn" @click="submitBind" :loading="binding" :disabled="binding || !referralCode.trim()">
- {{ binding ? '绑定中…' : '确认绑定' }}
- </button>
- </view>
- <view class="tip-card">
- <text class="tip-title">绑定说明</text>
- <text class="tip-desc">1. 绑定后推荐关系立即生效,与报名时填写邀请码效果一致</text>
- <text class="tip-desc">2. 每位用户仅可绑定一次,绑定后不可修改</text>
- <text class="tip-desc">3. 不能填写自己的邀请码</text>
- </view>
- </view>
- </template>
- <script>
- import { bindReferrer } from '@/utils/api.js'
- import { guardPage } from '@/utils/guard.js'
- export default {
- data() {
- return {
- referralCode: '',
- binding: false
- }
- },
- onLoad() {
- if (!guardPage()) return
- },
- methods: {
- submitBind() {
- var self = this
- var code = this.referralCode ? this.referralCode.trim() : ''
- if (!code) {
- uni.showToast({ title: '请输入邀请码', icon: 'none' })
- return
- }
- if (this.binding) return
- this.binding = true
- bindReferrer(code).then(function() {
- uni.showToast({ title: '绑定成功', icon: 'success' })
- setTimeout(function() {
- uni.navigateBack({})
- }, 800)
- }).catch(function() {
- // 业务错误已由全局请求层 toast
- }).then(function() {
- self.binding = false
- })
- }
- }
- }
- </script>
- <style scoped>
- .bind-page { min-height: 100vh; background: #F5F5F5; padding: 24rpx 32rpx; }
- .form-card { background: #FFF; border-radius: 16rpx; padding: 32rpx; margin-bottom: 24rpx; }
- .form-title { display: block; font-size: 30rpx; font-weight: 700; color: #2A2326; margin-bottom: 12rpx; }
- .form-desc { display: block; font-size: 24rpx; color: #5A4F4B; line-height: 40rpx; margin-bottom: 24rpx; }
- .code-input { height: 88rpx; border: 2rpx solid #E2E8F0; border-radius: 12rpx; padding: 0 24rpx; font-size: 32rpx; color: #2A2326; font-family: monospace; letter-spacing: 4rpx; margin-bottom: 24rpx; background: #FAFAFA; }
- .code-placeholder { font-size: 28rpx; color: #94877F; letter-spacing: 0; }
- .bind-btn { width: 100%; height: 88rpx; line-height: 88rpx; background: #FC7A57; color: #FFF; font-size: 30rpx; font-weight: 600; border-radius: 44rpx; border: none; }
- .bind-btn:active { opacity: 0.85; }
- .bind-btn[disabled] { background: #FDBA74; color: #FFF; }
- .tip-card { background: #FFF; border-radius: 16rpx; padding: 32rpx; }
- .tip-title { display: block; font-size: 30rpx; font-weight: 700; color: #2A2326; margin-bottom: 16rpx; border-left: 8rpx solid #FC7A57; padding-left: 16rpx; }
- .tip-desc { display: block; font-size: 26rpx; color: #475569; line-height: 48rpx; }
- </style>
|