edit.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <view class="container">
  3. <!-- 手机号码输入框 -->
  4. <!-- <view class="input-group">
  5. <text>手机号码:</text>
  6. <input type="number" maxlength="11" v-model="userInfo.desktopPhone" placeholder="请输入手机号码" />
  7. </view> -->
  8. <!-- 邮箱输入框 -->
  9. <!-- <view class="input-group">
  10. <text>邮箱:</text>
  11. <input type="text" v-model="userInfo.mail" placeholder="请输入邮箱地址" />
  12. </view> -->
  13. <!-- qq输入框 -->
  14. <view class="input-group">
  15. <text>qq:</text>
  16. <input type="text" v-model="userInfo.qq" placeholder="请输入qq" />
  17. </view>
  18. <!-- msn输入框 -->
  19. <view class="input-group">
  20. <text>msn:</text>
  21. <input type="text" v-model="userInfo.msn" placeholder="请输入msn" />
  22. </view>
  23. <!-- 用户生日输入框 -->
  24. <!-- <view class="input-group">
  25. <text>用户生日:</text>
  26. <view class="example-body">
  27. <uni-datetime-picker type="date" :clear-icon="false" v-model="userInfo.birthday" @maskClick="maskClick" />
  28. </view>
  29. </view> -->
  30. <!-- 性别选择器 -->
  31. <!-- <view class="sex-selector">
  32. <radio-group @change="handleGenderChange">
  33. <text>性别:</text>
  34. <view class="sexLabel">
  35. <label>
  36. <radio value="M" :checked="userInfo.sex === 'M' " />男
  37. </label>
  38. <label>
  39. <radio value="F" :checked="userInfo.sex === 'F'" />女
  40. </label>
  41. </view>
  42. </radio-group>
  43. </view> -->
  44. <!-- 提交按钮 -->
  45. <view class="primaryBtn">
  46. <button type="primary" @click="handleSubmit">提交</button>
  47. </view>
  48. </view>
  49. </template>
  50. <script setup>
  51. import {
  52. ref,
  53. reactive,
  54. onMounted
  55. } from 'vue';
  56. import { useUserStore } from '@/store/user';
  57. import { ModifyMe } from '@/api/mine';
  58. import $modal from '@/plugins/modal.js'
  59. // 定义用户信息的响应式对象
  60. const thisUser=useUserStore().user;
  61. let userInfo = reactive({
  62. staffId:thisUser.useId,
  63. // desktopPhone: thisUser.desktopPhone,
  64. // mail: thisUser.email,
  65. // sex: thisUser.sex,
  66. // birthday: thisUser.birthday,
  67. qq:thisUser.qqnum,
  68. msn:thisUser.msnnum
  69. });
  70. // function handleGenderChange(event) {
  71. // userInfo.sex = event.detail.value; // 更新性别
  72. // };
  73. // // 校验手机号码格式
  74. // function validatePhone(desktopPhone) {
  75. // const desktopPhoneRegex = /^1[3-9]\d{9}$/; // 手机号码格式正则(以1开头,11位数字)
  76. // return desktopPhoneRegex.test(desktopPhone);
  77. // }
  78. // // 校验邮箱格式
  79. // function validateEmail(mail) {
  80. // const mailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/; // 邮箱格式正则
  81. // return mailRegex.test(mail);
  82. // }
  83. // 处理提交事件
  84. function handleSubmit() {
  85. // if (!validatePhone(userInfo.desktopPhone)) {
  86. // uni.showToast({
  87. // title: '手机号码格式不正确',
  88. // icon: 'none'
  89. // });
  90. // return; // 终止提交
  91. // }
  92. // if (!validateEmail(userInfo.mail)) {
  93. // uni.showToast({
  94. // title: '邮箱格式不正确',
  95. // icon: 'none'
  96. // });
  97. // return; // 终止提交
  98. // }
  99. ModifyMe(userInfo).then(res=>{
  100. // console.log(res);
  101. if("success"==res.returnMsg){
  102. $modal.showToast('修改成功');
  103. useUserStore().GetInfo().then(res=>{
  104. console.log("GetInfo",res);
  105. })
  106. }
  107. })
  108. }
  109. </script>
  110. <style lang="scss" scoped>
  111. .container {
  112. padding: 30rpx;
  113. }
  114. .input-group {
  115. margin-bottom: 10rpx;
  116. }
  117. .input-group input,
  118. .sexLabel {
  119. padding-left: 20rpx;
  120. margin: 20rpx auto;
  121. height: 70rpx;
  122. }
  123. .input-group input {
  124. border: 1rpx solid gainsboro; /* 修改边框样式 */
  125. background-color: white;
  126. }
  127. .input-group text {
  128. display: block;
  129. margin-bottom: 20rpx;
  130. }
  131. .sex-selector label {
  132. margin-right: 15rpx;
  133. }
  134. .primaryBtn {
  135. margin-top: 70rpx;
  136. }
  137. </style>