index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <view class="main">
  3. <view class="one">
  4. <upload class='upload' :list="user.icon" name="icon" :count="1" @uplSuc="uplSuc" @uplDel="uplDel">
  5. </upload>
  6. </view>
  7. <view class="two">
  8. <view class="two_1">
  9. <view class="left">姓名</view>
  10. <view class="right">
  11. <input v-model="user.name" placeholder="请输入真实姓名" />
  12. <text class="iconfont icon-dayuhao"></text>
  13. </view>
  14. </view>
  15. <view class="two_1">
  16. <view class="left">手机号</view>
  17. <view class="right">
  18. <input v-model="user.mobile" placeholder="请输入手机号" />
  19. <text class="iconfont icon-dayuhao"></text>
  20. </view>
  21. </view>
  22. <view class="two_1">
  23. <view class="left">性别</view>
  24. <view class="right">
  25. <picker class="picker" mode="selector" :range="genderList" @change="genderChange" range-key="label">
  26. <view>{{user.gender||'请选择性别'}}</view>
  27. </picker>
  28. <text class="iconfont icon-dayuhao"></text>
  29. </view>
  30. </view>
  31. <view class="two_1">
  32. <view class="left">医院名称</view>
  33. <view class="right">
  34. <input v-model="user.hos_name" placeholder="请输入医院名称" />
  35. <text class="iconfont icon-dayuhao"></text>
  36. </view>
  37. </view>
  38. <view class="two_1">
  39. <view class="left">科室名称</view>
  40. <view class="right">
  41. <input v-model="user.dept_name" placeholder="请输入科室名称" />
  42. <text class="iconfont icon-dayuhao"></text>
  43. </view>
  44. </view>
  45. <view class="two_1">
  46. <view class="left">职务</view>
  47. <view class="right">
  48. <input v-model="user.title" placeholder="请输入职务" />
  49. <text class="iconfont icon-dayuhao"></text>
  50. </view>
  51. </view>
  52. <view class="two_1">
  53. <view class="left">职称</view>
  54. <view class="right">
  55. <input v-model="user.post" placeholder="请输入职称" />
  56. <text class="iconfont icon-dayuhao"></text>
  57. </view>
  58. </view>
  59. </view>
  60. <view class="thr">
  61. <button class="button" type="primary" size="mini" @click="onSubmit()">保存</button>
  62. </view>
  63. </view>
  64. </template>
  65. <script>
  66. import upload from '../../components/upload/index.vue';
  67. export default {
  68. components: {
  69. upload
  70. },
  71. data() {
  72. return {
  73. user: {},
  74. gender_name: '',
  75. // 字典表
  76. genderList: [{
  77. label: '男',
  78. value: '男'
  79. },
  80. {
  81. label: '女',
  82. value: '女'
  83. }
  84. ],
  85. }
  86. },
  87. onLoad: async function() {
  88. const that = this;
  89. await that.search();
  90. },
  91. onShow: async function(e) {
  92. const that = this;
  93. that.searchToken();
  94. },
  95. methods: {
  96. searchToken() {
  97. const that = this;
  98. try {
  99. const res = uni.getStorageSync('token');
  100. if (res) that.$set(that, `user`, res);
  101. } catch (e) {
  102. uni.showToast({
  103. title: err.errmsg,
  104. icon: 'error',
  105. duration: 2000
  106. });
  107. }
  108. },
  109. // 查询
  110. async search() {
  111. const that = this;
  112. },
  113. // 图片上传
  114. uplSuc(e) {
  115. const that = this;
  116. that.$set(that.user, `icon`, [e.data]);
  117. },
  118. // 图片删除
  119. uplDel(e) {
  120. const that = this;
  121. that.$set(that.user, `icon`, [])
  122. },
  123. // 性别选择
  124. genderChange(e) {
  125. const that = this;
  126. let data = that.genderList[e.detail.value];
  127. if (data) that.$set(that.user, `gender`, data.value)
  128. },
  129. // 保存
  130. async onSubmit() {
  131. const that = this;
  132. const form = that.user;
  133. let res;
  134. res = await that.$api(`/doctor/${form._id}`, 'POST', form);
  135. if (res.errcode == '0') {
  136. uni.showToast({
  137. title: '维护信息成功',
  138. icon: 'none'
  139. })
  140. } else {
  141. uni.showToast({
  142. title: res.errmsg,
  143. icon: 'none'
  144. })
  145. }
  146. },
  147. }
  148. }
  149. </script>
  150. <style lang="scss" scoped>
  151. .main {
  152. .one {
  153. display: flex;
  154. justify-content: center;
  155. padding: 2vw;
  156. }
  157. .two {
  158. padding: 2vw;
  159. .two_1 {
  160. display: flex;
  161. justify-content: space-between;
  162. padding: 4vw;
  163. border-bottom: 1px solid var(--f9Color);
  164. font-size: var(--font14Size);
  165. color: var(--f69Color);
  166. .right {
  167. display: flex;
  168. align-items: center;
  169. input {
  170. text-align: right;
  171. padding: 0 1vw;
  172. }
  173. }
  174. }
  175. }
  176. .thr {
  177. text-align: center;
  178. .button {
  179. margin: 2vw 0 0 0;
  180. background-color: var(--f3CColor);
  181. color: var(--mainColor);
  182. font-size: var(--font14Size);
  183. }
  184. }
  185. }
  186. </style>