userInfo.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <template>
  2. <view>
  3. <z-slide-card title="编辑个人资料" rightBtnText="保存" @rightClick="submit" :visible.sync="isvisible" @beforeClose="beforeClose">
  4. <z-cell label="头像" arrow @click.native="changeImage">
  5. <image class="head_img" :src="info.headImageSrc||'../../../static/touxiang_2.png'"></image>
  6. </z-cell>
  7. <z-cell label="姓名" :content="info.userName"></z-cell>
  8. <z-cell label="账号" :content="info.phone"></z-cell>
  9. <z-cell label="部门" content="销售部"></z-cell>
  10. <z-cell label="职务" :content="info.roleName"></z-cell>
  11. </z-slide-card>
  12. <u-toast ref="uToast"></u-toast>
  13. </view>
  14. </template>
  15. <script>
  16. const app = getApp({
  17. allowDefault: true
  18. });
  19. export default {
  20. props: {
  21. multiple: Boolean,
  22. value: String | Array,
  23. visible: Boolean
  24. },
  25. model: {
  26. prop: 'value',
  27. },
  28. data() {
  29. return {
  30. isvisible: false,
  31. info: {
  32. headImageSrc: ''
  33. },
  34. }
  35. },
  36. watch: {
  37. visible(newval, oldval) {
  38. this.isvisible = newval;
  39. }
  40. },
  41. mounted() {
  42. this.info=uni.getStorageSync('storeInfo');
  43. },
  44. methods: {
  45. changeImage() {
  46. var that = this;
  47. uni.chooseImage({
  48. count: 1,
  49. success: function(res) {
  50. const tempFilePaths = res.tempFilePaths;
  51. uni.uploadFile({
  52. //192.168.202.1:8083 api.order.ci2.cn
  53. url: 'http://api.order.ci2.cn/file/upload',
  54. filePath: tempFilePaths[0],
  55. name: 'file',
  56. formData: {
  57. type: 1
  58. },
  59. header: {
  60. "Authorization": app.globalData.authorization
  61. },
  62. success: (uploadFileRes) => {
  63. var data = JSON.parse(uploadFileRes.data);
  64. if (data.status) {
  65. that.$set(that.info, 'headImageSrc', data.data.url)
  66. } else {
  67. this.$refs.uToast.error(data.msg)
  68. }
  69. },
  70. fail: (err) => {
  71. this.$refs.uToast.error(err)
  72. }
  73. });
  74. }
  75. });
  76. },
  77. beforeClose() {
  78. this.$emit('update:visible', false)
  79. },
  80. submit() {
  81. console.log(this.info.headImageSrc)
  82. console.log(this.info)
  83. this.$axios.post('app/user/updateUserInfo', {
  84. "image": this.info.headImageSrc
  85. }).then(res => {
  86. console.log(res)
  87. uni.setStorage({
  88. key: 'storeInfo',
  89. data: this.info
  90. })
  91. this.$emit('changeImage',this.info.headImageSrc)
  92. this.$emit('update:visible', false)
  93. }).catch(err => {
  94. this.$refs.uToast.error(err.msg)
  95. })
  96. }
  97. }
  98. }
  99. </script>
  100. <style lang="scss" scoped>
  101. .head_img {
  102. width: 76rpx;
  103. height: 76rpx;
  104. border-radius: 50%;
  105. background: grey;
  106. margin-top: 10rpx;
  107. }
  108. </style>