index.vue
7.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
109
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
158
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
200
201
202
203
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
233
234
235
236
<template>
<div class="baseinfo">
<form class="baseinfo-box" @submit='commit'>
<div class="list-input">
<span>讲座标题</span>
<input placeholder="请输入讲座标题" name='name' :value="name" @input='name=service.Input($event)' placeholder-style='color:#9B9B9B'>
</div>
<div class="list-input between">
<span>讲座街道</span>
<picker :value='street.index' :range='street.columnOne' @change="pickerConfirm($event,'street')">
<div hover-class='hover'>{{street.label}}</div>
</picker>
</div>
<div class="list-input between">
<span>讲座社区</span>
<picker :disabled="street.label=='点击选择街道'" @tap='warning' :value='community.index' :range='community.columnOne' @change="pickerConfirm($event,'community')">
<div hover-class='hover'>{{community.label}}</div>
</picker>
</div>
<div class="list-input between">
<span>讲座日期</span>
<picker mode='date' :value='date' @change="pickerConfirm($event,'date')">
<div hover-class='hover' :class="{unset:date==''}">{{date || '点击选择'}}</div>
</picker>
</div>
<div class="list-input between">
<span>讲座时间</span>
<picker mode='time' :value='time' @change="pickerConfirm($event,'time')">
<div hover-class='hover' :class="{unset:time==''}">{{time || '点击选择'}}</div>
</picker>
</div>
<div class='greytitle'>讲座内容</div>
<div class='textarea'>
<textarea placeholder='请输入讲座内容' name='content' :value='content' @input='content=service.Input($event)' maxlength=10000 />
<div>{{content.length}}/10000</div>
</div>
<div class='commit'>
<button form-type='submit' hover-class='fade' :disabled='commiting'>提交</button>
</div>
</form>
</div>
</template>
<script>
export default {
data() {
return {
street: {
columnOne: [],
index: 0,
arrStruct: [],
label:'点击选择街道'
},
community: {
columnOne: [],
index: 0,
arrStruct: [],
label:'点击选择社区'
},
name: '',
content: '',
date: '',
time: '',
commiting: false
}
},
methods: {
commit(e, type='first') {
if(this.commiting){
return
}
console.log(e)
let inputs = this.service.filter(e.mp.detail.value)
if(!inputs.allowed){
return
}else{
inputs = inputs.obj
}
const street = this.street.label.replace('点击选择街道','')
const community = this.community.label.replace('点击选择社区','')
if(!this.service.checkEmptyInput([inputs.name,street,community,this.date,this.time,inputs.content],['讲座标题','街道','社区','讲座日期','讲座时间','讲座内容'])){
return
}
if(!this.service.checkBadWords([inputs.name,inputs.content],['标题','内容'])){
return
}
if(type=='first'){
wx.showModal({
title:'',
content: '确定要发布吗?',
success: res => {
if (res.confirm){
this.execCommit(e, inputs)
}
}
})
}else{
this.execCommit(e, inputs)
}
},
execCommit(e,inputs){
wx.showLoading({title:'正在上传'})
this.commiting = true
wx.request({
url: this.rootUrl + '/lecture/addlect',
header: { 'content-type': 'application/x-www-form-urlencoded' },
method: 'POST',
data: {
scid: this.community.arrStruct[this.community.index].value,
sessionID: wx.getStorageSync('sessionID'),
lecture_title: inputs.name,
lecture_content: inputs.content,
lecture_date: `${this.date} ${this.time}:00`
},
success: res => {
if(res.statusCode=='500'){
console.log('eeee')
this.service.getUnionId(this.rootAvatar,this.rootUrl).then(res=>{
console.log(res)
this.commiting = false
this.commit(e,'again')
})
}else{
console.log(res)
if(res.data === 1){
wx.hideLoading()
wx.showModal({
title: '发布成功',
content: '请在我的讲座中查看',
showCancel: false,
success: res => {
if(res.confirm){
this.name = ''
this.date = ''
this.time = ''
this.content = ''
this.$set(this.street,'index',0)
this.$set(this.street,'label','点击选择街道')
this.$set(this.community,'label','点击选择社区')
this.commiting = false
}
}
})
}else{
wx.hideLoading()
wx.showToast({title:'上传失败 请检查上传内容',icon: 'none'})
this.commiting = false
}
}
},
fail: res=>{
wx.hideLoading()
wx.showToast({title:'上传失败',icon: 'none'})
this.commiting = false
}
})
},
warning(){
if(this.street.label=='点击选择街道'){
wx.showToast({
title:'请先选择街道',
icon: 'none'
})
}
},
pickerConfirm(e, s) {
switch (s) {
case 'time': this.time = e.mp.detail.value;break
case 'date': this.date = e.mp.detail.value;break
case 'street': {
const oldLabel = this.street.label
this.street.index = e.mp.detail.value
this.street.label = this.street.columnOne[this.street.index]
if(oldLabel != this.street.label){
this.getCommunity()
}
break
}
case 'community': {
this.community.index = e.mp.detail.value
this.community.label = this.community.columnOne[this.community.index]
break
}
}
},
getCommunity(){
wx.showLoading({ title: '加载社区列表' })
wx.request({
url: this.rootUrl + '/comm/getbyid/' + this.street.arrStruct[this.street.index].value,
success: res => {
this.community.columnOne = res.data.map(v=>v.comm_Name)
this.community.arrStruct = res.data.map(v=>{return {label:v.comm_Name,value:v.scid}})
this.community.index = 0
this.community.label = this.community.columnOne[0]
wx.hideLoading()
}
})
}
},
onLoad() {
wx.request({
url: this.rootUrl + '/street/all',
success: res => {
this.street.columnOne = res.data.map(v => v.street_Name)
this.street.arrStruct = res.data.map(v => {
return { label: v.street_Name, value: v.ssid }
})
}
})
}
}
</script>
<style lang="stylus" scoped>
.baseinfo
position absolute
Height_Width(100%)
Background()
.baseinfo-box
Background()
.textarea
padding 0 30rpx 30rpx 30rpx
Font(30rpx, 40rpx)
background-color #fff
textarea
height 200rpx
width 100%
border-radius 10rpx
background #eee
box-sizing border-box
div
margin-top: 15rpx;
text-align: right;
color: #888;
font-size: 28rpx;
</style>