editProfile.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <template>
  2. <view>
  3. <u-navbar title="编辑资料"></u-navbar>
  4. <view class="main">
  5. <view class="photo" @click="uploadPhoto">
  6. <u-avatar v-if="form.headImg != null" class="avatar"
  7. :src="form.headImg+'?x-oss-process=image/resize,m_fill,w_256,h_256'" size="216">
  8. <img src="" alt="">
  9. </u-avatar>
  10. <!-- <img src="../../../assets/img/photowoman.png" alt=""> -->
  11. <view class="camera">
  12. <img src="../../../assets/img/md-camera_alt@1x.png" alt="">
  13. </view>
  14. </view>
  15. <view class="infos">
  16. <view class="item">
  17. <view class="title">
  18. 姓名
  19. </view>
  20. <view class="content">
  21. 夏奕琳
  22. </view>
  23. </view>
  24. <view class="item">
  25. <view class="title">
  26. 手机号
  27. </view>
  28. <view class="content">
  29. 13477489404
  30. </view>
  31. </view>
  32. <view class="item">
  33. <view class="title">
  34. 所属学部
  35. </view>
  36. <view class="content">
  37. 文艺部
  38. </view>
  39. </view>
  40. <view class="item">
  41. <view class="title">
  42. 所属项目中心
  43. </view>
  44. <view class="content">
  45. 中国舞项目中心
  46. </view>
  47. </view>
  48. <view class="item">
  49. <view class="title">
  50. 所属学科
  51. </view>
  52. <view class="content">
  53. 芭蕾舞
  54. </view>
  55. </view>
  56. <view class="honour">
  57. <view class="title">
  58. 荣誉奖项
  59. </view>
  60. <textarea name="" id="" cols="30" rows="10" placeholder="请简短描述您所获得的荣誉奖项及教学优质案例"></textarea>
  61. </view>
  62. </view>
  63. </view>
  64. <!-- 底部 -->
  65. <view class="bottom">
  66. <button class="btn" @click="save">保存</button>
  67. </view>
  68. </view>
  69. </template>
  70. <script>
  71. export default {
  72. data() {
  73. return {
  74. form: {
  75. headImg: '',
  76. },
  77. }
  78. },
  79. methods: {
  80. save() {
  81. uni.navigateBack({
  82. })
  83. },
  84. uploadPhoto() {
  85. let _self = this;
  86. const crop = {
  87. quality: 100,
  88. width: 600,
  89. height: 600,
  90. resize: true
  91. };
  92. // 上传图片
  93. uni.chooseImage({
  94. count: 1,
  95. crop,
  96. success: async (res) => {
  97. //(res);
  98. let tempFile = res.tempFiles[0],
  99. avatar_file = {
  100. // #ifdef H5
  101. extname: tempFile.name.split('.')[tempFile.name.split('.').length - 1],
  102. // #endif
  103. // #ifndef H5
  104. extname: tempFile.path.split('.')[tempFile.path.split('.').length - 1]
  105. // #endif
  106. },
  107. filePath = res.tempFilePaths[0]
  108. // #ifndef APP-PLUS
  109. //(`filePath=${filePath}`)
  110. //非app端用前端组件剪裁头像,app端用内置的原生裁剪
  111. let fileData = await new Promise((callback) => {
  112. uni.navigateTo({
  113. url: '/pages/components/cropImage?path=' + filePath +
  114. `&options=${JSON.stringify(crop)}`,
  115. animationType: "fade-in",
  116. events: {
  117. success: url => {
  118. callback(url)
  119. }
  120. }
  121. });
  122. })
  123. // #endif
  124. //返回 base64 图片
  125. //(fileData);
  126. var token = _self.carhelp.getToken()
  127. uni.showLoading({
  128. title: '上传中'
  129. });
  130. uni.request({
  131. url: process.car.BASE_URL + "/mobile/student/uploadBase64",
  132. method: 'POST',
  133. data: {
  134. photoBase64Data: fileData
  135. },
  136. header: {
  137. 'Authorization': token,
  138. 'content-type': 'application/x-www-form-urlencoded'
  139. },
  140. success: (res) => {
  141. let jsonData = res.data;
  142. _self.form.headImg = jsonData.data;
  143. // _self.save();
  144. uni.hideLoading();
  145. }
  146. });
  147. }
  148. });
  149. },
  150. }
  151. }
  152. </script>
  153. <style lang="scss" scoped>
  154. .main{
  155. background-color: #fff;
  156. .photo{
  157. width: 108px;
  158. height: 108px;
  159. margin: auto;
  160. padding-top: 20px;
  161. position: relative;
  162. img{
  163. width: 108px;
  164. height: 108px;
  165. border-radius: 999px;
  166. }
  167. .camera{
  168. width: 52rpx;
  169. height: 52rpx;
  170. border-radius: 999px;
  171. background-color: rgba(13, 186, 199, 1);
  172. text-align: center;
  173. border: 2px solid rgba(255, 255, 255, 1);
  174. position: absolute;
  175. bottom: -32rpx;
  176. right: 0;
  177. img{
  178. width: 32rpx;
  179. height: 32rpx;
  180. vertical-align: middle;
  181. }
  182. }
  183. }
  184. .infos{
  185. padding: 40px 16px 20px 16px;
  186. .item{
  187. display: flex;
  188. justify-content: space-between;
  189. line-height:44px;
  190. border-bottom: 1px solid rgba(229, 231, 234, 1);
  191. .title{
  192. color: rgba(119, 119, 119, 1);
  193. }
  194. .content{
  195. color: rgba(16, 16, 16, 1);
  196. }
  197. }
  198. .honour{
  199. padding-top: 12px;
  200. .title{
  201. color: rgba(119, 119, 119, 1);
  202. }
  203. uni-textarea{
  204. width: 100%;
  205. height: 160rpx;
  206. border-radius: 8px;
  207. background-color: rgba(229, 231, 234, 1);
  208. margin-top:8px;
  209. text-indent: 14px;
  210. }
  211. }
  212. }
  213. }
  214. .bottom{
  215. position: fixed;
  216. left: 0;
  217. right: 0;
  218. bottom: 0;
  219. background-color: #fff;
  220. padding: 10px 0;
  221. .btn{
  222. width: 91.4%;
  223. background-color: rgba(13, 186, 199, 1);
  224. color: rgba(255, 255, 255, 1);
  225. font-size: 16px;
  226. line-height: 40px;
  227. border-radius: 50px;
  228. }
  229. }
  230. </style>