dingdong-master/pages/my/personal-info.vue

96 lines
2.6 KiB
Vue

<template>
<view>
<!-- 顶部操作条 -->
<cu-custom :bgColor="'bg-main-color'" :isBack="true">
<block slot="backText">返回</block>
<block slot="content">商家信息</block>
</cu-custom>
<form @submit="submit">
<view class="text-center padding-tb-lg">
<button class="cu-avatar round"
:style="'width: 120rpx; height: 120rpx; background-image:url(' + curUserInfo.workerLogoUrl + ');'"
open-type="chooseAvatar" @chooseavatar="onChooseAvatar"></button>
</view>
<view class="margin-top-sm bg-white">
<view class="cu-form-group">
<view class="title">商家昵称</view>
<input name="name" v-model="curUserInfo.name"></input>
</view>
<view class="cu-form-group">
<view class="title">公司名称</view>
<input name="companyName" :value="curUserInfo.companyName"></input>
</view>
<view class="cu-form-group">
<view class="title">联系地址</view>
<input name="addressName" :value="curUserInfo.addressName"></input>
</view>
<view class="cu-form-group">
<view class="title">电子邮箱</view>
<input name="email" :value="curUserInfo.email"></input>
</view>
</view>
<view class="margin-top-sm bg-white">
<view class="cu-form-group" @click="showAccountSecurity">
<view class="title">帐号安全</view>
<view class="text-lg"><text class="cuIcon-right"></text></view>
</view>
</view>
<!-- 底部操作栏 -->
<view class="cu-bar tabbar border shop fixed-bottom-bar">
<button class="cu-btn bg-main-color long-btn margin-lr-sm shadow-blur" form-type="submit">保存</button>
</view>
</form>
</view>
</template>
<script>
export default {
data() {
return {
curUserInfo: {},
avatarUrl: '',
}
},
onLoad() {
this.loadData();
},
methods: {
onChooseAvatar(e) {
this.$request.uploadFile(e.detail.avatarUrl).then((url) => {
this.curUserInfo.workerLogoUrl = url;
});
},
async loadData() {
this.curUserInfo = await this.$request.getCurUserNoCache();
},
showAccountSecurity() {
uni.navigateTo({
url: '/pages/my/account-security'
})
},
async submit() {
let res = await this.$request.updateWorker({
workerId: this.curUserInfo.workerId,
name: this.curUserInfo.name,
workerLogoUrl: this.curUserInfo.workerLogoUrl
})
if (res && res.code === 0) {
uni.showToast({
icon: 'success',
title: '更新成功'
})
let timeout = setTimeout(() => {
uni.navigateTo({
url: '/pages/index/index?menuCode=myPage'
})
clearTimeout(timeout);
}, 1500);
}
}
},
}
</script>
<style>
</style>