doctorInfo.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. const app = getApp();
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. hospItalList: [{
  8. id: 1,
  9. name: "首都医科大学附属北京朝阳医院"
  10. }],
  11. hospital: '',
  12. imageUrl:''
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad: function (options) {
  18. this.getHospital()
  19. },
  20. getHospital() {
  21. var that = this;
  22. app.requestP({
  23. url: '/hospital/getlist',
  24. method: 'post',
  25. }).then(res => {
  26. console.log(res.data.data);
  27. that.setData({
  28. hospItalList: res.data.data
  29. })
  30. }).catch(err=>{
  31. app.showToptip(that,'error',err.data.msg)
  32. })
  33. },
  34. setHospitalType(e) {
  35. this.setData({
  36. hospital: e.detail.value
  37. })
  38. },
  39. chooseImageTap() {
  40. var that = this;
  41. wx.chooseImage({
  42. count: 1, // 单选
  43. success: function (res) {
  44. var filePath = res.tempFilePaths && res.tempFilePaths[0]
  45. app.wxUploadFile({
  46. url: "/oss/uploadImg",
  47. filePath: filePath,
  48. name:"file",
  49. }).then(function(res){
  50. var data = JSON.parse(res.data);
  51. if(data.url){
  52. that.setData({
  53. imageUrl:data.url
  54. })
  55. console.log(that.data.imageUrl);
  56. }else{
  57. app.showToptip(that, "error", "上传失败请联系管理员")
  58. }
  59. }).catch(function(){
  60. app.showToptip(that, "error", "上传失败请联系管理员")
  61. })
  62. }
  63. })
  64. },
  65. formSubmit(e){
  66. var that = this;
  67. var value = e.detail.value;
  68. const {username,idCard,hospitalId} = value;
  69. if(username&&idCard&&hospitalId&&that.data.imageUrl){
  70. app.requestP({
  71. url:'/hospitalUser/joinRequest',
  72. method:'post',
  73. contentType:' application/json',
  74. data:{
  75. name:username,
  76. idCard,
  77. hospitalId,
  78. license:that.data.imageUrl
  79. }
  80. }).then(res=>{
  81. app.showToptip(that,'success',res.data.msg);
  82. wx.navigateTo({
  83. url: '/pages/my/my',
  84. })
  85. }).catch(err=>{
  86. app.showToptip(that,'error',err.data.msg)
  87. })
  88. }else{
  89. app.showToptip(that,'error','身份信息不能为空')
  90. }
  91. },
  92. /**
  93. * 生命周期函数--监听页面初次渲染完成
  94. */
  95. onReady: function () {
  96. },
  97. /**
  98. * 生命周期函数--监听页面显示
  99. */
  100. onShow: function () {
  101. },
  102. /**
  103. * 生命周期函数--监听页面隐藏
  104. */
  105. onHide: function () {
  106. },
  107. /**
  108. * 生命周期函数--监听页面卸载
  109. */
  110. onUnload: function () {
  111. },
  112. /**
  113. * 页面相关事件处理函数--监听用户下拉动作
  114. */
  115. onPullDownRefresh: function () {
  116. },
  117. /**
  118. * 页面上拉触底事件的处理函数
  119. */
  120. onReachBottom: function () {
  121. },
  122. /**
  123. * 用户点击右上角分享
  124. */
  125. onShareAppMessage: function () {
  126. }
  127. })