myInfo.vue 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <template>
  2. <div class="page_myInfo">
  3. <div class="myInfoTitle">
  4. <i class="iconfont icon-zuojiantou jiantou" @click="$router.go(-1)"></i>
  5. <span class="titleName">我的信息</span>
  6. </div>
  7. <div class="infoBox">
  8. <div class="infoBoxOne">
  9. <p>头像</p>
  10. <div class="infoBoxOneRight">
  11. <img v-if="roleInfo.avatar != ''" :src="roleInfo.avatar" alt />
  12. <img
  13. v-if="roleInfo.avatar == ''"
  14. src="../../assets/images/mydefault.png"
  15. alt
  16. />
  17. <van-icon class="arrow" name="arrow" />
  18. </div>
  19. </div>
  20. <div class="infoBoxTwo" @click="editName">
  21. <p>姓名</p>
  22. <div class="infoBoxOneRight">
  23. <p>{{ roleInfo.user_name }}</p>
  24. <van-icon class="arrow" name="arrow" />
  25. </div>
  26. </div>
  27. <div class="infoBoxTwo" @click="show = true">
  28. <p>性别</p>
  29. <div class="infoBoxOneRight">
  30. <p>{{ sex }}</p>
  31. <van-icon class="arrow" name="arrow" />
  32. </div>
  33. </div>
  34. <div class="infoBoxTwo" @click="show1 = true">
  35. <p>生日</p>
  36. <div class="infoBoxOneRight">
  37. <p>{{ birthday }}</p>
  38. <van-icon class="arrow" name="arrow" />
  39. </div>
  40. </div>
  41. <div class="infoBoxTwo" @click="toMyPersonalsign">
  42. <p>个性签名</p>
  43. <div class="infoBoxOneRight">
  44. <p>{{ roleInfo.message }}</p>
  45. <van-icon class="arrow" name="arrow" />
  46. </div>
  47. </div>
  48. </div>
  49. <!-- 弹窗 -->
  50. <div>
  51. <van-popup v-model="show" position="bottom" :style="{ height: '40%' }">
  52. <van-picker
  53. :columns="columns"
  54. show-toolbar
  55. @cancel="onCancel"
  56. @confirm="onConfirm"
  57. />
  58. </van-popup>
  59. <van-popup v-model="show1" position="bottom" :style="{ height: '40%' }">
  60. <van-datetime-picker
  61. v-model="currentDate"
  62. type="date"
  63. :min-date="minDate"
  64. :max-date="maxDate"
  65. @cancel="onCancelOne"
  66. @confirm="onConfirmOne"
  67. />
  68. </van-popup>
  69. </div>
  70. </div>
  71. </template>
  72. <script>
  73. import { getMyInforName, SaveSex, SaveBirthday } from "@/api/patient/patient";
  74. import { uParseTime } from "@/utils/tools";
  75. import { setRem } from "@/libs/functionRem";
  76. export default {
  77. data() {
  78. return {
  79. sex: "",
  80. birthday: "",
  81. show: false,
  82. show1: false,
  83. columns: ["男", "女"],
  84. minDate: new Date(1900, 0, 1),
  85. maxDate: new Date(2025, 10, 1),
  86. currentDate: new Date(),
  87. roleInfo: {
  88. avatar: "",
  89. user_name: "",
  90. message: ""
  91. },
  92. admin_user_id: "",
  93. form: {
  94. sex: ""
  95. }
  96. };
  97. },
  98. methods: {
  99. getMyInforName(id) {
  100. getMyInforName(id).then(response => {
  101. if (response.data.state === 1) {
  102. var roleInfo = response.data.data.Rolename;
  103. var username = response.data.data.Username;
  104. if (roleInfo.sex === 1) {
  105. this.sex = "男";
  106. }
  107. if (roleInfo.sex === 2) {
  108. this.sex = "女";
  109. }
  110. this.birthday = this.getTime(roleInfo.birthday);
  111. this.roleInfo.user_name = roleInfo.user_name;
  112. this.roleInfo.avatar = roleInfo.avatar;
  113. this.roleInfo.message = roleInfo.message;
  114. if (roleInfo.user_name == "") {
  115. this.roleInfo.user_name = username.name;
  116. }
  117. this.userName = username;
  118. }
  119. });
  120. },
  121. toMyPersonalsign() {
  122. this.$router.push("/personalsign?id=" + this.admin_user_id);
  123. },
  124. editName() {
  125. this.$router.push("/editname?id=" + this.admin_user_id);
  126. },
  127. onConfirm(value) {
  128. if (value === "男") {
  129. this.form.sex = 1;
  130. }
  131. if (value === "女") {
  132. this.form.sex = 2;
  133. }
  134. SaveSex(this.form.sex, this.admin_user_id).then(response => {
  135. if (response.data.state === 1) {
  136. var role = response.data.data.role;
  137. this.sex = value;
  138. this.getMyInformation(this.admin_user_id);
  139. }
  140. });
  141. this.show = false;
  142. },
  143. onCancel() {
  144. this.show = false;
  145. },
  146. onCancelOne() {
  147. this.show1 = false;
  148. },
  149. onConfirmOne(value) {
  150. let year = value.getFullYear();
  151. let month = value.getMonth() + 1;
  152. let day = value.getDate();
  153. if (month >= 1 && month <= 9) {
  154. month = `0${month}`;
  155. }
  156. if (day >= 1 && day <= 9) {
  157. day = `0${day}`;
  158. }
  159. this.birthday = `${year}-${month}-${day}`;
  160. const params = {
  161. birth: this.birthday,
  162. id: this.admin_user_id
  163. };
  164. SaveBirthday(params).then(response => {
  165. if (response.data.state === 1) {
  166. var role = response.data.data.role;
  167. this.birthday = this.birthday;
  168. this.getMyInformation(this.admin_user_id);
  169. }
  170. });
  171. this.show1 = false;
  172. },
  173. getTime(time) {
  174. if (time == 0) {
  175. return "";
  176. }
  177. // return uParseTime(time, "{y}-{m}-{d} {h}:{i}:{s}");
  178. return uParseTime(time, "{y}-{m}-{d}");
  179. }
  180. },
  181. created() {
  182. setRem()
  183. var id = this.$route.query.id;
  184. this.admin_user_id = id;
  185. this.getMyInforName(id);
  186. }
  187. };
  188. </script>
  189. <style lang="scss" scoped>
  190. .page_myInfo {
  191. height: 100%;
  192. overflow-y: auto;
  193. background: #fafafa;
  194. .myInfoTitle {
  195. background: #fff;
  196. padding: 0 1.125rem;
  197. height: 3.125rem;
  198. display: flex;
  199. align-items: center;
  200. }
  201. .jiantou {
  202. font-size: 1.5rem;
  203. font-weight: 600;
  204. margin-right: 7rem;
  205. }
  206. .titleName {
  207. font-size: 1.125rem;
  208. font-weight: 600;
  209. }
  210. .infoBox {
  211. margin-top: 1rem;
  212. background: #fff;
  213. >div:last-child{
  214. border: none;
  215. }
  216. .infoBoxOne {
  217. font-size: 1rem;
  218. display: flex;
  219. align-items: center;
  220. justify-content: space-between;
  221. height: 4.5rem;
  222. padding: 0 0.875rem;
  223. // box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.1);
  224. border-bottom: 1px solid #e5e5e5;
  225. .infoBoxOneRight {
  226. display: flex;
  227. align-items: center;
  228. img {
  229. width: 2.5rem;
  230. height: 2.5rem;
  231. }
  232. .arrow {
  233. margin-left: 0.75rem;
  234. color: #9f9f9f;
  235. }
  236. }
  237. }
  238. .infoBoxTwo {
  239. font-size: 1rem;
  240. display: flex;
  241. align-items: center;
  242. justify-content: space-between;
  243. height: 2.8125rem;
  244. padding: 0 0.875rem;
  245. // box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.1);
  246. border-bottom: 1px solid #e5e5e5;
  247. .infoBoxOneRight {
  248. display: flex;
  249. align-items: center;
  250. p {
  251. width: 13.75rem;
  252. white-space: nowrap;
  253. text-overflow: ellipsis;
  254. overflow: hidden;
  255. word-break: break-all;
  256. text-align: right;
  257. }
  258. .arrow {
  259. margin-left: 0.75rem;
  260. color: #9f9f9f;
  261. }
  262. }
  263. }
  264. }
  265. a {
  266. color: #000;
  267. }
  268. }
  269. </style>