| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <template>
- <v-page>
- <v-header :title="`${user.phone?$t('safe.a0'):''} ${$t('safe.d2')}`"></v-header>
- <main class="layout-main bg-panel-4 m-t-md">
- <view class="form-item border-b p-md" v-if="!user.phone">
- <view class="label m-b-xs">{{$t('safe.d2')}}</view>
- <view class="input color-light">
- <v-input v-model="form.phone" :placeholder="$t('safe.d5')">
- <template #left>
- <v-country class="m-r-xs" ref="country" v-model="country_id" />
- </template>
- </v-input>
- </view>
- </view>
- <view class="form-item border-b p-md">
- <view class="label m-b-xs">SMS {{$t('safe.a7')}}</view>
- <view class="input color-light">
- <v-input v-model="form.sms_code" :placeholder="$t('safe.a6')">
- <template #right>
- <v-code url="/user/getCode" v-if="user.phone" :data="{type:1}" />
- <v-code
- url="/user/sendBindSmsCode"
- v-else
- :data="{phone:form.phone,country_code:$refs.country&&$refs.country.country_code}"
- />
- </template>
- </v-input>
- </view>
- </view>
- <view class="form-item border-b p-md" v-if="user.email_status==1">
- <view class="label m-b-xs">{{$t('safe.a5')}}</view>
- <view class="input color-light">
- <v-input v-model="form.email_code" :placeholder="$t('safe.a6')">
- <template #right>
- <v-code url="/user/getCode" :data="{type:2}" />
- </template>
- </v-input>
- </view>
- </view>
- <view class="form-item border-b p-md" v-if="user.google_status==1">
- <view class="label m-b-xs">google{{$t('safe.a7')}}</view>
- <view class="input color-light">
- <v-input v-model="form.google_code" :placeholder="$t('safe.a6')"></v-input>
- </view>
- </view>
- </main>
- <view class="p-md bg-panel-4">
- <v-button block class="w-max" type="theme" ref="btn" @click="changePhone">{{user.phone?$t('safe.a0'):$t('safe.e3')}}</v-button>
- </view>
- <van-toast id="van-toast" />
- </v-page>
- </template>
- <script>
- import Setting from "@/api/setting";
- import { mapState, mapActions } from "vuex";
- export default {
- data() {
- return {
- country_id: 195,
- form: {
- phone: "",
- country_code: "",
- email_code: "",
- sms_code: "",
- google_code: "",
- },
- };
- },
- computed: {
- ...mapState({
- user: "user",
- }),
- },
- methods: {
- ...mapActions({
- setUserInfo: "setUserInfo",
- }),
- changePhone() {
- this.form.country_code = this.$refs.country&&this.$refs.country.country_code;
- if (!this.user.phone && !this.form.phone) {
- this.$toast(this.$t('safe.d5'));
- return;
- }
- if (!this.form.sms_code) {
- this.$toast(this.$t('safe.d6'));
- return;
- }
- let changePhone = this.user.phone
- ? Setting.unbindPhone(this.form, { btn: this.$refs.btn })
- : Setting.bindPhone(this.form, { btn: this.$refs.btn });
- changePhone
- .then(() => {
- this.$toast.success(this.user.phone ? this.$t('safe.a8') : this.$t('safe.a9'));
- this.$back();
- this.setUserInfo();
- })
- .catch(() => {});
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- </style>
|