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

@ -1,22 +1,33 @@
<script setup lang="ts"> <script setup lang="ts">
import { getMemberProfileAPI, putMemberProfileAPI } from '@/services/profile' import { getMemberProfileAPI, postMemberProfileAPI } from '@/services/profile'
import { useMemberStore } from '@/stores' import { useMemberStore } from '@/stores'
import type { Gender, ProfileDetail } from '@/types/member' import type { Gender } from '@/types/member'
import { formatDate } from '@/utils' import { formatDate } from '@/utils'
import { onLoad } from '@dcloudio/uni-app' import { onLoad } from '@dcloudio/uni-app'
import { ref } from 'vue' import { computed, ref } from 'vue'
// //
const { safeAreaInsets } = uni.getSystemInfoSync() 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 getMemberProfileData = async () => {
const res = await getMemberProfileAPI() 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 // Store
memberStore.profile!.avatar = res.result.avatar memberStore.profile!.avatar = avatar
memberStore.profile!.nickname = res.result.nickname memberStore.profile!.nickname = obj.nickname
} }
onLoad(() => { onLoad(() => {
@ -26,23 +37,6 @@ onLoad(() => {
const memberStore = useMemberStore() const memberStore = useMemberStore()
// //
const onAvatarChange = () => { 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({ uni.chooseMedia({
// //
count: 1, count: 1,
@ -55,23 +49,23 @@ const onAvatarChange = () => {
uploadFile(tempFilePath) uploadFile(tempFilePath)
}, },
}) })
// #endif
} }
//
// -H5App
const uploadFile = (file: string) => { const uploadFile = (file: string) => {
// //
uni.uploadFile({ uni.uploadFile({
url: '/member/profile/avatar', url: '/file/uploadImg',
name: 'file', name: 'file',
filePath: file, filePath: file,
success: (res) => { success: (res) => {
if (res.statusCode === 200) { 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 // Store
memberStore.profile!.avatar = avatar memberStore.profile!.avatar = imgUrl
uni.showToast({ icon: 'success', title: '更新成功' }) uni.showToast({ icon: 'success', title: '更新成功' })
} else { } else {
uni.showToast({ icon: 'error', title: '出现错误' }) uni.showToast({ icon: 'error', title: '出现错误' })
@ -90,29 +84,18 @@ const onBirthdayChange: UniHelper.DatePickerOnChange = (ev) => {
profile.value.birthday = ev.detail.value 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 onSubmit = async () => {
const { nickname, gender, birthday, profession } = profile.value const { nickname, gender, birthday } = profile.value
const res = await putMemberProfileAPI({ const params = {
headIcon: headIcon.value,
nickname, nickname,
gender, gender,
birthday, birthday: birthday + ' ' + '00:00:01',
profession, }
provinceCode: fullLocationCode[0] || undefined, const res = await postMemberProfileAPI(params)
cityCode: fullLocationCode[1] || undefined,
countyCode: fullLocationCode[2] || undefined,
})
// Store // Store
memberStore.profile!.nickname = res.result.nickname memberStore.profile!.nickname = nickname
uni.showToast({ icon: 'success', title: '保存成功' }) uni.showToast({ icon: 'success', title: '保存成功' })
setTimeout(() => { setTimeout(() => {
uni.navigateBack() uni.navigateBack()
@ -140,7 +123,7 @@ const onSubmit = async () => {
<view class="form-content"> <view class="form-content">
<view class="form-item"> <view class="form-item">
<text class="label">账号</text> <text class="label">账号</text>
<text class="account placeholder">{{ profile?.account }}</text> <text class="account placeholder">{{ profile?.mobilePhone }}</text>
</view> </view>
<view class="form-item"> <view class="form-item">
<text class="label">昵称</text> <text class="label">昵称</text>
@ -150,11 +133,11 @@ const onSubmit = async () => {
<text class="label">性别</text> <text class="label">性别</text>
<radio-group @change="onGenderChange"> <radio-group @change="onGenderChange">
<label class="radio"> <label class="radio">
<radio value="男" color="#3775F6" :checked="profile?.gender === '男'" /> <radio value="1" color="#3271E5" :checked="profile?.gender === '男'" />
</label> </label>
<label class="radio"> <label class="radio">
<radio value="女" color="#3775F6" :checked="profile?.gender === '女'" /> <radio value="2" color="#3271E5" :checked="profile?.gender === '女'" />
</label> </label>
</radio-group> </radio-group>
@ -173,25 +156,6 @@ const onSubmit = async () => {
<view class="placeholder" v-else></view> <view class="placeholder" v-else></view>
</picker> </picker>
</view> </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> </view>
<!-- 提交按钮 --> <!-- 提交按钮 -->
<button @tap="onSubmit" class="form-button"> </button> <button @tap="onSubmit" class="form-button"> </button>
@ -208,7 +172,7 @@ page {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
height: 100%; 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-size: auto 420rpx;
background-repeat: no-repeat; background-repeat: no-repeat;
} }
@ -328,4 +292,5 @@ page {
background: linear-gradient(158deg, #51B6FF -10%, #3775F6 129%); 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 type { ProfileDetail, ProfileParams } from '@/types/member'
import { http } from '@/utils/http' import { http } from '@/utils/http'
@ -7,7 +15,7 @@ import { http } from '@/utils/http'
export const getMemberProfileAPI = () => { export const getMemberProfileAPI = () => {
return http<ProfileDetail>({ return http<ProfileDetail>({
method: 'GET', method: 'GET',
url: '/member/profile', url: '/recycler/info',
}) })
} }
@ -15,10 +23,10 @@ export const getMemberProfileAPI = () => {
* *
* @param data * @param data
*/ */
export const putMemberProfileAPI = (data: ProfileParams) => { export const postMemberProfileAPI = (data: ProfileParams) => {
return http<ProfileDetail>({ return http<ProfileDetail>({
method: 'PUT', method: 'POST',
url: '/member/profile', url: '/recycler/update',
data, data,
}) })
} }

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

Loading…
Cancel
Save