|
|
@@ -29,6 +29,10 @@ Component({
|
|
|
type: Boolean,
|
|
|
value: false
|
|
|
},
|
|
|
+ isCroppingFlag: { //是否开启裁剪功能
|
|
|
+ type: Boolean,
|
|
|
+ value: false
|
|
|
+ },
|
|
|
uploaderMAX: {
|
|
|
type: Number,
|
|
|
value: 5
|
|
|
@@ -88,7 +92,7 @@ Component({
|
|
|
checked: false
|
|
|
},
|
|
|
lifetimes: {
|
|
|
- attached: function () { },
|
|
|
+ attached: function () {},
|
|
|
detached: function () {
|
|
|
// 在组件实例被从页面节点树移除时执行
|
|
|
// 清空地址信息
|
|
|
@@ -174,7 +178,7 @@ Component({
|
|
|
// 检查它是否真的是一个数组
|
|
|
if (Array.isArray(array)) {
|
|
|
array.forEach(item => {
|
|
|
- if (item.tip&&this.selectComponent('#' + item.code)) {
|
|
|
+ if (item.tip && this.selectComponent('#' + item.code)) {
|
|
|
this.selectComponent('#' + item.code).setShowTipFlag(false)
|
|
|
}
|
|
|
});
|
|
|
@@ -798,20 +802,20 @@ Component({
|
|
|
} else {
|
|
|
bol = true
|
|
|
}
|
|
|
- if(bol){
|
|
|
- // 如果配置中用户未订阅消息 则弹窗
|
|
|
- wx.requestSubscribeMessage({
|
|
|
- tmplIds: tmplIds,
|
|
|
- success(res) {
|
|
|
- that.openDatePopTime(e)
|
|
|
- },
|
|
|
- fail(res) {
|
|
|
- that.openDatePopTime(e)
|
|
|
- }
|
|
|
- })
|
|
|
- } else {
|
|
|
- that.openDatePopTime(e)
|
|
|
- }
|
|
|
+ if (bol) {
|
|
|
+ // 如果配置中用户未订阅消息 则弹窗
|
|
|
+ wx.requestSubscribeMessage({
|
|
|
+ tmplIds: tmplIds,
|
|
|
+ success(res) {
|
|
|
+ that.openDatePopTime(e)
|
|
|
+ },
|
|
|
+ fail(res) {
|
|
|
+ that.openDatePopTime(e)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ that.openDatePopTime(e)
|
|
|
+ }
|
|
|
},
|
|
|
fail(res) {
|
|
|
that.openDatePopTime(e)
|
|
|
@@ -924,49 +928,107 @@ Component({
|
|
|
* @date : 2024/3/27 16:16
|
|
|
*/
|
|
|
afterRead(e) {
|
|
|
- // this.setData({
|
|
|
- // uploadFileFlag:true
|
|
|
- // })
|
|
|
const _this = this;
|
|
|
- const {
|
|
|
- file
|
|
|
- } = e.detail;
|
|
|
- // 配置存放的文件夹 公司code - 表名 - 年月 -- 日
|
|
|
- let folder = app.globalData.company.cpCode + '/' + this.data.table + '/' + new Date().toYearMonth2() + '/' + new Date().toDay()
|
|
|
- let url = config.upload_url;
|
|
|
- url = url.replace('mdm-server', 'mdm-server' + '-' + app.globalData.company.svcCode.replace('_', '-'))
|
|
|
- file.forEach((res, index) => {
|
|
|
- // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
|
|
|
- wx.uploadFile({
|
|
|
- url: url,
|
|
|
- filePath: res.path,
|
|
|
- name: 'file',
|
|
|
- formData: {
|
|
|
- 'folder': folder
|
|
|
- },
|
|
|
- header: {
|
|
|
- 'Authorization': 'Bearer ' + app.globalData.token
|
|
|
- },
|
|
|
- success(res) {
|
|
|
- let data = JSON.parse(res.data)
|
|
|
- if (data.code === 200) {
|
|
|
- let form = _this.data.form
|
|
|
- let annexPaths = form['annexPaths'] || []
|
|
|
- data.data.url = config.image_url + data.data.path
|
|
|
- annexPaths.push(data.data)
|
|
|
- form.annexPaths = annexPaths;
|
|
|
- _this.setData({
|
|
|
- form: form,
|
|
|
- value: JSON.stringify(form)
|
|
|
+ if (this.data.isCroppingFlag) { //开启裁剪功能
|
|
|
+ // 获取裁剪图片资源后,给data添加src属性及其值
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '/package-base-select/pages/cropper/cropper',
|
|
|
+ events: {
|
|
|
+ // 回调后
|
|
|
+ bindData: function (data) {
|
|
|
+ console.log('bindData',data);
|
|
|
+ const {
|
|
|
+ file
|
|
|
+ } = {file:[{path:data}]};
|
|
|
+ // 配置存放的文件夹 公司code - 表名 - 年月 -- 日
|
|
|
+ let folder = app.globalData.company.cpCode + '/' + _this.data.table + '/' + new Date().toYearMonth2() + '/' + new Date().toDay()
|
|
|
+ let url = config.upload_url;
|
|
|
+ url = url.replace('mdm-server', 'mdm-server' + '-' + app.globalData.company.svcCode.replace('_', '-'))
|
|
|
+ file.forEach((res, index) => {
|
|
|
+ // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
|
|
|
+ wx.uploadFile({
|
|
|
+ url: url,
|
|
|
+ filePath: res.path,
|
|
|
+ name: 'file',
|
|
|
+ formData: {
|
|
|
+ 'folder': folder
|
|
|
+ },
|
|
|
+ header: {
|
|
|
+ 'Authorization': 'Bearer ' + app.globalData.token
|
|
|
+ },
|
|
|
+ success(res) {
|
|
|
+ let data = JSON.parse(res.data)
|
|
|
+ if (data.code === 200) {
|
|
|
+ let form = _this.data.form
|
|
|
+ let annexPaths = form['annexPaths'] || []
|
|
|
+ data.data.url = config.image_url + data.data.path
|
|
|
+ annexPaths.push(data.data)
|
|
|
+ form.annexPaths = annexPaths;
|
|
|
+ _this.setData({
|
|
|
+ form: form,
|
|
|
+ value: JSON.stringify(form)
|
|
|
+ })
|
|
|
+ // 如果是最后一条
|
|
|
+ if (index == file.length - 1) {
|
|
|
+ _this.triggerEvent("uploadSucess", {})
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ })
|
|
|
})
|
|
|
- // 如果是最后一条
|
|
|
- if (index == file.length - 1) {
|
|
|
- _this.triggerEvent("uploadSucess", {})
|
|
|
- }
|
|
|
}
|
|
|
},
|
|
|
+ success: function (res) {
|
|
|
+ // 通过eventChannel向被打开页面传送数据
|
|
|
+ res.eventChannel.emit('params', {
|
|
|
+ src: e.detail.file[0].path,
|
|
|
+ })
|
|
|
+ }
|
|
|
})
|
|
|
- })
|
|
|
+ } else {
|
|
|
+ const {
|
|
|
+ file
|
|
|
+ } = e.detail;
|
|
|
+ // 配置存放的文件夹 公司code - 表名 - 年月 -- 日
|
|
|
+ let folder = app.globalData.company.cpCode + '/' + this.data.table + '/' + new Date().toYearMonth2() + '/' + new Date().toDay()
|
|
|
+ let url = config.upload_url;
|
|
|
+ url = url.replace('mdm-server', 'mdm-server' + '-' + app.globalData.company.svcCode.replace('_', '-'))
|
|
|
+ file.forEach((res, index) => {
|
|
|
+ // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
|
|
|
+ wx.uploadFile({
|
|
|
+ url: url,
|
|
|
+ filePath: res.path,
|
|
|
+ name: 'file',
|
|
|
+ formData: {
|
|
|
+ 'folder': folder
|
|
|
+ },
|
|
|
+ header: {
|
|
|
+ 'Authorization': 'Bearer ' + app.globalData.token
|
|
|
+ },
|
|
|
+ success(res) {
|
|
|
+ let data = JSON.parse(res.data)
|
|
|
+ if (data.code === 200) {
|
|
|
+ let form = _this.data.form
|
|
|
+ let annexPaths = form['annexPaths'] || []
|
|
|
+ data.data.url = config.image_url + data.data.path
|
|
|
+ annexPaths.push(data.data)
|
|
|
+ form.annexPaths = annexPaths;
|
|
|
+ _this.setData({
|
|
|
+ form: form,
|
|
|
+ value: JSON.stringify(form)
|
|
|
+ })
|
|
|
+ // 如果是最后一条
|
|
|
+ if (index == file.length - 1) {
|
|
|
+ _this.triggerEvent("uploadSucess", {})
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
},
|
|
|
/**
|
|
|
* @desc : 获取语言的方法
|