Blame view

pages/postDemand/postDemand.vue 5.87 KB
290144e9   易尊强   第一次
1
2
3
4
5
6
  <template>
  	<view class="page">
  		<!-- 反馈内容 -->
  		<view class="feedback-data">
  			<view class="titleall-box">
  				<view class="titleall-left">
6c679290   易尊强   3/6a上午
7
  					<view class="titleall-left-line"></view>填写需求信息
290144e9   易尊强   第一次
8
9
10
11
12
13
14
15
16
17
18
19
  				</view>
  			</view>
  			<uni-forms ref="valiForm" :rules="rules" :modelValue="valiFormData" style="width: 96%;margin: 0 auto;">
  				<uni-forms-item label="需求标题" required name="title">
  					<uni-easyinput v-model="valiFormData.title" placeholder="请输入" />
  				</uni-forms-item>
  				<uni-forms-item label="需求简介" required name="subTitle">
  					<uni-easyinput v-model="valiFormData.subTitle" placeholder="请输入" />
  				</uni-forms-item>
  				<uni-forms-item label="联系电话" required name="phone">
  					<uni-easyinput v-model="valiFormData.phone" placeholder="请输入电话号码" />
  				</uni-forms-item>
6c679290   易尊强   3/6a上午
20
  				<uni-forms-item label="详细内容">
290144e9   易尊强   第一次
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
  					<uni-easyinput type="textarea" v-model="valiFormData.bodyContent" placeholder="请输入详细产品介绍" />
  				</uni-forms-item>
  			</uni-forms>
  			<view class="example-body">
  				<uni-file-picker limit="9"  @select="select"
  					title="最多选择9张产品图片"></uni-file-picker>
  			</view>
  			<!-- <view class="voucher-img">
  				<view class="list">
  					<image src="/static/voucher_bg.png"></image>
  				</view>
  				<view class="list">
  					<image src="/static/img/yf_01.png"></image>
  				</view>
  				<view class="list">
  					<image src="/static/img/yf_01.png"></image>
  				</view>
  			</view> -->
  		</view>
  		<!-- 选择反馈类型 -->
  		<!-- <view class="feedback-type">
  			<view class="feedback-type-left">隶属类别</view>
  			<view class="feedback-type-right">
  				<view class="title">
  					<text>{{TypeArray[TypeIndex]}}</text>
  				</view>
  				<view class="picker">
  					<picker @change="FeedbackTypeCh" :value="TypeIndex" :range="TypeArray">
  						<view class="uni-input">{{TypeArray[TypeIndex]}}</view>
  					</picker>
  				</view>
  				<view class="more">
  					<image src="../../static/down1.png"></image>
  				</view>
  			</view>
  		</view> -->
  		<!-- 提交 -->
  		<view class="submit-btn" @click="submitContent('valiForm')">
  			<text>发布</text>
  		</view>
  	</view>
  </template>
  
  <script>
  	import {
  		data
  	} from '../../uview-ui/libs/mixin/mixin';
  	import request from '@/utils/request.js'
  	export default {
  		data() {
  			return {
  				userCode:{},
  				// 选择图片路径
  				filePath:[],
  				uploadPath:[],
  				imageValue: [],
  				TypeArray: ['资讯', '意见建议', '投诉', '表扬'],
  				TypeIndex: 0,
  				type: "",
  				lastModifyUserId: '',
  				// 校验表单数据
  				valiFormData: {
  					title: '',
  					bodyContent: '',
  					subTitle:'',
  					phone:''
  				},
  				creater: '',
  				rules: {
  					title: {
  						rules: [{
  							required: true,
  							errorMessage: '不能为空'
  						}]
  					},
  					subTitle: {
  						rules: [{
  							required: true,
  							errorMessage: '不能为空'
  						}]
  					},
  					phone: {
  						rules: [{
  							required: true,
  							errorMessage: '不能为空'
  						}]
  					},
  				},
9b1c150c   “wangming”   1
109
  				baseUrl:"https://www.dygxq-es.cn"
290144e9   易尊强   第一次
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
  			};
  
  		},
  		onShow() {
  			this.getType()
  		},
  		onLoad() {
  			this.getUser()
  			let user = uni.getStorageSync('user')
  			this.lastModifyUserId = user.userInfo.userId
  
  		},
  		methods: {
  			// 获取上传状态
  			select(e) {
  				console.log('选择文件:', e)
  				this.filePath = e.tempFilePaths
  			},
  			// 获取用户信息
  			getUser() {
  				if (uni.getStorageSync('user')) {
  					this.userCode = uni.getStorageSync('user').userInfo
  					// this.userInfo = this.userCode.userAccount
  					// this.userInfo = '123456'
  					console.log('用户已登录!',this.userCode)
  				} else {
  					uni.showToast({
  						title: '请登录',
  						icon: 'none'
  					})
  					setTimeout(() => {
  						uni.reLaunch({
  							url: '/pages/login/index'
  						})
  					})
  				}
  			},
  			// 提交内容
  			submitContent(ref) {
  				this.$refs[ref].validate().then(res => {
  					console.log('success', res);
  					uni.showToast({
  						title: `校验通过`
  					})
  					
  					this.uploadPath = []
  					for(let i=0;i<this.filePath.length;i++){
  						uni.uploadFile({
9b1c150c   “wangming”   1
158
  							url:"https://www.dygxq-es.cn/api/file/Uploader/1",
290144e9   易尊强   第一次
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
  							filePath:this.filePath[i],
  							name:'file',
  							success: (res) => {
  								console.log(JSON.parse(res.data))
  								let data = JSON.parse(res.data).data
  								console.log(data)
  								this.uploadPath.push(data)
  							}
  						})
  					}
  					console.log('需要',this.uploadPath)
  					let stageName = this.TypeArray[this.TypeIndex]
  					let that = this
  					setTimeout(function(){
  						console.log('需要',that.uploadPath)
  						if(that.uploadPath){
  							console.log('jinru')
  							request({
  								url:'/api/Extend/demandrelease',
  								method:'post',
  								// header:{
  								// 	"Content-Type": "application/json-patch+json'"
  								// },
  								data:{
  									title:that.valiFormData.title,
  									content:that.valiFormData.bodyContent,
  									creatorUserId:that.userCode.userId,
  									stageName:stageName,
  									stage:stageName,
  									comanyId:that.userCode.organizeId,
  									comapny:that.userCode.organizeName,
  									images:that.uploadPath,
  									subTitle:that.valiFormData.subTitle,
  									phone:that.valiFormData.phone
  								}
  							}).then(res=>{
  								if(res.code === 200){
  									console.log("上传后的值",res)
  									uni.showToast({
  										icon:"success",
  										title:"发布成功"
e6b161ae   易尊强   2/23
200
201
202
203
  									}).then(()=>{
  										uni.navigateTo({
  											url:"/pages/demand/demand"
  										})
290144e9   易尊强   第一次
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
  									})
  								}
  							})
  						}else{
  							uni.showToast({
  								icon:"error",
  								title:"请选择图片"
  							})
  						}
  					},2000)
  				}).catch(err => {
  					console.log('err', err);
  				})	
  			},
  			/**
  			 * 反馈类型
  			 * @param {Object} 
  			 */
  			FeedbackTypeCh(val) {
  				console.log(val);
  				this.TypeIndex = val.detail.value;
  			}
  		}
  	}
  </script>
  
  <style scoped lang="scss">
  	@import 'Feedback.scss';
  </style>