xiaoxin 3 лет назад
Родитель
Сommit
663818f726
33 измененных файлов с 1838 добавлено и 78 удалено
  1. 103 2
      pages/index/index.vue
  2. 1 1
      unpackage/dist/dev/mp-weixin/app.js
  3. 10 2
      unpackage/dist/dev/mp-weixin/common/vendor.js
  4. 1 1
      unpackage/dist/dev/mp-weixin/pages/authorization/authorization.js
  5. 82 6
      unpackage/dist/dev/mp-weixin/pages/index/index.js
  6. 2 1
      unpackage/dist/dev/mp-weixin/pages/index/index.json
  7. 1 1
      unpackage/dist/dev/mp-weixin/pages/index/index.wxml
  8. 40 40
      unpackage/dist/dev/mp-weixin/project.config.json
  9. 16 16
      unpackage/dist/dev/mp-weixin/project.private.config.json
  10. 1 1
      unpackage/dist/dev/mp-weixin/uni_modules/uni-data-checkbox/components/uni-data-checkbox/uni-data-checkbox.js
  11. 1 1
      unpackage/dist/dev/mp-weixin/uni_modules/uni-data-checkbox/components/uni-data-checkbox/uni-data-checkbox.wxml
  12. 1 1
      unpackage/dist/dev/mp-weixin/uni_modules/uni-data-select/components/uni-data-select/uni-data-select.js
  13. 1 1
      unpackage/dist/dev/mp-weixin/uni_modules/uni-data-select/components/uni-data-select/uni-data-select.wxml
  14. 1 1
      unpackage/dist/dev/mp-weixin/uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.js
  15. 1 1
      unpackage/dist/dev/mp-weixin/uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.wxml
  16. 200 0
      unpackage/dist/dev/mp-weixin/uni_modules/uni-file-picker/components/uni-file-picker/choose-and-upload-file.js
  17. 520 0
      unpackage/dist/dev/mp-weixin/uni_modules/uni-file-picker/components/uni-file-picker/uni-file-picker.js
  18. 7 0
      unpackage/dist/dev/mp-weixin/uni_modules/uni-file-picker/components/uni-file-picker/uni-file-picker.json
  19. 1 0
      unpackage/dist/dev/mp-weixin/uni_modules/uni-file-picker/components/uni-file-picker/uni-file-picker.wxml
  20. 42 0
      unpackage/dist/dev/mp-weixin/uni_modules/uni-file-picker/components/uni-file-picker/uni-file-picker.wxss
  21. 172 0
      unpackage/dist/dev/mp-weixin/uni_modules/uni-file-picker/components/uni-file-picker/upload-file.js
  22. 4 0
      unpackage/dist/dev/mp-weixin/uni_modules/uni-file-picker/components/uni-file-picker/upload-file.json
  23. 1 0
      unpackage/dist/dev/mp-weixin/uni_modules/uni-file-picker/components/uni-file-picker/upload-file.wxml
  24. 98 0
      unpackage/dist/dev/mp-weixin/uni_modules/uni-file-picker/components/uni-file-picker/upload-file.wxss
  25. 182 0
      unpackage/dist/dev/mp-weixin/uni_modules/uni-file-picker/components/uni-file-picker/upload-image.js
  26. 4 0
      unpackage/dist/dev/mp-weixin/uni_modules/uni-file-picker/components/uni-file-picker/upload-image.json
  27. 1 0
      unpackage/dist/dev/mp-weixin/uni_modules/uni-file-picker/components/uni-file-picker/upload-image.wxml
  28. 89 0
      unpackage/dist/dev/mp-weixin/uni_modules/uni-file-picker/components/uni-file-picker/upload-image.wxss
  29. 90 0
      unpackage/dist/dev/mp-weixin/uni_modules/uni-file-picker/components/uni-file-picker/utils.js
  30. 1 1
      unpackage/dist/dev/mp-weixin/uni_modules/uni-icons/components/uni-icons/uni-icons.js
  31. 1 1
      unpackage/dist/dev/mp-weixin/uni_modules/uni-load-more/components/uni-load-more/uni-load-more.js
  32. 66 0
      unpackage/dist/dev/mp-weixin/util/imageCompress.js
  33. 97 0
      util/imageCompress.js

+ 103 - 2
pages/index/index.vue

@@ -39,7 +39,8 @@
 
 			<view class="form_item">
 				<span class="icon">*</span>预计投标时间
-				<picker mode="date" fields="month" :start="getCurrentDate()" :value="biddingTime" @change="bindDateChange">
+				<picker mode="date" fields="month" :start="getCurrentDate()" :value="biddingTime"
+					@change="bindDateChange">
 					<uni-easyinput disabled placeholder="请选择预计投标时间" suffixIcon="calendar-filled" v-model="biddingTime">
 					</uni-easyinput>
 				</picker>
@@ -62,6 +63,14 @@
 				</uni-easyinput>
 			</view>
 
+			<view class="form_item">
+				附件材料(建议上传项目相关信息或清单图片)
+				<uni-file-picker ref="filePicker" limit="3" title="最多上传3张图片" :value="projectImgList"
+					fileMediatype="image" :image-styles="imageStyles" mode="grid" @select="select"
+					@delete="handleDelete">
+				</uni-file-picker>
+			</view>
+
 			<button class="form_button" @click="handleSubmit">提交</button>
 
 			<view class="footer">
@@ -70,6 +79,14 @@
 		</view>
 
 	</view>
+
+	<!-- 用于图片压缩的canvas画布 -->
+	<canvas :style="{
+	            width:cw+'px',
+	            height:cw+'px',
+	            position:'absolute', zIndex: -1, left: '-10000rpx' , top: '-10000rpx'}" canvas-id="zipCanvas">
+	</canvas>
+	<!--画布结束-->
 </template>
 
 <script setup>
@@ -79,7 +96,11 @@
 	} from 'vue'
 	import {
 		myRequest
-	} from "../../util/api.js"
+	} from "@/util/api.js"
+	// 图片压缩方法
+	import
+	getLessLimitSizeImage
+	from "@/util/imageCompress.js"
 
 	onMounted(() => {
 		const accredit = uni.getStorageSync('accredit')
@@ -87,6 +108,8 @@
 			submit()
 		}
 	})
+	//画板边长默认是屏幕宽度,正方形画布
+	const cw = uni.getSystemInfoSync().windowWidth
 	// 用户姓名绑定数据
 	const name = ref(uni.getStorageSync('form_name') || '')
 	// 用户手机号绑定数据
@@ -113,6 +136,16 @@
 	// 项目基本情况
 	const projectInformation = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content'))
 		.projectInformation : '')
+
+	// 显示的图片数据
+	const projectImgList = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content'))
+		.projectImgList : [])
+
+	// 上传的图片数据
+	const subImgList = ref(uni.getStorageSync('form_content') ? JSON.parse(uni.getStorageSync('form_content'))
+
+		.subImgList : [])
+
 	// 微信手机号码绑定数据
 	const wxPhone = ref(uni.getStorageSync('wxPhone') || '')
 
@@ -175,6 +208,20 @@
 		}]
 	)
 
+	// 图片上传框的样式
+	const imageStyles = {
+		width: 75,
+		height: 75,
+		border: {
+			color: "#ccc",
+			width: 1,
+			style: 'dashed',
+			radius: '5px'
+		}
+	}
+	// 上传组件元素
+	const filePicker = ref(null)
+
 	// 日期选择框绑定回调
 	const bindDateChange = (e) => {
 		const val = e.detail.value
@@ -196,6 +243,8 @@
 				industry: industry.value,
 				productType: productType.value,
 				projectInformation: projectInformation.value,
+				projectImgList: projectImgList.value,
+				subImgList: subImgList.value
 			}
 			uni.setStorageSync('form_content', JSON.stringify(formContent));
 			if (!wxPhone.value) {
@@ -339,6 +388,7 @@
 				trade: range.value[industry.value].text,
 				bProduct,
 				wxPhone: wxPhone.value,
+				bFile: subImgList.value
 			}
 		})
 		// console.log(res)
@@ -354,6 +404,9 @@
 			industry.value = ''
 			productType.value = []
 			projectInformation.value = ''
+			subImgList.value = []
+			projectImgList.value = []
+			filePicker.value.clearFiles()
 
 			uni.removeStorageSync('form_content')
 			uni.setStorageSync('accredit', false)
@@ -375,6 +428,54 @@
 		day = day > 9 ? day : '0' + day;
 		return `${year}-${month}-${day}`;
 	}
+
+	// 选择图片回调
+	const select = (e) => {
+		// console.log(e);
+		e.tempFiles.forEach((item) => {
+			//这里的id和页面中写的html代码的canvas的id要一致
+			let canvasId = 'zipCanvas'
+			//原图的路径
+			let imagePath = item.path;
+			//大小限制1024kb
+			let limitSize = 1024;
+			//初始绘画区域是画布自身的宽度也就是屏幕宽度
+			let drawWidth = uni.getSystemInfoSync().windowWidth;
+
+			getLessLimitSizeImage(canvasId, imagePath, limitSize, drawWidth, (resPath) => {
+				uni.showLoading({
+					title: '上传中'
+				});
+				uni.uploadFile({
+					url: `https://chtech.ncjti.edu.cn/gradiate-school/reporting/file/fileUpDown`,
+					filePath: resPath,
+					name: 'file',
+					success: (uploadFileRes) => {
+						subImgList.value.push((JSON.parse(uploadFileRes.data).data).join())
+						projectImgList.value.push({
+							url: item.path,
+							name: ""
+						})
+						uni.hideLoading();
+					},
+					fail: () => {
+						uni.showToast({
+							title: '上传失败',
+							icon: 'error'
+						})
+					}
+				});
+			})
+		})
+	}
+
+	// 删除图片回调
+	const handleDelete = (e) => {
+		// console.log(e);
+		const num = projectImgList.value.findIndex(v => v.url === e.tempFilePath);
+		subImgList.value.splice(num, 1);
+		projectImgList.value.splice(num, 1);
+	}
 </script>
 
 <style lang="scss" scoped>

+ 1 - 1
unpackage/dist/dev/mp-weixin/app.js

@@ -13,7 +13,7 @@ const _sfc_main = {
   onHide: function() {
   }
 };
-const App = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "G:/workSpace/agent-registration/App.vue"]]);
+const App = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "E:/workSpace/agent-registration/App.vue"]]);
 function createApp() {
   const app = common_vendor.createSSRApp(App);
   return {

+ 10 - 2
unpackage/dist/dev/mp-weixin/common/vendor.js

@@ -1502,8 +1502,8 @@ function populateParameters(fromRes, toRes) {
     appVersion: "1.0.0",
     appVersionCode: "100",
     appLanguage: getAppLanguage(hostLanguage),
-    uniCompileVersion: "3.7.8",
-    uniRuntimeVersion: "3.7.8",
+    uniCompileVersion: "3.7.9",
+    uniRuntimeVersion: "3.7.9",
     uniPlatform: "mp-weixin",
     deviceBrand,
     deviceModel: model,
@@ -6233,6 +6233,10 @@ function stringify(styles) {
   }
   return ret;
 }
+function setRef(ref2, id, opts = {}) {
+  const { $templateRefs } = getCurrentInstance();
+  $templateRefs.push({ i: id, r: ref2, k: opts.k, f: opts.f });
+}
 const o$1 = (value, key) => vOn(value, key);
 const f$1 = (source, renderItem) => vFor(source, renderItem);
 const s$1 = (value) => stringifyStyle(value);
@@ -6240,6 +6244,7 @@ const e = (target, ...sources) => extend(target, ...sources);
 const n$1 = (value) => normalizeClass(value);
 const t$1 = (val) => toDisplayString(val);
 const p$1 = (props) => renderProps(props);
+const sr = (ref2, id, opts) => setRef(ref2, id, opts);
 function createApp$1(rootComponent, rootProps = null) {
   rootComponent && (rootComponent.mpType = "app");
   return createVueApp(rootComponent, rootProps).use(plugin);
@@ -9495,4 +9500,7 @@ exports.p = p$1;
 exports.ref = ref;
 exports.resolveComponent = resolveComponent;
 exports.s = s$1;
+exports.sr = sr;
 exports.t = t$1;
+exports.unref = unref;
+exports.wx$1 = wx$1;

+ 1 - 1
unpackage/dist/dev/mp-weixin/pages/authorization/authorization.js

@@ -35,5 +35,5 @@ const _sfc_main = {
     };
   }
 };
-const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-2e3c7ef5"], ["__file", "G:/workSpace/agent-registration/pages/authorization/authorization.vue"]]);
+const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-2e3c7ef5"], ["__file", "E:/workSpace/agent-registration/pages/authorization/authorization.vue"]]);
 wx.createPage(MiniProgramPage);

+ 82 - 6
unpackage/dist/dev/mp-weixin/pages/index/index.js

@@ -1,17 +1,20 @@
 "use strict";
 const common_vendor = require("../../common/vendor.js");
 const util_api = require("../../util/api.js");
+const util_imageCompress = require("../../util/imageCompress.js");
 if (!Array) {
   const _easycom_uni_easyinput2 = common_vendor.resolveComponent("uni-easyinput");
   const _easycom_uni_data_select2 = common_vendor.resolveComponent("uni-data-select");
   const _easycom_uni_data_checkbox2 = common_vendor.resolveComponent("uni-data-checkbox");
-  (_easycom_uni_easyinput2 + _easycom_uni_data_select2 + _easycom_uni_data_checkbox2)();
+  const _easycom_uni_file_picker2 = common_vendor.resolveComponent("uni-file-picker");
+  (_easycom_uni_easyinput2 + _easycom_uni_data_select2 + _easycom_uni_data_checkbox2 + _easycom_uni_file_picker2)();
 }
 const _easycom_uni_easyinput = () => "../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.js";
 const _easycom_uni_data_select = () => "../../uni_modules/uni-data-select/components/uni-data-select/uni-data-select.js";
 const _easycom_uni_data_checkbox = () => "../../uni_modules/uni-data-checkbox/components/uni-data-checkbox/uni-data-checkbox.js";
+const _easycom_uni_file_picker = () => "../../uni_modules/uni-file-picker/components/uni-file-picker/uni-file-picker.js";
 if (!Math) {
-  (_easycom_uni_easyinput + _easycom_uni_data_select + _easycom_uni_data_checkbox)();
+  (_easycom_uni_easyinput + _easycom_uni_data_select + _easycom_uni_data_checkbox + _easycom_uni_file_picker)();
 }
 const _sfc_main = {
   __name: "index",
@@ -22,6 +25,7 @@ const _sfc_main = {
         submit();
       }
     });
+    const cw = common_vendor.index.getSystemInfoSync().windowWidth;
     const name = common_vendor.ref(common_vendor.index.getStorageSync("form_name") || "");
     const phone = common_vendor.ref(common_vendor.index.getStorageSync("form_phone") || "");
     const company = common_vendor.ref(common_vendor.index.getStorageSync("form_company") || "");
@@ -32,6 +36,8 @@ const _sfc_main = {
     const industry = common_vendor.ref(common_vendor.index.getStorageSync("form_content") ? JSON.parse(common_vendor.index.getStorageSync("form_content")).industry : "");
     const productType = common_vendor.ref(common_vendor.index.getStorageSync("form_content") ? JSON.parse(common_vendor.index.getStorageSync("form_content")).productType : []);
     const projectInformation = common_vendor.ref(common_vendor.index.getStorageSync("form_content") ? JSON.parse(common_vendor.index.getStorageSync("form_content")).projectInformation : "");
+    const projectImgList = common_vendor.ref(common_vendor.index.getStorageSync("form_content") ? JSON.parse(common_vendor.index.getStorageSync("form_content")).projectImgList : []);
+    const subImgList = common_vendor.ref(common_vendor.index.getStorageSync("form_content") ? JSON.parse(common_vendor.index.getStorageSync("form_content")).subImgList : []);
     const wxPhone = common_vendor.ref(common_vendor.index.getStorageSync("wxPhone") || "");
     const range = common_vendor.ref(
       [
@@ -90,6 +96,17 @@ const _sfc_main = {
         value: 5
       }]
     );
+    const imageStyles = {
+      width: 75,
+      height: 75,
+      border: {
+        color: "#ccc",
+        width: 1,
+        style: "dashed",
+        radius: "5px"
+      }
+    };
+    const filePicker = common_vendor.ref(null);
     const bindDateChange = (e) => {
       const val = e.detail.value;
       biddingTime.value = val;
@@ -107,7 +124,9 @@ const _sfc_main = {
           biddingTime: biddingTime.value,
           industry: industry.value,
           productType: productType.value,
-          projectInformation: projectInformation.value
+          projectInformation: projectInformation.value,
+          projectImgList: projectImgList.value,
+          subImgList: subImgList.value
         };
         common_vendor.index.setStorageSync("form_content", JSON.stringify(formContent));
         if (!wxPhone.value) {
@@ -246,7 +265,8 @@ const _sfc_main = {
           content: projectInformation.value,
           trade: range.value[industry.value].text,
           bProduct,
-          wxPhone: wxPhone.value
+          wxPhone: wxPhone.value,
+          bFile: subImgList.value
         }
       });
       if (res.success && res.code == 1) {
@@ -261,6 +281,9 @@ const _sfc_main = {
         industry.value = "";
         productType.value = [];
         projectInformation.value = "";
+        subImgList.value = [];
+        projectImgList.value = [];
+        filePicker.value.clearFiles();
         common_vendor.index.removeStorageSync("form_content");
         common_vendor.index.setStorageSync("accredit", false);
       } else {
@@ -279,6 +302,43 @@ const _sfc_main = {
       day = day > 9 ? day : "0" + day;
       return `${year}-${month}-${day}`;
     };
+    const select = (e) => {
+      e.tempFiles.forEach((item) => {
+        let canvasId = "zipCanvas";
+        let imagePath = item.path;
+        let limitSize = 1024;
+        let drawWidth = common_vendor.index.getSystemInfoSync().windowWidth;
+        util_imageCompress.getLessLimitSizeImage(canvasId, imagePath, limitSize, drawWidth, (resPath) => {
+          common_vendor.index.showLoading({
+            title: "上传中"
+          });
+          common_vendor.index.uploadFile({
+            url: `https://chtech.ncjti.edu.cn/gradiate-school/reporting/file/fileUpDown`,
+            filePath: resPath,
+            name: "file",
+            success: (uploadFileRes) => {
+              subImgList.value.push(JSON.parse(uploadFileRes.data).data.join());
+              projectImgList.value.push({
+                url: item.path,
+                name: ""
+              });
+              common_vendor.index.hideLoading();
+            },
+            fail: () => {
+              common_vendor.index.showToast({
+                title: "上传失败",
+                icon: "error"
+              });
+            }
+          });
+        });
+      });
+    };
+    const handleDelete = (e) => {
+      const num = projectImgList.value.findIndex((v) => v.url === e.tempFilePath);
+      subImgList.value.splice(num, 1);
+      projectImgList.value.splice(num, 1);
+    };
     return (_ctx, _cache) => {
       return {
         a: common_vendor.o(($event) => name.value = $event),
@@ -342,10 +402,26 @@ const _sfc_main = {
           placeholder: "建议填写竞争情况 , 客户情况",
           modelValue: projectInformation.value
         }),
-        y: common_vendor.o(handleSubmit)
+        y: common_vendor.sr(filePicker, "1cf27b2a-10", {
+          "k": "filePicker"
+        }),
+        z: common_vendor.o(select),
+        A: common_vendor.o(handleDelete),
+        B: common_vendor.p({
+          limit: "3",
+          title: "最多上传3张图片",
+          value: projectImgList.value,
+          fileMediatype: "image",
+          ["image-styles"]: imageStyles,
+          mode: "grid"
+        }),
+        C: common_vendor.o(handleSubmit),
+        D: common_vendor.unref(cw) + "px",
+        E: common_vendor.unref(cw) + "px",
+        F: -1
       };
     };
   }
 };
-const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-1cf27b2a"], ["__file", "G:/workSpace/agent-registration/pages/index/index.vue"]]);
+const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-1cf27b2a"], ["__file", "E:/workSpace/agent-registration/pages/index/index.vue"]]);
 wx.createPage(MiniProgramPage);

+ 2 - 1
unpackage/dist/dev/mp-weixin/pages/index/index.json

@@ -3,6 +3,7 @@
   "usingComponents": {
     "uni-easyinput": "../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput",
     "uni-data-select": "../../uni_modules/uni-data-select/components/uni-data-select/uni-data-select",
-    "uni-data-checkbox": "../../uni_modules/uni-data-checkbox/components/uni-data-checkbox/uni-data-checkbox"
+    "uni-data-checkbox": "../../uni_modules/uni-data-checkbox/components/uni-data-checkbox/uni-data-checkbox",
+    "uni-file-picker": "../../uni_modules/uni-file-picker/components/uni-file-picker/uni-file-picker"
   }
 }

Разница между файлами не показана из-за своего большого размера
+ 1 - 1
unpackage/dist/dev/mp-weixin/pages/index/index.wxml


+ 40 - 40
unpackage/dist/dev/mp-weixin/project.config.json

@@ -1,46 +1,46 @@
 {
-    "description": "项目配置文件。",
-    "packOptions": {
-        "ignore": [],
-        "include": []
+  "description": "项目配置文件。",
+  "packOptions": {
+    "ignore": [],
+    "include": []
+  },
+  "setting": {
+    "urlCheck": false,
+    "es6": true,
+    "postcss": false,
+    "minified": false,
+    "newFeature": true,
+    "bigPackageSizeSupport": true,
+    "babelSetting": {
+      "ignore": [],
+      "disablePlugins": [],
+      "outputPath": ""
+    }
+  },
+  "compileType": "miniprogram",
+  "libVersion": "2.31.0",
+  "appid": "wx2fc3f45732fae5d3",
+  "projectname": "agent-registration",
+  "condition": {
+    "search": {
+      "current": -1,
+      "list": []
     },
-    "setting": {
-        "urlCheck": false,
-        "es6": true,
-        "postcss": false,
-        "minified": false,
-        "newFeature": true,
-        "bigPackageSizeSupport": true,
-        "babelSetting": {
-            "ignore": [],
-            "disablePlugins": [],
-            "outputPath": ""
-        }
+    "conversation": {
+      "current": -1,
+      "list": []
     },
-    "compileType": "miniprogram",
-    "libVersion": "2.30.2",
-    "appid": "wx2fc3f45732fae5d3",
-    "projectname": "agent-registration",
-    "condition": {
-        "search": {
-            "current": -1,
-            "list": []
-        },
-        "conversation": {
-            "current": -1,
-            "list": []
-        },
-        "game": {
-            "current": -1,
-            "list": []
-        },
-        "miniprogram": {
-            "current": -1,
-            "list": []
-        }
+    "game": {
+      "current": -1,
+      "list": []
     },
-    "editorSetting": {
-        "tabIndent": "insertSpaces",
-        "tabSize": 4
+    "miniprogram": {
+      "current": -1,
+      "list": []
     }
+  },
+  "editorSetting": {
+    "tabIndent": "insertSpaces",
+    "tabSize": 2
+  }
 }

+ 16 - 16
unpackage/dist/dev/mp-weixin/project.private.config.json

@@ -1,20 +1,20 @@
 {
-    "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
-    "projectname": "agent-registration",
-    "setting": {
-        "compileHotReLoad": true
-    },
-    "condition": {
-        "miniprogram": {
-            "list": [
-                {
-                    "name": "",
-                    "pathName": "pages/authorization/authorization",
-                    "query": "",
-                    "launchMode": "default",
-                    "scene": null
-                }
-            ]
+  "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
+  "projectname": "agent-registration",
+  "setting": {
+    "compileHotReLoad": true
+  },
+  "condition": {
+    "miniprogram": {
+      "list": [
+        {
+          "name": "",
+          "pathName": "pages/authorization/authorization",
+          "query": "",
+          "launchMode": "default",
+          "scene": null
         }
+      ]
     }
+  }
 }

+ 1 - 1
unpackage/dist/dev/mp-weixin/uni_modules/uni-data-checkbox/components/uni-data-checkbox/uni-data-checkbox.js

@@ -427,5 +427,5 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
     v: $data.isTop + "px"
   });
 }
-const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "G:/workSpace/agent-registration/uni_modules/uni-data-checkbox/components/uni-data-checkbox/uni-data-checkbox.vue"]]);
+const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "E:/workSpace/agent-registration/uni_modules/uni-data-checkbox/components/uni-data-checkbox/uni-data-checkbox.vue"]]);
 wx.createComponent(Component);

Разница между файлами не показана из-за своего большого размера
+ 1 - 1
unpackage/dist/dev/mp-weixin/uni_modules/uni-data-checkbox/components/uni-data-checkbox/uni-data-checkbox.wxml


+ 1 - 1
unpackage/dist/dev/mp-weixin/uni_modules/uni-data-select/components/uni-data-select/uni-data-select.js

@@ -227,5 +227,5 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
     r: $data.current ? 1 : ""
   });
 }
-const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "G:/workSpace/agent-registration/uni_modules/uni-data-select/components/uni-data-select/uni-data-select.vue"]]);
+const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "E:/workSpace/agent-registration/uni_modules/uni-data-select/components/uni-data-select/uni-data-select.vue"]]);
 wx.createComponent(Component);

Разница между файлами не показана из-за своего большого размера
+ 1 - 1
unpackage/dist/dev/mp-weixin/uni_modules/uni-data-select/components/uni-data-select/uni-data-select.wxml


+ 1 - 1
unpackage/dist/dev/mp-weixin/uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.js

@@ -429,5 +429,5 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
     X: common_vendor.s($options.boxStyle)
   });
 }
-const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "G:/workSpace/agent-registration/uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.vue"]]);
+const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "E:/workSpace/agent-registration/uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.vue"]]);
 wx.createComponent(Component);

Разница между файлами не показана из-за своего большого размера
+ 1 - 1
unpackage/dist/dev/mp-weixin/uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.wxml


+ 200 - 0
unpackage/dist/dev/mp-weixin/uni_modules/uni-file-picker/components/uni-file-picker/choose-and-upload-file.js

@@ -0,0 +1,200 @@
+"use strict";
+const common_vendor = require("../../../../common/vendor.js");
+const ERR_MSG_OK = "chooseAndUploadFile:ok";
+const ERR_MSG_FAIL = "chooseAndUploadFile:fail";
+function chooseImage(opts) {
+  const {
+    count,
+    sizeType = ["original", "compressed"],
+    sourceType = ["album", "camera"],
+    extension
+  } = opts;
+  return new Promise((resolve, reject) => {
+    common_vendor.index.chooseImage({
+      count,
+      sizeType,
+      sourceType,
+      extension,
+      success(res) {
+        resolve(normalizeChooseAndUploadFileRes(res, "image"));
+      },
+      fail(res) {
+        reject({
+          errMsg: res.errMsg.replace("chooseImage:fail", ERR_MSG_FAIL)
+        });
+      }
+    });
+  });
+}
+function chooseVideo(opts) {
+  const {
+    camera,
+    compressed,
+    maxDuration,
+    sourceType = ["album", "camera"],
+    extension
+  } = opts;
+  return new Promise((resolve, reject) => {
+    common_vendor.index.chooseVideo({
+      camera,
+      compressed,
+      maxDuration,
+      sourceType,
+      extension,
+      success(res) {
+        const {
+          tempFilePath,
+          duration,
+          size,
+          height,
+          width
+        } = res;
+        resolve(normalizeChooseAndUploadFileRes({
+          errMsg: "chooseVideo:ok",
+          tempFilePaths: [tempFilePath],
+          tempFiles: [
+            {
+              name: res.tempFile && res.tempFile.name || "",
+              path: tempFilePath,
+              size,
+              type: res.tempFile && res.tempFile.type || "",
+              width,
+              height,
+              duration,
+              fileType: "video",
+              cloudPath: ""
+            }
+          ]
+        }, "video"));
+      },
+      fail(res) {
+        reject({
+          errMsg: res.errMsg.replace("chooseVideo:fail", ERR_MSG_FAIL)
+        });
+      }
+    });
+  });
+}
+function chooseAll(opts) {
+  const {
+    count,
+    extension
+  } = opts;
+  return new Promise((resolve, reject) => {
+    let chooseFile = common_vendor.index.chooseFile;
+    if (typeof common_vendor.wx$1 !== "undefined" && typeof common_vendor.wx$1.chooseMessageFile === "function") {
+      chooseFile = common_vendor.wx$1.chooseMessageFile;
+    }
+    if (typeof chooseFile !== "function") {
+      return reject({
+        errMsg: ERR_MSG_FAIL + " 请指定 type 类型,该平台仅支持选择 image 或 video。"
+      });
+    }
+    chooseFile({
+      type: "all",
+      count,
+      extension,
+      success(res) {
+        resolve(normalizeChooseAndUploadFileRes(res));
+      },
+      fail(res) {
+        reject({
+          errMsg: res.errMsg.replace("chooseFile:fail", ERR_MSG_FAIL)
+        });
+      }
+    });
+  });
+}
+function normalizeChooseAndUploadFileRes(res, fileType) {
+  res.tempFiles.forEach((item, index) => {
+    if (!item.name) {
+      item.name = item.path.substring(item.path.lastIndexOf("/") + 1);
+    }
+    if (fileType) {
+      item.fileType = fileType;
+    }
+    item.cloudPath = Date.now() + "_" + index + item.name.substring(item.name.lastIndexOf("."));
+  });
+  if (!res.tempFilePaths) {
+    res.tempFilePaths = res.tempFiles.map((file) => file.path);
+  }
+  return res;
+}
+function uploadCloudFiles(files, max = 5, onUploadProgress) {
+  files = JSON.parse(JSON.stringify(files));
+  const len = files.length;
+  let count = 0;
+  let self = this;
+  return new Promise((resolve) => {
+    while (count < max) {
+      next();
+    }
+    function next() {
+      let cur = count++;
+      if (cur >= len) {
+        !files.find((item) => !item.url && !item.errMsg) && resolve(files);
+        return;
+      }
+      const fileItem = files[cur];
+      const index = self.files.findIndex((v) => v.uuid === fileItem.uuid);
+      fileItem.url = "";
+      delete fileItem.errMsg;
+      common_vendor.Ls.uploadFile({
+        filePath: fileItem.path,
+        cloudPath: fileItem.cloudPath,
+        fileType: fileItem.fileType,
+        onUploadProgress: (res) => {
+          res.index = index;
+          onUploadProgress && onUploadProgress(res);
+        }
+      }).then((res) => {
+        fileItem.url = res.fileID;
+        fileItem.index = index;
+        if (cur < len) {
+          next();
+        }
+      }).catch((res) => {
+        fileItem.errMsg = res.errMsg || res.message;
+        fileItem.index = index;
+        if (cur < len) {
+          next();
+        }
+      });
+    }
+  });
+}
+function uploadFiles(choosePromise, {
+  onChooseFile,
+  onUploadProgress
+}) {
+  return choosePromise.then((res) => {
+    if (onChooseFile) {
+      const customChooseRes = onChooseFile(res);
+      if (typeof customChooseRes !== "undefined") {
+        return Promise.resolve(customChooseRes).then((chooseRes) => typeof chooseRes === "undefined" ? res : chooseRes);
+      }
+    }
+    return res;
+  }).then((res) => {
+    if (res === false) {
+      return {
+        errMsg: ERR_MSG_OK,
+        tempFilePaths: [],
+        tempFiles: []
+      };
+    }
+    return res;
+  });
+}
+function chooseAndUploadFile(opts = {
+  type: "all"
+}) {
+  if (opts.type === "image") {
+    return uploadFiles(chooseImage(opts), opts);
+  } else if (opts.type === "video") {
+    return uploadFiles(chooseVideo(opts), opts);
+  }
+  return uploadFiles(chooseAll(opts), opts);
+}
+exports.chooseAndUploadFile = chooseAndUploadFile;
+exports.uploadCloudFiles = uploadCloudFiles;

+ 520 - 0
unpackage/dist/dev/mp-weixin/uni_modules/uni-file-picker/components/uni-file-picker/uni-file-picker.js

@@ -0,0 +1,520 @@
+"use strict";
+const common_vendor = require("../../../../common/vendor.js");
+const uni_modules_uniFilePicker_components_uniFilePicker_chooseAndUploadFile = require("./choose-and-upload-file.js");
+const uni_modules_uniFilePicker_components_uniFilePicker_utils = require("./utils.js");
+const uploadImage = () => "./upload-image.js";
+const uploadFile = () => "./upload-file.js";
+const _sfc_main = {
+  name: "uniFilePicker",
+  components: {
+    uploadImage,
+    uploadFile
+  },
+  options: {
+    virtualHost: true
+  },
+  emits: ["select", "success", "fail", "progress", "delete", "update:modelValue", "input"],
+  props: {
+    modelValue: {
+      type: [Array, Object],
+      default() {
+        return [];
+      }
+    },
+    disabled: {
+      type: Boolean,
+      default: false
+    },
+    disablePreview: {
+      type: Boolean,
+      default: false
+    },
+    delIcon: {
+      type: Boolean,
+      default: true
+    },
+    // 自动上传
+    autoUpload: {
+      type: Boolean,
+      default: true
+    },
+    // 最大选择个数 ,h5只能限制单选或是多选
+    limit: {
+      type: [Number, String],
+      default: 9
+    },
+    // 列表样式 grid | list | list-card
+    mode: {
+      type: String,
+      default: "grid"
+    },
+    // 选择文件类型  image/video/all
+    fileMediatype: {
+      type: String,
+      default: "image"
+    },
+    // 文件类型筛选
+    fileExtname: {
+      type: [Array, String],
+      default() {
+        return [];
+      }
+    },
+    title: {
+      type: String,
+      default: ""
+    },
+    listStyles: {
+      type: Object,
+      default() {
+        return {
+          // 是否显示边框
+          border: true,
+          // 是否显示分隔线
+          dividline: true,
+          // 线条样式
+          borderStyle: {}
+        };
+      }
+    },
+    imageStyles: {
+      type: Object,
+      default() {
+        return {
+          width: "auto",
+          height: "auto"
+        };
+      }
+    },
+    readonly: {
+      type: Boolean,
+      default: false
+    },
+    returnType: {
+      type: String,
+      default: "array"
+    },
+    sizeType: {
+      type: Array,
+      default() {
+        return ["original", "compressed"];
+      }
+    }
+  },
+  data() {
+    return {
+      files: [],
+      localValue: []
+    };
+  },
+  watch: {
+    modelValue: {
+      handler(newVal, oldVal) {
+        this.setValue(newVal, oldVal);
+      },
+      immediate: true
+    }
+  },
+  computed: {
+    filesList() {
+      let files = [];
+      this.files.forEach((v) => {
+        files.push(v);
+      });
+      return files;
+    },
+    showType() {
+      if (this.fileMediatype === "image") {
+        return this.mode;
+      }
+      return "list";
+    },
+    limitLength() {
+      if (this.returnType === "object") {
+        return 1;
+      }
+      if (!this.limit) {
+        return 1;
+      }
+      if (this.limit >= 9) {
+        return 9;
+      }
+      return this.limit;
+    }
+  },
+  created() {
+    if (!(common_vendor.Ls.config && common_vendor.Ls.config.provider)) {
+      this.noSpace = true;
+      common_vendor.Ls.chooseAndUploadFile = uni_modules_uniFilePicker_components_uniFilePicker_chooseAndUploadFile.chooseAndUploadFile;
+    }
+    this.form = this.getForm("uniForms");
+    this.formItem = this.getForm("uniFormsItem");
+    if (this.form && this.formItem) {
+      if (this.formItem.name) {
+        this.rename = this.formItem.name;
+        this.form.inputChildrens.push(this);
+      }
+    }
+  },
+  methods: {
+    /**
+     * 公开用户使用,清空文件
+     * @param {Object} index
+     */
+    clearFiles(index) {
+      if (index !== 0 && !index) {
+        this.files = [];
+        this.$nextTick(() => {
+          this.setEmit();
+        });
+      } else {
+        this.files.splice(index, 1);
+      }
+      this.$nextTick(() => {
+        this.setEmit();
+      });
+    },
+    /**
+     * 公开用户使用,继续上传
+     */
+    upload() {
+      let files = [];
+      this.files.forEach((v, index) => {
+        if (v.status === "ready" || v.status === "error") {
+          files.push(Object.assign({}, v));
+        }
+      });
+      return this.uploadFiles(files);
+    },
+    async setValue(newVal, oldVal) {
+      const newData = async (v) => {
+        const reg = /cloud:\/\/([\w.]+\/?)\S*/;
+        let url = "";
+        if (v.fileID) {
+          url = v.fileID;
+        } else {
+          url = v.url;
+        }
+        if (reg.test(url)) {
+          v.fileID = url;
+          v.url = await this.getTempFileURL(url);
+        }
+        if (v.url)
+          v.path = v.url;
+        return v;
+      };
+      if (this.returnType === "object") {
+        if (newVal) {
+          await newData(newVal);
+        } else {
+          newVal = {};
+        }
+      } else {
+        if (!newVal)
+          newVal = [];
+        for (let i = 0; i < newVal.length; i++) {
+          let v = newVal[i];
+          await newData(v);
+        }
+      }
+      this.localValue = newVal;
+      if (this.form && this.formItem && !this.is_reset) {
+        this.is_reset = false;
+        this.formItem.setValue(this.localValue);
+      }
+      let filesData = Object.keys(newVal).length > 0 ? newVal : [];
+      this.files = [].concat(filesData);
+    },
+    /**
+     * 选择文件
+     */
+    choose() {
+      if (this.disabled)
+        return;
+      if (this.files.length >= Number(this.limitLength) && this.showType !== "grid" && this.returnType === "array") {
+        common_vendor.index.showToast({
+          title: `您最多选择 ${this.limitLength} 个文件`,
+          icon: "none"
+        });
+        return;
+      }
+      this.chooseFiles();
+    },
+    /**
+     * 选择文件并上传
+     */
+    chooseFiles() {
+      const _extname = uni_modules_uniFilePicker_components_uniFilePicker_utils.get_extname(this.fileExtname);
+      common_vendor.Ls.chooseAndUploadFile({
+        type: this.fileMediatype,
+        compressed: false,
+        sizeType: this.sizeType,
+        // TODO 如果为空,video 有问题
+        extension: _extname.length > 0 ? _extname : void 0,
+        count: this.limitLength - this.files.length,
+        //默认9
+        onChooseFile: this.chooseFileCallback,
+        onUploadProgress: (progressEvent) => {
+          this.setProgress(progressEvent, progressEvent.index);
+        }
+      }).then((result) => {
+        this.setSuccessAndError(result.tempFiles);
+      }).catch((err) => {
+        console.log("选择失败", err);
+      });
+    },
+    /**
+     * 选择文件回调
+     * @param {Object} res
+     */
+    async chooseFileCallback(res) {
+      const _extname = uni_modules_uniFilePicker_components_uniFilePicker_utils.get_extname(this.fileExtname);
+      const is_one = Number(this.limitLength) === 1 && this.disablePreview && !this.disabled || this.returnType === "object";
+      if (is_one) {
+        this.files = [];
+      }
+      let {
+        filePaths,
+        files
+      } = uni_modules_uniFilePicker_components_uniFilePicker_utils.get_files_and_is_max(res, _extname);
+      if (!(_extname && _extname.length > 0)) {
+        filePaths = res.tempFilePaths;
+        files = res.tempFiles;
+      }
+      let currentData = [];
+      for (let i = 0; i < files.length; i++) {
+        if (this.limitLength - this.files.length <= 0)
+          break;
+        files[i].uuid = Date.now();
+        let filedata = await uni_modules_uniFilePicker_components_uniFilePicker_utils.get_file_data(files[i], this.fileMediatype);
+        filedata.progress = 0;
+        filedata.status = "ready";
+        this.files.push(filedata);
+        currentData.push({
+          ...filedata,
+          file: files[i]
+        });
+      }
+      this.$emit("select", {
+        tempFiles: currentData,
+        tempFilePaths: filePaths
+      });
+      res.tempFiles = files;
+      if (!this.autoUpload || this.noSpace) {
+        res.tempFiles = [];
+      }
+    },
+    /**
+     * 批传
+     * @param {Object} e
+     */
+    uploadFiles(files) {
+      files = [].concat(files);
+      return uni_modules_uniFilePicker_components_uniFilePicker_chooseAndUploadFile.uploadCloudFiles.call(this, files, 5, (res) => {
+        this.setProgress(res, res.index, true);
+      }).then((result) => {
+        this.setSuccessAndError(result);
+        return result;
+      }).catch((err) => {
+        console.log(err);
+      });
+    },
+    /**
+     * 成功或失败
+     */
+    async setSuccessAndError(res, fn) {
+      let successData = [];
+      let errorData = [];
+      let tempFilePath = [];
+      let errorTempFilePath = [];
+      for (let i = 0; i < res.length; i++) {
+        const item = res[i];
+        const index = item.uuid ? this.files.findIndex((p) => p.uuid === item.uuid) : item.index;
+        if (index === -1 || !this.files)
+          break;
+        if (item.errMsg === "request:fail") {
+          this.files[index].url = item.path;
+          this.files[index].status = "error";
+          this.files[index].errMsg = item.errMsg;
+          errorData.push(this.files[index]);
+          errorTempFilePath.push(this.files[index].url);
+        } else {
+          this.files[index].errMsg = "";
+          this.files[index].fileID = item.url;
+          const reg = /cloud:\/\/([\w.]+\/?)\S*/;
+          if (reg.test(item.url)) {
+            this.files[index].url = await this.getTempFileURL(item.url);
+          } else {
+            this.files[index].url = item.url;
+          }
+          this.files[index].status = "success";
+          this.files[index].progress += 1;
+          successData.push(this.files[index]);
+          tempFilePath.push(this.files[index].fileID);
+        }
+      }
+      if (successData.length > 0) {
+        this.setEmit();
+        this.$emit("success", {
+          tempFiles: this.backObject(successData),
+          tempFilePaths: tempFilePath
+        });
+      }
+      if (errorData.length > 0) {
+        this.$emit("fail", {
+          tempFiles: this.backObject(errorData),
+          tempFilePaths: errorTempFilePath
+        });
+      }
+    },
+    /**
+     * 获取进度
+     * @param {Object} progressEvent
+     * @param {Object} index
+     * @param {Object} type
+     */
+    setProgress(progressEvent, index, type) {
+      this.files.length;
+      const percentCompleted = Math.round(progressEvent.loaded * 100 / progressEvent.total);
+      let idx = index;
+      if (!type) {
+        idx = this.files.findIndex((p) => p.uuid === progressEvent.tempFile.uuid);
+      }
+      if (idx === -1 || !this.files[idx])
+        return;
+      this.files[idx].progress = percentCompleted - 1;
+      this.$emit("progress", {
+        index: idx,
+        progress: parseInt(percentCompleted),
+        tempFile: this.files[idx]
+      });
+    },
+    /**
+     * 删除文件
+     * @param {Object} index
+     */
+    delFile(index) {
+      this.$emit("delete", {
+        tempFile: this.files[index],
+        tempFilePath: this.files[index].url
+      });
+      this.files.splice(index, 1);
+      this.$nextTick(() => {
+        this.setEmit();
+      });
+    },
+    /**
+     * 获取文件名和后缀
+     * @param {Object} name
+     */
+    getFileExt(name) {
+      const last_len = name.lastIndexOf(".");
+      const len = name.length;
+      return {
+        name: name.substring(0, last_len),
+        ext: name.substring(last_len + 1, len)
+      };
+    },
+    /**
+     * 处理返回事件
+     */
+    setEmit() {
+      let data = [];
+      if (this.returnType === "object") {
+        data = this.backObject(this.files)[0];
+        this.localValue = data ? data : null;
+      } else {
+        data = this.backObject(this.files);
+        if (!this.localValue) {
+          this.localValue = [];
+        }
+        this.localValue = [...data];
+      }
+      this.$emit("update:modelValue", this.localValue);
+    },
+    /**
+     * 处理返回参数
+     * @param {Object} files
+     */
+    backObject(files) {
+      let newFilesData = [];
+      files.forEach((v) => {
+        newFilesData.push({
+          extname: v.extname,
+          fileType: v.fileType,
+          image: v.image,
+          name: v.name,
+          path: v.path,
+          size: v.size,
+          fileID: v.fileID,
+          url: v.url
+        });
+      });
+      return newFilesData;
+    },
+    async getTempFileURL(fileList) {
+      fileList = {
+        fileList: [].concat(fileList)
+      };
+      const urls = await common_vendor.Ls.getTempFileURL(fileList);
+      return urls.fileList[0].tempFileURL || "";
+    },
+    /**
+     * 获取父元素实例
+     */
+    getForm(name = "uniForms") {
+      let parent = this.$parent;
+      let parentName = parent.$options.name;
+      while (parentName !== name) {
+        parent = parent.$parent;
+        if (!parent)
+          return false;
+        parentName = parent.$options.name;
+      }
+      return parent;
+    }
+  }
+};
+if (!Array) {
+  const _component_upload_image = common_vendor.resolveComponent("upload-image");
+  const _component_upload_file = common_vendor.resolveComponent("upload-file");
+  (_component_upload_image + _component_upload_file)();
+}
+function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
+  return common_vendor.e({
+    a: $props.title
+  }, $props.title ? {
+    b: common_vendor.t($props.title),
+    c: common_vendor.t($options.filesList.length),
+    d: common_vendor.t($options.limitLength)
+  } : {}, {
+    e: $props.fileMediatype === "image" && $options.showType === "grid"
+  }, $props.fileMediatype === "image" && $options.showType === "grid" ? {
+    f: common_vendor.o($options.uploadFiles),
+    g: common_vendor.o($options.choose),
+    h: common_vendor.o($options.delFile),
+    i: common_vendor.p({
+      readonly: $props.readonly,
+      ["image-styles"]: $props.imageStyles,
+      ["files-list"]: $options.filesList,
+      limit: $options.limitLength,
+      disablePreview: $props.disablePreview,
+      delIcon: $props.delIcon
+    })
+  } : {}, {
+    j: $props.fileMediatype !== "image" || $options.showType !== "grid"
+  }, $props.fileMediatype !== "image" || $options.showType !== "grid" ? {
+    k: common_vendor.o($options.uploadFiles),
+    l: common_vendor.o($options.choose),
+    m: common_vendor.o($options.delFile),
+    n: common_vendor.p({
+      readonly: $props.readonly,
+      ["list-styles"]: $props.listStyles,
+      ["files-list"]: $options.filesList,
+      showType: $options.showType,
+      delIcon: $props.delIcon
+    })
+  } : {});
+}
+const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "E:/workSpace/agent-registration/uni_modules/uni-file-picker/components/uni-file-picker/uni-file-picker.vue"]]);
+wx.createComponent(Component);

+ 7 - 0
unpackage/dist/dev/mp-weixin/uni_modules/uni-file-picker/components/uni-file-picker/uni-file-picker.json

@@ -0,0 +1,7 @@
+{
+  "component": true,
+  "usingComponents": {
+    "upload-image": "./upload-image",
+    "upload-file": "./upload-file"
+  }
+}

Разница между файлами не показана из-за своего большого размера
+ 1 - 0
unpackage/dist/dev/mp-weixin/uni_modules/uni-file-picker/components/uni-file-picker/uni-file-picker.wxml


+ 42 - 0
unpackage/dist/dev/mp-weixin/uni_modules/uni-file-picker/components/uni-file-picker/uni-file-picker.wxss

@@ -0,0 +1,42 @@
+
+.uni-file-picker {
+
+		box-sizing: border-box;
+		overflow: hidden;
+		width: 100%;
+
+		flex: 1;
+}
+.uni-file-picker__header {
+		padding-top: 5px;
+		padding-bottom: 10px;
+
+		display: flex;
+
+		justify-content: space-between;
+}
+.file-title {
+		font-size: 14px;
+		color: #333;
+}
+.file-count {
+		font-size: 14px;
+		color: #999;
+}
+.is-add {
+
+		display: flex;
+
+		align-items: center;
+		justify-content: center;
+}
+.icon-add {
+		width: 50px;
+		height: 5px;
+		background-color: #f1f1f1;
+		border-radius: 2px;
+}
+.rotate {
+		position: absolute;
+		transform: rotate(90deg);
+}

+ 172 - 0
unpackage/dist/dev/mp-weixin/uni_modules/uni-file-picker/components/uni-file-picker/upload-file.js

@@ -0,0 +1,172 @@
+"use strict";
+const common_vendor = require("../../../../common/vendor.js");
+const _sfc_main = {
+  name: "uploadFile",
+  emits: ["uploadFiles", "choose", "delFile"],
+  props: {
+    filesList: {
+      type: Array,
+      default() {
+        return [];
+      }
+    },
+    delIcon: {
+      type: Boolean,
+      default: true
+    },
+    limit: {
+      type: [Number, String],
+      default: 9
+    },
+    showType: {
+      type: String,
+      default: ""
+    },
+    listStyles: {
+      type: Object,
+      default() {
+        return {
+          // 是否显示边框
+          border: true,
+          // 是否显示分隔线
+          dividline: true,
+          // 线条样式
+          borderStyle: {}
+        };
+      }
+    },
+    readonly: {
+      type: Boolean,
+      default: false
+    }
+  },
+  computed: {
+    list() {
+      let files = [];
+      this.filesList.forEach((v) => {
+        files.push(v);
+      });
+      return files;
+    },
+    styles() {
+      let styles = {
+        border: true,
+        dividline: true,
+        "border-style": {}
+      };
+      return Object.assign(styles, this.listStyles);
+    },
+    borderStyle() {
+      let {
+        borderStyle,
+        border
+      } = this.styles;
+      let obj = {};
+      if (!border) {
+        obj.border = "none";
+      } else {
+        let width = borderStyle && borderStyle.width || 1;
+        width = this.value2px(width);
+        let radius = borderStyle && borderStyle.radius || 5;
+        radius = this.value2px(radius);
+        obj = {
+          "border-width": width,
+          "border-style": borderStyle && borderStyle.style || "solid",
+          "border-color": borderStyle && borderStyle.color || "#eee",
+          "border-radius": radius
+        };
+      }
+      let classles = "";
+      for (let i in obj) {
+        classles += `${i}:${obj[i]};`;
+      }
+      return classles;
+    },
+    borderLineStyle() {
+      let obj = {};
+      let {
+        borderStyle
+      } = this.styles;
+      if (borderStyle && borderStyle.color) {
+        obj["border-color"] = borderStyle.color;
+      }
+      if (borderStyle && borderStyle.width) {
+        let width = borderStyle && borderStyle.width || 1;
+        let style = borderStyle && borderStyle.style || 0;
+        if (typeof width === "number") {
+          width += "px";
+        } else {
+          width = width.indexOf("px") ? width : width + "px";
+        }
+        obj["border-width"] = width;
+        if (typeof style === "number") {
+          style += "px";
+        } else {
+          style = style.indexOf("px") ? style : style + "px";
+        }
+        obj["border-top-style"] = style;
+      }
+      let classles = "";
+      for (let i in obj) {
+        classles += `${i}:${obj[i]};`;
+      }
+      return classles;
+    }
+  },
+  methods: {
+    uploadFiles(item, index) {
+      this.$emit("uploadFiles", {
+        item,
+        index
+      });
+    },
+    choose() {
+      this.$emit("choose");
+    },
+    delFile(index) {
+      this.$emit("delFile", index);
+    },
+    value2px(value) {
+      if (typeof value === "number") {
+        value += "px";
+      } else {
+        value = value.indexOf("px") !== -1 ? value : value + "px";
+      }
+      return value;
+    }
+  }
+};
+function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
+  return common_vendor.e({
+    a: !$props.readonly
+  }, !$props.readonly ? {
+    b: common_vendor.o((...args) => $options.choose && $options.choose(...args))
+  } : {}, {
+    c: $options.list.length > 0
+  }, $options.list.length > 0 ? {
+    d: common_vendor.f($options.list, (item, index, i0) => {
+      return common_vendor.e({
+        a: common_vendor.t(item.name)
+      }, $props.delIcon && !$props.readonly ? {
+        b: common_vendor.o(($event) => $options.delFile(index), index)
+      } : {}, {
+        c: item.progress && item.progress !== 100 || item.progress === 0
+      }, item.progress && item.progress !== 100 || item.progress === 0 ? {
+        d: item.progress === -1 ? 0 : item.progress,
+        e: item.errMsg ? "#ff5a5f" : "#EBEBEB"
+      } : {}, {
+        f: item.status === "error"
+      }, item.status === "error" ? {
+        g: common_vendor.o(($event) => $options.uploadFiles(item, index), index)
+      } : {}, {
+        h: index,
+        i: index !== 0 && $options.styles.dividline ? 1 : "",
+        j: common_vendor.s(index !== 0 && $options.styles.dividline && $options.borderLineStyle)
+      });
+    }),
+    e: $props.delIcon && !$props.readonly,
+    f: common_vendor.s($options.borderStyle)
+  } : {});
+}
+const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "E:/workSpace/agent-registration/uni_modules/uni-file-picker/components/uni-file-picker/upload-file.vue"]]);
+wx.createComponent(Component);

+ 4 - 0
unpackage/dist/dev/mp-weixin/uni_modules/uni-file-picker/components/uni-file-picker/upload-file.json

@@ -0,0 +1,4 @@
+{
+  "component": true,
+  "usingComponents": {}
+}

Разница между файлами не показана из-за своего большого размера
+ 1 - 0
unpackage/dist/dev/mp-weixin/uni_modules/uni-file-picker/components/uni-file-picker/upload-file.wxml


+ 98 - 0
unpackage/dist/dev/mp-weixin/uni_modules/uni-file-picker/components/uni-file-picker/upload-file.wxss

@@ -0,0 +1,98 @@
+/* 水平间距 */
+/* 水平间距 */
+.uni-file-picker__files {
+  display: flex;
+  flex-direction: column;
+  justify-content: flex-start;
+}
+.uni-file-picker__lists {
+  position: relative;
+  margin-top: 5px;
+  overflow: hidden;
+}
+.file-picker__mask {
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  position: absolute;
+  right: 0;
+  top: 0;
+  bottom: 0;
+  left: 0;
+  color: #fff;
+  font-size: 14px;
+  background-color: rgba(0, 0, 0, 0.4);
+}
+.uni-file-picker__lists-box {
+  position: relative;
+}
+.uni-file-picker__item {
+  display: flex;
+  align-items: center;
+  padding: 8px 10px;
+  padding-right: 5px;
+  padding-left: 10px;
+}
+.files-border {
+  border-top: 1px #eee solid;
+}
+.files__name {
+  flex: 1;
+  font-size: 14px;
+  color: #666;
+  margin-right: 25px;
+  word-break: break-all;
+  word-wrap: break-word;
+}
+.icon-files {
+  position: static;
+  background-color: initial;
+}
+.is-list-card {
+  border: 1px #eee solid;
+  margin-bottom: 5px;
+  border-radius: 5px;
+  box-shadow: 0 0 2px 0px rgba(0, 0, 0, 0.1);
+  padding: 5px;
+}
+.files__image {
+  width: 40px;
+  height: 40px;
+  margin-right: 10px;
+}
+.header-image {
+  width: 100%;
+  height: 100%;
+}
+.is-text-box {
+  border: 1px #eee solid;
+  border-radius: 5px;
+}
+.is-text-image {
+  width: 25px;
+  height: 25px;
+  margin-left: 5px;
+}
+.rotate {
+  position: absolute;
+  transform: rotate(90deg);
+}
+.icon-del-box {
+  display: flex;
+  margin: auto 0;
+  align-items: center;
+  justify-content: center;
+  position: absolute;
+  top: 0px;
+  bottom: 0;
+  right: 5px;
+  height: 26px;
+  width: 26px;
+  z-index: 2;
+  transform: rotate(-45deg);
+}
+.icon-del {
+  width: 15px;
+  height: 1px;
+  background-color: #333;
+}

+ 182 - 0
unpackage/dist/dev/mp-weixin/uni_modules/uni-file-picker/components/uni-file-picker/upload-image.js

@@ -0,0 +1,182 @@
+"use strict";
+const common_vendor = require("../../../../common/vendor.js");
+const _sfc_main = {
+  name: "uploadImage",
+  emits: ["uploadFiles", "choose", "delFile"],
+  props: {
+    filesList: {
+      type: Array,
+      default() {
+        return [];
+      }
+    },
+    disabled: {
+      type: Boolean,
+      default: false
+    },
+    disablePreview: {
+      type: Boolean,
+      default: false
+    },
+    limit: {
+      type: [Number, String],
+      default: 9
+    },
+    imageStyles: {
+      type: Object,
+      default() {
+        return {
+          width: "auto",
+          height: "auto",
+          border: {}
+        };
+      }
+    },
+    delIcon: {
+      type: Boolean,
+      default: true
+    },
+    readonly: {
+      type: Boolean,
+      default: false
+    }
+  },
+  computed: {
+    styles() {
+      let styles = {
+        width: "auto",
+        height: "auto",
+        border: {}
+      };
+      return Object.assign(styles, this.imageStyles);
+    },
+    boxStyle() {
+      const {
+        width = "auto",
+        height = "auto"
+      } = this.styles;
+      let obj = {};
+      if (height === "auto") {
+        if (width !== "auto") {
+          obj.height = this.value2px(width);
+          obj["padding-top"] = 0;
+        } else {
+          obj.height = 0;
+        }
+      } else {
+        obj.height = this.value2px(height);
+        obj["padding-top"] = 0;
+      }
+      if (width === "auto") {
+        if (height !== "auto") {
+          obj.width = this.value2px(height);
+        } else {
+          obj.width = "33.3%";
+        }
+      } else {
+        obj.width = this.value2px(width);
+      }
+      let classles = "";
+      for (let i in obj) {
+        classles += `${i}:${obj[i]};`;
+      }
+      return classles;
+    },
+    borderStyle() {
+      let {
+        border
+      } = this.styles;
+      let obj = {};
+      const widthDefaultValue = 1;
+      const radiusDefaultValue = 3;
+      if (typeof border === "boolean") {
+        obj.border = border ? "1px #eee solid" : "none";
+      } else {
+        let width = border && border.width || widthDefaultValue;
+        width = this.value2px(width);
+        let radius = border && border.radius || radiusDefaultValue;
+        radius = this.value2px(radius);
+        obj = {
+          "border-width": width,
+          "border-style": border && border.style || "solid",
+          "border-color": border && border.color || "#eee",
+          "border-radius": radius
+        };
+      }
+      let classles = "";
+      for (let i in obj) {
+        classles += `${i}:${obj[i]};`;
+      }
+      return classles;
+    }
+  },
+  methods: {
+    uploadFiles(item, index) {
+      this.$emit("uploadFiles", item);
+    },
+    choose() {
+      this.$emit("choose");
+    },
+    delFile(index) {
+      this.$emit("delFile", index);
+    },
+    prviewImage(img, index) {
+      let urls = [];
+      if (Number(this.limit) === 1 && this.disablePreview && !this.disabled) {
+        this.$emit("choose");
+      }
+      if (this.disablePreview)
+        return;
+      this.filesList.forEach((i) => {
+        urls.push(i.url);
+      });
+      common_vendor.index.previewImage({
+        urls,
+        current: index
+      });
+    },
+    value2px(value) {
+      if (typeof value === "number") {
+        value += "px";
+      } else {
+        if (value.indexOf("%") === -1) {
+          value = value.indexOf("px") !== -1 ? value : value + "px";
+        }
+      }
+      return value;
+    }
+  }
+};
+function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
+  return common_vendor.e({
+    a: common_vendor.f($props.filesList, (item, index, i0) => {
+      return common_vendor.e({
+        a: item.url,
+        b: common_vendor.o(($event) => $options.prviewImage(item, index), index)
+      }, $props.delIcon && !$props.readonly ? {
+        c: common_vendor.o(($event) => $options.delFile(index), index)
+      } : {}, {
+        d: item.progress && item.progress !== 100 || item.progress === 0
+      }, item.progress && item.progress !== 100 || item.progress === 0 ? {
+        e: item.progress === -1 ? 0 : item.progress,
+        f: item.errMsg ? "#ff5a5f" : "#EBEBEB"
+      } : {}, {
+        g: item.errMsg
+      }, item.errMsg ? {
+        h: common_vendor.o(($event) => $options.uploadFiles(item, index), index)
+      } : {}, {
+        i: index
+      });
+    }),
+    b: $props.delIcon && !$props.readonly,
+    c: common_vendor.s($options.borderStyle),
+    d: common_vendor.s($options.boxStyle),
+    e: $props.filesList.length < $props.limit && !$props.readonly
+  }, $props.filesList.length < $props.limit && !$props.readonly ? {
+    f: common_vendor.s($options.borderStyle),
+    g: common_vendor.o((...args) => $options.choose && $options.choose(...args)),
+    h: common_vendor.s($options.boxStyle)
+  } : {});
+}
+const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "E:/workSpace/agent-registration/uni_modules/uni-file-picker/components/uni-file-picker/upload-image.vue"]]);
+wx.createComponent(Component);

+ 4 - 0
unpackage/dist/dev/mp-weixin/uni_modules/uni-file-picker/components/uni-file-picker/upload-image.json

@@ -0,0 +1,4 @@
+{
+  "component": true,
+  "usingComponents": {}
+}

Разница между файлами не показана из-за своего большого размера
+ 1 - 0
unpackage/dist/dev/mp-weixin/uni_modules/uni-file-picker/components/uni-file-picker/upload-image.wxml


+ 89 - 0
unpackage/dist/dev/mp-weixin/uni_modules/uni-file-picker/components/uni-file-picker/upload-image.wxss

@@ -0,0 +1,89 @@
+/* 水平间距 */
+/* 水平间距 */
+.uni-file-picker__container {
+  display: flex;
+  box-sizing: border-box;
+  flex-wrap: wrap;
+  margin: -5px;
+}
+.file-picker__box {
+  position: relative;
+  width: 33.3%;
+  height: 0;
+  padding-top: 33.33%;
+  box-sizing: border-box;
+}
+.file-picker__box-content {
+  position: absolute;
+  top: 0;
+  right: 0;
+  bottom: 0;
+  left: 0;
+  margin: 5px;
+  border: 1px #eee solid;
+  border-radius: 5px;
+  overflow: hidden;
+}
+.file-picker__progress {
+  position: absolute;
+  bottom: 0;
+  left: 0;
+  right: 0;
+  /* border: 1px red solid; */
+  z-index: 2;
+}
+.file-picker__progress-item {
+  width: 100%;
+}
+.file-picker__mask {
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  position: absolute;
+  right: 0;
+  top: 0;
+  bottom: 0;
+  left: 0;
+  color: #fff;
+  font-size: 12px;
+  background-color: rgba(0, 0, 0, 0.4);
+}
+.file-image {
+  width: 100%;
+  height: 100%;
+}
+.is-add {
+  display: flex;
+  align-items: center;
+  justify-content: center;
+}
+.icon-add {
+  width: 50px;
+  height: 5px;
+  background-color: #f1f1f1;
+  border-radius: 2px;
+}
+.rotate {
+  position: absolute;
+  transform: rotate(90deg);
+}
+.icon-del-box {
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  position: absolute;
+  top: 3px;
+  right: 3px;
+  height: 26px;
+  width: 26px;
+  border-radius: 50%;
+  background-color: rgba(0, 0, 0, 0.5);
+  z-index: 2;
+  transform: rotate(-45deg);
+}
+.icon-del {
+  width: 15px;
+  height: 2px;
+  background-color: #fff;
+  border-radius: 2px;
+}

+ 90 - 0
unpackage/dist/dev/mp-weixin/uni_modules/uni-file-picker/components/uni-file-picker/utils.js

@@ -0,0 +1,90 @@
+"use strict";
+const common_vendor = require("../../../../common/vendor.js");
+const get_file_ext = (name) => {
+  const last_len = name.lastIndexOf(".");
+  const len = name.length;
+  return {
+    name: name.substring(0, last_len),
+    ext: name.substring(last_len + 1, len)
+  };
+};
+const get_extname = (fileExtname) => {
+  if (!Array.isArray(fileExtname)) {
+    let extname = fileExtname.replace(/(\[|\])/g, "");
+    return extname.split(",");
+  } else {
+    return fileExtname;
+  }
+};
+const get_files_and_is_max = (res, _extname) => {
+  let filePaths = [];
+  let files = [];
+  if (!_extname || _extname.length === 0) {
+    return {
+      filePaths,
+      files
+    };
+  }
+  res.tempFiles.forEach((v) => {
+    let fileFullName = get_file_ext(v.name);
+    const extname = fileFullName.ext.toLowerCase();
+    if (_extname.indexOf(extname) !== -1) {
+      files.push(v);
+      filePaths.push(v.path);
+    }
+  });
+  if (files.length !== res.tempFiles.length) {
+    common_vendor.index.showToast({
+      title: `当前选择了${res.tempFiles.length}个文件 ,${res.tempFiles.length - files.length} 个文件格式不正确`,
+      icon: "none",
+      duration: 5e3
+    });
+  }
+  return {
+    filePaths,
+    files
+  };
+};
+const get_file_info = (filepath) => {
+  return new Promise((resolve, reject) => {
+    common_vendor.index.getImageInfo({
+      src: filepath,
+      success(res) {
+        resolve(res);
+      },
+      fail(err) {
+        reject(err);
+      }
+    });
+  });
+};
+const get_file_data = async (files, type = "image") => {
+  let fileFullName = get_file_ext(files.name);
+  const extname = fileFullName.ext.toLowerCase();
+  let filedata = {
+    name: files.name,
+    uuid: files.uuid,
+    extname: extname || "",
+    cloudPath: files.cloudPath,
+    fileType: files.fileType,
+    url: files.path || files.path,
+    size: files.size,
+    //单位是字节
+    image: {},
+    path: files.path,
+    video: {}
+  };
+  if (type === "image") {
+    const imageinfo = await get_file_info(files.path);
+    delete filedata.video;
+    filedata.image.width = imageinfo.width;
+    filedata.image.height = imageinfo.height;
+    filedata.image.location = imageinfo.path;
+  } else {
+    delete filedata.image;
+  }
+  return filedata;
+};
+exports.get_extname = get_extname;
+exports.get_file_data = get_file_data;
+exports.get_files_and_is_max = get_files_and_is_max;

+ 1 - 1
unpackage/dist/dev/mp-weixin/uni_modules/uni-icons/components/uni-icons/uni-icons.js

@@ -59,5 +59,5 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
     f: common_vendor.o((...args) => $options._onClick && $options._onClick(...args))
   };
 }
-const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "G:/workSpace/agent-registration/uni_modules/uni-icons/components/uni-icons/uni-icons.vue"]]);
+const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "E:/workSpace/agent-registration/uni_modules/uni-icons/components/uni-icons/uni-icons.vue"]]);
 wx.createComponent(Component);

+ 1 - 1
unpackage/dist/dev/mp-weixin/uni_modules/uni-load-more/components/uni-load-more/uni-load-more.js

@@ -107,5 +107,5 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
     q: common_vendor.o((...args) => $options.onClick && $options.onClick(...args))
   });
 }
-const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "G:/workSpace/agent-registration/uni_modules/uni-load-more/components/uni-load-more/uni-load-more.vue"]]);
+const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "E:/workSpace/agent-registration/uni_modules/uni-load-more/components/uni-load-more/uni-load-more.vue"]]);
 wx.createComponent(Component);

+ 66 - 0
unpackage/dist/dev/mp-weixin/util/imageCompress.js

@@ -0,0 +1,66 @@
+"use strict";
+const common_vendor = require("../common/vendor.js");
+function imageSizeIsLessLimitSize(imagePath, limitSize, lessCallback, moreCallback) {
+  common_vendor.wx$1.getFileSystemManager().getFileInfo({
+    filePath: imagePath,
+    success: (res) => {
+      if (res.size > 1024 * limitSize) {
+        moreCallback();
+      } else {
+        lessCallback();
+      }
+    }
+  });
+}
+function getCanvasImage(canvasId, imagePath, imageW, imageH, getImgSuccess) {
+  const ctx = common_vendor.wx$1.createCanvasContext(canvasId);
+  ctx.drawImage(imagePath, 0, 0, imageW, imageH);
+  ctx.draw(false, setTimeout(function() {
+    common_vendor.wx$1.canvasToTempFilePath({
+      canvasId,
+      x: 0,
+      y: 0,
+      width: imageW,
+      height: imageH,
+      quality: 1,
+      //最高质量
+      success: (res) => {
+        getImgSuccess(res.tempFilePath);
+      }
+    });
+  }, 200));
+}
+function getLessLimitSizeImage(canvasId, imagePath, limitSize = 1024, drawWidth, callback) {
+  imageSizeIsLessLimitSize(
+    imagePath,
+    limitSize,
+    (lessRes) => {
+      callback(imagePath);
+    },
+    (moreRes) => {
+      common_vendor.wx$1.getImageInfo({
+        src: imagePath,
+        success: (imageInfo) => {
+          let maxSide = Math.max(imageInfo.width, imageInfo.height);
+          let windowW = drawWidth;
+          let scale = 1;
+          if (maxSide > windowW) {
+            scale = windowW / maxSide;
+          }
+          let imageW = Math.trunc(imageInfo.width * scale);
+          let imageH = Math.trunc(imageInfo.height * scale);
+          getCanvasImage(
+            canvasId,
+            imagePath,
+            imageW,
+            imageH,
+            (pressImgPath) => {
+              getLessLimitSizeImage(canvasId, pressImgPath, limitSize, drawWidth * 0.95, callback);
+            }
+          );
+        }
+      });
+    }
+  );
+}
+exports.getLessLimitSizeImage = getLessLimitSizeImage;

+ 97 - 0
util/imageCompress.js

@@ -0,0 +1,97 @@
+ //通过canvas将图片压缩至指定大小
+
+ //判断图片大小是否满足需求,limitSize的单位是kb
+ function imageSizeIsLessLimitSize(imagePath, limitSize, lessCallback, moreCallback) {
+ 	//获取文件信息
+ 	wx.getFileSystemManager().getFileInfo({
+ 		filePath: imagePath,
+ 		success: (res) => {
+ 			// console.log("压缩前图片大小", res.size / 1024, 'kb');
+ 			//如果图片太大了走moreCallback
+ 			if (res.size > 1024 * limitSize) {
+ 				moreCallback()
+ 			}
+ 			//图片满足要求了走lessCallback
+ 			else {
+ 				lessCallback()
+ 			}
+ 		}
+ 	})
+ }
+
+ //将图片画在画布上并获取画好之后的图片的路径
+ function getCanvasImage(canvasId, imagePath, imageW, imageH, getImgSuccess) {
+ 	//创建画布内容
+ 	const ctx = wx.createCanvasContext(canvasId);
+ 	//图片画上去,imageW和imageH是画上去的尺寸,图像和画布间隔都是0
+ 	ctx.drawImage(imagePath, 0, 0, imageW, imageH);
+ 	//这里一定要加定时器,给足够的时间去画(所以每次递归最少要耗时200ms,多次递归很耗时!)
+ 	ctx.draw(false, setTimeout(function() {
+ 		//把当前画布指定区域的内容导出生成指定大小的图片,并返回文件路径
+ 		wx.canvasToTempFilePath({
+ 			canvasId: canvasId,
+ 			x: 0,
+ 			y: 0,
+ 			width: imageW,
+ 			height: imageH,
+ 			quality: 1, //最高质量
+ 			success: (res) => {
+ 				//将取出的图片路径通过回调函数返回
+ 				getImgSuccess(res.tempFilePath);
+ 			}
+ 		})
+ 	}, 200));
+ }
+
+ //主函数,默认限制大小1024kb即1mb,drawWidth是绘画区域的大小
+ //初始值传入为画布自身的边长(我们这是一个正方形的画布)
+ function getLessLimitSizeImage(canvasId, imagePath, limitSize = 1024, drawWidth, callback) {
+ 	//判断图片尺寸是否满足要求
+ 	imageSizeIsLessLimitSize(imagePath, limitSize,
+ 		(lessRes) => {
+ 			//满足要求走callback,将压缩后的文件路径返回
+ 			callback(imagePath);
+ 		},
+ 		(moreRes) => {
+ 			//不满足要求需要压缩的时候
+ 			wx.getImageInfo({
+ 				src: imagePath,
+ 				success: (imageInfo) => {
+ 					let maxSide = Math.max(imageInfo.width, imageInfo.height);
+ 					let windowW = drawWidth;
+ 					let scale = 1;
+ 					/*
+ 					这里的目的是当绘画区域缩小的比图片自身尺寸还要小的时候
+ 					取图片长宽的最大值,然后和当前绘画区域计算出需要放缩的比例
+ 					然后再画经过放缩后的尺寸,保证画出的一定是一个完整的图片。由于每次递归绘画区域都会缩小,
+ 					所以不用担心scale永远都是1绘画尺寸永远不变的情况,只要不满足压缩后体积的要求
+ 					就会缩小绘画区域,早晚会有绘画区域小于图片尺寸的情况发生
+ 					*/
+ 					if (maxSide > windowW) {
+ 						scale = windowW / maxSide;
+ 					}
+ 					//trunc是去掉小数
+ 					let imageW = Math.trunc(imageInfo.width * scale);
+ 					let imageH = Math.trunc(imageInfo.height * scale);
+ 					// console.log('调用压缩', imageW, imageH);
+ 					//图片在规定绘画区域上画并获取新的图片的path
+ 					getCanvasImage(canvasId, imagePath, imageW, imageH,
+ 						(pressImgPath) => {
+ 							/*
+ 							再去检查是否满足要求,始终缩小绘画区域,让图片适配绘画区域
+ 							这里乘以0.95是必须的,如果不缩小绘画区域,会出现尺寸比绘画区域小,
+ 							而体积比要求压缩体积大的情况出现,就会无穷递归下去,因为scale的值永远是1
+ 							但0.95不是固定的,你可以根据需要自己改,0到1之间,越小则绘画区域缩小的越快
+ 							但不建议取得太小,绘画区域缩小的太快,压出来的将总是很糊的
+ 							*/
+ 							getLessLimitSizeImage(canvasId, pressImgPath, limitSize, drawWidth *
+ 								0.95, callback);
+ 						}
+ 					)
+ 				}
+ 			})
+ 		}
+ 	)
+ }
+
+ export default getLessLimitSizeImage