修改 app
This commit is contained in:
@@ -1,16 +1,29 @@
|
||||
<template>
|
||||
<Cn-page :loading="loading">
|
||||
<view slot="body">
|
||||
<view class="head">
|
||||
<image class="head-img" :src="userInfo.avatar" v-if="userInfo.avatar"></image>
|
||||
<image class="head-img" src="/static/head.png" v-else></image>
|
||||
<view class="head-setup">
|
||||
<view class="head-setup-item" @click="take('album')">从相册选一张</view>
|
||||
<view class="head-setup-item" @click="take('camera')">拍一张照片</view>
|
||||
<view>
|
||||
<Cn-page :loading="loading">
|
||||
<view slot="body">
|
||||
<view class="head">
|
||||
<image class="head-img" :src="userInfo.avatar" v-if="userInfo.avatar"></image>
|
||||
<image class="head-img" src="/static/head.png" v-else></image>
|
||||
<view class="head-setup">
|
||||
<view class="head-setup-item" @click="take('album')">从相册选一张</view>
|
||||
<view class="head-setup-item" @click="take('camera')">拍一张照片</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</Cn-page>
|
||||
</Cn-page>
|
||||
<uni-popup ref="alertDialog" type="dialog">
|
||||
<uni-popup-dialog
|
||||
type="info"
|
||||
cancelText="禁止"
|
||||
confirmText="允许"
|
||||
title="权限说明"
|
||||
content='是否允许"灿能物联"使用相机?'
|
||||
@confirm="handleScon('camera')"
|
||||
@close="dialogClose"
|
||||
></uni-popup-dialog>
|
||||
</uni-popup>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import { uploadImage, getImageUrl } from '@/common/api/basic'
|
||||
@@ -25,12 +38,27 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
take(type) {
|
||||
if (type == 'camera') {
|
||||
if (
|
||||
plus.os.name == 'Android' &&
|
||||
plus.navigator.checkPermission('android.permission.CAMERA') === 'undetermined'
|
||||
) {
|
||||
//未授权
|
||||
|
||||
this.$refs.alertDialog.open()
|
||||
} else {
|
||||
this.handleScon(type)
|
||||
}
|
||||
} else {
|
||||
this.handleScon(type)
|
||||
}
|
||||
},
|
||||
handleScon(type) {
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ['original', 'compressed'],
|
||||
sourceType: [type],
|
||||
success: (res) => {
|
||||
console.log(res)
|
||||
uploadImage(res.tempFilePaths[0]).then((res) => {
|
||||
console.log(res)
|
||||
let result = JSON.parse(res[1].data)
|
||||
@@ -47,7 +75,9 @@ export default {
|
||||
},
|
||||
})
|
||||
},
|
||||
dialogClose() {},
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
this.userInfo = uni.getStorageSync(this.$cacheKey.userInfo)
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user