// 医生信息页面 // 网络请求工具类 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) { }) } })