bind.vue 3.3 KB

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