information.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <view class="common_page" :style="{'height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header title="个人资料" bgColor="#FFFFFF"></cus-header>
  4. <div class="form">
  5. <div class="avatar">
  6. <div class="title">头像</div>
  7. <div class="imgbox">
  8. <up-upload
  9. :fileList="fileList"
  10. @afterRead="afterRead"
  11. @delete="deletePic"
  12. multiple
  13. :maxCount="1"
  14. width="122rpx"
  15. height="122rpx"
  16. >
  17. <image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/29/b04d6b0e-0d30-4043-a2b1-d639e15e2aac.png"
  18. mode="widthFix" style="width: 122rpx;height: 122rpx;"></image>
  19. </up-upload>
  20. </div>
  21. </div>
  22. <div class="item adfacjb">
  23. <div class="left">用户名</div>
  24. <div class="right">
  25. <up-input v-model="userInfo.username" border="none" placeholder="请输入用户名"></up-input>
  26. </div>
  27. </div>
  28. <div class="item adfacjb">
  29. <div class="left">手机号码</div>
  30. <div class="right">
  31. <up-input v-model="userInfo.phone" border="none" placeholder="请输入手机号码"></up-input>
  32. </div>
  33. </div>
  34. <div class="item adfacjb">
  35. <div class="left">家庭公益名称</div>
  36. <div class="right">
  37. <up-input v-model="userInfo.nonprofitName" border="none" placeholder="请输入家庭公益名称"></up-input>
  38. </div>
  39. </div>
  40. <div class="item adfacjb">
  41. <div class="left">家庭公益口号</div>
  42. <div class="right">
  43. <up-input v-model="userInfo.nonprofitNo" border="none" placeholder="请输入家庭公益口号"></up-input>
  44. </div>
  45. </div>
  46. </div>
  47. <div class="btn" @tap="save">保存</div>
  48. </view>
  49. </template>
  50. <script setup name="">
  51. import CusHeader from '@/components/CusHeader/index.vue'
  52. import { ref, onMounted, getCurrentInstance } from 'vue'
  53. const { proxy } = getCurrentInstance()
  54. const fileList = ref([])
  55. const userInfo = ref({
  56. avatar:'',
  57. username:'',
  58. phone:'',
  59. nonprofitName:'',
  60. nonprofitNo:''
  61. })
  62. const save = () => {
  63. if(!userInfo.value.avatar) return proxy.$showToast('请上传用户头像')
  64. if(!userInfo.value.username) return proxy.$showToast('请输入用户名')
  65. if(!proxy.$reg.mobile(userInfo.value.phone)) return proxy.$showToast('请输入正确的手机号')
  66. if(!userInfo.value.nonprofitName) return proxy.$showToast('请输入家庭公益名称')
  67. if(!userInfo.value.nonprofitNo) return proxy.$showToast('请输入家庭公益口号')
  68. console.log(userInfo.value,'userInfo');
  69. }
  70. const deletePic = (event) => {
  71. fileList.value.splice(event.index, 1);
  72. };
  73. // 新增图片
  74. const afterRead = async (event) => {
  75. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  76. let lists = [].concat(event.file);
  77. let fileListLen = fileList.value.length;
  78. lists.map((item) => {
  79. fileList.value.push({
  80. ...item,
  81. status: 'uploading',
  82. message: '上传中',
  83. });
  84. });
  85. for (let i = 0; i < lists.length; i++) {
  86. const result = await uploadFilePromise(lists[i].url);
  87. let item = fileList.value[fileListLen];
  88. fileList.value.splice(fileListLen, 1, {
  89. ...item,
  90. status: 'success',
  91. message: '',
  92. url: result,
  93. });
  94. fileListLen++;
  95. }
  96. };
  97. const uploadFilePromise = (url) => {
  98. return new Promise((resolve, reject) => {
  99. let a = uni.uploadFile({
  100. url: 'http://192.168.2.21:7001/upload', // 仅为示例,非真实的接口地址
  101. filePath: url,
  102. name: 'file',
  103. formData: {
  104. user: 'test',
  105. },
  106. success: (res) => {
  107. setTimeout(() => {
  108. resolve(res.data.data);
  109. }, 1000);
  110. },
  111. });
  112. });
  113. };
  114. onMounted(()=>{
  115. })
  116. </script>
  117. <style scoped lang="scss">
  118. ::v-deep .u-input__content input{
  119. font-family: PingFangSC, PingFang SC;
  120. font-weight: 400;
  121. font-size: 30rpx !important;
  122. color: #252525 !important;
  123. line-height: 42rpx !important;
  124. text-align: right !important;
  125. }
  126. .common_page{
  127. .form{
  128. background: #FFFFFF;
  129. border-radius: 24rpx;
  130. padding: 14rpx 22rpx 0;
  131. margin-top: 20rpx;
  132. .avatar{
  133. .title{
  134. font-family: PingFang-SC, PingFang-SC;
  135. font-weight: bold;
  136. font-size: 30rpx;
  137. color: #252525;
  138. line-height: 42rpx;
  139. }
  140. .imgbox{
  141. padding: 34rpx 0 47rpx;
  142. }
  143. border-bottom: 1rpx solid #E6E6E6;
  144. }
  145. .item{
  146. height: 110rpx;
  147. box-shadow: inset 0rpx -1rpx 0rpx 0rpx #E6E6E6;
  148. .left{
  149. width: 200rpx;
  150. font-family: PingFang-SC, PingFang-SC;
  151. font-weight: bold;
  152. font-size: 30rpx;
  153. color: #252525;
  154. line-height: 42rpx;
  155. padding-right: 20rpx;
  156. box-sizing: border-box;
  157. }
  158. .right{
  159. width: calc(100% - 200rpx);
  160. }
  161. }
  162. }
  163. .btn{
  164. width: calc(100% - 80rpx);
  165. height: 90rpx;
  166. background: #B7F358;
  167. border-radius: 45rpx;
  168. font-family: PingFang-SC, PingFang-SC;
  169. font-weight: bold;
  170. font-size: 32rpx;
  171. color: #151B29;
  172. line-height: 90rpx;
  173. text-align: center;
  174. letter-spacing: 2rpx;
  175. position: fixed;
  176. left: 40rpx;
  177. bottom: 64rpx;
  178. }
  179. }
  180. </style>