Browse Source

越改越多……

shaogen1995 5 months ago
parent
commit
d37a763634

+ 28 - 8
后台管理/src/components/ZupOne/index.tsx

@@ -18,7 +18,14 @@ import { API_upFile } from '@/store/action/layout'
 import { forwardRef, useImperativeHandle } from 'react'
 import MyPopconfirm from '../MyPopconfirm'
 
-type MyTypeType = 'thumb' | 'video' | 'audio' | 'model' | 'pdf' | 'epub'
+type MyTypeType =
+  | 'thumb'
+  | 'video'
+  | 'audio'
+  | 'model'
+  | 'pdf'
+  | 'epub'
+  | 'pdf、doc、docx'
 
 // 这个组件 只处理 上传 一张图片或者 视频 音频 模型 pdf 的情况
 
@@ -72,8 +79,12 @@ function ZupOne(
 
         // 校验格式
         const type = format
-
-        if (myType === 'pdf') {
+        if (myType === 'pdf、doc、docx') {
+          if (!filesInfo.type.includes('pdf') && !filesInfo.type.includes('doc')) {
+            e.target.value = ''
+            return MessageFu.warning(`只支持${formatTxt}格式!`)
+          }
+        } else if (myType === 'pdf') {
           if (!filesInfo.type.includes('pdf')) {
             e.target.value = ''
             return MessageFu.warning(`只支持${formatTxt}格式!`)
@@ -99,7 +110,7 @@ function ZupOne(
         const fd = new FormData()
         // 把files添加进FormData对象(‘photo’为后端需要的字段)
         let myTypeRes: string = myType
-        if (['pdf', 'epub'].includes(myTypeRes)) myTypeRes = 'doc'
+        if (['pdf', 'epub', 'pdf、doc、docx'].includes(myTypeRes)) myTypeRes = 'doc'
         fd.append('type', myTypeRes)
         fd.append('dirCode', dirCode)
         fd.append('file', filesInfo)
@@ -153,7 +164,8 @@ function ZupOne(
 
   const acceptRes = useMemo(() => {
     let accept = '.png,.jpg,.jpeg'
-    if (myType === 'video') accept = '.mp4'
+    if (myType === 'pdf、doc、docx') accept = '.pdf,.doc,.docx'
+    else if (myType === 'video') accept = '.mp4'
     else if (myType === 'audio') accept = '.mp3'
     else if (myType === 'model') accept = '.4dage'
     else if (myType === 'pdf') accept = '.pdf'
@@ -164,7 +176,7 @@ function ZupOne(
   // 点击 预览(除了图片)
   const lookFileNoImgFu = useCallback(
     (type: MyTypeType) => {
-      if (type === 'pdf' || type === 'thumb') {
+      if (type === 'pdf' || type === 'thumb' || type === 'pdf、doc、docx') {
         // 新窗口打开
         window.open(baseURL + fileUrl.filePath)
       } else if (type !== 'epub') {
@@ -241,7 +253,12 @@ function ZupOne(
               }
               rev={undefined}
             />
-            <a href={baseURL + fileUrl.filePath} download target='_blank' rel='noreferrer'>
+            <a
+              href={baseURL + fileUrl.filePath}
+              download
+              target='_blank'
+              rel='noreferrer'
+            >
               <DownloadOutlined rev={undefined} />
             </a>
           </div>
@@ -283,7 +300,10 @@ function ZupOne(
         格式要求:支持{formatTxt}格式;最大支持{size}M。{upTxt}
         <br />
         <div
-          className={classNames('noUpThumb', !fileUrl.filePath && fileCheck ? 'noUpThumbAc' : '')}
+          className={classNames(
+            'noUpThumb',
+            !fileUrl.filePath && fileCheck ? 'noUpThumbAc' : ''
+          )}
         >
           {checkTxt}
         </div>

+ 3 - 3
后台管理/src/pages/A2orderSet/A2template.tsx

@@ -75,10 +75,10 @@ function A2template({ closeFu, type }: Props) {
             dirCode='A2templatePDF'
             myUrl='cms/book/upload'
             format={['application/pdf']}
-            formatTxt='pdf'
-            checkTxt='请上传pdf附件!'
+            formatTxt='pdf、doc、docx'
+            checkTxt='请上传pdf、doc、docx附件!'
             upTxt='最多1个'
-            myType='pdf'
+            myType='pdf、doc、docx'
             otherArr={[{ key: 'moduleName', value: 'config' }]}
           />
         </div>

+ 3 - 0
后台管理/src/pages/A2orderSet/index.module.scss

@@ -125,6 +125,9 @@
     .ant-modal-close {
       display: none;
     }
+    .ant-modal {
+      width: 700px !important;
+    }
 
     .formRow {
       display: flex;

+ 6 - 0
小程序入口_嵌套展示端/.vscode/settings.json

@@ -0,0 +1,6 @@
+{
+  "files.associations": {
+    "*.wxml": "html",
+    "*.wxss": "css"
+  }
+}

+ 6 - 0
小程序入口_嵌套展示端/jsconfig.json

@@ -0,0 +1,6 @@
+{
+	"compilerOptions": {
+		"target": "es2015",
+		"module": "commonjs"
+	}	
+}

+ 6 - 1
小程序入口_嵌套展示端/pages/download/index.js

@@ -49,6 +49,11 @@ Page({
       let that = this;
       console.log('--------url路径', decodeURI(o.url));
       const url = decodeURI(o.url)
+
+      // 拿到后缀
+      const fiLeHouZuiArr =url.split('.')
+      const fiLeHouZui =fiLeHouZuiArr[fiLeHouZuiArr.length-1]
+
       wx.downloadFile({
         url,
         success(res) {
@@ -56,7 +61,7 @@ Page({
             // 临时存储路径,先有临时存储路径方可使用wx官方的存储本地路径( wx.env.USER_DATA_PATH )
             tempFilePath: res.tempFilePath,
             //定义本地的存储路径及名称
-            filePath: wx.env.USER_DATA_PATH + '/' + Date.now() + '.pdf',
+            filePath: wx.env.USER_DATA_PATH + '/' + Date.now() + '.'+fiLeHouZui,
             success(res) {
               // console.log('pppppp', res);
               const savedFilePath = res.savedFilePath;

File diff suppressed because it is too large
+ 2705 - 0
小程序入口_嵌套展示端/typings/wx.d.ts