xinelu-applet-ui/pagesC/selectInstitution/selectInstitution.vue

157 lines
3.5 KiB
Vue
Raw Normal View History

2023-10-12 09:47:40 +08:00
<template>
<view class="app">
<view class="top">
<u-dropdown active-color='#26A888'>
<u-dropdown-item v-model="address" :title="addressname" :options="addressoptions"
@change='dropitemchange'></u-dropdown-item>
</u-dropdown>
<view class="inputs">
<i class="icon"></i>
2023-10-16 09:19:16 +08:00
<input type="text" name="" id="" class="input" placeholder="搜签约机构" v-model="query.orgName">
2023-10-12 09:47:40 +08:00
</view>
</view>
<view class="text">
请选择您想要签约的机构
</view>
<view class="list">
<view class="item" v-for="item in institutionlist" @tap='emitdata(item)'>
<view class="title">
{{item.orgName?item.orgName:''}}
</view>
<view class="address">
{{item.address?item.address:''}}
</view>
<view class="distance" v-if="item.distance">
2024-06-25 18:25:50 +08:00
<image src="@/static/address.png" mode=""></image>
2023-10-12 09:47:40 +08:00
<view class="">
{{item.distance}} KM
</view>
</view>
2023-10-16 09:19:16 +08:00
<view class="Selected" v-if='item.orgNo == orgNo'>
2023-10-12 09:47:40 +08:00
已选择
</view>
</view>
</view>
</view>
</template>
<script>
import {
getCounty,
getNearbyOrg
} from '@/api/pagesC/selectInstitution/index.js'
export default {
data() {
return {
2023-10-16 09:19:16 +08:00
orgNo: '',
2023-10-12 09:47:40 +08:00
address: 1,
addressname: '全部',
addressoptions: [{
label: '全部',
value: '',
}, ],
query: {
lat: '',
lng: '',
pageSize: 10,
2023-10-16 09:19:16 +08:00
pageNum: 1,
orgName: '',
2023-10-12 09:47:40 +08:00
},
institutionlist: [],
institutiontotal: 0,
};
},
2023-10-16 09:19:16 +08:00
watch: {
'query.orgName': {
handler(newval, oldval) {
2024-06-25 18:25:50 +08:00
this.query.pageNum = 1
2023-10-16 09:19:16 +08:00
this.getNearbyOrginfo();
}
}
},
2023-10-12 09:47:40 +08:00
methods: {
dropitemchange(e) {
this.addressname = this.addressoptions.find(m => m.value === e).label
this.query.countyNo = e
this.getNearbyOrginfo()
},
getCountyinfo() {
var obj = {
pageSize: 10,
pageNum: 1
}
2024-01-03 12:40:18 +08:00
getCounty(obj).then(respp => {
2023-10-12 09:47:40 +08:00
respp.data = respp.data.forEach(e => {
e.label = e.orgName
e.value = e.orgNo
this.addressoptions.push(e)
})
})
},
getNearbyOrginfo() {
2024-01-03 12:40:18 +08:00
getNearbyOrg(this.query).then(respp => {
2023-10-12 09:47:40 +08:00
this.institutionlist = respp.rows
this.institutiontotal = respp.total
})
},
emitdata(item) {
uni.$emit('data', {
data: JSON.stringify(item),
})
uni.navigateBack({
delta: 1
});
},
},
onLoad(options) {
2023-10-16 09:19:16 +08:00
options.orgNo ? this.orgNo = options.orgNo : ''
2023-10-12 09:47:40 +08:00
this.getCountyinfo()
var that = this
uni.getLocation({
type: 'wgs84',
success: function(resp) {
that.query.lat = resp.latitude
that.query.lng = resp.longitude
that.getNearbyOrginfo()
},
2023-10-12 15:03:29 +08:00
fail: function(err) {
// uni.openSetting({
// success(res) {
// if (res.authSetting['scope.userLocation']) {
// uni.getLocation({
// type: 'wgs84',
// success: function(resp) {
// that.query.lat = resp.latitude
// that.query.lng = resp.longitude
// that.getNearbyOrginfo()
// },
// });
// }
// }
// });
},
2023-10-12 09:47:40 +08:00
});
},
onReachBottom() { //上滑加载
if (this.institutionlist.length >= this.institutiontotal) {} else {
this.query.pageNum++;
2024-01-03 12:40:18 +08:00
getNearbyOrg(this.query).then(respp => {
2023-10-12 09:47:40 +08:00
respp.rows.forEach(e => {
this.institutionlist.push(e)
})
})
}
},
onPullDownRefresh() { //下拉刷新
2023-10-16 09:19:16 +08:00
this.query.pageNum = 1;
2023-10-12 09:47:40 +08:00
this.getNearbyOrginfo()
setTimeout(function() {
uni.stopPullDownRefresh();
}, 1000);
},
}
</script>
<style lang="scss">
2023-10-23 16:32:39 +08:00
@import './selectInstitution.scss';
2024-06-25 18:25:50 +08:00
</style>