27
This commit is contained in:
@@ -19,13 +19,13 @@
|
||||
|
||||
<u-datetime-picker :minDate="0" :maxDate="nowDate" :show="showDatePicker" @confirm="confirmDate"
|
||||
@cancel="() => (showDatePicker = false)" v-model="selfInfo.birth" mode="date" />
|
||||
|
||||
<c-cut-avatar ref="cutAvatar" @save="saveAvatar" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
businessInfoUpdate
|
||||
} from "@/api/login";
|
||||
import {businessInfoUpdate,upload} from "@/api/login";
|
||||
import IMSDK from "openim-uniapp-polyfill";
|
||||
import CustomNavBar from "@/components/CustomNavBar/index.vue";
|
||||
import MyAvatar from "@/components/MyAvatar/index.vue";
|
||||
@@ -87,14 +87,31 @@
|
||||
},
|
||||
});
|
||||
},
|
||||
saveAvatar(e){
|
||||
this.tempFilePath = e.path;
|
||||
upload(e.path,{
|
||||
'url':"/user/avatar",
|
||||
savePath: "avatar"
|
||||
}).then((res) => {
|
||||
console.log("上传成功",res);
|
||||
this.$store.commit("user/SET_SELF_INFO",{
|
||||
...this.$store.getters.storeSelfInfo,
|
||||
faceURL: res.data.avatar,
|
||||
});
|
||||
}).catch((res1) => {
|
||||
console.log("上传失败",res1);
|
||||
});
|
||||
},
|
||||
updateAvatar() {
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ["compressed"],
|
||||
sizeType: ["original"],
|
||||
success: async ({
|
||||
tempFilePaths
|
||||
}) => {
|
||||
const path = tempFilePaths[0];
|
||||
this.$refs.cutAvatar.enterEditor(path);
|
||||
return ;
|
||||
const nameIdx = path.lastIndexOf("/") + 1;
|
||||
const typeIdx = path.lastIndexOf(".") + 1;
|
||||
const fileName = path.slice(nameIdx);
|
||||
|
||||
Reference in New Issue
Block a user