usercore.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template>
  2. <div>
  3. <cu-custom bgColor="bg-gradual-pink" :isBack="true">
  4. <block slot="backText">返回</block>
  5. <block slot="content">个人中心</block>
  6. </cu-custom>
  7. <div class="img" >
  8. <div style="height: 15px;width: 100%;"></div>
  9. <ul style="text-align: center;">
  10. <li>
  11. <div style="position: relative;">
  12. <div class="tx" @click="upload()">
  13. <image :src="avatar" style="width:80px; height:80px;"></image>
  14. </div>
  15. <text class='cuIcon-cameraadd' @tap="ChooseImage" style="position: absolute;top: 65px;margin-left: 25px;"></text>
  16. </div>
  17. </li>
  18. <li>
  19. <div class="row">
  20. <span><h2>admin</h2></span>
  21. <!-- <image src="../../static/icon/xbn.png" class="ic"></image> -->
  22. </div>
  23. <!-- <ul class="ls" style="margin-left: 33%;">
  24. <li ><span><h2>admin</h2></span></li>
  25. <li ><image src="../../static/icon/xbn.png" class="ic"></image></li>
  26. </ul> -->
  27. </li>
  28. </ul>
  29. </div>
  30. <div style="background-color: #FFFFFF;">
  31. <ul>
  32. <li>
  33. <div style="margin-top: -5px;">
  34. <span>
  35. <image src="../../static/zl.png" class="bac"></image>
  36. </span>
  37. </div>
  38. <div style="margin-left: 15%; margin-top: -33px;">
  39. <span >个人信息</span>
  40. </div>
  41. <span style="width: 10px;height: 10px;float: right;"></span>
  42. <div style="float: right;margin-top: -23px;" @click="queryUser()">
  43. <image src="../../static/fh2.png" class="bacImg"></image>
  44. </div>
  45. <div style="width: 100%; height: 1px; border-top: solid #ACC0D8 1px;margin-top: 10px;"></div>
  46. </li>
  47. <li>
  48. <div style="height: 10px;width: 100%;"></div>
  49. <div style="margin-top: -5px;">
  50. <span>
  51. <image src="../../static/pwd.png" class="bac"></image>
  52. </span>
  53. </div>
  54. <div style="margin-left: 15%; margin-top: -31px;">
  55. <span >修改密码</span>
  56. </div>
  57. <span style="width: 10px;height: 10px;float: right;"></span>
  58. <div style="float: right;margin-top: -23px;" @click="userpwd()">
  59. <image src="../../static/fh2.png" class="bacImg"></image>
  60. </div>
  61. <div style="width: 100%; height: 1px; border-top: solid #ACC0D8 1px;margin-top: 10px;"></div>
  62. </li>
  63. <li>
  64. <div style="height: 10px;width: 100%;"></div>
  65. <div style="margin-top: -5px;">
  66. <span>
  67. <image src="../../static/wz.png" class="bac"></image>
  68. </span>
  69. </div>
  70. <div style="margin-left: 15%; margin-top: -32px;">
  71. <span >位置</span>
  72. </div>
  73. <span style="width: 10px;height: 10px;float: right;"></span>
  74. <div style="float: right;margin-top: -23px;" @click="userdt()">
  75. <image src="../../static/fh2.png" class="bacImg"></image>
  76. </div>
  77. <div style="width: 100%; height: 1px; border-top: solid #ACC0D8 1px;margin-top: 10px;"></div>
  78. </li>
  79. <li>
  80. <div style="height: 10px;width: 100%;"></div>
  81. <div >
  82. <span>
  83. <image src="../../static/tc2.png" class="bac"></image>
  84. </span>
  85. </div>
  86. <div style="margin-left: 15%; margin-top: -32px;">
  87. <span >退出登录</span>
  88. </div>
  89. <span style="width: 10px;height: 10px;float: right;"></span>
  90. <div style="float: right;margin-top: -23px;" @click="exit()">
  91. <image src="../../static/fh2.png" class="bacImg"></image>
  92. </div>
  93. <div style="width: 100%; height: 1px; border-top: solid #ACC0D8 1px;margin-top: 10px;"></div>
  94. </li>
  95. </ul>
  96. </div>
  97. </div>
  98. </template>
  99. <script>
  100. import {ACCESS_TOKEN} from '@/common/util/constants.js'
  101. import api from '@/api/api'
  102. export default {
  103. data() {
  104. return {
  105. userUrl:'/sys/user/edit',
  106. Url:'/sys/user/queryById',
  107. avatar:"",
  108. uploadUrl:"/sys/common/upload",
  109. }
  110. },
  111. created() {
  112. let avatars=(this.$store.getters.avatar && this.$store.getters.avatar.length > 0)? api.getFileAccessHttpUrl(this.$store.getters.avatar):'/static/avatar_boy.png'
  113. this.avatar=avatars;
  114. console.log(this.avatar)
  115. },
  116. methods:{
  117. ChooseImage() {
  118. var that=this;
  119. uni.chooseImage({
  120. count: 4, //默认9
  121. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  122. sourceType: ['album'], //从相册选择
  123. success: (res) => {
  124. /* alert(res.tempFilePaths) */
  125. that.$http.upload(that.$config.apiUrl+that.uploadUrl, {
  126. filePath: res.tempFilePaths[0],
  127. name: 'file'
  128. })
  129. .then(res => {
  130. console.log(res)
  131. if(res.statusCode==200){
  132. this.$http.put(this.userUrl,{id:this.$store.getters.userid,avatar:res.data.message}).then(res=>{
  133. if(res.data.code==200){
  134. this.$http.get(this.Url,{params:{id:this.$store.getters.userid}}).then(res=>{
  135. let perArr = res.data.data;
  136. let avatars=(perArr.avatar && perArr.avatar.length > 0)? api.getFileAccessHttpUrl(perArr.avatar):'/static/avatar_boy.png'
  137. let ava="/static/avatar_boy.png"
  138. if(perArr.avatar!=null ||perArr.avatar!=""){
  139. ava=perArr.avatar;
  140. }
  141. this.$store.commit('SET_AVATAR',ava);
  142. this.avatar=avatars;
  143. }).catch(err => {
  144. console.log(err);
  145. });
  146. this.$tip.success('更换成功!')
  147. }
  148. }).catch(err => {
  149. console.log(err);
  150. });
  151. }
  152. })
  153. .catch(err => {
  154. that.$tip.error(err.data.message)
  155. });
  156. }
  157. });
  158. },
  159. queryUser:function(){
  160. this.$Router.push({name:'peruser'})
  161. },
  162. exit:function(){
  163. this.$Router.push({name:'userexit'})
  164. },
  165. userpwd:function(){
  166. this.$Router.push({name:'userpwd'})
  167. },
  168. userdt:function(){
  169. this.$Router.push({name:'userdt'})
  170. }
  171. }
  172. }
  173. </script>
  174. <style>
  175. .img{
  176. height: 155px;
  177. background-image: url(../../static/bj001.jpeg);
  178. background-size:100% 100%;
  179. }
  180. ul li{
  181. list-style-type:none;
  182. margin-left: -20px;
  183. }
  184. .bacImg{
  185. height: 23px;
  186. width: 23px;
  187. background-size:100% 100%;
  188. }
  189. .tx{
  190. width:80px;
  191. height:80px;
  192. border-radius:50%;
  193. overflow:hidden;
  194. margin: 0 auto;
  195. }
  196. .bac{
  197. height: 32px;
  198. width: 32px;
  199. background-size:100% 100%;
  200. }
  201. .ic{
  202. width: 20px;
  203. height: 20px;
  204. margin-left: 10px;
  205. background-size:100% 100%;
  206. margin-top: 5px;
  207. }
  208. .ls li{
  209. list-style-type:none;
  210. display: block;
  211. float: left;
  212. margin-left: -5px;
  213. }
  214. </style>