| | |
| | | <view class="content chuany-flex chuany-align-end chuany-justify-center"> |
| | | <button class="avatar-wrapper" open-type="chooseAvatar" @chooseavatar="onChooseAvatar"> |
| | | <!-- <image class="avatar" src="{{avatarUrl}}"></image> --> |
| | | <up-avatar :src="avatarUrlImg" shape="circle" size='80'></up-avatar> |
| | | <up-avatar :src="userInfo.avatar" shape="circle" size='80'></up-avatar> |
| | | </button> |
| | | |
| | | </view> |
| | |
| | | <up-icon name="edit-pen" @click='isShow'></up-icon> |
| | | </template> --> |
| | | </up-input> |
| | | |
| | | |
| | | </up-form-item> |
| | | </up-form> |
| | | <text v-else>{{userInfo.nickname}}</text> |
| | |
| | | <up-icon name="edit-pen" @click='isShow'></up-icon> |
| | | </template> |
| | | </up-cell> |
| | | <up-cell title="手机号" :value="userInfo.phone" isLink :border="false"></up-cell> |
| | | <up-cell title="手机号" :value="userInfo.phone" :border="false"></up-cell> |
| | | <!-- <up-cell @click="goApply" title="申请接单" isLink :border="false"></up-cell> --> |
| | | <!-- <view class="tabbtns"> |
| | | <up-button color='#fece01' class="text-69" text="保存" @click=''></up-button> |
| | |
| | | ref, |
| | | reactive, |
| | | getCurrentInstance, |
| | | toRefs |
| | | toRefs, |
| | | computed |
| | | } from 'vue'; |
| | | const { |
| | | $upload, |
| | |
| | | $db, |
| | | $util |
| | | } = getCurrentInstance().appContext.config.globalProperties |
| | | import { |
| | | useStore |
| | | } from 'vuex' |
| | | const store = useStore() |
| | | onLoad(() => { |
| | | // getUser() |
| | | }) |
| | | onShow(() => { |
| | | getUser() |
| | | // getUser() |
| | | }) |
| | | let avatarUrlImg = ref('') |
| | | let number1 = ref(0) |
| | | let userInfo = reactive({ |
| | | nickname: '', |
| | | phone: '', |
| | | userWorker: false |
| | | }) |
| | | // let userInfo = reactive({ |
| | | // nickname: '', |
| | | // phone: '', |
| | | // userWorker: false |
| | | // }) |
| | | let userInfo = computed(() => store.getters.userInfo || {}) |
| | | let showEdit = ref(false) |
| | | // let src = "http://pic2.sc.chinaz.com/Files/pic/pic9/202002/hpic2119_s.jpg" |
| | | const goApply = () => { |
| | |
| | | const { |
| | | avatarUrl |
| | | } = e.detail |
| | | console.log(typeof(avatarUrl), avatarUrl, 'avatarUrl’'); |
| | | avatarUrlImg = avatarUrl |
| | | uploadFile(avatarUrl) |
| | | } |
| | | const uploadFile = (val) => { |
| | | uni.showLoading(); |
| | | let userToken = $db.get("userToken"); |
| | | uni.uploadFile({ |
| | | url: apiBaseUrl + '/api/UpFile/UpdateFile', |
| | |
| | | 'upfile': val |
| | | }, |
| | | success: (uploadFileRes) => { |
| | | //console.log("交互成功"); |
| | | //console.log(uploadFileRes); |
| | | |
| | | let res = JSON.parse(uploadFileRes.data); |
| | | let obj = { |
| | | Avatar: res.data |
| | | } |
| | | console.log(res.data, res, 'res.data', obj); |
| | | $api.saveUser(obj).then(res => { |
| | | if (res.code == 1) { |
| | | $util.showToast({ |
| | | title: "头像保存成功!", |
| | | icon: "success" |
| | | }) |
| | | getUser() |
| | | if (res.code == 1) { |
| | | let obj = { |
| | | Avatar: res.data |
| | | } |
| | | }) |
| | | $api.saveUser(obj).then(red => { |
| | | if (red.code == 1) { |
| | | $util.showToast({ |
| | | title: "头像保存成功!", |
| | | icon: "success" |
| | | }) |
| | | store.dispatch('getUserInfo') |
| | | } else { |
| | | this.$util.showToast({ |
| | | title: red.error |
| | | }) |
| | | } |
| | | }) |
| | | } else { |
| | | this.$util.showToast({ |
| | | title: res.error |
| | | }) |
| | | } |
| | | |
| | | }, |
| | | fail: (error) => { |
| | | console.log("交互失败"); |
| | |
| | | } |
| | | }, |
| | | complete: () => { |
| | | setTimeout(function() { |
| | | uni.hideLoading(); |
| | | }, |
| | | 250); |
| | | uni.hideLoading(); |
| | | } |
| | | }); |
| | | } |
| | | const getUser = (e) => { |
| | | $api.getUser().then(res => { |
| | | userInfo.nickname = res.data.nickname |
| | | userInfo.phone = res.data.phone |
| | | avatarUrlImg = res.data.avatar |
| | | $db.set('userInfo', JSON.stringify(res.data)) |
| | | }) |
| | | } |
| | | const saveUserNikename = (val) => { |
| | | if(!userInfo.nickname){ |
| | | $util.showToast({ |
| | | title: "请输入昵称!", |
| | | icon: "success" |
| | | }) |
| | | return |
| | | } |
| | | $api.saveUser({ |
| | | Nickname: userInfo.nickname |
| | | }).then(res => { |
| | |
| | | title: "昵称保存成功!", |
| | | icon: "success" |
| | | }) |
| | | getUser() |
| | | store.commit('setUserInfo',userInfo.value) |
| | | showEdit.value = false |
| | | } |
| | | }) |
| | |
| | | color: #7F7F7F; |
| | | flex-shrink: 0; |
| | | } |
| | | |
| | | .u-form-item__body{ |
| | | |
| | | .u-form-item__body { |
| | | padding: 0 !important; |
| | | } |
| | | </style> |