primary.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <v-page>
  3. <v-header :title="$t('auth.a1')"></v-header>
  4. <main class=" m-lg bg-panel-3 rounded-md p-x-md box-shadow">
  5. <view class="form-item border-b p-md m-b-md">
  6. <view class="label m-b-xs">{{$t('auth.a7')}}</view>
  7. <view class="input color-light" v-if="this.detail.primary_status == 0">
  8. <v-picker :value="form.country_id" @change="selectCountry" :list="countryList" range-value="id" range-label="name">
  9. <v-input disabled :value="activeCountry.name" :placeholder="$t('auth.a8')">
  10. <template #right>
  11. <van-icon class="color-default" name="arrow" />
  12. </template>
  13. </v-input>
  14. </v-picker>
  15. </view>
  16. <view class="input color-light" v-if="this.detail.primary_status == 1">
  17. <v-input disabled :value="activeCountry.name" :placeholder="$t('auth.a8')">
  18. </v-input>
  19. </view>
  20. </view>
  21. <view class="form-item border-b p-md m-b-md">
  22. <view class="label m-b-xs">{{$t('auth.a9')}}</view>
  23. <view class="input color-light">
  24. <v-input v-model="form.realname" :disabled="this.detail.primary_status == 1" :placeholder="$t('auth.b0')"></v-input>
  25. </view>
  26. </view>
  27. <view class="form-item border-b p-md m-b-md">
  28. <view class="label m-b-xs">{{$t('auth.b1')}}</view>
  29. <view class="input color-light">
  30. <v-input v-model="form.id_card" :disabled="this.detail.primary_status == 1" :placeholder="$t('auth.b2')"></v-input>
  31. </view>
  32. </view>
  33. <view class="p-md " v-if="this.detail.primary_status == 0">
  34. <v-button block type="blue" class="w-max rounded-md" ref="btn" @click="primaryAuth">{{$t('auth.b3')}}</v-button>
  35. </view>
  36. </main>
  37. <van-toast id="van-toast" />
  38. </v-page>
  39. </template>
  40. <script>
  41. import Profile from "@/api/profile";
  42. import Member from "@/api/member";
  43. export default {
  44. data() {
  45. return {
  46. detail: {},
  47. countryList: [],
  48. form: {
  49. id_card: "",
  50. realname: "",
  51. country_id: "",
  52. country_code: "",
  53. },
  54. };
  55. },
  56. computed: {
  57. activeCountry() {
  58. console.log(this.form.country_id)
  59. return (
  60. this.countryList.find((item) => item.id == this.form.country_id) || {}
  61. );
  62. },
  63. activeIndex(){
  64. return this.countryList.findIndex((item) => item.id == this.form.country_id)
  65. },
  66. },
  67. methods: {
  68. getAuthInfo() {
  69. Profile.getAuthInfo().then((res) => {
  70. this.detail = res.data;
  71. if(res.data.primary_status == 1) {
  72. this.form.id_card = res.data.id_card;
  73. this.form.realname = res.data.realname;
  74. this.form.country_code = res.data.country_code;
  75. this.form.country_id = res.data.country_id;
  76. }
  77. this.getCountryCode();
  78. });
  79. },
  80. // 获取区号
  81. getCountryCode() {
  82. Member.getCountryCode()
  83. .then((res) => {
  84. res.data.forEach(e => {
  85. if(e.name == '台湾省'){
  86. e.name = '台湾'
  87. }
  88. })
  89. this.countryList = res.data;
  90. if(this.form.country_id =='') {
  91. this.form.country_id = this.countryList[0].id;
  92. }
  93. })
  94. .catch(() => {});
  95. },
  96. selectCountry(value) {
  97. this.form.country_id = value
  98. },
  99. // 认证
  100. primaryAuth() {
  101. let data = this.form;
  102. data.country_code = this.activeCountry.country_code;
  103. Profile.primaryAuth(data,{btn:this.$refs.btn}).then(() => {
  104. this.$toast.success(this.$t('auth.b4'));
  105. this.$back();
  106. }).catch(()=>{});
  107. },
  108. },
  109. created() {
  110. this.getAuthInfo();
  111. },
  112. };
  113. </script>
  114. <style lang="scss">
  115. </style>