nurseWeChatAppletUI/pages/site/site.vue

274 lines
7.6 KiB
Vue

<template>
<view class="app">
<view class="inputs">
<i class="icon"></i>
<input v-model="goodsName" type="text" name="" id="" class="input" placeholder="请输入">
</view>
<view class="Classificationlist">
<view v-for="(item,index) in nurseItemClassifyInfoList" :key="index" @tap='tapitemclass(item)'
:class="item.id == itemClassId?'itemclass':'item'">
<image :src="item.classifyPictureUrl" mode=""></image>
<view class="title">
{{item.classifyName}}
</view>
</view>
<view class="item" v-if='nurseItemClassifyInfoList.length>8'>
<image src="../../static/gd.png" mode=""></image>
<view class="title">
更多
</view>
</view>
</view>
<swiper class="swiper-block" :indicator-dots="true" :autoplay="true" :interval="5000" :duration="3000"
circular='true' current='0'>
<swiper-item class="swiper-item" v-for="(item,index) in lbinfo">
<image :src="item.image" class="slide-image">
</image>
</swiper-item>
</swiper>
<view class="conNew">
<view class="title">
周边医养机构
</view>
<u-tabs :list="nurseAgencyClassifyInfoList" :current="conNewcurrent" @change="change"></u-tabs>
<view class="addressContent" v-for="(item,index) in nursestationlist" :key="index">
<view class="lists" @tap='godetails(item)'>
<view class="nurse">{{item.nurseStationName}}</view>
<view class="distance"
v-show="homeLatitudeLongitude.homeLatitude&&homeLatitudeLongitude.homeLongitude">
距离您{{item.distance}}KM</view>
<image class="background" :src="item.stationPictureUrl" mode=""></image>
<view class="tags">
<view class="tag" v-for="uitem in item.nurseStationClassifyList">
{{uitem.classifyName}}
</view>
</view>
</view>
</view>
</view>
<view class="masks" style="" v-if="mask">
<view class="mask">
<view class="picture">
<image src="../../static/locatinsmall.png"></image>
</view>
<view class="text">
请打开系统定位
</view>
<view class="btns">
<view class="bt" @tap='cancel()'>取消</view>
<view class="btn" @tap='getlocation()'>确定</view>
</view>
</view>
</view>
</view>
</template>
<script>
import {
nearbyList,
getPatientInfo,
getNurseClassifyList
} from '@/api/site/site.js';
import baseurl from '@/api/baseurl.js'
export default {
data() {
return {
nurseAgencyClassifyInfoList: [], //护理站分类
conNewcurrent: 0,
nurseItemClassifyInfoList: [], //护理项目分类
lbinfo: [{
image: 'http://192.168.16.30:8088/profile/goodsPictureUrl/2023/02/15/2ff771a32e9e218b7a375437f3912a4_20230215094755A00126dbdd9a1d.png',
},
{
image: 'http://192.168.16.30:8088/profile/goodsPictureUrl/2023/02/15/2ff771a32e9e218b7a375437f3912a4_20230215094755A00126dbdd9a1d.png',
},
{
image: 'http://192.168.16.30:8088/profile/goodsPictureUrl/2023/02/15/2ff771a32e9e218b7a375437f3912a4_20230215094755A00126dbdd9a1d.png',
}
], //轮播list
nursestationlist: [],
mask: false,
pageNum: 1,
pageSize: 10,
total: 0,
latitude: 39.90374,
longitude: 116.397827,
homeLatitudeLongitude: null,
nurseClassId: '', //护理站分类id
itemClassId: '', //护理项目分类id
}
},
methods: {
//点击护理项目分类
tapitemclass(item) {
if (this.itemClassId == item.id) {
this.itemClassId = ''
} else {
this.itemClassId = item.id
}
this.requestinfo()
},
//护理站和护理项目分类
getNurseClassifyinfo() {
getNurseClassifyList().then(res => {
this.nurseAgencyClassifyInfoList.push({
name: '全部',
id: '',
})
res.data.nurseAgencyClassifyInfoList.forEach(e => {
e.name = e.classifyName
this.nurseAgencyClassifyInfoList.push(e)
})
res.data.nurseItemClassifyInfoList.forEach(e => {
e.classifyPictureUrl = baseurl + e.classifyPictureUrl
})
this.nurseItemClassifyInfoList = res.data.nurseItemClassifyInfoList.slice(0, 7)
})
},
change(index) {
this.conNewcurrent = index;
this.nurseClassId = this.nurseAgencyClassifyInfoList[index].id
this.requestinfo()
},
getlocation(value) {
var that = this
uni.openSetting({
success(res) {
if (res.authSetting['scope.userLocation']) {
// uni.getLocation({
// type: 'wgs84',
// success: function(res) {
// that.latitude = res.latitude
// that.longitude = res.longitude
// that.mask = false
// }
// });
}
}
});
},
requestinfo() {
this.pageNum = 1;
nearbyList(this.pageSize, this.pageNum, this.longitude, this.latitude, this.nurseClassId, this.itemClassId)
.then(res => {
if (res.total > 0) {
uni.removeStorageSync('Refresh');
res.rows.forEach(e => {
e.stationPictureUrl = baseurl + e.stationPictureUrl
e.nurseStationClassifyList = e.nurseStationClassifyList.slice(0, 2)
})
this.nursestationlist = res.rows
this.mask = false
this.total = res.total
}
})
},
godetails(item) {
uni.navigateTo({
url: `/pages/nursestation/nursestation?nurseStationId=${item.nurseStationId}&distance=${item.distance}`
})
},
cancel() {
this.mask = false
uni.switchTab({
url: '/pages/homepage/homepage',
})
},
},
onReachBottom() { //上滑加载
if (this.nursestationlist.length >= this.total) {} else {
this.pageNum++;
nearbyList(this.pageSize, this.pageNum, this.longitude, this.latitude, this.nurseClassId, this.itemClassId)
.then(res => {
res.rows.forEach(e => {
e.stationPictureUrl = baseurl + e.stationPictureUrl
e.nurseStationClassifyList = e.nurseStationClassifyList.slice(0, 2)
this.nursestationlist.push(e)
})
})
}
},
onPullDownRefresh() { //下拉刷新
this.pageNum = 1;
this.requestinfo()
setTimeout(function() {
uni.stopPullDownRefresh();
}, 1000);
},
watch: {
iptVal() {
// this.requestinfo()
},
},
onShow() {
this.nurseClassId = ''
this.itemClassId = ''
var that = this
const value = uni.getStorageSync('patientId');
if (value) {
getPatientInfo(value).then(res => {
if (res.code == 200) {
this.homeLatitudeLongitude = res.data
if (res.data.homeLatitude && res.data.homeLongitude) {
that.latitude = res.data.homeLatitude
that.longitude = res.data.homeLongitude
that.requestinfo();
} else {
that.requestinfo();
// uni.getLocation({
// type: 'wgs84',
// success: function(resp) {
// that.latitude = resp.latitude
// that.longitude = resp.longitude
// that.requestinfo();
// },
// fail(err) {
// that.mask = true;
// }
// });
}
} else if (res.code == 9999) {} else {
that.requestinfo();
}
})
} else {
that.requestinfo();
// uni.getLocation({
// type: 'wgs84',
// success: function(res) {
// that.latitude = res.latitude
// that.longitude = res.longitude
// that.requestinfo();
// },
// fail(err) {
// that.mask = true;
// }
// });
}
},
onLoad() {
this.getNurseClassifyinfo();
},
//1.分享给朋友
onShareAppMessage(res) {
let pages = getCurrentPages();
let url = pages[pages.length - 1].$page.fullPath
return {
title: '泉医到家',
path: url,
}
},
//2.分享到朋友圈
onShareTimeline(res) {
let pages = getCurrentPages();
let url = pages[pages.length - 1].$page.fullPath
return {
title: '泉医到家',
path: url,
}
},
}
</script>
<style lang="scss">
@import './site.scss'
</style>