This commit is contained in:
yanran200730
2022-07-02 16:17:55 +08:00
parent 54f0d57b37
commit 58022d5154
7 changed files with 230 additions and 123 deletions

View File

@@ -68,79 +68,93 @@
</template>
<script>
import {mapState} from 'vuex'
import {mapState} from 'vuex'
export default {
name: 'add',
data() {
return {
name: '',
files: [],
form: {
bossName: '',
businessAddress: '',
businessName: '',
lat: '',
lon: '',
storePicUrl: [],
telephone: ''
export default {
name: 'add',
appName: '新增商户',
data() {
return {
name: '',
files: [],
form: {
bossName: '',
businessAddress: '',
businessName: '',
lat: '',
lng: '',
storePicUrl: [],
telephone: ''
},
id: ''
}
}
},
computed: {...mapState(['user'])},
onLoad () {
},
onShow() {
document.title = "新增商户"
},
methods: {
chooseLocation () {
uni.chooseLocation({
success: res => {
this.form.businessAddress = res.name
this.form.lat = res.latitude
this.form.lon = res.longitude
}
})
},
save () {
if (!this.form.bossName) {
return this.$u.toast('请输入店名')
}
computed: {...mapState(['user'])},
if (!this.form.businessAddress) {
return this.$u.toast('请输入所在地址')
}
onLoad (query) {
this.id = query.id
this.getInfo()
},
if (!this.form.businessName) {
return this.$u.toast('请输入店长名称')
}
methods: {
chooseLocation () {
uni.chooseLocation({
success: res => {
this.form.businessAddress = res.name
this.form.lat = res.latitude
this.form.lng = res.longitude
}
})
},
this.$loading()
this.$http.post('/api/appcompany/addORUpdate', {
...this.form,
storePicUrl: this.form.storePicUrl.length ? this.form.storePicUrl[0].url : ''
}).then(res => {
if (res.code === 0) {
this.$u.toast('提交成功')
getInfo () {
this.$loading()
this.$http.post(`/app/appcompany/getDetailById?id=${this.id}`).then(res => {
if (res.code === 0) {
this.form = {
...this.form,
...res.data,
storePicUrl: res.data.storePicUrl ? [{url: res.data.storePicUrl}] : []
}
}
})
},
setTimeout(() => {
uni.$emit('update')
uni.navigateBack({
delta: 1
})
}, 500)
save () {
if (!this.form.bossName) {
return this.$u.toast('请输入店名')
}
if (!this.form.businessAddress) {
return this.$u.toast('请输入所在地址')
}
if (!this.form.businessName) {
return this.$u.toast('请输入店长名称')
}
this.$loading()
this.$http.post('/api/appcompany/addORUpdate', {
...this.form,
storePicUrl: this.form.storePicUrl.length ? this.form.storePicUrl[0].url : ''
}).then(res => {
if (res.code === 0) {
this.$u.toast('提交成功')
setTimeout(() => {
uni.$emit('update')
uni.navigateBack({
delta: 1
})
}, 500)
}
})
}
})
}
}
}
</script>
<style lang="scss" scoped>