bind.vue 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <view class="bind-page">
  3. <view class="form-card">
  4. <text class="form-title">输入推荐人邀请码</text>
  5. <text class="form-desc">由好友分享给你的专属邀请码(6 位字母数字),可在好友的海报页复制</text>
  6. <input
  7. class="code-input"
  8. v-model="referralCode"
  9. placeholder="请输入邀请码"
  10. placeholder-class="code-placeholder"
  11. maxlength="16"
  12. :disabled="binding"
  13. />
  14. <button class="bind-btn" @click="submitBind" :loading="binding" :disabled="binding || !referralCode.trim()">
  15. {{ binding ? '绑定中…' : '确认绑定' }}
  16. </button>
  17. </view>
  18. <view class="tip-card">
  19. <text class="tip-title">绑定说明</text>
  20. <text class="tip-desc">1. 绑定后推荐关系立即生效,与报名时填写邀请码效果一致</text>
  21. <text class="tip-desc">2. 每位用户仅可绑定一次,绑定后不可修改</text>
  22. <text class="tip-desc">3. 不能填写自己的邀请码</text>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import { bindReferrer } from '@/utils/api.js'
  28. import { guardPage } from '@/utils/guard.js'
  29. export default {
  30. data() {
  31. return {
  32. referralCode: '',
  33. binding: false
  34. }
  35. },
  36. onLoad() {
  37. if (!guardPage()) return
  38. },
  39. methods: {
  40. submitBind() {
  41. var self = this
  42. var code = this.referralCode ? this.referralCode.trim() : ''
  43. if (!code) {
  44. uni.showToast({ title: '请输入邀请码', icon: 'none' })
  45. return
  46. }
  47. if (this.binding) return
  48. this.binding = true
  49. bindReferrer(code).then(function() {
  50. uni.showToast({ title: '绑定成功', icon: 'success' })
  51. setTimeout(function() {
  52. uni.navigateBack({})
  53. }, 800)
  54. }).catch(function() {
  55. // 业务错误已由全局请求层 toast
  56. }).then(function() {
  57. self.binding = false
  58. })
  59. }
  60. }
  61. }
  62. </script>
  63. <style scoped>
  64. .bind-page { min-height: 100vh; background: #F5F5F5; padding: 24rpx 32rpx; }
  65. .form-card { background: #FFF; border-radius: 16rpx; padding: 32rpx; margin-bottom: 24rpx; }
  66. .form-title { display: block; font-size: 30rpx; font-weight: 700; color: #2A2326; margin-bottom: 12rpx; }
  67. .form-desc { display: block; font-size: 24rpx; color: #5A4F4B; line-height: 40rpx; margin-bottom: 24rpx; }
  68. .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; }
  69. .code-placeholder { font-size: 28rpx; color: #94877F; letter-spacing: 0; }
  70. .bind-btn { width: 100%; height: 88rpx; line-height: 88rpx; background: #FC7A57; color: #FFF; font-size: 30rpx; font-weight: 600; border-radius: 44rpx; border: none; }
  71. .bind-btn:active { opacity: 0.85; }
  72. .bind-btn[disabled] { background: #FDBA74; color: #FFF; }
  73. .tip-card { background: #FFF; border-radius: 16rpx; padding: 32rpx; }
  74. .tip-title { display: block; font-size: 30rpx; font-weight: 700; color: #2A2326; margin-bottom: 16rpx; border-left: 8rpx solid #FC7A57; padding-left: 16rpx; }
  75. .tip-desc { display: block; font-size: 26rpx; color: #475569; line-height: 48rpx; }
  76. </style>