doctor.js 2.54 KB
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
// 医生信息页面

// 网络请求工具类
var networkUtil = require('../../utils/network_util.js')
var api = require('../../utils/apiFile.js')




Page({
data: {
starsM: '../../source/imageSource/icon_star.png',
hideStar: '../../source/imageSource/icon_star_light.png',
doctorInfo: {},
hospitalName: '',
doctorLevel: '',
deptName: '',
hxName: '',
member: []
},
/*---------生命周期--------*/
onLoad: function (options) {
console.log(options)
// networkUtil.showLoading()
// options.hospitalId = 177
// options.doctorId = 473
this.requestData(options.hospitalId, options.doctorId)
},
chatWithDoctor() {
var self = this
if (!self.data.hxName) {
networkUtil.showErrorToast('暂时无法咨询该医生哦')
return;
}
if (!getApp().globalData.canChat) {
networkUtil.showErrorToast('您还没有开通咨询服务,暂时无法咨询该医生哦')
return;
}
// var member = wx.getStorageSync('member')
// var isinclude = false
// for (var i = 0; i < member.length; i++) {
// if (member[i].name == self.data.hxName) {
// isinclude = true
// break;
// }
// }
// if (isinclude) {
// self.addFriend(self.data.hxName)
// }
self.addFriend(self.data.hxName)
var my = wx.getStorageSync('hxName')
var nameList = {
myName: my,
your: self.data.hxName,
yourName: self.data.doctorInfo.username,
yourIcon: self.data.doctorInfo.avatar,
}
wx.navigateTo({
url: '../chatroom/chatroom?username=' + JSON.stringify(nameList)
})
},
addFriend(hxName) {
// console.log("hxName:" + hxName)
// console.log("userName:" + wx.getStorageSync('hxName'))
var self = this
networkUtil._get(api.doctorAddFriend, { userName: wx.getStorageSync('hxName'),friendName: hxName }, function (res) {
console.log(res)
self.getRoster()
}, function (res) {

})
},
getRoster() {
var that = this

},
/*---------自定义函数--------*/
requestData(hospitalId, doctorId) {
var self = this
networkUtil._get(api.doctorInfo, { hospitalId: getApp().globalData.userInfo.hospitalId, id: doctorId, sourceType:1}, function (res) {
self.setData({
doctorInfo: res.data.doctorObj,
hospitalName: res.data.hospitalName,
deptName: res.data.deptName,
doctorLevel: res.data.doctorLevel,
hxName: res.data.hxName,
hospitalLevel: res.data.hospitalLevel
})
console.log(res)
}, function (res) {

})
}
})