1. 优化了一些交互,中药药品编辑交互
2. dev和生产环境统一鉴别
This commit is contained in:
@@ -49,6 +49,7 @@
|
||||
logout,
|
||||
toUpload,
|
||||
} from '@/api/all.js'
|
||||
import { chooseAvatarImage } from '@/common/js/select-avatar-image.js';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@@ -85,56 +86,24 @@
|
||||
}
|
||||
},
|
||||
selectAct() {
|
||||
uni.chooseImage({
|
||||
count: 1, //默认9
|
||||
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
|
||||
sourceType: ['album', 'camera'],
|
||||
success: (res) => {
|
||||
uni.showLoading({
|
||||
title: '请稍后...'
|
||||
})
|
||||
const tempFiles = res.tempFiles;
|
||||
let resSize = tempFiles[0].size;
|
||||
// 1M=1024KB=1048576B
|
||||
console.log(resSize)
|
||||
if (resSize > 1048576) {
|
||||
uni.showToast({
|
||||
title: "上传图片大小不能超过1MB",
|
||||
icon: 'error'
|
||||
chooseAvatarImage({
|
||||
formData: {
|
||||
store_id: uni.getStorageSync('store_id') || '11001',
|
||||
},
|
||||
onSuccess: (res) => {
|
||||
const req = this.$u.test.jsonString(res.data) ? JSON.parse(res.data) : res.data;
|
||||
if (req.errcode == 0) {
|
||||
toUpload({
|
||||
store_id: uni.getStorageSync('store_id') || '11001',
|
||||
avatar: req.data.url,
|
||||
}).then(() => {
|
||||
this.getDoctor();
|
||||
this.$toast('编辑成功');
|
||||
});
|
||||
return
|
||||
} else {
|
||||
this.$toast(res.msg);
|
||||
}
|
||||
uni.uploadFile({
|
||||
url: 'https://api.xiaokang88.com/open-api/upload/old-admin-img',
|
||||
filePath: res.tempFiles[0]['path'],
|
||||
name: 'file',
|
||||
header: {
|
||||
authorization: `Bearer ${uni.getStorageSync('token')}`
|
||||
},
|
||||
formData: {
|
||||
store_id: uni.getStorageSync('store_id') || '11001'
|
||||
},
|
||||
success: res => {
|
||||
let req = this.$u.test.jsonString(res.data) ? JSON.parse(res
|
||||
.data) : res.data
|
||||
// console.log(req, 'req')
|
||||
if (req.errcode == 0) {
|
||||
toUpload({
|
||||
store_id: uni.getStorageSync('store_id') ||
|
||||
'11001',
|
||||
avatar: req.data.url
|
||||
}).then((res) => {
|
||||
this.getDoctor()
|
||||
this.$toast('编辑成功');
|
||||
|
||||
})
|
||||
uni.hideLoading()
|
||||
} else {
|
||||
this.$toast(res.msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
logout() {
|
||||
|
||||
Reference in New Issue
Block a user