index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <v-page>
  3. <v-header class="nav-tab" :title="$t('reg.b9')"></v-header>
  4. <view class="layout-main">
  5. <view class="form m-lg bg-panel-3 p-lg rounded-md">
  6. <!-- <view class="d-flex justify-center">
  7. <view class="item transition-3 p-y-sp-r-sm p-x-xs fn-20" :class="{
  8. 'color-light':form.type==2
  9. }" @click="form.type=2">{{$t('reg.a1')}}
  10. <view class="w-5 h-5 rounded-max bg-light justify-center mauto m-y-sm" :class="{
  11. 'disnone':form.type==1
  12. }">
  13. </view>
  14. </view>
  15. <view v-if="true" class="item transition-3 p-y-sp-r-sm p-x-xs fn-20 " :class="{
  16. 'color-light ':form.type==1
  17. }" @click="showToast()" >{{$t('reg.a0')}}
  18. <view class="w-5 h-5 rounded-max bg-light justify-center mauto m-y-sm" :class="{
  19. 'disnone':form.type==2
  20. }">
  21. </view>
  22. </view>
  23. </view> -->
  24. <view class="form-item border-b m-b-md p-b-xs">
  25. <template v-if="form.type==1">
  26. <view key="1">
  27. <view class="label m-b-xs">{{$t('reg.a2')}}</view>
  28. <v-input v-model="form.account" class="color-light" :placeholder="$t('reg.a3')">
  29. <template #left>
  30. <v-country ref="country" @country_code="country_code=$event" class="m-r-xs"
  31. v-model="form.country_id" />
  32. </template>
  33. </v-input>
  34. </view>
  35. </template>
  36. <template v-else-if="form.type==2">
  37. <view key="2">
  38. <view class="label m-b-xs">{{$t('reg.a4')}}</view>
  39. <v-input v-model="form.account" class="color-light" :placeholder="$t('reg.a5')"></v-input>
  40. </view>
  41. </template>
  42. </view>
  43. <view class="form-item border-b m-b-md p-b-xs">
  44. <view class="label m-b-xs">{{$t('reg.a6')}}</view>
  45. <v-input class="color-light" v-model="form.code" :placeholder="$t('reg.a7')">
  46. <template #right>
  47. <!-- 手机 -->
  48. <v-code v-show="form.type==1" url="/register/sendSmsCode" :data="{
  49. phone:form.account,
  50. country_code:country_code,
  51. type:1
  52. }"></v-code>
  53. <!-- 邮箱 -->
  54. <v-code url="/register/sendEmailCode" :data="{
  55. email:form.account,
  56. type:1
  57. }" v-show="form.type==2"></v-code>
  58. </template>
  59. </v-input>
  60. </view>
  61. <view class="form-item border-b m-b-md p-b-xs">
  62. <view class="label m-b-xs">{{$t('reg.a8')}}</view>
  63. <v-input class="color-light" v-model="form.password" type="password" :placeholder="$t('reg.a9')">
  64. </v-input>
  65. </view>
  66. <view class="form-item border-b m-b-md p-b-xs">
  67. <view class="label m-b-xs">{{$t('reg.b0')}}</view>
  68. <v-input class="color-light" v-model="form.password_confirmation" type="password"
  69. :placeholder="$t('reg.b1')"></v-input>
  70. </view>
  71. <view class="form-item border-b m-b-md p-b-xs">
  72. <view class="label m-b-xs">{{$t('reg.b2')}} ({{$t('reg.b4')}})</view>
  73. <v-input class="color-light" v-model="form.invite_code" :placeholder="`${$t('reg.b3')} (${$t('reg.b4')})`"></v-input>
  74. </view>
  75. <view class="tips d-flex m-b-md fn-sm">
  76. <van-checkbox :value="check" @change="check=!check" class="flex-shrink" icon-size="15px"
  77. checked-color="#f05319"></van-checkbox>
  78. <view class="m-l-xs">
  79. {{$t('reg.b5')}}
  80. <v-link class="color-sell" v-if="agreement.agreement"
  81. :to="{path:'/pages/notice/detail',query:{id:agreement.agreement.id}}">
  82. 《{{agreement.agreement.title}}》</v-link>{{$t('reg.b7')}}
  83. <v-link class="color-sell" v-if="agreement.clause"
  84. :to="{path:'/pages/notice/detail',query:{id:agreement.clause.id}}">
  85. 《{{agreement.clause.title}}》</v-link>
  86. </view>
  87. </view>
  88. <v-button type="blue" block class="w-max m-b-md rounded-md" @click="register">{{$t('reg.b9')}}
  89. </v-button>
  90. </view>
  91. </view>
  92. <view class="m-x-lg p-x-lg">
  93. <view class="p-y-md border-t fn-center">
  94. {{$t('reg.c0')}}
  95. <v-link class="color-sell" to="/pages/login/index">{{$t('reg.c1')}}</v-link>
  96. </view>
  97. </view>
  98. <van-toast id="van-toast" />
  99. </v-page>
  100. </template>
  101. <script>
  102. import Member from "@/api/member";
  103. import app from "app.js";
  104. export default {
  105. data() {
  106. return {
  107. form: {
  108. type: 2,
  109. country_code: "",
  110. country_id: 195,
  111. account: "",
  112. code: "",
  113. password: "",
  114. password_confirmation: "",
  115. invite_code: "",
  116. },
  117. check: false,
  118. agreement: {},
  119. country_code: ''
  120. };
  121. },
  122. computed: {},
  123. methods: {
  124. showToast(){
  125. uni.showToast({
  126. title:this.$t('base.h1'),
  127. icon:'none'
  128. })
  129. },
  130. register() {
  131. if (!this.check) {
  132. this.$toast(this.$t('reg.c2'));
  133. return;
  134. }
  135. // if (!this.form.invite_code) {
  136. // this.$toast(this.$t('reg.b3'));
  137. // return;
  138. // }
  139. if (!this.form.account) {
  140. if (this.form.type == 1) {
  141. this.$toast(this.$t('reg.c3'));
  142. } else if (this.form.type == 2) {
  143. this.$toast(this.$t('reg.a5'));
  144. }
  145. return;
  146. }
  147. if(!this.form.code){
  148. this.$toast(this.$t('reg.a7'));
  149. return
  150. }
  151. this.form.type = this.form.type
  152. this.form.country_code = this.country_code;
  153. Member.register(this.form).then(() => {
  154. // #ifdef H5
  155. // this.$dialog.confirm({
  156. // title: this.$t("common.tips"),
  157. // message: this.$t('common.toDwon'),
  158. // cancel: true,
  159. // cancelButtonText: this.$t('common.cancelButtonText'),
  160. // confirmButtonText: this.$t('common.confirmButtonText')
  161. // })
  162. // .then(() => {
  163. // window.open(app.baseUrl + "/down", "_blank ");
  164. // }).catch(() => {
  165. this.$toast(this.$t('reg.c5'));
  166. setTimeout(()=>{
  167. if (this.query.from) {
  168. this.$back();
  169. } else {
  170. this._router.replace("/pages/login/index");
  171. }
  172. },1500)
  173. // });
  174. // #endif
  175. // #ifdef APP-PLUS
  176. this.$toast(this.$t('reg.c5'));
  177. setTimeout(()=>{
  178. if (this.query.from) {
  179. this.$back();
  180. } else {
  181. this._router.replace("/pages/login/index");
  182. }
  183. },1500)
  184. // #endif
  185. });
  186. },
  187. // 获取协议
  188. clause() {
  189. Member.clause().then((res) => {
  190. this.agreement = res.data;
  191. });
  192. },
  193. },
  194. mounted() {},
  195. onLoad(query) {
  196. this.query = query
  197. this.form.invite_code = this.query.invite_code || this.form.invite_code
  198. },
  199. created() {
  200. this.clause();
  201. },
  202. };
  203. </script>
  204. <style lang="scss" scoped>
  205. .nav-tab {
  206. background: transparent;
  207. &::after {
  208. border: none;
  209. }
  210. }
  211. .transition-3 {
  212. transition: all 0.2s;
  213. }
  214. .mauto {
  215. margin: auto;
  216. }
  217. .disnone {
  218. display: none;
  219. }
  220. </style>