接口对接

This commit is contained in:
仲么了
2023-03-30 09:04:07 +08:00
parent 3f966d4024
commit 0325347e06
15 changed files with 226 additions and 61 deletions

View File

@@ -35,6 +35,10 @@
</uni-list-item>
</uni-list>
</view>
<view style="padding: 0 20rpx" v-show="navMenuActive == 2">
<image class="gplot gplot-box" mode="aspectFill" src="/static/test2.pic.png"
v-for="(item, key) in 3" :key="key" />
</view>
<uni-load-more status="nomore"></uni-load-more>
</view>
<uni-fab ref="fab" direction="vertical" horizontal="right" vertical="bottom" :content="content"
@@ -53,9 +57,11 @@ export default {
loading: false,
project: '',
navMenuList: [{
text: '设备列表'
text: '设备'
}, {
text: '子用户列表'
text: '子用户'
}, {
text: '拓扑图'
}],
content: [],
navHeight: 0,
@@ -168,4 +174,10 @@ export default {
border-radius: 10rpx;
}
}
.gplot {
position: relative;
width: 100%;
border: 8rpx solid #ccc;
}
</style>

View File

@@ -4,7 +4,8 @@
<uni-nav-bar dark :fixed="true" status-bar left-icon="left" :rightIcon="userInfo.role == '2' ? '' : 'plusempty'"
background-color="#fff" color="#111" title="项目管理" @clickLeft="back" @clickRight="add" />
<view class="message">
<uni-card title="XXX项目1" extra="用能" @click="jump('XXX项目1')">
<uni-card :title="item.name" :extra="item.projectType" @click="jump('XXX项目1')"
v-for="(item, index) in store.data" :key="index">
<view class="term-list-bottom">
<view class="term-list-bottom-item">
<view>设备个数</view>
@@ -16,25 +17,16 @@
</view>
</view>
</uni-card>
<uni-card title="XXX项目2" extra="监测" @click="jump('XXX项目2')">
<view class="term-list-bottom">
<view class="term-list-bottom-item">
<view>设备个数</view>
<view>3</view>
</view>
<view class="term-list-bottom-item">
<view>用户个数</view>
<view>1</view>
</view>
</view>
</uni-card>
<uni-load-more status="nomore"></uni-load-more>
<Cn-empty v-if="store.empty"></Cn-empty>
<uni-load-more v-if="store.data && store.data.length > 0" :status="store.status"></uni-load-more>
</view>
</view>
</template>
<script>
import list from '../../common/js/list'
export default {
mixins: [list],
data () {
return {
loading: false,
@@ -43,7 +35,8 @@ export default {
},
methods: {
init () {
this.userInfo = uni.getStorageSync('userInfo')
this.store = this.DataSource('/project/queryProject')
this.store.reload()
},
back () {
uni.navigateBack()

View File

@@ -8,20 +8,22 @@
<uni-easyinput type="number" v-model="formData.name" placeholder="请输入项目名称" />
</uni-forms-item>
<uni-forms-item label="项目类别">
<uni-data-select v-model="formData.type" :localdata="TypeRange"></uni-data-select>
<uni-data-select v-model="formData.projectType" :localdata="TypeRange"></uni-data-select>
</uni-forms-item>
<uni-forms-item label="区域">
<view style="display:flex;">
<uni-easyinput :clearable="false" type="textarea" autoHeight v-model="formData.address"
<uni-easyinput :clearable="false" type="textarea" autoHeight v-model="formData.area"
placeholder="请输入区域信息" />
<uni-icons type="location" color="#007aff" size="26" class="ml20"
@click="chooseLocation"></uni-icons>
</view>
</uni-forms-item>
<uni-forms-item label="描述">
<uni-easyinput type="textarea" autoHeight v-model="formData.name" placeholder="请输入项目描述" />
<uni-easyinput type="textarea" autoHeight v-model="formData.description"
placeholder="请输入项目描述" />
</uni-forms-item>
<uni-file-picker title="请上传拓扑图" :sourceType="['album']"></uni-file-picker>
<uni-file-picker v-model="formData.files" title="请上传拓扑图" :sourceType="['album']"
@select="select"></uni-file-picker>
</uni-forms>
</view>
<view class="btn-wrap">
@@ -32,14 +34,20 @@
</Cn-page>
</template>
<script>
import { addAppProject } from '../../common/api/project'
export default {
data () {
return {
loading: false,
formData: {
area: "",
files: [],
description: '',
projectType: '1',
name: '',
gplot: '',
type:''
userId: '123456',
lat: '2',
lng: '3'
},
TypeRange: [
{
@@ -53,8 +61,22 @@ export default {
]
}
},
onLoad () {
uni.getLocation({
type: 'wgs84',
success: function (res) {
console.log(res);
console.log('当前位置的经度:' + res.longitude);
console.log('当前位置的纬度:' + res.latitude);
}
});
},
methods: {
select (e) {
console.log(e);
},
chooseLocation () {
uni.chooseLocation({
success: function (res) {
this.address = res.name
@@ -65,11 +87,44 @@ export default {
}
});
},
submit () {
this.$util.toast('项目创建成功')
setTimeout(() => {
uni.navigateBack({ delta: 1 })
}, 1500);
async submit () {
if (!this.formData.name) {
this.$util.toast('请输入项目名称')
return
}
if (!this.formData.projectType) {
this.$util.toast('请选择项目类别')
return
}
if (!this.formData.area) {
this.$util.toast('请输入区域信息')
return
}
if (!this.formData.description) {
this.$util.toast('请输入项目描述')
return
}
if (!this.formData.files.length) {
this.$util.toast('请上传拓扑图')
return
}
let arr = []
for (let i = 0; i < this.formData.files.length; i++) {
let item = this.formData.files[i]
arr.push({
name: 'files',
url: item.url
})
}
let data = JSON.parse(JSON.stringify(this.formData))
delete data.files
addAppProject(data, arr).then(res => {
console.log(res)
this.$util.toast('项目创建成功')
// setTimeout(() => {
// uni.navigateBack({ delta: 1 })
// }, 1500);
})
}
}
}