This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref } from "vue";
|
||||
import Taro from "@tarojs/taro";
|
||||
import headImg from "../static/def_avatar.png";
|
||||
import logoImg from "../static/logo.jpg";
|
||||
import { BASE_URL } from "@/utils/request";
|
||||
import { getPhone, login } from "@/api/user";
|
||||
import {computed, ref} from 'vue';
|
||||
import Taro from '@tarojs/taro';
|
||||
import headImg from '../static/def_avatar.png';
|
||||
import logoImg from '../static/logo.jpg';
|
||||
import {BASE_URL} from '@/utils/request';
|
||||
import {getPhone, login} from '@/api/user';
|
||||
|
||||
const props = defineProps({
|
||||
isShow: {
|
||||
@@ -12,18 +12,18 @@ const props = defineProps({
|
||||
default: false,
|
||||
},
|
||||
});
|
||||
const emits = defineEmits(["closeEdit", "update:isShow"]);
|
||||
const emits = defineEmits(['closeEdit', 'update:isShow']);
|
||||
|
||||
const userInfo = ref({
|
||||
nickname: "",
|
||||
avatar: "",
|
||||
phone: "",
|
||||
nickname: '',
|
||||
avatar: '',
|
||||
phone: '',
|
||||
});
|
||||
|
||||
const show = computed({
|
||||
get: (): boolean => props.isShow,
|
||||
set: (val) => {
|
||||
emits("update:isShow", val);
|
||||
set: val => {
|
||||
emits('update:isShow', val);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -32,15 +32,15 @@ const mp_is_new = ref(true);
|
||||
const canvasStatus = ref(false);
|
||||
|
||||
const closeAttr = () => {
|
||||
emits("closeEdit");
|
||||
emits('closeEdit');
|
||||
};
|
||||
|
||||
const onChooseAvatar = (e) => {
|
||||
const { avatarUrl } = e.detail;
|
||||
const onChooseAvatar = e => {
|
||||
const {avatarUrl} = e.detail;
|
||||
Taro.uploadFile({
|
||||
url: `${BASE_URL}/upload`,
|
||||
filePath: avatarUrl,
|
||||
name: "file",
|
||||
name: 'file',
|
||||
success: function (res) {
|
||||
const data = JSON.parse(res.data);
|
||||
userInfo.value.avatar = data.data.data;
|
||||
@@ -54,10 +54,10 @@ const uploadPic = () => {
|
||||
|
||||
const getPhoneNumber = async (e: any) => {
|
||||
Taro.showLoading({
|
||||
title: "授权手机号中",
|
||||
title: '授权手机号中',
|
||||
mask: true,
|
||||
});
|
||||
const { code } = e.detail;
|
||||
const {code} = e.detail;
|
||||
const res = await getPhone({
|
||||
code: code,
|
||||
});
|
||||
@@ -68,39 +68,39 @@ const getPhoneNumber = async (e: any) => {
|
||||
const formSubmit = async (e: any) => {
|
||||
if (!userInfo.value.avatar)
|
||||
return Taro.showToast({
|
||||
title: "请上传头像",
|
||||
icon: "none",
|
||||
title: '请上传头像',
|
||||
icon: 'none',
|
||||
});
|
||||
userInfo.value.nickname = e.detail.value.nickname;
|
||||
if (!userInfo.value.nickname)
|
||||
return Taro.showToast({
|
||||
title: "请输入昵称",
|
||||
icon: "none",
|
||||
title: '请输入昵称',
|
||||
icon: 'none',
|
||||
});
|
||||
if (!userInfo.value.phone)
|
||||
return Taro.showToast({
|
||||
title: "请授权手机号码",
|
||||
icon: "none",
|
||||
title: '请授权手机号码',
|
||||
icon: 'none',
|
||||
});
|
||||
const res = await login({
|
||||
Code: Taro.getStorageSync("wx_code"),
|
||||
Code: Taro.getStorageSync('wx_code'),
|
||||
NickName: userInfo.value.nickname,
|
||||
AvatarUrl: userInfo.value.avatar,
|
||||
Phone: userInfo.value.phone,
|
||||
Referee: Taro.getStorageSync("bind_id") || "",
|
||||
Referee: Taro.getStorageSync('bind_id') || '',
|
||||
});
|
||||
emits("closeEdit");
|
||||
emits('closeEdit');
|
||||
Taro.showToast({
|
||||
title: res.msg,
|
||||
icon: "success",
|
||||
icon: 'success',
|
||||
duration: 2000,
|
||||
});
|
||||
Taro.setStorageSync("token", res.data.token);
|
||||
Taro.setStorageSync('token', res.data.token);
|
||||
setTimeout(() => {
|
||||
Taro.removeStorageSync("wx_code");
|
||||
Taro.removeStorageSync("bind_id");
|
||||
Taro.removeStorageSync('wx_code');
|
||||
Taro.removeStorageSync('bind_id');
|
||||
Taro.switchTab({
|
||||
url: "/pages/user/index",
|
||||
url: '/pages/user/index',
|
||||
});
|
||||
}, 2000);
|
||||
};
|
||||
@@ -112,11 +112,10 @@ const formSubmit = async (e: any) => {
|
||||
position="bottom"
|
||||
safe-area-inset-bottom
|
||||
closeable
|
||||
:style="{ padding: '20px 10px' }"
|
||||
:style="{padding: '20px 10px'}"
|
||||
v-model:visible="show"
|
||||
@close="closeAttr"
|
||||
:close-on-click-overlay="false"
|
||||
>
|
||||
:close-on-click-overlay="false">
|
||||
<view class="mp-data">
|
||||
<image class="image" :src="logoImg"></image>
|
||||
<text class="mp-name">捷兑通 申请</text>
|
||||
@@ -133,23 +132,19 @@ const formSubmit = async (e: any) => {
|
||||
<view
|
||||
class="avatar-box"
|
||||
v-if="!mp_is_new"
|
||||
@click.stop="uploadPic"
|
||||
>
|
||||
@click.stop="uploadPic">
|
||||
<image
|
||||
:src="userInfo.avatar || headImg"
|
||||
mode="aspectFill"
|
||||
></image>
|
||||
mode="aspectFill"></image>
|
||||
</view>
|
||||
<button
|
||||
v-else
|
||||
class="avatar-box"
|
||||
open-type="chooseAvatar"
|
||||
@chooseavatar="onChooseAvatar"
|
||||
>
|
||||
@chooseavatar="onChooseAvatar">
|
||||
<image
|
||||
:src="userInfo.avatar || headImg"
|
||||
mode="aspectFill"
|
||||
></image>
|
||||
mode="aspectFill"></image>
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
@@ -163,8 +158,7 @@ const formSubmit = async (e: any) => {
|
||||
placeholder="请输入昵称"
|
||||
name="nickname"
|
||||
:maxlength="16"
|
||||
:value="userInfo.nickname"
|
||||
/>
|
||||
:value="userInfo.nickname" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -174,9 +168,8 @@ const formSubmit = async (e: any) => {
|
||||
<view class="input">
|
||||
<button
|
||||
open-type="getPhoneNumber"
|
||||
@getphonenumber="getPhoneNumber"
|
||||
>
|
||||
{{ !userInfo.phone ? "请授权手机号" : "授权成功" }}
|
||||
@getphonenumber="getPhoneNumber">
|
||||
{{ !userInfo.phone ? '请授权手机号' : '授权成功' }}
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
Reference in New Issue
Block a user