Commit a2bed2e4 by cen

fix: 修复bug

1 parent 200f23df
...@@ -164,17 +164,17 @@ function requestAndroidPermission(permissionID) { ...@@ -164,17 +164,17 @@ function requestAndroidPermission(permissionID) {
var result = 0; var result = 0;
for (var i = 0; i < resultObj.granted.length; i++) { for (var i = 0; i < resultObj.granted.length; i++) {
var grantedPermission = resultObj.granted[i]; var grantedPermission = resultObj.granted[i];
uni.$logger.local.info('已获取的权限:' + grantedPermission); console.log('已获取的权限:' + grantedPermission);
result = 1 result = 1
} }
for (var i = 0; i < resultObj.deniedPresent.length; i++) { for (var i = 0; i < resultObj.deniedPresent.length; i++) {
var deniedPresentPermission = resultObj.deniedPresent[i]; var deniedPresentPermission = resultObj.deniedPresent[i];
uni.$logger.local.info('拒绝本次申请的权限:' + deniedPresentPermission); console.log('拒绝本次申请的权限:' + deniedPresentPermission);
result = 0 result = 0
} }
for (var i = 0; i < resultObj.deniedAlways.length; i++) { for (var i = 0; i < resultObj.deniedAlways.length; i++) {
var deniedAlwaysPermission = resultObj.deniedAlways[i]; var deniedAlwaysPermission = resultObj.deniedAlways[i];
uni.$logger.local.info('永久拒绝申请的权限:' + deniedAlwaysPermission); console.log('永久拒绝申请的权限:' + deniedAlwaysPermission);
result = -1 result = -1
} }
resolve(result); resolve(result);
...@@ -184,7 +184,7 @@ function requestAndroidPermission(permissionID) { ...@@ -184,7 +184,7 @@ function requestAndroidPermission(permissionID) {
// } // }
}, },
function(error) { function(error) {
uni.$logger.error('申请权限错误:' + error.code + " = " + error.message); console.log('申请权限错误:' + error.code + " = " + error.message);
resolve({ resolve({
code: error.code, code: error.code,
message: error.message message: error.message
......
...@@ -80,11 +80,35 @@ ...@@ -80,11 +80,35 @@
<!-- 弹窗 --> <!-- 弹窗 -->
<OrderPopup ref="orderPopup" :data="displayData" :isDefeatOrder="true" :externalData="[]" @onConfirm="onConfirm" :popupType="0" /> <OrderPopup ref="orderPopup" :data="displayData" :isDefeatOrder="true" :externalData="[]" @onConfirm="onConfirm" :popupType="0" />
<SelectCar ref="selectCar" title="选择车型" @car-selected="handleCarSelected" /> <SelectCar ref="selectCar" title="选择车型" @car-selected="handleCarSelected" />
<SelectCity ref="selectCity" title="选择城市" @city-selected="handleCitySelected" /> <SelectCity
<SelectCity ref="selectCarCity" title="选择城市" @city-selected="handleCarCitySelected" /> ref="selectCity"
title="选择城市"
@city-selected="handleCitySelected"
:defaultProvince="{
code: formData.carBaseReqDTO.registrationProvinceId,
name: formData.carBaseReqDTO.registrationProvinceName
}"
:defaultCity="{
code: formData.carBaseReqDTO.registrationCityId,
name: formData.carBaseReqDTO.registrationCityName
}"
/>
<SelectCity
ref="selectCarCity"
title="选择城市"
@city-selected="handleCarCitySelected"
:defaultProvince="{
code: formData.carBaseReqDTO.carProvinceId,
name: formData.carBaseReqDTO.carProvinceName
}"
:defaultCity="{
code: formData.carBaseReqDTO.carCityId,
name: formData.carBaseReqDTO.carCityName
}"
/>
<GeneralPopup ref="calendarGeneralPopup" popupClass="calendarGeneralPopup" :showClose="false" :showTitle="false" @confirm="confirmCalendar"> <GeneralPopup ref="calendarGeneralPopup" popupClass="calendarGeneralPopup" :showClose="false" :showTitle="false" @confirm="confirmCalendar">
<template #content> <template #content>
<uni-calendar class="calendar" :showMonth="false" :endDate="endDate" @change="calendarChange" /> <uni-calendar class="calendar" :showMonth="false" :startDate="startDate" :endDate="endDate" @change="calendarChange" />
</template> </template>
</GeneralPopup> </GeneralPopup>
<GeneralPopup ref="tipsPopup" popupClass="tipsPopup" type="center" :showClose="true" :showTitle="false" :noTitle="true"> <GeneralPopup ref="tipsPopup" popupClass="tipsPopup" type="center" :showClose="true" :showTitle="false" :noTitle="true">
...@@ -124,7 +148,7 @@ import UploadMedia from './components/uploadMedia.vue' ...@@ -124,7 +148,7 @@ import UploadMedia from './components/uploadMedia.vue'
import NoticePopup from '@/components/NoticePopup.vue' import NoticePopup from '@/components/NoticePopup.vue'
import { debounce } from 'lodash' import { debounce } from 'lodash'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { max } from 'lodash' import permision from '@/js_sdk/wa-permission/permission.js'
export default { export default {
name: 'AddEvaluationFrom', name: 'AddEvaluationFrom',
components: { components: {
...@@ -159,6 +183,7 @@ export default { ...@@ -159,6 +183,7 @@ export default {
popupTypeEnum, popupTypeEnum,
title: '新增评估单', title: '新增评估单',
selectedCarInfo: null, selectedCarInfo: null,
startDate: '',
endDate: dayjs().format('YYYY-MM-DD'), endDate: dayjs().format('YYYY-MM-DD'),
isExistSamePlate: false, isExistSamePlate: false,
formData: { formData: {
...@@ -851,15 +876,15 @@ export default { ...@@ -851,15 +876,15 @@ export default {
this.$set(this.formData.carBaseReqDTO, 'carTypeName', date.year.name) this.$set(this.formData.carBaseReqDTO, 'carTypeName', date.year.name)
}, },
handleCitySelected(date) { handleCitySelected(date) {
this.$set(this.formData.carBaseReqDTO, 'registrationProvinceId', '') this.$set(this.formData.carBaseReqDTO, 'registrationProvinceId', date.province.code)
this.$set(this.formData.carBaseReqDTO, 'registrationProvinceName', date.province.name) this.$set(this.formData.carBaseReqDTO, 'registrationProvinceName', date.province.name)
this.$set(this.formData.carBaseReqDTO, 'registrationCityId', '') this.$set(this.formData.carBaseReqDTO, 'registrationCityId', date.city.code)
this.$set(this.formData.carBaseReqDTO, 'registrationCityName', date.city.name) this.$set(this.formData.carBaseReqDTO, 'registrationCityName', date.city.name)
}, },
handleCarCitySelected(date) { handleCarCitySelected(date) {
this.$set(this.formData.carBaseReqDTO, 'carProvinceId', '') this.$set(this.formData.carBaseReqDTO, 'carProvinceId', date.province.code)
this.$set(this.formData.carBaseReqDTO, 'carProvinceName', date.province.name) this.$set(this.formData.carBaseReqDTO, 'carProvinceName', date.province.name)
this.$set(this.formData.carBaseReqDTO, 'carCityId', '') this.$set(this.formData.carBaseReqDTO, 'carCityId', date.city.code)
this.$set(this.formData.carBaseReqDTO, 'carCityName', date.city.name) this.$set(this.formData.carBaseReqDTO, 'carCityName', date.city.name)
console.log('handleCarCitySelected', this.formData.carBaseReqDTO) console.log('handleCarCitySelected', this.formData.carBaseReqDTO)
}, },
...@@ -1031,7 +1056,22 @@ export default { ...@@ -1031,7 +1056,22 @@ export default {
}) })
}, },
scan(type) { async scan(type) {
const photoLibrary = await permision.requestAndroidPermission('android.permission.READ_EXTERNAL_STORAGE')
const camera = await permision.requestAndroidPermission('android.permission.CAMERA')
const isOnline = await uni.$isNetWork()
if (photoLibrary != 1) {
uni.showToast({ title: '您的设备不支持相册功能或未授权访问,请前往设置中开启相册权限', icon: 'none' })
return
}
if (camera != 1) {
uni.showToast({ title: '您的设备不支持摄像头功能或未授权访问,请前往设置中开启摄像头权限', icon: 'none' })
return
}
if (!isOnline) {
uni.showToast({ title: '当前无网络连接,请连接网络后重试', icon: 'none' })
return
}
uni.showActionSheet({ uni.showActionSheet({
itemList: ['拍照', '从相册选择'], itemList: ['拍照', '从相册选择'],
success: res => { success: res => {
......
...@@ -149,6 +149,9 @@ export default { ...@@ -149,6 +149,9 @@ export default {
width: 100%; width: 100%;
height: toRpx(164); height: toRpx(164);
background-color: #fff; background-color: #fff;
.btn {
width: toRpx(720);
}
} }
} }
//小弹窗 //小弹窗
...@@ -221,7 +224,7 @@ export default { ...@@ -221,7 +224,7 @@ export default {
width: 100%; width: 100%;
} }
.btn { .btn {
flex: 1; width: toRpx(720);
height: toRpx(76); height: toRpx(76);
border-radius: toRpx(48); border-radius: toRpx(48);
opacity: 1; opacity: 1;
......
<template> <template>
<GeneralPopup ref="carPopup" popupClass="carPopup" :list="list" :title="title" @confirm="handleConfirm"> <GeneralPopup ref="cityPopup" popupClass="cityPopup" :list="list" :title="title" @confirm="handleConfirm">
<template v-slot:content> <template v-slot:content>
<StepTab :steps="steps" :currentStep="currentStep" :clickable="true" @step-change="onStepChange" :isShowStepNumber="false"></StepTab> <view v-if="isLoading" class="loading-container">
<view class="loading-spinner"></view>
<text class="loading-text">加载中...</text>
</view>
<view v-else class="content-container">
<StepTab :steps="dynamicSteps" :currentStep="currentStep" :clickable="true" @step-change="onStepChange" :isShowStepNumber="false"></StepTab>
<view class="list-component"> <view class="list-component">
<SortByNameList :items="currentStepData" :activeValue="currentSelectedId" :activeField="'name'" :itemNameField="'name'" :groupKeyField="'letter'" :itemsPerRow="3" :itemSpacing="32" @item-click="handleItemClick" /> <SortByNameList :items="currentStepData" :activeValue="currentSelectedId" :activeField="'code'" :itemNameField="'name'" :groupKeyField="'letter'" :itemsPerRow="3" :itemSpacing="32" @item-click="handleItemClick" />
</view>
</view> </view>
</template> </template>
</GeneralPopup> </GeneralPopup>
...@@ -15,7 +21,7 @@ import StepTab from './StepTab.vue' ...@@ -15,7 +21,7 @@ import StepTab from './StepTab.vue'
import { sign, md532, md516 } from 'utils/common' import { sign, md532, md516 } from 'utils/common'
import pinyin from 'pinyin.js' import pinyin from 'pinyin.js'
export default { export default {
name: 'SelectCar', name: 'SelectCity',
components: { components: {
GeneralPopup, GeneralPopup,
SortByNameList, SortByNameList,
...@@ -24,11 +30,19 @@ export default { ...@@ -24,11 +30,19 @@ export default {
props: { props: {
title: { title: {
type: String, type: String,
default: '选择车型' default: '选择城市'
}, },
list: { list: {
type: Array, type: Array,
default: () => [] default: () => []
},
defaultProvince: {
type: Object,
default: null
},
defaultCity: {
type: Object,
default: null
} }
}, },
data() { data() {
...@@ -39,46 +53,55 @@ export default { ...@@ -39,46 +53,55 @@ export default {
{ label: '选择省份', number: 1 }, { label: '选择省份', number: 1 },
{ label: '选择市', number: 2 } { label: '选择市', number: 2 }
], ],
carBrandData: [], provinceData: [],
selectedBrand: null, selectedProvince: null,
selectedSeries: null, selectedCity: null,
selectedModel: null, selectionResult: null,
selectedYear: null, isLoading: true
loadingYearData: false, // 添加加载状态标记
selectionResult: null
} }
}, },
created() {
this.loadCityData()
},
computed: { computed: {
dynamicSteps() {
const newSteps = [...this.steps]
if (this.selectedProvince && this.selectedProvince.name) {
newSteps[0].label = this.selectedProvince.name
} else {
newSteps[0].label = '选择省份'
}
if (this.currentStep >= 1) {
if (this.selectedCity && this.selectedCity.name) {
newSteps[1].label = this.selectedCity.name
} else {
newSteps[1].label = '选择市'
}
}
return newSteps
},
currentStepData() { currentStepData() {
let data = [] let data = []
switch (this.currentStep) { switch (this.currentStep) {
case 0: case 0:
data = this.carBrandData.map(item => this.addLetterToItem(item)) data = this.provinceData.map(item => this.addLetterToItem(item))
break break
case 1: case 1:
data = (this.selectedBrand?.districts || []).map(item => this.addLetterToItem(item)) data = (this.selectedProvince?.districts || []).map(item => this.addLetterToItem(item))
break break
// case 2:
// data = (this.selectedSeries?.districts || []).map(item => this.addLetterToItem(item))
// break
// case 3:
// data = (this.selectedModel?.districts || []).map(item => this.addLetterToItem(item))
// break
default: default:
data = [] data = []
} }
console.log(`Step ${this.currentStep} data:`, data.length, 'items') console.log(`Step ${this.currentStep} data:`, data.length, 'items')
return data return data
} }
}, },
methods: { methods: {
loadCarData() { loadCityData() {
let that = this let that = this
this.isLoading = true
uni.request({ uni.request({
url: 'http://eshield.test.glsx.com.cn/nesi/apiRegion/search?keyword=全国&sub_admin=3&extensions_code=0', url: 'http://eshield.test.glsx.com.cn/nesi/apiRegion/search?keyword=全国&sub_admin=3&extensions_code=1',
method: 'GET', method: 'GET',
data: {}, data: {},
dataType: 'json', dataType: 'json',
...@@ -86,133 +109,109 @@ export default { ...@@ -86,133 +109,109 @@ export default {
console.log('请求结果:', JSON.parse(result.data.data)) console.log('请求结果:', JSON.parse(result.data.data))
let { status, districts } = JSON.parse(result.data.data) let { status, districts } = JSON.parse(result.data.data)
if (status === 0 && districts) { if (status === 0 && districts) {
that.carBrandData = districts[0].districts that.provinceData = districts[0].districts
console.log('carBrandData', that.carBrandData) console.log('provinceData', that.provinceData)
that.updateSelectionWithLoadedData()
} else { } else {
console.error('Invalid car data format:', result) console.error('Invalid city data format:', result)
} }
that.isLoading = false
}, },
fail(error) { fail(error) {
console.log(error, 'error') console.log(error, 'error')
that.isLoading = false
} }
}) })
}, },
updateSelectionWithLoadedData() {
// 加载指定车型的年份数据 console.log('Updating selection with loaded data...', this.defaultProvince)
loadYearDataForModel(model) { console.log('Updating selection with loaded data...', this.defaultCity)
console.log('loadYearDataForModel', model) console.log('Updating selection with loaded data...', this.provinceData)
// 如果已经加载过数据,则不再重复加载 if (this.defaultProvince && (this.defaultProvince.code || this.defaultProvince.id)) {
if (model.districts && model.districts.length > 0) { const defaultProvinceCode = String(this.defaultProvince.code || this.defaultProvince.id)
return Promise.resolve(model.districts) const foundProvince = this.provinceData.find(p => String(p.code) === defaultProvinceCode || String(p.id) === defaultProvinceCode)
} console.log('foundProvince', foundProvince)
if (foundProvince) {
this.loadingYearData = true this.selectedProvince = foundProvince
let that = this const defaultCityCode = this.defaultCity ? String(this.defaultCity.code || this.defaultCity.id) : null
const params = { if (defaultCityCode) {
app_key: '48e5e13229b82c1b4e6e8c96151f0637', const foundCity = foundProvince.districts?.find(c => String(c.code) === defaultCityCode || String(c.id) === defaultCityCode)
v: '1.0.0', if (foundCity) {
timestamp: '1234567890', this.selectedCity = foundCity
source: 'dev_author', this.currentStep = 1
method: 'glsx.accounts.base.car.types', this.currentSelectedId = foundCity.code
format: 'json', }
csId: model.id }
} this.selectionResult = {
const secret = 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b' province: this.selectedProvince,
const signature = sign(params, secret) city: this.selectedCity
console.log('签名结果:', signature) }
return new Promise((resolve, reject) => { }
uni.request({
url: 'http://qcdidicb.glsx.com.cn/router?method=glsx.accounts.base.car.types',
method: 'GET',
dataType: 'json',
success(result) {
console.log('请求结果:', result)
if (result.data && result.data.code === '0' && result.data.data && result.data.data.carinfos) {
model.districts = result.data.data.carinfos
this.loadingYearData = false
resolve(model.districts)
} else {
reject(new Error('Invalid car data format'))
} }
}, },
fail(error) { open() {
console.log(error, 'error') if (!this.defaultProvince) {
this.resetSelection()
}
this.$nextTick(() => {
if (this.$refs.cityPopup) {
this.$refs.cityPopup.open()
} }
})
}) })
}, },
resetSelection() {
open() { this.currentStep = 0
console.log('Opening car selector popup') this.currentSelectedId = null
this.$refs.carPopup.open() this.selectedProvince = null
this.loadCarData() this.selectedCity = null
this.selectionResult = null
}, },
onStepChange(index) { onStepChange(index) {
console.log(`Changing step from ${this.currentStep} to ${index}`) console.log(`Changing step from ${this.currentStep} to ${index}`)
// 限制只能前进到已选择的下一级
if (index === 0) { if (index === 0) {
this.currentStep = 0 this.currentStep = 0
} else if (index === 1 && this.selectedBrand) { this.currentSelectedId = this.selectedProvince?.code || null
} else if (index === 1 && this.selectedProvince) {
this.currentStep = 1 this.currentStep = 1
this.currentSelectedId = this.selectedCity?.code || null
} }
// 重置当前步骤的选中ID
this.currentSelectedId = null
}, },
// 处理项目点击事件
handleItemClick(item) { handleItemClick(item) {
console.log('Item clicked:', item) this.currentSelectedId = item.code
this.currentSelectedId = item.id || item.name
if (this.currentStep === 0) { if (this.currentStep === 0) {
this.selectedBrand = item this.selectedProvince = item
this.selectedSeries = null this.selectedCity = null
this.selectedModel = null
this.selectedYear = null
this.currentStep = 1 this.currentStep = 1
this.$emit('brand-selected', item) this.$emit('province-selected', item)
} else if (this.currentStep === 1) { } else if (this.currentStep === 1) {
this.selectedSeries = item this.selectedCity = item
this.selectedModel = null this.$emit('city-selected', item)
this.selectedYear = null
this.$emit('series-selected', item)
} }
this.selectionResult = { this.selectionResult = {
province: this.selectedBrand, province: this.selectedProvince,
city: this.selectedSeries city: this.selectedCity
} }
}, },
// 为数据项添加首字母
addLetterToItem(item) { addLetterToItem(item) {
if (!item || !item.name) { if (!item || !item.name) {
return { ...item, letter: '#' } return { ...item, letter: '#' }
} }
try { try {
const firstChar = item.name.charAt(0) const firstChar = item.name.charAt(0)
if (/[一-龥]/.test(firstChar)) {
if (/[\u4e00-\u9fa5]/.test(firstChar)) {
let pinyinResult let pinyinResult
try { try {
pinyinResult = pinyin(firstChar) pinyinResult = pinyin(firstChar)
} catch (e1) { } catch (e1) {
console.warn('pinyin without options failed:', e1) console.warn('pinyin without options failed:', e1)
try { try {
pinyinResult = pinyin(firstChar, { style: 0 }) pinyinResult = pinyin(firstChar, { style: 0 })
} catch (e2) { } catch (e2) {
console.warn('pinyin with simple options failed:', e2) console.warn('pinyin with simple options failed:', e2)
const simplePinyinMap = { const simplePinyinMap = {
安: 'A', 安: 'A',
北: 'B', 北: 'B',
重: 'C', 重: 'C',
重: 'C',
川: 'C', 川: 'C',
大: 'D', 大: 'D',
东: 'D', 东: 'D',
...@@ -241,14 +240,12 @@ export default { ...@@ -241,14 +240,12 @@ export default {
云: 'Y', 云: 'Y',
浙: 'Z' 浙: 'Z'
} }
return { return {
...item, ...item,
letter: simplePinyinMap[firstChar] || '#' letter: simplePinyinMap[firstChar] || '#'
} }
} }
} }
let letter = '#' let letter = '#'
if (pinyinResult && pinyinResult.length > 0) { if (pinyinResult && pinyinResult.length > 0) {
if (Array.isArray(pinyinResult[0])) { if (Array.isArray(pinyinResult[0])) {
...@@ -259,7 +256,6 @@ export default { ...@@ -259,7 +256,6 @@ export default {
letter = pinyinResult.charAt(0).toUpperCase() letter = pinyinResult.charAt(0).toUpperCase()
} }
} }
if (/^[A-Z]$/.test(letter)) { if (/^[A-Z]$/.test(letter)) {
return { ...item, letter } return { ...item, letter }
} else { } else {
...@@ -281,7 +277,6 @@ export default { ...@@ -281,7 +277,6 @@ export default {
return { ...item, letter: '#' } return { ...item, letter: '#' }
} }
}, },
handleConfirm() { handleConfirm() {
console.log(this.selectionResult) console.log(this.selectionResult)
this.$emit('city-selected', this.selectionResult) this.$emit('city-selected', this.selectionResult)
...@@ -290,7 +285,7 @@ export default { ...@@ -290,7 +285,7 @@ export default {
} }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
::v-deep .carPopup { ::v-deep .cityPopup {
.content { .content {
width: 100%; width: 100%;
height: toRpx(764); height: toRpx(764);
...@@ -300,7 +295,42 @@ export default { ...@@ -300,7 +295,42 @@ export default {
.list-component { .list-component {
width: 100%; width: 100%;
height: calc(100% - #{toRpx(100)}); height: calc(100% - #{toRpx(100)});
overflow-y: auto;
}
}
}
.content-container {
width: 100%;
height: 100%
}
.loading-container {
width: 100%;
height: toRpx(764);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-color: #fff;
}
.loading-spinner {
width: toRpx(60);
height: toRpx(60);
border: toRpx(6) solid #f3f3f3;
border-top: toRpx(6) solid #3498db;
border-radius: 50%;
animation: spin 1s linear infinite;
}
.loading-text {
margin-top: toRpx(20);
color: #666;
font-size: toRpx(28);
}
@keyframes spin {
0% {
transform: rotate(0deg);
} }
100% {
transform: rotate(360deg);
} }
} }
</style> </style>
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
<script> <script>
// import { uploadFile } from '@/utils/ossUploadFile/uploadFile.js' // import { uploadFile } from '@/utils/ossUploadFile/uploadFile.js'
import { uploadFile } from '@/utils/ossUpload.js' import { uploadFile } from '@/utils/ossUpload.js'
import permision from '@/js_sdk/wa-permission/permission.js'
export default { export default {
name: 'UploadMedia', name: 'UploadMedia',
...@@ -73,7 +74,22 @@ export default { ...@@ -73,7 +74,22 @@ export default {
}, },
methods: { methods: {
// 处理媒体上传 // 处理媒体上传
handleMediaUpload(field) { async handleMediaUpload(field) {
const photoLibrary = await permision.requestAndroidPermission('android.permission.READ_EXTERNAL_STORAGE')
const camera = await permision.requestAndroidPermission('android.permission.CAMERA')
const isOnline = await uni.$isNetWork()
if (photoLibrary != 1) {
uni.showToast({ title: '您的设备不支持相册功能或未授权访问,请前往设置中开启相册权限', icon: 'none' })
return
}
if (camera != 1) {
uni.showToast({ title: '您的设备不支持摄像头功能或未授权访问,请前往设置中开启摄像头权限', icon: 'none' })
return
}
if (!isOnline) {
uni.showToast({ title: '当前无网络连接,请连接网络后重试', icon: 'none' })
return
}
// 根据字段类型显示不同的操作菜单 // 根据字段类型显示不同的操作菜单
const itemList = [] const itemList = []
if (field.accept === 'image' || !field.accept) { if (field.accept === 'image' || !field.accept) {
......
...@@ -114,6 +114,7 @@ import OrderPopup from '@/components/OrderPopup/index.vue' ...@@ -114,6 +114,7 @@ import OrderPopup from '@/components/OrderPopup/index.vue'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import NoticePopup from '@/components/NoticePopup.vue' import NoticePopup from '@/components/NoticePopup.vue'
import { debounce } from 'lodash' import { debounce } from 'lodash'
import permision from '@/js_sdk/wa-permission/permission.js'
export default { export default {
components: { components: {
FormCell, FormCell,
...@@ -374,7 +375,22 @@ export default { ...@@ -374,7 +375,22 @@ export default {
}) })
} }
}, },
handleImageUpload(field) { async handleImageUpload(field) {
const photoLibrary = await permision.requestAndroidPermission('android.permission.READ_EXTERNAL_STORAGE')
const camera = await permision.requestAndroidPermission('android.permission.CAMERA')
const isOnline = await uni.$isNetWork()
if (photoLibrary != 1) {
uni.showToast({ title: '您的设备不支持相册功能或未授权访问,请前往设置中开启相册权限', icon: 'none' })
return
}
if (camera != 1) {
uni.showToast({ title: '您的设备不支持摄像头功能或未授权访问,请前往设置中开启摄像头权限', icon: 'none' })
return
}
if (!isOnline) {
uni.showToast({ title: '当前无网络连接,请连接网络后重试', icon: 'none' })
return
}
// 显示操作菜单,让用户选择拍照或从相册选择 // 显示操作菜单,让用户选择拍照或从相册选择
uni.showActionSheet({ uni.showActionSheet({
itemList: ['拍照', '从相册选择'], itemList: ['拍照', '从相册选择'],
......
...@@ -271,6 +271,7 @@ import dayjs from 'dayjs' ...@@ -271,6 +271,7 @@ import dayjs from 'dayjs'
import NoticePopup from '@/components/NoticePopup.vue' import NoticePopup from '@/components/NoticePopup.vue'
import { debounce } from 'lodash' import { debounce } from 'lodash'
import { max } from 'lodash' import { max } from 'lodash'
import permision from '@/js_sdk/wa-permission/permission.js'
export default { export default {
components: { components: {
FormCell, FormCell,
...@@ -823,7 +824,22 @@ export default { ...@@ -823,7 +824,22 @@ export default {
.join(', ') .join(', ')
console.log('selectedItemsText', this.selectedItemsText) console.log('selectedItemsText', this.selectedItemsText)
}, },
handleImageUpload(field) { async handleImageUpload(field) {
const photoLibrary = await permision.requestAndroidPermission('android.permission.READ_EXTERNAL_STORAGE')
const camera = await permision.requestAndroidPermission('android.permission.CAMERA')
const isOnline = await uni.$isNetWork()
if (photoLibrary != 1) {
uni.showToast({ title: '您的设备不支持相册功能或未授权访问,请前往设置中开启相册权限', icon: 'none' })
return
}
if (camera != 1) {
uni.showToast({ title: '您的设备不支持摄像头功能或未授权访问,请前往设置中开启摄像头权限', icon: 'none' })
return
}
if (!isOnline) {
uni.showToast({ title: '当前无网络连接,请连接网络后重试', icon: 'none' })
return
}
uni.showActionSheet({ uni.showActionSheet({
itemList: ['拍照', '从相册选择'], itemList: ['拍照', '从相册选择'],
success: res => { success: res => {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!