You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
297 lines
5.7 KiB
297 lines
5.7 KiB
import http from '../../utils/api'
|
|
const baseUrl = require('../../utils/baseUrl')
|
|
Page({
|
|
data: {
|
|
// 轮播图数据
|
|
currentSwiper: 0,
|
|
baseUrl: baseUrl,
|
|
swiperList: [],
|
|
articleList: [{
|
|
title: '发布信息',
|
|
describe: '快速发布养殖知识|视频培训发布',
|
|
icon: '/pages/images/fkjy.png'
|
|
}, ],
|
|
// 通知公告数据
|
|
currentNotice: 0,
|
|
noticeList: [],
|
|
forum: [],
|
|
suffer: [],
|
|
// 添加用户数据
|
|
user: {},
|
|
county: ''
|
|
},
|
|
|
|
// 查询用户信息
|
|
getUserInfo() {
|
|
http.UserInfo({
|
|
data: {},
|
|
success: res => {
|
|
console.log(111, res);
|
|
this.setData({
|
|
user: res.data.user.area
|
|
})
|
|
}
|
|
})
|
|
},
|
|
|
|
|
|
// 跳转发布信息
|
|
bindPx() {
|
|
wx.navigateTo({
|
|
url: '/pagesB/pages/training/training',
|
|
})
|
|
},
|
|
|
|
// 远程诊疗
|
|
bindYczl() {
|
|
wx.navigateTo({
|
|
url: '/pagesA/pages/askingSy/askingSy',
|
|
})
|
|
},
|
|
|
|
|
|
// 在线问答列表页
|
|
bindwdlist() {
|
|
wx.navigateTo({
|
|
url: '/pagesB/pages/forumlist/forumlist',
|
|
})
|
|
},
|
|
|
|
// 问答详情
|
|
bindTw(e) {
|
|
console.log(e);
|
|
const id = e.currentTarget.dataset.id
|
|
wx.navigateTo({
|
|
url: `/pagesB/pages/onlineAsk/onlineAsk?id=${id}`,
|
|
})
|
|
},
|
|
|
|
// 在线问答
|
|
getforumList() {
|
|
http.forumList({
|
|
data: {},
|
|
success: res => {
|
|
const zxwd = []
|
|
zxwd.push(res.rows[0])
|
|
this.setData({
|
|
forum: zxwd
|
|
})
|
|
}
|
|
})
|
|
},
|
|
|
|
// 经验分享列表
|
|
getexperience() {
|
|
http.experience({
|
|
data: {},
|
|
success: res => {
|
|
const zyfx = []
|
|
zyfx.push(res.rows[0])
|
|
this.setData({
|
|
suffer: zyfx
|
|
})
|
|
}
|
|
})
|
|
},
|
|
|
|
// 轮播
|
|
getCarousel() {
|
|
http.carousel({
|
|
data: {},
|
|
success: res => {
|
|
this.setData({
|
|
swiperList: res.rows
|
|
})
|
|
}
|
|
})
|
|
},
|
|
|
|
|
|
|
|
// 区域划分跳转
|
|
bindXzqh() {
|
|
wx.navigateTo({
|
|
url: '/pagesB/pages/administrativeDivision/administrativeDivision',
|
|
})
|
|
},
|
|
|
|
// AI问诊
|
|
bindAI() {
|
|
wx.navigateTo({
|
|
url: '/pagesA/pages/wzai/wzai',
|
|
})
|
|
},
|
|
|
|
// 接收咨询
|
|
bindWsy() {
|
|
wx.navigateTo({
|
|
url: '/pagesA/pages/advisory/advisory',
|
|
})
|
|
},
|
|
|
|
// 找专家
|
|
bindZj() {
|
|
wx.navigateTo({
|
|
url: '/pagesA/pages/expert/expert',
|
|
})
|
|
},
|
|
|
|
// 方案制定
|
|
bindYao() {
|
|
wx.navigateTo({
|
|
url: '/pagesA/pages/precept/precept',
|
|
})
|
|
},
|
|
|
|
|
|
// 问答列表
|
|
bindwdlist() {
|
|
wx.navigateTo({
|
|
url: '/pagesB/pages/forumlist/forumlist',
|
|
})
|
|
},
|
|
|
|
|
|
// 经验分享列表
|
|
viewexperience() {
|
|
wx.navigateTo({
|
|
url: '/pagesB/pages/experienceList/experienceList',
|
|
})
|
|
},
|
|
|
|
// 经验分享详情
|
|
bindfx(e) {
|
|
const id = e.currentTarget.dataset.id
|
|
wx.navigateTo({
|
|
url: `/pagesB/pages/experienceDetails/experienceDetails?id=${id}`,
|
|
})
|
|
},
|
|
|
|
|
|
|
|
// 查看所有问题
|
|
viewAllQuestions() {
|
|
this.bindwdlist()
|
|
},
|
|
|
|
// 获取当前位置信息
|
|
getLocation() {
|
|
let that = this;
|
|
// 腾讯获取的密钥
|
|
let key = 'AOBBZ-6LUK7-WXGXX-HJUXS-HHUM5-FWFPJ'
|
|
wx.getLocation({
|
|
isHighAccuracy: true,
|
|
type: 'gcj02',
|
|
success: function (res) {
|
|
let latitude = res.latitude;
|
|
let longitude = res.longitude;
|
|
wx.request({
|
|
url: `https://apis.map.qq.com/ws/geocoder/v1/?location=${latitude},${longitude}&key=${key}`,
|
|
success: res => {
|
|
that.setData({
|
|
county: res.data.result.address_component.district //城市
|
|
});
|
|
}
|
|
})
|
|
}
|
|
})
|
|
},
|
|
|
|
onLoad() {
|
|
this.getCarousel()
|
|
this.getLocation()
|
|
this.getforumList()
|
|
this.getexperience()
|
|
},
|
|
|
|
onShow() {
|
|
this.resetSwiper()
|
|
this.getUserInfo()
|
|
},
|
|
|
|
// 重置轮播图(解决轮播不自动播放的问题)
|
|
resetSwiper() {
|
|
setTimeout(() => {
|
|
if (this.data.swiperList.length > 0) {
|
|
this.setData({
|
|
currentSwiper: this.data.currentSwiper
|
|
})
|
|
}
|
|
}, 300)
|
|
},
|
|
|
|
// 轮播图变化事件
|
|
onSwiperChange(e) {
|
|
const current = e.detail.current;
|
|
this.setData({
|
|
currentSwiper: current
|
|
});
|
|
},
|
|
|
|
// 轮播图指示器点击
|
|
onIndicatorTap(e) {
|
|
const index = e.currentTarget.dataset.index;
|
|
this.setData({
|
|
currentSwiper: index
|
|
});
|
|
},
|
|
|
|
|
|
// 轮播图点击
|
|
onSwiperTap(e) {
|
|
console.log(1111, e);
|
|
var id = e.currentTarget.dataset.value.carouselId
|
|
wx.navigateTo({
|
|
url: `/pagesA/pages/carouselDetail/carouselDetail?id=${id}`,
|
|
})
|
|
},
|
|
|
|
|
|
onReady() {
|
|
// 当前网络状态
|
|
wx.getNetworkType({
|
|
success: function (res) {
|
|
// 返回网络类型, 有效值:
|
|
// wifi/2g/3g/4g/unknown(Android下不常见的网络类型)/none(无网络)
|
|
console.log(res);
|
|
var networkType = res.networkType
|
|
if (networkType !== 'unknown') {
|
|
wx.showToast({
|
|
title: '当前使用"' + networkType + '"网络',
|
|
icon: 'none',
|
|
duration: 1000
|
|
})
|
|
}
|
|
}
|
|
})
|
|
},
|
|
|
|
// 下拉刷新
|
|
onPullDownRefresh() {
|
|
wx.showNavigationBarLoading()
|
|
|
|
// 重新加载所有数据
|
|
Promise.all([
|
|
new Promise(resolve => this.getUserInfo(resolve)),
|
|
new Promise(resolve => this.getCarousel(resolve)),
|
|
new Promise(resolve => this.getforumList(resolve)),
|
|
new Promise(resolve => this.getexperience(resolve))
|
|
]).then(() => {
|
|
wx.showToast({
|
|
title: '刷新成功',
|
|
icon: 'none',
|
|
duration: 1000
|
|
})
|
|
wx.hideNavigationBarLoading()
|
|
wx.stopPullDownRefresh()
|
|
}).catch(() => {
|
|
wx.hideNavigationBarLoading()
|
|
wx.stopPullDownRefresh()
|
|
})
|
|
},
|
|
|
|
// 页面滚动
|
|
onPageScroll(e) {
|
|
// 可以根据需要添加滚动效果
|
|
}
|
|
});
|