bind.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <view class="container">
  3. <navBar :show-title="true" :title="$t('bind.绑定邀请人')" url="/pages/index/index"></navBar>
  4. <view class="logoBox">
  5. <image class="logo" src="../../static/img/itemList1.png" mode="widthFix"></image>
  6. </view>
  7. <view class="shareBox">
  8. <view class="title">{{$t('bind.邀请码')}}</view>
  9. <view class="inputBox ">
  10. <input class="input" v-model="spread" type="text" placeholder-class="pClass"
  11. :placeholder="$t('bind.请输入上级邀请码')" />
  12. </view>
  13. </view>
  14. <view class="bindButtom" @click="bindShare">{{$t('bind.立即注册')}}</view>
  15. </view>
  16. </template>
  17. <script>
  18. import {
  19. mapState,
  20. } from "vuex";
  21. import {
  22. addSpread
  23. } from '@/api/user.js';
  24. import navBar from "@/components/nav/nav.vue"
  25. export default {
  26. data() {
  27. return {
  28. spread: ''
  29. }
  30. },
  31. components: {
  32. navBar
  33. },
  34. computed: {
  35. ...mapState('user', ['userInfo']),
  36. },
  37. onLoad(option) {
  38. this.spread = option.spread || uni.getStorageSync('spread') || '';
  39. },
  40. methods: {
  41. // 请求载入数据
  42. async bindShare() {
  43. const that = this;
  44. const USER_BIND = 'USER_BIND' + (new Date()).getTime();
  45. ethereum.request({
  46. "method": "personal_sign",
  47. "params": [
  48. USER_BIND,
  49. that.userInfo.address
  50. ]
  51. }).then((res) => {
  52. addSpread({
  53. address: that.spread,
  54. sign: res,
  55. msg: USER_BIND,
  56. }).then((res) => {
  57. that.$util.Tips({
  58. title: that.$t('bind.绑定成功'),
  59. icon: 'success'
  60. }, {
  61. tab: 2,
  62. url: '/pages/index/index'
  63. })
  64. })
  65. });
  66. },
  67. },
  68. }
  69. </script>
  70. <style lang="scss">
  71. .container {
  72. width: 100%;
  73. padding: 25rpx;
  74. line-height: 1;
  75. min-height: 100vh;
  76. background-color: rgb(12, 8, 21);
  77. color: #fff;
  78. }
  79. .shareBox {
  80. background-color: rgba(255, 255, 255, .09);
  81. border-radius: 10rpx;
  82. padding: 40rpx 30rpx;
  83. margin-top: 100rpx;
  84. font-weight: 700;
  85. .title {
  86. font-size: 40rpx;
  87. text-align: center;
  88. }
  89. .inputBox {
  90. background-color: rgba(72, 74, 84, 1);
  91. border-radius: 40rpx;
  92. .input {
  93. margin-top: 50rpx;
  94. color: rgba(255, 255, 255, 1);
  95. font-size: 30rpx;
  96. text-align: center;
  97. line-height: 2.5em;
  98. height: 2.5em;
  99. }
  100. .pClass {
  101. color: rgba(255, 255, 255, 0.5);
  102. }
  103. }
  104. }
  105. .bindButtom {
  106. margin-top: 100rpx;
  107. background: linear-gradient(90deg, #7D32FF, #3EE0FF);
  108. text-align: center;
  109. font-size: 36rpx;
  110. padding: 30rpx;
  111. font-weight: bold;
  112. border-radius: 10rpx;
  113. color: #FFF;
  114. }
  115. .logoBox {
  116. padding-top: 50rpx;
  117. text-align: center;
  118. .logo {
  119. width: 300rpx;
  120. }
  121. }
  122. .topBox {
  123. padding-bottom: 31rpx;
  124. width: 700rpx;
  125. .topTpl {
  126. background: rgba(255, 255, 255, .09);
  127. border: 2rpx solid #CCCECF;
  128. border-radius: 36rpx;
  129. height: 71rpx;
  130. padding-left: 10rpx;
  131. font-weight: bold;
  132. padding-right: 20rpx;
  133. &.margin-l-30 {
  134. width: 0;
  135. flex-grow: 1;
  136. }
  137. .userIcon {
  138. width: 51rpx;
  139. height: 48rpx;
  140. flex-shrink: 0;
  141. }
  142. .tpl {
  143. font-size: 28rpx;
  144. }
  145. .tpls {
  146. font-size: 30rpx;
  147. }
  148. }
  149. }
  150. </style>