小程序底座架构完成
This commit is contained in:
@@ -35,7 +35,7 @@
|
||||
<div class="form-item__right" @click="chooseAddress">
|
||||
<span v-if="form.address">{{ form.address }}</span>
|
||||
<i v-else>请选择</i>
|
||||
<u-icon name="arrow-right" color="#ddd" />
|
||||
<u-icon name="arrow-right" color="#ddd"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -45,13 +45,14 @@
|
||||
<i>*</i>
|
||||
<h2>所属网格</h2>
|
||||
</div>
|
||||
<picker :range="gridList" mode="multiSelector" range-key="girdName" @columnchange="onColumnChange" @change="onChange">
|
||||
<div class="form-item__right">
|
||||
<span v-if="form.girdName">{{ form.girdName }}</span>
|
||||
<i v-else>请选择</i>
|
||||
<u-icon name="arrow-right" color="#ddd" />
|
||||
</div>
|
||||
</picker>
|
||||
<picker :range="gridList" mode="multiSelector" range-key="girdName" @columnchange="onColumnChange"
|
||||
@change="onChange">
|
||||
<div class="form-item__right">
|
||||
<span v-if="form.girdName">{{ form.girdName }}</span>
|
||||
<i v-else>请选择</i>
|
||||
<u-icon name="arrow-right" color="#ddd"/>
|
||||
</div>
|
||||
</picker>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -64,7 +65,7 @@
|
||||
<span>(最多9张)</span>
|
||||
</div>
|
||||
<div class="form-item__right">
|
||||
<ai-uploader v-model="form.files" :limit="9"></ai-uploader>
|
||||
<AiUploader v-model="form.files" :limit="9"></AiUploader>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -77,7 +78,7 @@
|
||||
<h2>姓名</h2>
|
||||
</div>
|
||||
<div class="form-item__right">
|
||||
<input placeholder="请输入" v-model="form.name" :maxlength="20" />
|
||||
<input placeholder="请输入" v-model="form.name" :maxlength="20"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -88,7 +89,7 @@
|
||||
<h2>联系方式</h2>
|
||||
</div>
|
||||
<div class="form-item__right">
|
||||
<input placeholder="请输入" v-model="form.phone" :maxlength="20" />
|
||||
<input placeholder="请输入" v-model="form.phone" :maxlength="20"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -100,285 +101,277 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import AiUploader from '@/components/AiUploader/AiUploader'
|
||||
import AiSelect from '@/components/AiSelect/AiSelect'
|
||||
import { mapState } from 'vuex'
|
||||
import {mapState} from 'vuex'
|
||||
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
isShowType: false,
|
||||
form: {
|
||||
content: '',
|
||||
lat: '',
|
||||
lng: '',
|
||||
address: '',
|
||||
name: '',
|
||||
phone: '',
|
||||
groupId: '',
|
||||
groupName: '',
|
||||
girdName: '',
|
||||
girdId: '',
|
||||
files: []
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
isShowType: false,
|
||||
form: {
|
||||
content: '',
|
||||
lat: '',
|
||||
lng: '',
|
||||
address: '',
|
||||
name: '',
|
||||
phone: '',
|
||||
groupId: '',
|
||||
groupName: '',
|
||||
girdName: '',
|
||||
girdId: '',
|
||||
files: []
|
||||
},
|
||||
dictList: [],
|
||||
arr: [],
|
||||
gridList: [[], []],
|
||||
flag: false
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapState(['user'])
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.getDict()
|
||||
this.form.phone = this.user.phone
|
||||
this.form.name = this.user.realName || ''
|
||||
this.getGirdList()
|
||||
},
|
||||
|
||||
methods: {
|
||||
chooseAddress() {
|
||||
uni.authorize({
|
||||
scope: 'scope.userLocation',
|
||||
success: () => {
|
||||
uni.chooseLocation({
|
||||
success: res => {
|
||||
this.form.address = res.address
|
||||
this.form.lat = res.latitude
|
||||
this.form.lng = res.longitude
|
||||
}
|
||||
})
|
||||
},
|
||||
dictList: [],
|
||||
arr: [],
|
||||
gridList: [[], []],
|
||||
flag: false
|
||||
}
|
||||
},
|
||||
|
||||
components: {
|
||||
AiSelect,
|
||||
AiUploader
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapState(['user'])
|
||||
},
|
||||
|
||||
onLoad () {
|
||||
this.getDict()
|
||||
this.form.phone = this.user.phone
|
||||
this.form.name = this.user.realName || ''
|
||||
this.getGirdList()
|
||||
},
|
||||
|
||||
methods: {
|
||||
chooseAddress () {
|
||||
uni.authorize({
|
||||
scope: 'scope.userLocation',
|
||||
success: () => {
|
||||
uni.chooseLocation({
|
||||
fail: () => {
|
||||
this.$dialog.confirm({
|
||||
content: '您未授权定位权限,无法选择位置'
|
||||
}).then(() => {
|
||||
wx.openSetting({
|
||||
success: res => {
|
||||
this.form.address = res.address
|
||||
this.form.lat = res.latitude
|
||||
this.form.lng = res.longitude
|
||||
}
|
||||
})
|
||||
},
|
||||
fail: () => {
|
||||
this.$dialog.confirm({
|
||||
content: '您未授权定位权限,无法选择位置'
|
||||
}).then(() => {
|
||||
wx.openSetting({
|
||||
success: res => {
|
||||
if (!res.authSetting['scope.userLocation']) {
|
||||
this.$dialog.alert({
|
||||
content: '您未授权定位权限,无法选择位置'
|
||||
}).then(() => {
|
||||
})
|
||||
} else {
|
||||
console.log('设置定位权限')
|
||||
}
|
||||
if (!res.authSetting['scope.userLocation']) {
|
||||
this.$dialog.alert({
|
||||
content: '您未授权定位权限,无法选择位置'
|
||||
}).then(() => {
|
||||
})
|
||||
} else {
|
||||
console.log('设置定位权限')
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
getDict () {
|
||||
this.$instance.post(`/app/appclapeventgroup/list?current=1&size=100000`).then(res => {
|
||||
if (res.code == 0) {
|
||||
this.dictList = res.data.records.map(v => {
|
||||
return {
|
||||
value: v.id,
|
||||
label: v.groupName
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
getGirdData (x) {
|
||||
if (x > -1) {
|
||||
this.$set(this.gridList, '1', this.arr[0].girdList[x].girdList)
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
|
||||
getGirdList () {
|
||||
this.$instance.post(`/app/appgirdinfo/listAllByTop`).then(res => {
|
||||
if (res.code == 0) {
|
||||
this.arr = res.data
|
||||
this.gridList[0] = res.data[0].girdList
|
||||
this.gridList[1] = res.data[0].girdList[0].girdList
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
onColumnChange (e) {
|
||||
const column = e.detail.column
|
||||
const value = e.detail.value
|
||||
|
||||
|
||||
|
||||
if (column === column) {
|
||||
this.getGirdData(value)
|
||||
getDict() {
|
||||
this.$instance.post(`/app/appclapeventgroup/list?current=1&size=100000`).then(res => {
|
||||
if (res.code == 0) {
|
||||
this.dictList = res.data.records.map(v => {
|
||||
return {
|
||||
value: v.id,
|
||||
label: v.groupName
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
|
||||
onChange (e) {
|
||||
console.log(e)
|
||||
const v = e.detail.value[1]
|
||||
console.log(v)
|
||||
if (this.gridList[1][v]) {
|
||||
this.form.girdName = this.gridList[1][v].girdName
|
||||
this.form.girdId = this.gridList[1][v].id
|
||||
} else {
|
||||
return this.$toast('所属网格必须选第三级网格')
|
||||
// this.form.girdName = this.gridList[e.detail.value[0].girdName
|
||||
// this.form.girdId = this.gridList[e.detail.value[0].id
|
||||
}
|
||||
},
|
||||
|
||||
submit () {
|
||||
if (!this.form.groupId) {
|
||||
return this.$toast('请选择事件类型')
|
||||
}
|
||||
|
||||
if (!this.form.content) {
|
||||
return this.$toast('请输入事件描述')
|
||||
}
|
||||
if (!this.form.address) {
|
||||
return this.$toast('请选择上报位置')
|
||||
}
|
||||
|
||||
if (!this.form.girdName) {
|
||||
return this.$toast('请选择所属网格')
|
||||
}
|
||||
if (!this.form.name) {
|
||||
return this.$toast('请输入上报人姓名')
|
||||
}
|
||||
|
||||
if (!this.form.girdName) {
|
||||
return this.$toast('请输入上报人联系方式')
|
||||
}
|
||||
if(this.flag) return
|
||||
this.flag = true
|
||||
|
||||
this.$loading()
|
||||
this.$instance.post(`/app/appclapeventinfo/addOrUpdate`, {
|
||||
...this.form,
|
||||
openid: this.user.openid,
|
||||
portrait: this.user.avatarUrl,
|
||||
files: this.form.files,
|
||||
groupName: this.dictList.filter(v => v.value === this.form.groupId)[0].label
|
||||
}).then(res => {
|
||||
this.$hideLoading()
|
||||
this.flag = false
|
||||
if (res.code == 0) {
|
||||
uni.$emit('update')
|
||||
setTimeout(() => {
|
||||
uni.redirectTo({
|
||||
url: './PhotoResult?id=' + res.data.id
|
||||
})
|
||||
}, 400)
|
||||
}
|
||||
this.$hideLoading()
|
||||
})
|
||||
getGirdData(x) {
|
||||
if (x > -1) {
|
||||
this.$set(this.gridList, '1', this.arr[0].girdList[x].girdList)
|
||||
}
|
||||
},
|
||||
|
||||
getGirdList() {
|
||||
this.$instance.post(`/app/appgirdinfo/listAllByTop`).then(res => {
|
||||
if (res.code == 0) {
|
||||
this.arr = res.data
|
||||
this.gridList[0] = res.data[0].girdList
|
||||
this.gridList[1] = res.data[0].girdList[0].girdList
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
onColumnChange(e) {
|
||||
const column = e.detail.column
|
||||
const value = e.detail.value
|
||||
|
||||
|
||||
if (column === column) {
|
||||
this.getGirdData(value)
|
||||
}
|
||||
},
|
||||
|
||||
onChange(e) {
|
||||
console.log(e)
|
||||
const v = e.detail.value[1]
|
||||
console.log(v)
|
||||
if (this.gridList[1][v]) {
|
||||
this.form.girdName = this.gridList[1][v].girdName
|
||||
this.form.girdId = this.gridList[1][v].id
|
||||
} else {
|
||||
return this.$toast('所属网格必须选第三级网格')
|
||||
// this.form.girdName = this.gridList[e.detail.value[0].girdName
|
||||
// this.form.girdId = this.gridList[e.detail.value[0].id
|
||||
}
|
||||
},
|
||||
|
||||
submit() {
|
||||
if (!this.form.groupId) {
|
||||
return this.$toast('请选择事件类型')
|
||||
}
|
||||
|
||||
if (!this.form.content) {
|
||||
return this.$toast('请输入事件描述')
|
||||
}
|
||||
if (!this.form.address) {
|
||||
return this.$toast('请选择上报位置')
|
||||
}
|
||||
|
||||
if (!this.form.girdName) {
|
||||
return this.$toast('请选择所属网格')
|
||||
}
|
||||
if (!this.form.name) {
|
||||
return this.$toast('请输入上报人姓名')
|
||||
}
|
||||
|
||||
if (!this.form.girdName) {
|
||||
return this.$toast('请输入上报人联系方式')
|
||||
}
|
||||
if (this.flag) return
|
||||
this.flag = true
|
||||
|
||||
this.$loading()
|
||||
this.$instance.post(`/app/appclapeventinfo/addOrUpdate`, {
|
||||
...this.form,
|
||||
openid: this.user.openid,
|
||||
portrait: this.user.avatarUrl,
|
||||
files: this.form.files,
|
||||
groupName: this.dictList.filter(v => v.value === this.form.groupId)[0].label
|
||||
}).then(res => {
|
||||
this.$hideLoading()
|
||||
this.flag = false
|
||||
if (res.code == 0) {
|
||||
uni.$emit('update')
|
||||
setTimeout(() => {
|
||||
uni.redirectTo({
|
||||
url: './PhotoResult?id=' + res.data.id
|
||||
})
|
||||
}, 400)
|
||||
}
|
||||
this.$hideLoading()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.album {
|
||||
padding-bottom: 140px;
|
||||
.album {
|
||||
padding-bottom: 140px;
|
||||
|
||||
.form-item__group {
|
||||
margin-bottom: 24px;
|
||||
background: #fff;
|
||||
}
|
||||
.form-item__group {
|
||||
margin-bottom: 24px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.form-item {
|
||||
padding-left: 32px;
|
||||
.form-item {
|
||||
padding-left: 32px;
|
||||
|
||||
.form-item__wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
height: 128px;
|
||||
padding-right: 28px;
|
||||
border-bottom: 1px solid #DDDDDD;
|
||||
.form-item__wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
height: 128px;
|
||||
padding-right: 28px;
|
||||
border-bottom: 1px solid #DDDDDD;
|
||||
|
||||
input {
|
||||
flex: 1;
|
||||
height: 100%;
|
||||
text-align: right;
|
||||
padding-right: 10px;
|
||||
}
|
||||
|
||||
.form-item__right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 32px;
|
||||
|
||||
span {
|
||||
max-width: 400px;
|
||||
margin-right: 8px;
|
||||
color: #333333;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
i {
|
||||
margin-right: 8px;
|
||||
color: #999999;
|
||||
}
|
||||
}
|
||||
input {
|
||||
flex: 1;
|
||||
height: 100%;
|
||||
text-align: right;
|
||||
padding-right: 10px;
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
.form-item__wrapper {
|
||||
border-bottom: none;
|
||||
.form-item__right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 32px;
|
||||
|
||||
span {
|
||||
max-width: 400px;
|
||||
margin-right: 8px;
|
||||
color: #333333;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
i {
|
||||
margin-right: 8px;
|
||||
color: #999999;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
.form-item__wrapper {
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
|
||||
.form-item__title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
i {
|
||||
font-size: 32px;
|
||||
color: #FF4466;
|
||||
}
|
||||
|
||||
span {
|
||||
font-size: 28px;
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
h2 {
|
||||
padding: 0 4px;
|
||||
font-weight: 600;
|
||||
font-size: 32px;
|
||||
color: #333333;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
&.form-item__imgs, &.form-item__textarea {
|
||||
.form-item__wrapper {
|
||||
display: block;
|
||||
height: auto;
|
||||
padding-bottom: 32px;
|
||||
}
|
||||
|
||||
textarea {
|
||||
width: 100%;
|
||||
height: 160px;
|
||||
}
|
||||
|
||||
.form-item__title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
i {
|
||||
font-size: 32px;
|
||||
color: #FF4466;
|
||||
}
|
||||
|
||||
span {
|
||||
font-size: 28px;
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
h2 {
|
||||
padding: 0 4px;
|
||||
font-weight: 600;
|
||||
font-size: 32px;
|
||||
color: #333333;
|
||||
}
|
||||
padding: 32px 0;
|
||||
}
|
||||
|
||||
|
||||
&.form-item__imgs, &.form-item__textarea {
|
||||
.form-item__wrapper {
|
||||
display: block;
|
||||
height: auto;
|
||||
padding-bottom: 32px;
|
||||
}
|
||||
|
||||
textarea {
|
||||
width: 100%;
|
||||
height: 160px;
|
||||
}
|
||||
|
||||
.form-item__title {
|
||||
padding: 32px 0;
|
||||
}
|
||||
|
||||
.form-item__right {
|
||||
padding-left: 18px;
|
||||
}
|
||||
.form-item__right {
|
||||
padding-left: 18px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user