feat:新增登录页面与相关功能,移除自动登录,对接用户反馈功能

This commit is contained in:
2025-10-08 02:29:48 +08:00
parent 0ec86fba8e
commit 8560ff778e
10 changed files with 317 additions and 35 deletions
+62 -19
View File
@@ -1,6 +1,6 @@
<template>
<view class="feedback-container">
<form>
<!-- <form> -->
<!-- 问题类型选择 -->
<view class="type-section">
<view class="section-title">问题类型</view>
@@ -21,7 +21,7 @@
</view>
<!-- 图片上传 -->
<!-- <view class="upload-section">
<!-- <view class="upload-section">
<view class="section-title">图片上传选填</view>
<view class="upload-grid">
<view class="upload-item" v-for="(img, index) in images" :key="index">
@@ -46,7 +46,7 @@
<view class="submit-section">
<view class="submit-btn" @click="submitFeedback">提交反馈</view>
</view>
</form>
<!-- </form> -->
</view>
</template>
@@ -55,10 +55,11 @@
ref
} from 'vue'
import {
URL
URL,
appid
} from '../../config/url'
import {
addUserFeedback
uploadOssResource
} from '../../config/user'
// 响应式数据
@@ -78,8 +79,25 @@
const chooseImage = () => {
uni.chooseImage({
count: 3 - images.value.length,
success: (res) => {
images.value = [...images.value, ...res.tempFilePaths]
success: async (res) => {
const toUpload = res.tempFilePaths || []
for (const localPath of toUpload) {
// 先追加本地预览,再上传并替换为远程URL
images.value.push(localPath)
try {
const remoteUrl = await uploadOssResource(localPath)
const idx = images.value.indexOf(localPath)
if (idx !== -1) {
images.value.splice(idx, 1, remoteUrl)
}
} catch (e) {
const idx = images.value.indexOf(localPath)
if (idx !== -1) {
images.value.splice(idx, 1)
}
uni.showToast({ title: '图片上传失败', icon: 'none' })
}
}
}
})
}
@@ -126,18 +144,43 @@
phone: contact.value,
// images: images.value
}
const res = await addUserFeedback(feedbackData);
if (res.code == 200) {
uni.showToast({
title: '反馈成功',
icon: 'success'
})
} else {
uni.showToast({
title: '反馈失败',
icon: 'none'
})
}
uni.request({
url: `${apiUrl}/app/feedback/add`,
method: 'POST',
data: feedbackData,
header: {
'Content-Type': 'application/json',
'appid': appid,
'Authorization': 'Bearer ' + uni.getStorageSync('token'),
'Clientid': uni.getStorageSync('client_id')
},
dataType: 'json',
success: (res) => {
// 兼容后端返回 { code: 200 } 或 HTTP 200 情况
if ((res.statusCode === 200) && ((res.data && res.data.code === 200) || res.data === true || res.data?.success === true)) {
uni.showToast({
title: '反馈成功',
icon: 'success'
})
setTimeout(() => {
uni.navigateBack();
}, 1500);
return
}
uni.showToast({
title: (res.data && (res.data.msg || res.data.message)) || '反馈失败',
icon: 'none'
})
},
fail: (err) => {
console.error('feedback request failed:', err)
uni.showToast({
title: '网络错误,请稍后重试',
icon: 'none'
})
}
})
}
</script>