|
|
@@ -0,0 +1,112 @@
|
|
|
+<template>
|
|
|
+ <view>
|
|
|
+ <view style="padding: 0 62rpx;background-color: #ffffff;">
|
|
|
+ <uni-forms ref="form" :modelValue="form" :border="true" label-width="80">
|
|
|
+ <uni-forms-item name="consumerName" label="头像">
|
|
|
+ <view style="display: flex;justify-content: flex-end;">
|
|
|
+ <image :src="form.avatar||avatarUrl" style="width:100rpx;height: 100rpx;border-radius: 50%;"
|
|
|
+ mode="scaleToFill" @click="showActionSheet">
|
|
|
+ </image>
|
|
|
+ </view>
|
|
|
+ </uni-forms-item>
|
|
|
+ <uni-forms-item name="consumerName" label="用户名">
|
|
|
+ <uni-easyinput v-model="form.consumerName" class="right-align" placeholder-class="placeholder-right"
|
|
|
+ placeholder="请输入用户名" :inputBorder="false" :clearable="false"></uni-easyinput>
|
|
|
+ </uni-forms-item>
|
|
|
+ <uni-forms-item name="consumerPhone" label="手机号">
|
|
|
+ <uni-easyinput v-model="form.consumerPhone" class="right-align"
|
|
|
+ placeholder-class="placeholder-right" placeholder=" " :inputBorder="false" :disabled="true"
|
|
|
+ :clearable="false"></uni-easyinput>
|
|
|
+ </uni-forms-item>
|
|
|
+ </uni-forms>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ avatarUrl: '/static/images/me/head.png',
|
|
|
+ tempFilePaths: [],
|
|
|
+ form: {}
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onLoad() {
|
|
|
+
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ showActionSheet() {
|
|
|
+ uni.showActionSheet({
|
|
|
+ itemList: ['拍照', '从相册选择'],
|
|
|
+ success: (res) => {
|
|
|
+ if (res.tapIndex === 0) {
|
|
|
+ this.chooseMedia('camera')
|
|
|
+ } else {
|
|
|
+ this.chooseMedia('album')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ chooseMedia(sourceType) {
|
|
|
+ uni.chooseMedia({
|
|
|
+ count: 1,
|
|
|
+ mediaType: ['image'],
|
|
|
+ sourceType: [sourceType],
|
|
|
+ sizeType: ['original', 'compressed'],
|
|
|
+ camera: 'front',
|
|
|
+ success: (res) => {
|
|
|
+ // this.avatarUrl = res.tempFiles[0].tempFilePath
|
|
|
+ this.tempFilePaths = res.tempFiles.map(file => file.tempFilePath)
|
|
|
+ this.uploadFiles()
|
|
|
+ },
|
|
|
+ fail: (err) => {
|
|
|
+ console.log(err)
|
|
|
+ },
|
|
|
+ })
|
|
|
+ },
|
|
|
+ uploadFiles() {
|
|
|
+ const uploadTasks = this.tempFilePaths.map((filePath, index) => {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ uni.uploadFile({
|
|
|
+ url: 'https://lt.echepei.com/api/blade-resource/oss/endpoint/put-file',
|
|
|
+ filePath: filePath,
|
|
|
+ name: 'file',
|
|
|
+ header: {
|
|
|
+ 'Blade-Auth': 'bearer ' + uni.getStorageSync('accessToken'),
|
|
|
+ appId: uni.getAccountInfoSync().miniProgram.appId
|
|
|
+ },
|
|
|
+ success: (uploadRes) => {
|
|
|
+ let obj = {
|
|
|
+ id: this.userData.userId,
|
|
|
+ avatar: JSON.parse(uploadRes.data).data.link
|
|
|
+ }
|
|
|
+ // updateUserAvatar(obj).then(res => {
|
|
|
+ // uni.showToast({
|
|
|
+ // title: "上传成功",
|
|
|
+ // icon: "none",
|
|
|
+ // mask: true
|
|
|
+ // });
|
|
|
+ // this.getUserData()
|
|
|
+ // })
|
|
|
+ },
|
|
|
+ fail: (err) => {
|
|
|
+ reject(err)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ }
|
|
|
+ }
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+ // ::v-deep .uni-section {
|
|
|
+ // padding: 0 62rpx;
|
|
|
+ // }
|
|
|
+ ::v-deep .uni-forms-item.is-direction-left {
|
|
|
+
|
|
|
+ align-items: center !important;
|
|
|
+ }
|
|
|
+</style>
|