提交 d4e9d1e6 作者: wk

增加汇筑questionAdd页面

父级 24551d7d
......@@ -546,6 +546,15 @@
}
}
,{
"path" : "pages/questionAdd/questionAdd",
"style" :
{
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
}
],
"globalStyle": {
"navigationBarTextStyle": "white",
......
<template>
<view>
<view class="info-box">
<view class="flex-between">
<view class="title"><span class="red">*</span>问题标签</view>
<picker @change="bindPickerChange" :value="index" :range="labelData" range-key="labelMsg">
<view class="uni-input">{{labelData[index] ? labelData[index].labelMsg : '请选择问题标签'}}</view>
</picker>
</view>
</view>
<view class="info-box">
<view class="flex-between">
<view class="title"><span class="red">*</span>标题</view>
<input class="text-right" placeholder="请输入标题" v-model="title" />
</view>
</view>
<view class="info-box">
<view class="title"><span class="red">*</span>内容</view>
<textarea class="mar-top-10" v-model="content" placeholder="请输入内容"/>
</view>
<view class="info-box">
<view class="title">附件</view>
<view class="upload-body mar-top-10">
<view class="upload-box" v-for="(item, index) in fileList" :key="index">
<image :src="item.url" mode="aspectFill"></image>
<icon @click="handleClose(index)" type="cancel" size="20"/>
</view>
<view class="upload-box" @click="handlePic">
<span>+</span>
</view>
</view>
</view>
<view class="bottom-button" @click="handleSave">提交</view>
</view>
</template>
<script>
export default {
data() {
return {
// baseUrl: 'https://cwcd-h5.huizhucloud.com/api', // 测试环境接口
baseUrl: 'https://gdt-front-mobile.hibuilding.cn/api', // 生产环境接口
projectId: '',
token: '',
labelData: [],
index: '',
title: '',
content: '',
attath: [],
fileList: [],
}
},
onLoad(option) {
console.log('option', option)
const { projectId, token } = option
this.projectId = projectId
this.token = token
this.getLabelData()
},
methods: {
getLabelData:function() {
uni.request({
url: `${this.baseUrl}/macro-cwcd/problemLabel/setting/list`,
data: {},
header: {
'Macro-Auth': this.token //自定义请求头信息
},
success: (res) => {
console.log(res.data.data);
this.labelData = res.data.data
}
});
},
bindPickerChange: function(e) {
this.index = e.detail.value
},
handlePic: function() {
uni.chooseImage({
success: (chooseImageRes) => {
const tempFilePaths = chooseImageRes.tempFilePaths;
uni.uploadFile({
url: `${this.baseUrl}/macro-resource/filesys/upload`,
filePath: tempFilePaths[0],
name: 'file',
formData: {
'user': 'test'
},
header: {
'Macro-Auth': this.token //自定义请求头信息
},
success: (uploadFileRes) => {
console.log(uploadFileRes);
const data = JSON.parse(uploadFileRes.data).data
console.log(data);
this.fileList = [...this.fileList].concat([{ url: data.fileUrl, id: data.fileId }])
}
});
}
});
},
handleClose: function(index) {
const temp = []
this.fileList.map((item, aindex) => {
if (index != aindex) temp.push(item)
})
this.fileList = temp
},
handleSave: function() {
const label = this.labelData[this.index] ? this.labelData[this.index].label : ''
const attach = this.fileList.map(item => item.id)
if (!label || !this.title || !this.content) {
uni.showToast({
title: '请完善信息!',
icon: 'error'
})
return
}
console.log('label', label)
uni.request({
url: `${this.baseUrl}/macro-cwcd/problemFeedback/worker/create`,
method: 'POST',
data: {
label: parseInt(label),
title: this.title,
content: this.content,
attach: attach.join(','),
projectId: this.projectId
},
header: {
'Macro-Auth': this.token //自定义请求头信息
},
success: (res) => {
console.log('create-httpCode', res.data.httpCode);
if (res.data.httpCode === 200) {/* */
uni.navigateBack()
} else {
uni.showToast({
title: res.data.sys_msg,
icon:'error'
})
}
}
});
}
}
}
</script>
<style lang="scss">
page {
background: #f5f5f5;
}
.flex-between {
display: flex;
justify-content: space-between;
align-items: center;
}
.flex-start {
display: flex;
justify-content: flex-start;
}
.text-right {
text-align: right;
}
.info-box {
background: #fff;
// border-radius: 16rpx;
padding: 20rpx;
font-size: 28rpx;
margin-top: 30rpx;
position: relative;
color: #656565;
.red {
color: #FF3141
}
.title {
color: #333;
}
.mar-top-10 {
margin-top: 20rpx;
}
.upload-body {
display: flex;
justify-content: flex-start;
.upload-box {
width: 160rpx;
height: 160rpx;
color: #dcdee0;
background-color: #f7f8fa;
// line-height: 160rpx;
text-align: center;
font-size: 60rpx;
margin-right: 20rpx;
position: relative;
display: flex;
justify-content: center;
align-items: center;
image {
width: 100%;
height: 100%;
}
icon {
position: absolute;
right: 0px;
top: 0px;
}
}
}
}
.bottom-button {
position: fixed;
bottom: 0rpx;
width: 100%;
height: 96rpx;
background: #3b73fe;
text-align: center;
color: #fff;
line-height: 96rpx;
font-size: 32rpx;
left: 0;
}
</style>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
Please register or to comment