You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

183 lines
3.7 KiB

  1. <template>
  2. <view class="invitation-container">
  3. <!-- 填写邀请码区域 -->
  4. <view class="invitation-section">
  5. <view class="section-header">
  6. <text class="iconfont icon-invite"></text>
  7. <text class="section-title">填写邀请码</text>
  8. </view>
  9. <view class="section-subtitle">邀请人有且只有一位添加后不可更改</view>
  10. <view class="input-area">
  11. <input type="text" class="invite-input"
  12. :disabled="!!userInfo.inviteCode"
  13. placeholder="请输入邀请码" v-model="inviteCode" />
  14. </view>
  15. <view class="submit-btn"
  16. v-if="userInfo.inviteCode"
  17. style="background-color: #aaa;color: #fff;"
  18. >已绑定</view>
  19. <view class="submit-btn"
  20. v-else
  21. @click="submitInviteCode">立即绑定</view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. import { bindCode } from '@/api/order/order.js'
  27. import {
  28. getOpenIdKey
  29. } from '@/utils/auth'
  30. export default {
  31. name: 'InvitationCode',
  32. data() {
  33. return {
  34. inviteCode: '', // 用户输入的邀请码
  35. myInviteCode: 'b1014pib' // 我的邀请码
  36. }
  37. },
  38. onLoad() {
  39. this.inviteCode = this.userInfo.inviteCode || ''
  40. },
  41. methods: {
  42. // 提交邀请码
  43. async submitInviteCode() {
  44. if (!this.inviteCode) {
  45. uni.showToast({
  46. title: '请输入邀请码',
  47. icon: 'none'
  48. })
  49. return
  50. }
  51. await bindCode({
  52. openId : getOpenIdKey(),
  53. code : this.inviteCode,
  54. })
  55. uni.showToast({
  56. title: '邀请码绑定成功',
  57. icon: 'success'
  58. })
  59. this.$store.commit('getUserInfo')
  60. setTimeout(uni.navigateBack, 500, -1)
  61. },
  62. }
  63. }
  64. </script>
  65. <style lang="scss" scoped>
  66. .invitation-container {
  67. padding: 20rpx;
  68. font-family: PingFang SC, Helvetica Neue, Helvetica, Arial, sans-serif;
  69. }
  70. /* 公共样式 */
  71. .section-header {
  72. display: flex;
  73. align-items: center;
  74. margin-bottom: 10rpx;
  75. }
  76. .iconfont {
  77. margin-right: 10rpx;
  78. font-size: 36rpx;
  79. color: #FFBF60;
  80. }
  81. .section-title {
  82. font-size: 34rpx;
  83. font-weight: bold;
  84. color: #333;
  85. }
  86. .section-subtitle {
  87. font-size: 24rpx;
  88. color: #999;
  89. margin-bottom: 20rpx;
  90. }
  91. /* 填写邀请码区域 */
  92. .invitation-section {
  93. background-color: #fff;
  94. border-radius: 12rpx;
  95. padding: 30rpx;
  96. margin-bottom: 20rpx;
  97. }
  98. .input-area {
  99. background-color: #F5F7FA;
  100. border-radius: 12rpx;
  101. margin-bottom: 20rpx;
  102. }
  103. .invite-input {
  104. height: 80rpx;
  105. padding: 0 20rpx;
  106. font-size: 28rpx;
  107. text-align: center;
  108. font-weight: 900;
  109. }
  110. .submit-btn {
  111. background-color: #FFBF60;
  112. color: #fff;
  113. text-align: center;
  114. height: 80rpx;
  115. line-height: 80rpx;
  116. border-radius: 40rpx;
  117. font-size: 30rpx;
  118. }
  119. /* 我的邀请码区域 */
  120. .my-invitation-section {
  121. background-color: #fff;
  122. border-radius: 12rpx;
  123. padding: 30rpx;
  124. margin-bottom: 20rpx;
  125. }
  126. .my-code-area {
  127. display: flex;
  128. align-items: center;
  129. justify-content: space-between;
  130. }
  131. .my-code {
  132. font-size: 36rpx;
  133. font-weight: bold;
  134. color: #333;
  135. }
  136. .copy-btn {
  137. border: 1px solid #FFBF60;
  138. color: #FFBF60;
  139. padding: 8rpx 30rpx;
  140. border-radius: 30rpx;
  141. font-size: 24rpx;
  142. }
  143. /* 推广员入口 */
  144. .promotion-section {
  145. text-align: center;
  146. margin-top: 60rpx;
  147. }
  148. .promotion-text {
  149. font-size: 26rpx;
  150. color: #666;
  151. margin-bottom: 20rpx;
  152. }
  153. .promotion-btn {
  154. background-color: #FFBF60;
  155. color: #fff;
  156. height: 90rpx;
  157. line-height: 90rpx;
  158. border-radius: 45rpx;
  159. font-size: 32rpx;
  160. }
  161. </style>