25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

Myprofile.vue 3.9 KiB

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