index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <template>
  2. <view class="doctor-register-content">
  3. <view class="register-wrap">
  4. <view class="zhcx-table">
  5. <view class="zhcx-table-row">
  6. <view class="name">
  7. <text>账号</text>
  8. </view>
  9. <view class="text" >
  10. <input type="text" v-model="form.accountName" />
  11. </view>
  12. </view>
  13. <view class="zhcx-table-row">
  14. <view class="name">
  15. <text>密码</text>
  16. </view>
  17. <view class="text" >
  18. <input type="text" v-model="form.password" />
  19. </view>
  20. </view>
  21. <view class="zhcx-table-row">
  22. <view class="name">
  23. <text>姓名</text>
  24. </view>
  25. <view class="text" >
  26. <input type="text" v-model="form.name" />
  27. </view>
  28. </view>
  29. <view class="zhcx-table-row">
  30. <view class="name">
  31. <text>身份证</text>
  32. </view>
  33. <view class="text" >
  34. <input type="text" v-model="form.idCard" />
  35. </view>
  36. </view>
  37. <view class="zhcx-table-row">
  38. <view class="name">
  39. <text>性别</text>
  40. </view>
  41. <view class="text" >
  42. <radio-group @change="changeGender">
  43. <label>
  44. <radio value="0" :checked="form.gender==='0'" /><text>男</text>
  45. </label>
  46. <label class="gender-item-woman">
  47. <radio value="1" :checked="form.gender==='1'" /><text>女</text>
  48. </label>
  49. </radio-group>
  50. </view>
  51. </view>
  52. <view class="zhcx-table-row">
  53. <view class="name">
  54. <text>住址</text>
  55. </view>
  56. <view class="text" >
  57. <input type="text" v-model="form.address" />
  58. </view>
  59. </view>
  60. <view class="zhcx-table-row">
  61. <view class="name">
  62. <text>所属医院</text>
  63. </view>
  64. <view class="text" >
  65. <input type="text" v-model="form.hospital" />
  66. </view>
  67. </view>
  68. <view class="zhcx-table-row">
  69. <view class="name">
  70. <text>科室</text>
  71. </view>
  72. <view class="text" >
  73. <input type="text" v-model="form.offices" />
  74. </view>
  75. </view>
  76. <view class="zhcx-table-row">
  77. <view class="name">
  78. <text>医生资格证号</text>
  79. </view>
  80. <view class="text" >
  81. <input type="text" v-model="form.doctorQualificationsNumber" />
  82. </view>
  83. </view>
  84. <view class="zhcx-table-row">
  85. <view class="name">
  86. <text>资格证照片</text>
  87. </view>
  88. <!-- <view class="text" >
  89. <input type="text" v-model="form.qualificationsImg" />
  90. </view> -->
  91. </view>
  92. <image :src="uploadServer+form.qualificationsImg"
  93. mode="widthFix"
  94. @click="preview(form.qualificationsImg)"
  95. v-if="form.qualificationsImg" class="qualificationsImg"></image>
  96. <view class="zhcx-upload" @click="uploadBt">
  97. <div class="icon"></div>
  98. <text class="uploadTitle">点击上传</text>
  99. </view>
  100. </view>
  101. </view>
  102. <view class="handle-wrap">
  103. <view class="submit-BT" @click="submit">
  104. <text>提交</text>
  105. </view>
  106. </view>
  107. </view>
  108. </template>
  109. <script>
  110. import { validPhone ,notEmpty} from '@/libs/index';
  111. import {register} from '@/api/user';
  112. import {upload} from '@/api/index';
  113. import config from'@/config';
  114. export default {
  115. data() {
  116. return {
  117. uploadServer:config.uploadServer,
  118. form:{
  119. name:"",
  120. phoneNumber:"",
  121. idCard:"",
  122. gender:"",
  123. address:"",
  124. password:"",
  125. hospital:"",
  126. offices:"",
  127. doctorQualificationsNumber:"",
  128. qualificationsImg:""
  129. }
  130. }
  131. },
  132. methods: {
  133. changeGender({detail}){
  134. this.form.gender=detail.value;
  135. },
  136. submit(){
  137. let form=this.form;
  138. if(!validPhone(form['accountName'])){
  139. uni.showToast({
  140. icon:"none",
  141. title:"账号必须位11位手机号码"
  142. })
  143. return;
  144. }
  145. if(!notEmpty(form['password'])){
  146. uni.showToast({
  147. icon:"none",
  148. title:"请设置登录密码"
  149. })
  150. return;
  151. }
  152. if(!notEmpty(form['name'])){
  153. uni.showToast({
  154. icon:"none",
  155. title:"请填写真实姓名"
  156. })
  157. return;
  158. }
  159. if(!notEmpty(form['idCard'])){
  160. uni.showToast({
  161. icon:"none",
  162. title:"请填写身份证号码"
  163. })
  164. return;
  165. }
  166. var params={
  167. accountName:form['accountName'],
  168. password:form['password'],
  169. accountType:1,
  170. doctorName:form['name'],
  171. accountTel:form['accountName'],
  172. doctorSex:form['gender'],
  173. doctorIdCard:form['idCard'],
  174. doctorHospital:form['hospital'],
  175. doctorDepartment:form['offices'],
  176. doctorQualificationsNumber:form['doctorQualificationsNumber'],
  177. doctorQualificationsImg:form['qualificationsImg'],
  178. doctorAddress:form['address']
  179. }
  180. register(params).then(()=>{
  181. uni.showToast({
  182. title:"注册成功!"
  183. })
  184. setTimeout(()=>{
  185. uni.reLaunch({
  186. url:"/pages/login/index"
  187. })
  188. },1500)
  189. })
  190. },
  191. uploadBt(){
  192. uni.chooseImage({
  193. success: (chooseImageRes) => {
  194. const tempFilePaths = chooseImageRes.tempFilePaths;
  195. this.uploadSubmit(tempFilePaths[0])
  196. }
  197. });
  198. },
  199. uploadSubmit(filePath){
  200. upload({filePath}).then((res)=>{
  201. let cont=JSON.parse(res)
  202. this.$set(this.form,'qualificationsImg',cont.data.path);
  203. uni.showToast({
  204. title:'上传成功!',
  205. icon:'success'
  206. })
  207. }).catch((msg)=>{
  208. uni.showToast({
  209. title:'上传失败!',
  210. icon:'none'
  211. })
  212. })
  213. },
  214. preview(path){
  215. let urls=[];
  216. let imgsrc=config.uploadServer+path;
  217. urls.push(imgsrc)
  218. uni.previewImage({
  219. urls,
  220. fail() {
  221. uni.showToast({
  222. icon:'none',
  223. title:'预览失败!'
  224. })
  225. }
  226. })
  227. }
  228. }
  229. }
  230. </script>
  231. <style lang="scss" scoped>
  232. .doctor-register-content{
  233. padding-bottom: 200upx;
  234. .register-wrap{
  235. .zhcx-table-row{
  236. .text{
  237. text-align: left;
  238. .gender-item-woman{
  239. margin-left: 40upx;
  240. }
  241. }
  242. }
  243. .zhcx-upload{
  244. margin-top: 10upx;
  245. }
  246. }
  247. .qualificationsImg{
  248. display: block;
  249. width: 100upx;
  250. height: 100upx;
  251. }
  252. }
  253. .handle-wrap{
  254. &{
  255. width: 100%;
  256. position: fixed;
  257. bottom: 0;
  258. left: 0;
  259. padding: 10upx 0;
  260. }
  261. .submit-BT{
  262. width: 702upx;
  263. height: 100upx;
  264. line-height: 100upx;
  265. text-align: center;
  266. background-color: #3384FF;
  267. border-radius: 12upx;
  268. color: #fff;
  269. font-size: 32upx;
  270. margin: 0 auto;
  271. }
  272. }
  273. </style>