register.vue 4.5 KB

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