master
王文杰 8 months ago
parent 8163828e62
commit 79b6d0b129

@ -76,15 +76,14 @@ const handleNewsList = () => {
<image class="img" src="/static/images/order_my.png" mode="scaleToFill" />
<view class="text"> 已完成订单 </view>
</button>
<!-- <button hover-class="none" class="item arrow" open-type="feedback">问题反馈</button> -->
<button hover-class="none" class="item arrow" open-type="contact">
<image class="img" src="/static/images/kefu_my.png" mode="scaleToFill" />
<view class="text"> 联系我们 </view>
</button>
<button hover-class="none" class="item arrow" @click="handleOrderAuto">
<!-- <button hover-class="none" class="item arrow" @click="handleOrderAuto">
<image class="img" src="/static/images/order_auto_my.png" mode="scaleToFill" />
<view class="text"> 自动接单 </view>
</button>
</button> -->
<navigator
class="settings item arrow"
url="/pagesMember/settings/settings"
@ -103,10 +102,10 @@ const handleNewsList = () => {
检查更新
</view>
</button> -->
<button hover-class="none" class="item arrow" @click="handleNewsList">
<!-- <button hover-class="none" class="item arrow" @click="handleNewsList">
<image class="img" src="/static/images/detail_concat.png" mode="scaleToFill" />
<view class="text"> 消息列表 </view>
</button>
</button> -->
</view>
</view>
</template>

@ -1,22 +1,33 @@
<script setup lang="ts">
import { getMemberProfileAPI, putMemberProfileAPI } from '@/services/profile'
import { getMemberProfileAPI, postMemberProfileAPI } from '@/services/profile'
import { useMemberStore } from '@/stores'
import type { Gender, ProfileDetail } from '@/types/member'
import type { Gender } from '@/types/member'
import { formatDate } from '@/utils'
import { onLoad } from '@dcloudio/uni-app'
import { ref } from 'vue'
import { computed, ref } from 'vue'
//
const { safeAreaInsets } = uni.getSystemInfoSync()
const isDev = import.meta.env.DEV
const domain = isDev ? 'http://192.168.0.166:8808' : 'http://222.71.165.188:8808'
//
const profile = ref({} as ProfileDetail)
const profile = ref({})
const headIcon = ref()
const getMemberProfileData = async () => {
const res = await getMemberProfileAPI()
profile.value = res.result
const obj = res.data
const avatar = domain + JSON.parse(obj.headIcon).url
profile.value = {
avatar,
gender: obj.gender + '',
mobilePhone: obj.mobilePhone,
nickName: obj.nickName,
birthday: obj.birthday?.slice(0, 10),
}
// Store
memberStore.profile!.avatar = res.result.avatar
memberStore.profile!.nickname = res.result.nickname
memberStore.profile!.avatar = avatar
memberStore.profile!.nickname = obj.nickname
}
onLoad(() => {
@ -26,23 +37,6 @@ onLoad(() => {
const memberStore = useMemberStore()
//
const onAvatarChange = () => {
// /
//
// #ifdef H5 || APP-PLUS
// 2.21.0 wx.chooseImage 使 uni.chooseMedia
uni.chooseImage({
count: 1,
success: (res) => {
//
const tempFilePaths = res.tempFilePaths
//
uploadFile(tempFilePaths[0])
},
})
// #endif
// #ifdef MP-WEIXIN
// uni.chooseMedia
uni.chooseMedia({
//
count: 1,
@ -55,23 +49,23 @@ const onAvatarChange = () => {
uploadFile(tempFilePath)
},
})
// #endif
}
// -H5App
//
const uploadFile = (file: string) => {
//
uni.uploadFile({
url: '/member/profile/avatar',
url: '/file/uploadImg',
name: 'file',
filePath: file,
success: (res) => {
if (res.statusCode === 200) {
const avatar = JSON.parse(res.data).result.avatar
headIcon.value = JSON.stringify(JSON.parse(res.data).data)
const avatar = JSON.parse(res.data).data.url
//
profile.value.avatar = avatar
const imgUrl = domain + avatar
profile.value.avatar = imgUrl
// Store
memberStore.profile!.avatar = avatar
memberStore.profile!.avatar = imgUrl
uni.showToast({ icon: 'success', title: '更新成功' })
} else {
uni.showToast({ icon: 'error', title: '出现错误' })
@ -90,29 +84,18 @@ const onBirthdayChange: UniHelper.DatePickerOnChange = (ev) => {
profile.value.birthday = ev.detail.value
}
//
let fullLocationCode: [string, string, string] = ['', '', '']
const onFullLocationChange: UniHelper.RegionPickerOnChange = (ev) => {
//
profile.value.fullLocation = ev.detail.value.join(' ')
//
fullLocationCode = ev.detail.code!
}
//
const onSubmit = async () => {
const { nickname, gender, birthday, profession } = profile.value
const res = await putMemberProfileAPI({
const { nickname, gender, birthday } = profile.value
const params = {
headIcon: headIcon.value,
nickname,
gender,
birthday,
profession,
provinceCode: fullLocationCode[0] || undefined,
cityCode: fullLocationCode[1] || undefined,
countyCode: fullLocationCode[2] || undefined,
})
birthday: birthday + ' ' + '00:00:01',
}
const res = await postMemberProfileAPI(params)
// Store
memberStore.profile!.nickname = res.result.nickname
memberStore.profile!.nickname = nickname
uni.showToast({ icon: 'success', title: '保存成功' })
setTimeout(() => {
uni.navigateBack()
@ -140,7 +123,7 @@ const onSubmit = async () => {
<view class="form-content">
<view class="form-item">
<text class="label">账号</text>
<text class="account placeholder">{{ profile?.account }}</text>
<text class="account placeholder">{{ profile?.mobilePhone }}</text>
</view>
<view class="form-item">
<text class="label">昵称</text>
@ -150,11 +133,11 @@ const onSubmit = async () => {
<text class="label">性别</text>
<radio-group @change="onGenderChange">
<label class="radio">
<radio value="男" color="#3775F6" :checked="profile?.gender === '男'" />
<radio value="1" color="#3271E5" :checked="profile?.gender === '男'" />
</label>
<label class="radio">
<radio value="女" color="#3775F6" :checked="profile?.gender === '女'" />
<radio value="2" color="#3271E5" :checked="profile?.gender === '女'" />
</label>
</radio-group>
@ -173,25 +156,6 @@ const onSubmit = async () => {
<view class="placeholder" v-else></view>
</picker>
</view>
<!-- 只有微信小程序端内置了省市区数据 -->
<!-- #ifdef MP-WEIXIN -->
<view class="form-item">
<text class="label">城市</text>
<picker
@change="onFullLocationChange"
mode="region"
class="picker"
:value="profile?.fullLocation?.split(' ')"
>
<view v-if="profile?.fullLocation">{{ profile.fullLocation }}</view>
<view class="placeholder" v-else></view>
</picker>
</view>
<!-- #endif -->
<view class="form-item">
<text class="label">职业</text>
<input class="input" type="text" placeholder="请填写职业" v-model="profile.profession" />
</view>
</view>
<!-- 提交按钮 -->
<button @tap="onSubmit" class="form-button"> </button>
@ -208,7 +172,7 @@ page {
display: flex;
flex-direction: column;
height: 100%;
background-image: url(https://pcapi-xiaotuxian-front-devtest.itheima.net/miniapp/images/order_bg.png);
background: linear-gradient(158deg, #51B6FF -10%, #3775F6 129%);
background-size: auto 420rpx;
background-repeat: no-repeat;
}
@ -328,4 +292,5 @@ page {
background: linear-gradient(158deg, #51B6FF -10%, #3775F6 129%);
}
}
</style>
</style>import type { parse } from 'path'

@ -1,3 +1,11 @@
/*
* @Author:
* @Date: 2024-01-04 12:54:56
* @LastEditors:
* @LastEditTime: 2024-03-07 17:15:12
* @FilePath: /app-nx-recycle/src/services/profile.ts
* @Description: ,`customMade`, koroFileHeader : https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import type { ProfileDetail, ProfileParams } from '@/types/member'
import { http } from '@/utils/http'
@ -7,7 +15,7 @@ import { http } from '@/utils/http'
export const getMemberProfileAPI = () => {
return http<ProfileDetail>({
method: 'GET',
url: '/member/profile',
url: '/recycler/info',
})
}
@ -15,10 +23,10 @@ export const getMemberProfileAPI = () => {
*
* @param data
*/
export const putMemberProfileAPI = (data: ProfileParams) => {
export const postMemberProfileAPI = (data: ProfileParams) => {
return http<ProfileDetail>({
method: 'PUT',
url: '/member/profile',
method: 'POST',
url: '/recycler/update',
data,
})
}

@ -1,8 +1,8 @@
/*
* @Author:
* @Date: 2024-01-04 12:54:56
* @LastEditors:
* @LastEditTime: 2024-03-07 12:57:28
* @LastEditors:
* @LastEditTime: 2024-03-07 17:18:09
* @FilePath: /app-nx-recycle/src/utils/http.ts
* @Description: ,`customMade`, koroFileHeader : https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
@ -20,8 +20,8 @@
import { useMemberStore } from '@/stores'
// const baseURL = 'http://192.168.0.166:8808/api'
const baseURL = 'http://222.71.165.188:8808/api'
const baseURL = 'http://192.168.0.166:8808/api'
// const baseURL = 'http://222.71.165.188:8808/api'
// 添加拦截器
const httpInterceptor = {
// 拦截前触发

Loading…
Cancel
Save