index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <template>
  2. <view class="content">
  3. <view class="user-info-item userInfo" v-if="Formtype==='edit'">
  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="name" disabled />
  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="phoneNumber" disabled />
  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="idCard" disabled />
  27. </view>
  28. </view>
  29. <view class="zhcx-table-row">
  30. <view class="name">
  31. <text>性别</text>
  32. </view>
  33. <view class="text" >
  34. <radio-group @change="changeGender">
  35. <label>
  36. <radio value="0" :checked="gender==='0'" disabled /><text>男</text>
  37. </label>
  38. <label class="gender-item-woman">
  39. <radio value="1" :checked="gender==='1'" disabled /><text>女</text>
  40. </label>
  41. </radio-group>
  42. </view>
  43. </view>
  44. <view class="zhcx-table-row">
  45. <view class="name">
  46. <text>住址</text>
  47. </view>
  48. <view class="text" >
  49. <input type="text" v-model="address" />
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. <!-- 修改密码 -->
  55. <view class="user-info-item password" v-else>
  56. <view class="zhcx-table">
  57. <view class="zhcx-table-row">
  58. <view class="name">
  59. <text>原密码</text>
  60. </view>
  61. <view class="text" >
  62. <input type="text" v-model="oldPassword" placeholder="请输入原密码" />
  63. </view>
  64. </view>
  65. <view class="zhcx-table-row">
  66. <view class="name">
  67. <text>新密码</text>
  68. </view>
  69. <view class="text" >
  70. <input type="text" v-model="password" placeholder="请输入新密码" />
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. <view class="handle-wrap">
  76. <view class="submit-BT" @click="submit">
  77. <text>提交</text>
  78. </view>
  79. </view>
  80. </view>
  81. </template>
  82. <script>
  83. import {getInfo,updatePwd,logout} from '@/api/user';
  84. import {updatePatientrInfo} from '@/api/patient';
  85. import {updateDoctorInfo} from '@/api/doctor';
  86. export default {
  87. data() {
  88. return {
  89. Formtype:'edit',
  90. name:"",
  91. phoneNumber:"",
  92. idCard:"",
  93. gender:"",
  94. address:"",
  95. oldPassword:"",
  96. password:"",
  97. userId:null,
  98. userType:null
  99. }
  100. },
  101. onLoad({type}) {
  102. this.Formtype=type;
  103. this.init(type);
  104. },
  105. methods: {
  106. init(type){
  107. if(type==="edit"){
  108. this.getUserInfo();
  109. }else{
  110. uni.setNavigationBarTitle({
  111. title:"修改密码"
  112. })
  113. }
  114. },
  115. getUserInfo(){
  116. let accountInfo=uni.getStorageSync("accountInfo");
  117. let userType=accountInfo.userType;
  118. this.userType=userType;
  119. getInfo().then((res)=>{
  120. let info=res.data;
  121. if(userType==1){
  122. this.userId=info.doctorId;
  123. this.name=info.doctorName;
  124. this.gender=info.doctorSex;
  125. this.phoneNumber=info.accountTel;
  126. this.idCard=info.doctorIdCard;
  127. this.address=info.doctorAddress;
  128. }
  129. else if(userType==2){
  130. this.userId=info.patientId;
  131. this.name=info.patientName;
  132. this.gender=info.patientSex;
  133. this.phoneNumber=info.accountTel;
  134. this.idCard=info.patientIdCard;
  135. this.address=info.patientAddress;
  136. }
  137. })
  138. },
  139. changeGender({detail}){
  140. this.gender=detail.value;
  141. },
  142. submit(){
  143. let type=this.Formtype;
  144. let userType=this.userType;
  145. let userId=this.userId;
  146. let params=null;
  147. if(type==="edit"){
  148. let address=(this.address).trim();
  149. if(address.length<1){
  150. uni.showToast({
  151. title:"请填写地址!"
  152. })
  153. return
  154. }
  155. if(userType==1){
  156. params={"doctorAddress":address,"doctorId":userId}
  157. updateDoctorInfo(params).then((res)=>{
  158. uni.showToast({
  159. title:"修改成功!",
  160. mask:true,
  161. success() {
  162. uni.reLaunch({
  163. url:"/pages/myCenter/index"
  164. })
  165. }
  166. })
  167. });
  168. }else{
  169. params={"patientAddress":address,"patientId":userId}
  170. updatePatientrInfo(params).then((res)=>{
  171. uni.showToast({
  172. title:"修改成功!",
  173. mask:true,
  174. success() {
  175. uni.reLaunch({
  176. url:"/pages/myCenter/index"
  177. })
  178. }
  179. })
  180. });
  181. }
  182. }else{
  183. let oldPassword=(this.oldPassword).trim()
  184. let password=(this.password).trim();
  185. updatePwd({
  186. oldPassword,password
  187. }).then((res)=>{
  188. if(res.code===0){
  189. if(res.code===0){
  190. uni.showToast({
  191. title:"修改成功!",
  192. mask:true,
  193. success() {
  194. logout().then(()=>{
  195. uni.clearStorageSync();
  196. uni.reLaunch({
  197. url:"/pages/login/index"
  198. })
  199. })
  200. }
  201. })
  202. }
  203. }
  204. })
  205. }
  206. }
  207. }
  208. }
  209. </script>
  210. <style lang="scss" scoped>
  211. .content{
  212. .user-info-item{
  213. .zhcx-table-row{
  214. .text{
  215. text-align: left;
  216. .gender-item-woman{
  217. margin-left: 40upx;
  218. }
  219. }
  220. }
  221. }
  222. }
  223. .handle-wrap{
  224. &{
  225. width: 100%;
  226. position: fixed;
  227. bottom: 0;
  228. left: 0;
  229. padding: 10upx 0;
  230. }
  231. .submit-BT{
  232. width: 702upx;
  233. height: 100upx;
  234. line-height: 100upx;
  235. text-align: center;
  236. background-color: #3384FF;
  237. border-radius: 12upx;
  238. color: #fff;
  239. font-size: 32upx;
  240. margin: 0 auto;
  241. }
  242. }
  243. </style>