wip: 4.0
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-05-16 14:27:57 +08:00
parent b09c1d9537
commit 8f3b158032
72 changed files with 3931 additions and 2161 deletions

View File

@@ -1,45 +1,25 @@
<script lang="ts" setup>
import Taro from "@tarojs/taro";
import { ref } from "vue";
import { editPersonalInfo } from "@/api/user";
import { View } from "@tarojs/components";
import { BASE_URL } from "@/utils/request";
import Taro from '@tarojs/taro';
import {ref} from 'vue';
import {editPersonalInfo} from '@/api/user';
import {BASE_URL} from '@/utils/request';
// const toPage = (e: string) => {};
const userInfo = ref<any>({});
Taro.useLoad(() => {
const { data: data } = Taro.getStorageSync("userInfo");
const {data: data} = Taro.getStorageSync('userInfo');
userInfo.value = data;
});
const logOut = () => {
Taro.showModal({
title: "提示",
content: "确定退出登录吗?",
success: function (res) {
if (res.confirm) {
Taro.removeStorageSync("token");
Taro.removeStorageSync("userInfo");
Taro.removeStorageSync("mer_type");
Taro.reLaunch({
url: "/pages/index/index",
});
} else if (res.cancel) {
console.log("用户点击取消");
}
},
});
};
const chooseavatar = (e: any) => {
Taro.uploadFile({
url: `${BASE_URL}/upload`,
filePath: e.detail.avatarUrl,
name: "file",
name: 'file',
header: {
token: Taro.getStorageSync("token"),
token: Taro.getStorageSync('token'),
},
success: function (res) {
const data = JSON.parse(res.data);
@@ -53,65 +33,48 @@ const subUser = async () => {
const reg = /^1(3\d|4[5-9]|5[0-35-9]|6[567]|7[0-8]|8\d|9[0-35-9])\d{8}$/;
if (!reg.test(userInfo.value.phone))
return Taro.showToast({
title: "请输入正确的手机号码",
icon: "none",
title: '请输入正确的手机号码',
icon: 'none',
});
const res = await editPersonalInfo(userInfo.value);
Taro.showToast({
title: res.msg,
icon: "none",
icon: 'none',
});
Taro.switchTab({
url: "/pages/user/index",
url: '/pages/user/index',
});
} catch (error) {
Taro.showToast({
title: error.msg,
icon: "none",
icon: 'none',
});
}
};
// const getUserInfo = async () => {
// try {
// const res = await getPersonalInfo();
// userInfo.value = res.data.data;
// } catch (error) {
// Taro.showToast({
// title: error.msg,
// icon: "none",
// });
// }
// };
</script>
<template>
<view class="app">
<view class="user-card">
<view>管理我的账号</view>
<!-- {{ userInfo }} -->
<view class="avatar-card">
<view class="left">
<nut-button open-type="chooseAvatar" @chooseavatar="chooseavatar">
<nut-cell-group>
<nut-cell title="头像">
<template v-slot:link>
<nut-button
style="border: none; height: auto; padding: 0"
open-type="chooseAvatar"
@chooseavatar="chooseavatar">
<nut-avatar size="large">
<img style="border-radius: 50%" :src="userInfo.avatarUrl" />
</nut-avatar>
</nut-button>
<view class="name">{{ userInfo.nickName }}</view>
</view>
</view>
</view>
<nut-cell-group>
<!-- :desc="userInfo.nickName" -->
</nut-button> </template
></nut-cell>
<nut-cell title="昵称">
<template v-slot:link>
<nut-input
type="nickname"
v-model="userInfo.nickName"
:border="false"
input-align="right"
placeholder="请输入昵称"
/> </template
placeholder="请输入昵称" /> </template
></nut-cell>
<nut-cell title="手机号码">
<template v-slot:link>
@@ -119,27 +82,30 @@ const subUser = async () => {
v-model="userInfo.phone"
:border="false"
input-align="right"
disabled
/>
disabled />
</template>
</nut-cell>
<nut-cell title="登录密码">
<!-- <nut-cell title="登录密码">
<template v-slot:link>
<nut-input
v-model="userInfo.password"
:border="false"
input-align="right"
placeholder="修改登录密码"
/>
placeholder="修改登录密码" />
</template>
</nut-cell>
<nut-cell title="注销账号" desc="账号注销后不能恢复" is-link> </nut-cell>
</nut-cell> -->
<nut-cell title="交易密码" desc="创建/修改交易密码" is-link> </nut-cell>
<!-- <nut-cell title="注销账号" desc="账号注销后不能恢复" is-link> </nut-cell> -->
</nut-cell-group>
<view class="btn">
<nut-button block @click="subUser">保存信息</nut-button>
</view>
<view class="btn">
<nut-button block type="primary" @click="logOut">退出登录</nut-button>
<nut-button
shape="square"
style="border-radius: 10px"
type="primary"
block
@click="subUser"
>保存信息</nut-button
>
</view>
</view>
</template>