Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
swx_weapp
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
hookehuyr
2022-10-21 17:22:43 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b70fa78ec46e3b0845c970627e234afadfcf32ea
b70fa78e
1 parent
d349d23e
新增个人信息API联调
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
5 deletions
src/api/User/index.js
src/pages/apxUserInfo/index.vue
src/api/User/index.js
0 → 100644
View file @
b70fa78
/*
* @Date: 2022-10-20 13:15:00
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-10-21 17:12:41
* @FilePath: /swx/src/api/User/index.js
* @Description: 用户信息
*/
import
{
fn
,
fetch
}
from
'../fn'
;
const
Api
=
{
USER_INFO
:
'/srv/?a=user_info'
,
USER_EDIT
:
'/srv/?a=user_edit'
,
}
/**
* @description: 我的信息
* @returns
*/
export
const
infoUserAPI
=
(
params
)
=>
fn
(
fetch
.
get
(
Api
.
USER_INFO
,
params
));
/**
* @description: 修改我的信息
* @returns
*/
export
const
editUserAPI
=
(
params
)
=>
fn
(
fetch
.
post
(
Api
.
USER_EDIT
,
params
));
src/pages/apxUserInfo/index.vue
View file @
b70fa78
<!--
* @Date: 2022-09-19 14:11:06
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-10-21 1
3:36:39
* @LastEditTime: 2022-10-21 1
7:21:34
* @FilePath: /swx/src/pages/apxUserInfo/index.vue
* @Description: 补充资料
-->
...
...
@@ -17,11 +17,11 @@
<label class="h5-label at-input__title at-input__title--required">头像</label>
<van-uploader v-if="!has_image" @after-read="afterRead">
<view class="">
<van-icon :name="icon_upload" size="
5
rem" color="" class="upload-icon" />
<van-icon :name="icon_upload" size="
3
rem" color="" class="upload-icon" />
</view>
</van-uploader>
<view v-else class="upload-box">
<van-image :round="true" width="
5rem" height="5
rem" :src="uploader_image" />
<van-image :round="true" width="
3rem" height="3
rem" :src="uploader_image" />
<van-icon name="clear" size="1.5rem" color="#000" class="upload-close" @tap="removeUploadImage" />
</view>
</view>
...
...
@@ -35,13 +35,14 @@
<script setup>
import Taro from '@tarojs/taro'
import { ref } from "vue";
import { ref
, onMounted
} from "vue";
import { AtInput } from 'taro-ui-vue3'
import "taro-ui-vue3/dist/style/components/input.scss";
import bottomButton from "@/components/bottom-button";
import icon_upload from '@/images/icon/qiandao@2x.png'
import BASE_URL from '@/utils/config';
import Toast from '@/components/vant-weapp/toast/toast';
import { editUserAPI, infoUserAPI } from '@/api/User/index';
const nickname = ref('');
const has_image = ref(false)
...
...
@@ -84,7 +85,7 @@ const removeUploadImage = () => {
uploader_image.value = ''
}
const onSubmit = () => {
const onSubmit =
async
() => {
if (!uploader_image.value) {
Toast('头像不能为空');
return false;
...
...
@@ -93,7 +94,31 @@ const onSubmit = () => {
Toast('昵称不能为空');
return false;
}
const params = {
nickname: nickname.value,
avatar: uploader_image.value
}
const { code, data } = await editUserAPI(params);
if (code) {
Taro.showToast({
title: '保存成功',
icon: 'success',
duration: 2000
});
Taro.navigateBack()
}
}
onMounted(async () => {
const { code, data } = await infoUserAPI();
if (code) {
nickname.value = data.user.nickname;
if (data.user.avatar) {
has_image.value = true;
uploader_image.value = data.user.avatar;
}
}
})
</script>
<script>
...
...
Please
register
or
login
to post a comment