接口对接修改

This commit is contained in:
仲么了
2023-07-24 08:47:20 +08:00
parent 2104bc0c4c
commit 689436759f
31 changed files with 1070 additions and 448 deletions

View File

@@ -14,10 +14,16 @@
<uni-icons type="location" color="#007aff" size="26" class="ml20"
@click="chooseLocation"></uni-icons>
</view> -->
<uni-data-picker :localdata="localdata" @change="areaChange"> </uni-data-picker>
<uni-data-picker :localdata="localdata" @change="areaChange" v-model="value">
</uni-data-picker>
</uni-forms-item>
<uni-forms-item label="描述">
<uni-easyinput type="textarea" autoHeight v-model="formData.description" placeholder="请输入工程描述" />
<uni-easyinput
type="textarea"
autoHeight
v-model="formData.description"
placeholder="请输入工程描述"
/>
</uni-forms-item>
</uni-forms>
</view>
@@ -29,22 +35,36 @@
</Cn-page>
</template>
<script>
import { addEngineering } from '../../common/api/engineering'
import { addEngineering, auditEngineering } from '../../common/api/engineering'
import area from '../../common/js/area.json'
export default {
data() {
return {
localdata: area,
loading: false,
value: '',
formData: {
city: '',
description: '',
name: '',
province: '',
},
engineering: {},
}
},
onLoad() {
onLoad(options) {
if (options.engineering) {
this.engineering = JSON.parse(decodeURIComponent(options.engineering))
console.log(this.engineering)
for (let key in this.formData) {
if (this.engineering[key]) {
this.formData[key] = this.engineering[key]
}
}
this.value = this.engineering.city
this.formData.id = this.engineering.id
uni.setNavigationBarTitle({ title: '工程编辑' })
}
uni.getLocation({
type: 'wgs84',
success: function (res) {
@@ -54,13 +74,17 @@ export default {
},
})
// console.log(area);
console.log( this.$util.prePage());
console.log(this.$util.prePage())
},
methods: {
areaChange(e) {
console.log(e)
this.formData.province = e.detail.value[0].value
this.formData.city = e.detail.value[1].value
if (e.detail.value.length) {
this.formData.province = e.detail.value[0].value
this.formData.city = e.detail.value[1].value
} else {
this.formData.province = ''
this.formData.city = ''
}
},
select(e) {
console.log(e)
@@ -91,14 +115,20 @@ export default {
this.$util.toast('请输入工程描述')
return
}
addEngineering(this.formData).then((res) => {
console.log(res)
this.$util.toast('工程创建成功')
this.$util.prePage().store?.reload()
if (this.formData.id) {
await auditEngineering(this.formData)
this.$util.toast('工程修改成功')
let pages = getCurrentPages()
let prePage = pages[pages.length -3]
prePage.store.reload()
setTimeout(() => {
uni.navigateBack({ delta: 1 })
uni.navigateBack({ delta: 2 })
}, 1500)
})
} else {
await addEngineering(this.formData)
this.$util.prePage().store?.reload()
this.$util.toast('工程创建成功')
}
},
},
}