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