|
|
@ -5,7 +5,8 @@ |
|
|
<!-- 头部导航 --> |
|
|
<!-- 头部导航 --> |
|
|
<view class="header"> |
|
|
<view class="header"> |
|
|
<view class="back-icon"> |
|
|
<view class="back-icon"> |
|
|
<image @click="onBack" src="/static/customer-service-platform/cs-platform-back.png" class="header-icon-image"></image> |
|
|
|
|
|
|
|
|
<image @click="onBack" src="/static/customer-service-platform/cs-platform-back.png" |
|
|
|
|
|
class="header-icon-image"></image> |
|
|
</view> |
|
|
</view> |
|
|
<view class="title">{{headerTitle}}</view> |
|
|
<view class="title">{{headerTitle}}</view> |
|
|
<view class="notification-icon"> |
|
|
<view class="notification-icon"> |
|
|
@ -29,15 +30,14 @@ |
|
|
<view class="card"> |
|
|
<view class="card"> |
|
|
<view class="suggest-header"> |
|
|
<view class="suggest-header"> |
|
|
<text class="suggest-title">猜你想问</text> |
|
|
<text class="suggest-title">猜你想问</text> |
|
|
<view class="swap" @click="shuffleQuestions"> |
|
|
|
|
|
|
|
|
<view class="swap" @click="getQuestionList()"> |
|
|
<image class="swap-icon" src="/static/customer-service-platform/refresh-icon.png"></image> |
|
|
<image class="swap-icon" src="/static/customer-service-platform/refresh-icon.png"></image> |
|
|
<text class="swap-title">换一换</text> |
|
|
<text class="swap-title">换一换</text> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
<view class="card-line"></view> |
|
|
<view class="card-line"></view> |
|
|
<view class="suggest-list"> |
|
|
<view class="suggest-list"> |
|
|
<view class="suggest-item" v-for="(q, idx) in showQuestions" :key="idx" |
|
|
|
|
|
@click="onQuestionClick(q)"> |
|
|
|
|
|
|
|
|
<view class="suggest-item" v-for="(q, idx) in showQuestions" :key="idx" @click="onQuestionClick(q)"> |
|
|
<view class="left"> |
|
|
<view class="left"> |
|
|
<view :class="['num', 'num-' + ((idx % 5) + 1)]">{{ idx + 1 }}</view> |
|
|
<view :class="['num', 'num-' + ((idx % 5) + 1)]">{{ idx + 1 }}</view> |
|
|
<text class="q-text">{{ q }}</text> |
|
|
<text class="q-text">{{ q }}</text> |
|
|
@ -90,11 +90,17 @@ |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script> |
|
|
<script> |
|
|
import { getQuestion} from "../../api/customerServicePlatform/customerServicePlatform"; |
|
|
|
|
|
|
|
|
import { |
|
|
|
|
|
getQuestionApi, |
|
|
|
|
|
addFeedbackRecordApi, |
|
|
|
|
|
uploadImageApi |
|
|
|
|
|
} from "../../api/customerServicePlatform/customerServicePlatform"; |
|
|
|
|
|
|
|
|
import FeedbackModal from '@/components/FeedbackModal.vue' |
|
|
import FeedbackModal from '@/components/FeedbackModal.vue' |
|
|
export default { |
|
|
export default { |
|
|
components: { FeedbackModal }, |
|
|
|
|
|
|
|
|
components: { |
|
|
|
|
|
FeedbackModal |
|
|
|
|
|
}, |
|
|
data() { |
|
|
data() { |
|
|
return { |
|
|
return { |
|
|
headerTitle: '智能客服中台', |
|
|
headerTitle: '智能客服中台', |
|
|
@ -116,14 +122,12 @@ |
|
|
mounted() { |
|
|
mounted() { |
|
|
// 状态栏高度 |
|
|
// 状态栏高度 |
|
|
this.iSMT = uni.getSystemInfoSync().statusBarHeight; |
|
|
this.iSMT = uni.getSystemInfoSync().statusBarHeight; |
|
|
|
|
|
this.getQuestionList() |
|
|
}, |
|
|
}, |
|
|
created() { |
|
|
created() { |
|
|
this.shuffleQuestions(); |
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
onSumbitFeedback(){ |
|
|
|
|
|
this.onSuccess(); |
|
|
|
|
|
}, |
|
|
|
|
|
onSuccess() { |
|
|
onSuccess() { |
|
|
this.$refs.feedback.show({ |
|
|
this.$refs.feedback.show({ |
|
|
status: 'success', |
|
|
status: 'success', |
|
|
@ -146,24 +150,17 @@ |
|
|
if (typeof uni !== 'undefined') uni.navigateBack(); |
|
|
if (typeof uni !== 'undefined') uni.navigateBack(); |
|
|
}, |
|
|
}, |
|
|
async getQuestionList() { |
|
|
async getQuestionList() { |
|
|
const res = await getQuestion() |
|
|
|
|
|
|
|
|
const res = await getQuestionApi() |
|
|
|
|
|
console.log(res) |
|
|
if (res.code == 200) { |
|
|
if (res.code == 200) { |
|
|
this.showQuestions = res.data |
|
|
this.showQuestions = res.data |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
shuffleQuestions() { |
|
|
|
|
|
// 随机取前4条或展示5条 |
|
|
|
|
|
const arr = this.questions.slice(); |
|
|
|
|
|
for (let i = arr.length - 1; i > 0; i--) { |
|
|
|
|
|
const j = Math.floor(Math.random() * (i + 1)); |
|
|
|
|
|
[arr[i], arr[j]] = [arr[j], arr[i]]; |
|
|
|
|
|
} |
|
|
|
|
|
this.showQuestions = arr.slice(0, 5); |
|
|
|
|
|
}, |
|
|
|
|
|
onQuestionClick(q) { |
|
|
onQuestionClick(q) { |
|
|
// 可跳转到问答页或直接填入反馈 |
|
|
|
|
|
this.feedbackText = q; |
|
|
|
|
|
|
|
|
if (typeof uni !== 'undefined') uni.navigateTo({ |
|
|
|
|
|
url: `/pages/customerServicePlatform/questionDetail?question=${encodeURIComponent(q)}` |
|
|
|
|
|
}); |
|
|
}, |
|
|
}, |
|
|
chooseImage() { |
|
|
chooseImage() { |
|
|
const that = this; |
|
|
const that = this; |
|
|
@ -179,23 +176,22 @@ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
uni.chooseImage({ |
|
|
uni.chooseImage({ |
|
|
count: remain, // 最多选取剩余可上传数量 |
|
|
|
|
|
|
|
|
count: remain, |
|
|
sizeType: ['original', 'compressed'], |
|
|
sizeType: ['original', 'compressed'], |
|
|
sourceType: ['album', 'camera'], |
|
|
sourceType: ['album', 'camera'], |
|
|
success(res) { |
|
|
success(res) { |
|
|
// res.tempFilePaths 是数组(小程序/APP) |
|
|
|
|
|
const paths = res.tempFilePaths || (res.tempFiles && res.tempFiles.map(f => f.path)) || []; |
|
|
const paths = res.tempFilePaths || (res.tempFiles && res.tempFiles.map(f => f.path)) || []; |
|
|
// 追加到 images(Vue2 下 push 是响应式的) |
|
|
|
|
|
for (let p of paths) { |
|
|
for (let p of paths) { |
|
|
if (that.images.length < 3) { |
|
|
if (that.images.length < 3) { |
|
|
that.images.push(p); |
|
|
that.images.push(p); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
// 可选:若要立即上传到服务器,可在这里调用 uni.uploadFile |
|
|
|
|
|
}, |
|
|
}, |
|
|
fail(err) { |
|
|
fail(err) { |
|
|
// 处理取消或失败(不需要提示太多) |
|
|
|
|
|
// console.log('chooseImage fail', err) |
|
|
|
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: `选择图片失败`, |
|
|
|
|
|
icon: 'none' |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
|
@ -204,7 +200,7 @@ |
|
|
// 删除并保持响应 |
|
|
// 删除并保持响应 |
|
|
this.images.splice(index, 1); |
|
|
this.images.splice(index, 1); |
|
|
}, |
|
|
}, |
|
|
submit() { |
|
|
|
|
|
|
|
|
async onSumbitFeedback() { |
|
|
if (!this.feedbackText.trim()) { |
|
|
if (!this.feedbackText.trim()) { |
|
|
if (typeof uni !== 'undefined') uni.showToast({ |
|
|
if (typeof uni !== 'undefined') uni.showToast({ |
|
|
title: '请填写反馈内容', |
|
|
title: '请填写反馈内容', |
|
|
@ -212,32 +208,87 @@ |
|
|
}); |
|
|
}); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
// 模拟上传 |
|
|
|
|
|
if (typeof uni !== 'undefined') uni.showLoading({ |
|
|
if (typeof uni !== 'undefined') uni.showLoading({ |
|
|
title: '提交中...' |
|
|
title: '提交中...' |
|
|
}); |
|
|
}); |
|
|
setTimeout(() => { |
|
|
|
|
|
if (typeof uni !== 'undefined') { |
|
|
|
|
|
uni.hideLoading(); |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: '提交成功', |
|
|
|
|
|
icon: 'success' |
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
let uploadedImages = []; |
|
|
|
|
|
let imgFlag = true |
|
|
|
|
|
for (let i = 0; i < this.images.length; i++) { |
|
|
|
|
|
const f = this.images[i]; |
|
|
|
|
|
await new Promise((resolve, reject) => { |
|
|
|
|
|
uni.getImageInfo({ |
|
|
|
|
|
src: f, |
|
|
|
|
|
success: () => resolve(), |
|
|
|
|
|
fail: reject |
|
|
}); |
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
const uploadRes = await new Promise((resolve, reject) => { |
|
|
|
|
|
uni.uploadFile({ |
|
|
|
|
|
url: 'http://39.101.133.168:8828/hljw/api/aws/upload', |
|
|
|
|
|
filePath: f, |
|
|
|
|
|
name: 'file', |
|
|
|
|
|
formData: { |
|
|
|
|
|
dir: 'deepchart' |
|
|
|
|
|
}, |
|
|
|
|
|
success: (res) => { |
|
|
|
|
|
try { |
|
|
|
|
|
const data = JSON.parse(res.data); |
|
|
|
|
|
if (data.code === 200) { |
|
|
|
|
|
uploadedImages.push(data.data.url); |
|
|
|
|
|
resolve(data); |
|
|
} else { |
|
|
} else { |
|
|
console.log('提交数据', { |
|
|
|
|
|
text: this.feedbackText, |
|
|
|
|
|
images: this.images |
|
|
|
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: `第${i + 1}张图片上传失败`, |
|
|
|
|
|
icon: 'none' |
|
|
|
|
|
}); |
|
|
|
|
|
imgFlag = false; |
|
|
|
|
|
reject(data); |
|
|
|
|
|
} |
|
|
|
|
|
} catch (err) { |
|
|
|
|
|
imgFlag = false; |
|
|
|
|
|
reject(err); |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
fail: (err) => { |
|
|
|
|
|
imgFlag = false; |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: `第${i + 1}张图片上传失败`, |
|
|
|
|
|
icon: 'none' |
|
|
}); |
|
|
}); |
|
|
|
|
|
reject(err); |
|
|
} |
|
|
} |
|
|
// 清空 |
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
if (!imgFlag) { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
const [image1 = '', image2 = '', image3 = ''] = uploadedImages; |
|
|
|
|
|
const res = await addFeedbackRecordApi({ |
|
|
|
|
|
token: "a1bef735d336831ccb0cc3f532093b60", |
|
|
|
|
|
content: this.feedbackText, |
|
|
|
|
|
image1, |
|
|
|
|
|
image2, |
|
|
|
|
|
image3 |
|
|
|
|
|
}) |
|
|
|
|
|
if (res.code == 200) { |
|
|
|
|
|
this.onSuccess() |
|
|
|
|
|
} else { |
|
|
|
|
|
this.onFail() |
|
|
|
|
|
} |
|
|
|
|
|
} catch { |
|
|
|
|
|
this.onFail() |
|
|
|
|
|
} finally { |
|
|
|
|
|
uni.hideLoading(); |
|
|
this.feedbackText = ''; |
|
|
this.feedbackText = ''; |
|
|
this.images = [null, null]; |
|
|
|
|
|
}, 1000); |
|
|
|
|
|
|
|
|
this.images = []; |
|
|
|
|
|
} |
|
|
}, |
|
|
}, |
|
|
viewHistory() { |
|
|
viewHistory() { |
|
|
// 跳转到历史页 |
|
|
// 跳转到历史页 |
|
|
if (typeof uni !== 'undefined') uni.navigateTo({ |
|
|
if (typeof uni !== 'undefined') uni.navigateTo({ |
|
|
url: '/pages/customerServicePlatform/questionDetail' |
|
|
|
|
|
|
|
|
url: '/pages/customerServicePlatform/historyRecord' |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|