demingshangjia/pages/user/info.vue

211 lines
4.7 KiB
Vue
Raw Normal View History

2020-06-12 07:08:37 +00:00
<template>
2020-07-29 12:35:33 +00:00
<view class="info">
<view class="head" @click="chooseImage">
2020-08-10 04:04:09 +00:00
<image :src="fileurl+'?'+new Date().getTime()"></image>
2020-07-29 12:35:33 +00:00
<text>更换头像</text>
</view>
<view class="item">
<text class="title" v-if="role == 2">店铺名称</text>
<text class="title" v-else>达人名称</text>
2020-07-30 01:41:08 +00:00
<input type="text" value="" v-model="info.member_nickname" placeholder="请输入用户名"/>
2020-07-29 12:35:33 +00:00
</view>
2020-06-12 10:05:39 +00:00
<view class="item">
2020-07-29 12:35:33 +00:00
<text class="title">个性签名</text>
2020-07-30 01:41:08 +00:00
<input type="text" value="" v-model="info.signature" placeholder="请输入个性签名"/>
2020-07-29 12:35:33 +00:00
</view>
2020-09-05 04:30:22 +00:00
<view class="password" @click="updatePwd" v-if="role != 4">
2020-06-12 10:05:39 +00:00
<text>修改密码</text>
<image src="/static/image/user/1.png"></image>
</view>
2020-07-29 12:35:33 +00:00
<u-toast ref="uToast" />
</view>
2020-06-12 07:08:37 +00:00
</template>
<script>
export default {
2020-07-29 12:35:33 +00:00
name: 'info',
2020-06-12 10:05:39 +00:00
data() {
return {
2020-07-29 12:35:33 +00:00
fileurl: "",
filename:"",
info:{},
2020-09-05 04:30:22 +00:00
num:0,
role: 0,
2020-07-29 12:35:33 +00:00
};
},
onLoad() {
2020-09-05 04:30:22 +00:00
this.getmyinfo();
let userinfo = uni.getStorageSync("userinfo");
this.role = userinfo.role;
// console.log(this.role);
2020-07-29 12:35:33 +00:00
},
2020-09-19 12:02:43 +00:00
// 保存信息
2020-07-29 12:35:33 +00:00
onNavigationBarButtonTap() {
let that = this;
2020-08-10 04:04:09 +00:00
let obj ={
nickname:that.info.member_nickname,
avatar:that.filename,
signature:that.info.signature
}
console.log(obj)
2020-07-29 12:35:33 +00:00
this.$u.api.changeinfo({
nickname:that.info.member_nickname,
avatar:that.filename,
signature:that.info.signature
}).then(res => {
console.log(res);
if (res.errCode != 0) {
this.$refs.uToast.show({
title: res.message,
type: 'error'
});
} else {
this.$refs.uToast.show({
title: res.message,
type: 'success'
});
2020-08-10 12:24:58 +00:00
uni.navigateBack({
delta:1
})
2020-07-29 12:35:33 +00:00
}
});
2020-06-12 10:05:39 +00:00
},
methods: {
2020-07-29 12:35:33 +00:00
// 获取个人信息
getmyinfo(){
let that = this;
2020-07-30 11:49:12 +00:00
this.$u.api.getshopinfo({}).then(res => {
2020-07-29 12:35:33 +00:00
console.log(res);
if (res.errCode != 0) {
this.$refs.uToast.show({
title: res.message,
type: 'error'
});
} else {
this.info = res.data.memberInfo
this.fileurl = res.data.memberInfo.member_avatar
}
});
},
// 获取图片,上传图片
2020-06-12 10:05:39 +00:00
chooseImage(sourceType) {
2020-09-21 07:03:27 +00:00
let that = this;
let photo_type = "";
if (this.role == 2) {
photo_type = "store_avatar"
} else {
photo_type = "avatar"
}
2020-07-29 12:35:33 +00:00
const token = uni.getStorageSync('token');
2020-06-12 10:05:39 +00:00
uni.chooseImage({
count: 1,
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
2020-07-29 12:35:33 +00:00
success: function(res) {
2020-06-12 10:05:39 +00:00
console.log(JSON.stringify(res.tempFilePaths));
2020-07-29 12:35:33 +00:00
const tempFilePaths = res.tempFilePaths;
uni.uploadFile({
2020-08-18 07:31:03 +00:00
url: 'https://mall.dmygkeji.com/storeapi/Upload/uploadFile',
2020-07-29 12:35:33 +00:00
filePath: tempFilePaths[0],
2020-09-21 07:03:27 +00:00
name: photo_type,
2020-07-29 12:35:33 +00:00
formData:{
2020-09-21 07:03:27 +00:00
name: photo_type,
store_id: that.info.store_id
2020-07-29 12:35:33 +00:00
},
header:{
Authorization:'Bearer' + " " + token
},
success: uploadFileRes => {
let obj = JSON.parse(uploadFileRes.data)
that.fileurl = obj.data.file_path+'?'+new Date().getTime()
2020-07-29 12:35:33 +00:00
that.filename = obj.data.file_name
that.num++
console.log(that.fileurl,that.filename)
2020-09-21 07:03:27 +00:00
},
fail: (res) => {
console.log(res);
}
2020-07-29 12:35:33 +00:00
});
2020-06-12 10:05:39 +00:00
}
});
},
updatePwd() {
uni.navigateTo({
url: '/pages/user/updatePassword'
});
}
2020-07-29 12:35:33 +00:00
}
};
2020-06-12 07:08:37 +00:00
</script>
<style lang="scss" scoped>
2020-07-29 12:35:33 +00:00
.info {
2020-06-12 10:05:39 +00:00
min-height: calc(100vh - var(--window-top));
2020-07-29 12:35:33 +00:00
background: #ececec;
.head {
height: 202rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-color: #fff;
2020-06-12 10:05:39 +00:00
margin-bottom: 2rpx;
2020-07-29 12:35:33 +00:00
> image {
width: 120rpx;
height: 120rpx;
border-radius: 50%;
}
> text {
font-size: 24rpx;
color: #ff780f;
margin-top: 20rpx;
}
margin-bottom: 2rpx;
}
2020-06-12 10:05:39 +00:00
.item {
display: flex;
align-items: center;
height: 98rpx;
2020-07-29 12:35:33 +00:00
background: rgba(255, 255, 255, 1);
2020-06-12 10:05:39 +00:00
padding: 0 30rpx;
margin-bottom: 2rpx;
.title {
width: 120rpx;
font-size: 30rpx;
2020-07-29 12:35:33 +00:00
color: rgba(51, 51, 51, 1);
2020-06-12 10:05:39 +00:00
margin-right: 120rpx;
}
.value {
font-size: 30rpx;
2020-07-29 12:35:33 +00:00
color: rgba(101, 101, 101, 1);
2020-06-12 10:05:39 +00:00
}
}
.password {
margin-top: 20rpx;
padding: 0 30rpx;
height: 98rpx;
display: flex;
align-items: center;
justify-content: space-between;
2020-07-29 12:35:33 +00:00
background: rgba(255, 255, 255, 1);
2020-06-12 10:05:39 +00:00
> text {
font-size: 30rpx;
2020-07-29 12:35:33 +00:00
color: rgba(51, 51, 51, 1);
2020-06-12 10:05:39 +00:00
}
> image {
width: 11rpx;
height: 22rpx;
}
}
.image-popup {
padding: 0 30rpx;
> view {
2020-07-29 12:35:33 +00:00
font-size: 28rpx;
color: rgba(51, 51, 51, 1);
2020-06-12 10:05:39 +00:00
line-height: 98rpx;
text-align: center;
&:first-child {
2020-07-29 12:35:33 +00:00
border-bottom: 2rpx solid #ebebeb;
2020-06-12 10:05:39 +00:00
}
}
}
2020-06-12 07:08:37 +00:00
}
2020-07-29 12:35:33 +00:00
</style>