register.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <view class="register-box">
  3. <top-head :top-type="1"></top-head>
  4. <view class="contract-data">
  5. <view class="data-input">
  6. <view class="input-item">
  7. <view class="item-detail">{{$t('index.register.address')}}:</view>
  8. <view class="item-detail"></view>
  9. </view>
  10. <view class="input-item-two">
  11. <input v-model="inviteCode" :placeholder="$t('index.register.add-address')">
  12. </view>
  13. </view>
  14. <view class="data-but">
  15. <button @click="register">{{$t('index.index.affirm')}}</button>
  16. </view>
  17. <view class="data-button" @click="goToUrl(1)">
  18. <image src="@/static/img/index/msg.svg"></image>
  19. <view>{{$t('index.contract.word')}}>></view>
  20. </view>
  21. </view>
  22. <view class="register-from" v-if="false">
  23. <view class="from-input"><input v-model="inviteCode" :placeholder="$t('index.index.affirm')"></view>
  24. <view class="from-but">
  25. <button @click="register">{{$t('index.index.affirm')}}</button>
  26. </view>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import {register} from "@/api/member";
  32. import tools from "@/common/js/tools";
  33. import TopHead from "@/pages/index/components/top-head";
  34. export default {
  35. name: "register",
  36. props: {},
  37. components: {TopHead},
  38. data() {
  39. return {
  40. address: '',
  41. inviteCode: '',
  42. isAjax: false
  43. }
  44. },
  45. onLoad(query) {
  46. if (query.address !== undefined) {
  47. this.address = query.address
  48. let inviteCode = uni.getStorageSync('inviteCode');
  49. if (inviteCode) {
  50. this.inviteCode = inviteCode
  51. }
  52. } else {
  53. tools.leftClick()
  54. }
  55. },
  56. mounted() {
  57. },
  58. methods: {
  59. goToUrl(type) {
  60. switch (type) {
  61. case 1:
  62. uni.navigateTo({
  63. 'url': 'pages/index/intro'
  64. })
  65. break
  66. }
  67. },
  68. register() {
  69. if (this.inviteCode === '') {
  70. tools.error(this.$t('index.error.errorMsg.noInvite'))
  71. return;
  72. }
  73. if (this.isAjax) {
  74. return;
  75. }
  76. this.isAjax = true
  77. register({'inviteCode': this.inviteCode, 'address': this.address}).then((res) => {
  78. if (res.code) {
  79. tools.setLoginInfo(res.data)
  80. setTimeout(() => {
  81. uni.reLaunch({
  82. url: '/pages/index/index'
  83. })
  84. }, 50)
  85. } else {
  86. tools.error(res.msg)
  87. this.isAjax = false
  88. }
  89. }).catch((e) => {
  90. this.isAjax = false
  91. })
  92. }
  93. }
  94. }
  95. </script>
  96. <style scoped lang="scss">
  97. .register-box{
  98. padding-top: 40rpx;
  99. box-shadow: 0 0 24rpx 0 #000;
  100. box-sizing: border-box;
  101. width: 100%;
  102. height: 100vh;
  103. background: linear-gradient(0deg, rgb(64, 74, 96) 0%, rgb(9, 21, 36) 100%);
  104. .contract-data {
  105. background: #fff;
  106. width: 90%;
  107. margin: 120rpx auto 0;
  108. border-radius: 20rpx;
  109. padding: 40rpx 20rpx;
  110. font-size: 36rpx;
  111. box-shadow: 8rpx 8rpx 16rpx 0 rgba(255, 255, 255, 0.3);
  112. .data-input {
  113. border: 1rpx solid #000;
  114. overflow: hidden;
  115. border-radius: 10rpx;
  116. padding: 20rpx;
  117. .input-item {
  118. display: flex;
  119. justify-content: space-between;
  120. .item-detail {
  121. font-size: 26rpx;
  122. }
  123. }
  124. .item-img {
  125. display: flex;
  126. justify-content: right;
  127. .text-img {
  128. display: inline-block;
  129. border-radius: 50%;
  130. height: 60rpx;
  131. width: 60rpx;
  132. box-sizing: border-box;
  133. margin-right: 10rpx;
  134. image {
  135. width: 60rpx;
  136. height: 60rpx;
  137. z-index: 100;
  138. }
  139. }
  140. .text {
  141. line-height: 60rpx;
  142. }
  143. }
  144. .input-item:first-child {
  145. margin-bottom: 40rpx;
  146. }
  147. .input-item-two {
  148. height: 60rpx;
  149. }
  150. }
  151. .data-but {
  152. border-radius: 20rpx;
  153. margin-top: 60rpx;
  154. button {
  155. height: 90rpx;
  156. line-height: 90rpx;
  157. text-align: center;
  158. background: rgb(0, 87, 255);
  159. color: #fff;
  160. font-size: 26rpx;
  161. }
  162. }
  163. .data-button {
  164. margin-top: 40rpx;
  165. display: flex;
  166. justify-content: right;
  167. image {
  168. width: 40rpx;
  169. height: 40rpx;
  170. }
  171. view {
  172. font-size: 26rpx;
  173. margin-left: 10rpx;
  174. color: rgb(0, 87, 255);
  175. line-height: 40rpx;
  176. }
  177. }
  178. }
  179. }
  180. </style>