AI销管
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

Myprofile.vue 4.2 KiB

2 år sedan
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <view class="main">
  3. <view class="setBox">
  4. <view class="setList" @tap="setHead" style="height: 140rpx;line-height: 120rpx;">
  5. <text style="font-size: 30rpx;color: #333333;">头像</text>
  6. <view class="setList-right">
  7. <image :src="avatar||'https://qufang.oss-cn-beijing.aliyuncs.com/upload/icon/xcx/zkgj/headPicture.png'"
  8. class="headPicture"></image>
  9. <image src="/static/images/arrow.png" class="more"></image>
  10. </view>
  11. </view>
  12. <view>
  13. <navigator class="setList" :url="'/pages/mine/nickname?userName=' + name + '&imgSrc=' + imgSrc">
  14. <text style="font-size: 30rpx;color: #333333;">名字</text>
  15. <view class="setList-right">
  16. <text class="userName">{{name||"暂无昵称"}}</text>
  17. <image src="/static/images/arrow.png" class="more"></image>
  18. </view>
  19. </navigator>
  20. <!-- <navigator class="setList" url="/pages/mine/signature">
  21. <text style="font-size: 30rpx;color: #333333;">签名</text>
  22. <image src="/static/images/arrow.png" class="more"></image>
  23. <text class="userName">{{personalProfile||"暂无签名"}}</text>
  24. </navigator> -->
  25. </view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. var app = getApp();
  31. var util = require("../../utils/util.js");
  32. var config = require("../../config");
  33. export default {
  34. data() {
  35. return {
  36. userInfo: {},
  37. avatar: "",
  38. name: "",
  39. personalProfile: ""
  40. };
  41. },
  42. onShow: function() {
  43. const userInfo = uni.getStorageSync("weapp_session_userInfo_data");
  44. this.userInfo = userInfo;
  45. this.avatar = userInfo.avatar;
  46. this.name = userInfo.name;
  47. this.personalProfile = userInfo.personalProfile;
  48. },
  49. methods: {
  50. // 图片上传
  51. setHead: function() {
  52. var _this = this;
  53. uni.chooseImage({
  54. count: 1,
  55. sizeType: ['original', 'compressed'],
  56. // original 原图,compressed 压缩图,默认二者都有
  57. sourceType: ['album', 'camera'],
  58. // album 从相册选图,camera 使用相机,默认二者都有
  59. success: function(res) {
  60. // success
  61. _this.imgSrc = res.tempFilePaths; //图片路径
  62. _this.uploadimg();
  63. },
  64. fail: function() { // fail
  65. },
  66. complete: function() { // complete
  67. }
  68. });
  69. },
  70. //上传图片至服务器
  71. uploadimg: function() {
  72. var that = this; //获取本地用户信息
  73. const tempFilePaths = that.imgSrc;
  74. if (tempFilePaths.length < 1) {
  75. util.showNone("请上传图片");
  76. return false;
  77. }
  78. console.log(tempFilePaths);
  79. uni.uploadFile({
  80. url: config.service.uploadHeadImg,
  81. header: {
  82. 'Authorization': 'Bearer '+uni.getStorageSync('weapp_session_login_data').token
  83. },
  84. filePath: tempFilePaths[0],
  85. name: 'file',
  86. success(res) {
  87. console.log(res);
  88. const result = JSON.parse(res.data);
  89. if (result.code == 10000) {
  90. console.log(result.data);
  91. that.avatar = result.data;
  92. that.userInfo.avatar = result.data;
  93. uni.setStorageSync("weapp_session_userInfo_data", that.userInfo);
  94. util.showSuccess('修改成功');
  95. } else {
  96. util.showNone(result.message != '' ? result.message : '操作失败,请重新尝试');
  97. return false;
  98. }
  99. },
  100. fail(err) {
  101. console.log(err);
  102. }
  103. });;
  104. }
  105. }
  106. };
  107. </script>
  108. <style lang="scss" scoped>
  109. .main {
  110. width: 100vw;
  111. min-height: calc(100vh - var(--window-top));
  112. background: #F8F8F8;
  113. display: flex;
  114. flex-direction: column;
  115. }
  116. .setBox {
  117. margin-top: 20rpx;
  118. flex-grow: 1;
  119. background: #fff;
  120. }
  121. .setList {
  122. padding: 36rpx 30rpx;
  123. width: 100%;
  124. box-sizing: border-box;
  125. border-bottom: 1rpx solid #EEEEEE;
  126. display: flex;
  127. align-items: center;
  128. justify-content: space-between;
  129. .setList-right {
  130. display: flex;
  131. align-items: center;
  132. }
  133. }
  134. .headPicture {
  135. border-radius: 50%;
  136. width: 120rpx;
  137. height: 120rpx;
  138. float: right;
  139. object-fit: cover;
  140. -o-object-fit: cover;
  141. border: 1rpx solid #ccc;
  142. }
  143. .userName {
  144. }
  145. .more {
  146. width: 18rpx;
  147. height: 32rpx;
  148. margin-left: 20rpx;
  149. }
  150. .save {
  151. width: 100%;
  152. height: 87rpx;
  153. text-align: center;
  154. line-height: 87rpx;
  155. color: #fff;
  156. font-size: 32rpx;
  157. background: #0A6EE9;
  158. margin: 32rpx auto 36rpx;
  159. }
  160. </style>