index.vue 2.07 KB
<!--
 * @Date: 2022-09-19 14:11:06
 * @LastEditors: hookehuyr hookehuyr@gmail.com
 * @LastEditTime: 2023-12-20 18:02:57
 * @FilePath: /meihuaApp/src/pages/myInfo/index.vue
 * @Description: 我的信息页面
-->
<template>
  <view class="my-info-page">
    <view class="avatar" @tap="uploadImg">
        <nut-avatar size="100">
          <img :src="imageUrl" style="border-radius: 50%;"/>
        </nut-avatar>
        <view class="edit">编辑</view>
    </view>
    <view class="info-name">
      <nut-row type="flex" justify="center" align="center">
        <nut-col span="4">姓名</nut-col>
        <nut-col span="20">
          <view class="wrapper">
            <nut-input v-model="username" placeholder="请输入姓名" :border="false" />
          </view>
        </nut-col>
      </nut-row>
    </view>
    <view class="info-tel">
      <nut-row type="flex" justify="center" align="center">
        <nut-col span="4">电话</nut-col>
        <nut-col span="20">
          <view class="wrapper">
            <nut-input v-model="tel" placeholder="请输入电话" :border="false" type="number" />
          </view>
        </nut-col>
      </nut-row>
    </view>
    <view class="save-btn">
      <nut-button @tap="save" block color="#6A4925" size="large">
        <text>保&nbsp;存</text>
      </nut-button>
    </view>
  </view>
</template>

<script setup>
import Taro from '@tarojs/taro'
import { ref } from "vue";

const username = ref('');
const tel = ref('');

const imageUrl = ref(
  'https://img.yzcdn.cn/vant/cat.jpeg'
);
const cutImage = (url) => {
  console.warn(url);
  imageUrl.value = url;
};

const uploadImg = () => {
  Taro.chooseImage({
    count: 1,
    success: (res) => {
      console.warn(res);
      const tempFilePaths = res.tempFilePaths[0];
      console.warn(tempFilePaths);
      imageUrl.value = tempFilePaths;
    }
  })
}

const save = () => {
  console.warn(username.value, tel.value);
  Taro.showToast({
    title: '保存成功',
    icon:'success',
    duration: 2000
  });
}
</script>

<script>
import "./index.less";
export default {
  name: "myInfoPage",
};
</script>