| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- <template>
- <view class="container">
- <view class="body">
- <!-- 个人头像区域 -->
- <view class="body_box">
- 个人头像
- <view class="box_right" @click="handleClickPhoto">
- <img mode="aspectFill" class="img" :src="imgUrl || '../../static/my/portrait.png'" />
- <img class="img2" src="../../static/my/right.png" />
- </view>
- </view>
- <!-- 账号名区域 -->
- <view class="body_box" @click="handleClickName">
- 账号名
- <view class="box_right">
- <view class="msg">{{ name }}</view>
- <img class="img2" src="../../static/my/right.png" />
- </view>
- </view>
- <!-- ID区域 -->
- <view class="body_box">
- ID
- <view class="box_right">
- <view class="msg">1925689</view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- // 头像
- imgUrl: '',
- // 账号名
- name: '张三'
- }
- },
- methods: {
- // 点击头像图片回调
- handleClickPhoto() {
- uni.showActionSheet({
- itemList: ['更换头像'],
- success: (res) => {
- if (res.tapIndex === 0) {
- this.changeImg()
- }
- }
- })
- },
- // 更换头像回调
- changeImg() {
- uni.chooseImage({
- count: 1,
- sizeType: ['compressed'],
- sourceType: ['album'], //从相册选择
- success: (res) => {
- // console.log(res.tempFilePaths)
- this.imgUrl = res.tempFilePaths[0]
- }
- })
- },
- // 点击账号名回调
- handleClickName() {
- uni.showActionSheet({
- itemList: ['修改账号名'],
- success: (res) => {
- if (res.tapIndex === 0) {
- this.changeName()
- }
- }
- })
- },
- // 修改账号名回调
- changeName() {
- uni.showModal({
- title: '请输入账号名',
- editable: true,
- success: async (res) => {
- if (res.confirm) {
- if (!res.content) {
- uni.showToast({
- title: '账号名不能为空',
- icon: 'none'
- })
- setTimeout(() => {
- this.changeName()
- }, 1500)
- } else {
- const result = await this.$myRequest({
- url: '/mhotel/ampupdateUserInfo.action',
- data: {
- userId: uni.getStorageSync('userInfo').id,
- userName: res.content,
- headPhoto: ''
- }
- })
- console.log(result)
- // this.name = res.content
- }
- }
- }
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .container {
- display: flex;
- flex-direction: column;
- min-height: 100vh;
- background-color: #ebeced;
- .body {
- box-sizing: border-box;
- margin-top: 20rpx;
- padding: 0 30rpx;
- height: calc(100vh - 20rpx);
- background-color: #fff;
- .body_box {
- display: flex;
- justify-content: space-between;
- align-items: center;
- height: 100rpx;
- font-size: 28rpx;
- border-bottom: 1rpx solid #e6e6e6;
- .box_right {
- display: flex;
- justify-content: flex-end;
- align-items: center;
- height: 100rpx;
- .img {
- width: 64rpx;
- height: 64rpx;
- border-radius: 50%;
- }
- .img2 {
- margin-left: 7rpx;
- width: 47rpx;
- height: 47rpx;
- }
- .msg {
- color: #808080;
- }
- }
- }
- }
- }
- </style>
|