ソースを参照

微信文件打印, 区分图片/文件

“shengjie.huang” 1 年間 前
コミット
425d4a7779

+ 31 - 5
src/pages/index/index.vue

@@ -42,12 +42,13 @@
       <!-- 补充入口 -->
       <view class="content">
         <view class="section">
-          <view class="item" @click="toConnect()">
-            <view class="title">
-              <wd-img :src="connectSrc" width="40" mode="widthFix"></wd-img>
-              <view class="title-text">设备配网</view>
+          <view class="item">
+            <view class="title" @click="toPrint('wxImg')">
+              <wd-img :src="wechatFileSrc" width="40" mode="widthFix"></wd-img>
+              <view class="title-text">微信图片</view>
             </view>
           </view>
+          <!-- msg -->
           <view class="item" @click="toPrint('image')">
             <view class="title">
               <wd-img :src="pictureSrc" width="40" mode="widthFix"></wd-img>
@@ -55,7 +56,7 @@
             </view>
           </view>
           <view class="item">
-            <view class="title" @click="toPrint('msg')">
+            <view class="title" @click="toPrint('wxFile')">
               <wd-img :src="wechatFileSrc" width="40" mode="widthFix"></wd-img>
               <view class="title-text">微信文件</view>
             </view>
@@ -66,6 +67,18 @@
               <view class="title-text">微信发票</view>
             </view>
           </view>
+          <view class="item" @click="toConnect()">
+            <view class="title">
+              <wd-img :src="connectSrc" width="40" mode="widthFix"></wd-img>
+              <view class="title-text">设备配网</view>
+            </view>
+          </view>
+          <view class="item" @click="toJob()">
+            <view class="title">
+              <wd-img :src="historySrc" width="40" mode="widthFix"></wd-img>
+              <view class="title-text">打印任务</view>
+            </view>
+          </view>
           <!-- <view class="item">
             <view class="title">
               <image :src="settingSrc"></image>
@@ -111,6 +124,8 @@ const connectSrc = ref('/static/images/connect.png')
 const pictureSrc = ref('/static/images/picture.png')
 const wechatFileSrc = ref('/static/images/wechat_file.png')
 const wechatInvoiceSrc = ref('/static/images/wechat_invoice.png')
+const historySrc = ref('/static/images/history.png')
+const shareSrc = ref('/static/images/share.png')
 const swiperList = ref([])
 const current = ref(0)
 
@@ -162,6 +177,17 @@ function toConnect() {
   })
 }
 
+function toJob() {
+  if (isLogined.value) {
+    uni.navigateTo({
+      url: `/pages/print/job`,
+    })
+  } else {
+    toast.warning('请先前往登录')
+    toLogin(1500)
+  }
+}
+
 onLoad((option: any) => {
   initSwiperList()
 })

+ 30 - 3
src/pages/print/index.vue

@@ -349,12 +349,39 @@ function getFileIcon(fileName) {
 // 处理选择文件
 function selectFile() {
   switch(accept.value) {
-    case "msg":
+    case "wxImg":
       uni.chooseMessageFile({
         count: 10,
-        type: "all",
+        type: "image",
         success (res) {
-          console.log('chooseMessageFile res: ', res);
+          console.log('chooseMessageFile IMG res: ', res);
+          if (res.errMsg == "chooseMessageFile:ok") {
+            let failList = []
+            res.tempFiles.forEach(item => {
+              if (item.size > maxSize || !allowType.includes(getFileType(item.name))) {
+                failList.push(item)
+              } else {
+                fileList.value.push({
+                  name: item.name,
+                  filePath: item.path,
+                })
+                handleFileListChange()
+              }
+            })
+            if (failList.length > 0) toast.warning(`文件大小限制为10MB, 文件格式仅支持 ${allowType.join('、')}, 所选文件有 ${failList.length} 格式不符合`)
+          }
+        },
+        fail () {
+          toast.warning("选择微信图片失败, 请重试")
+        }
+      })
+      break;
+    case "wxFile":
+      uni.chooseMessageFile({
+        count: 10,
+        type: "file",
+        success (res) {
+          console.log('chooseMessageFile FILE res: ', res);
           if (res.errMsg == "chooseMessageFile:ok") {
             let failList = []
             res.tempFiles.forEach(item => {

BIN
src/static/images/history.png


BIN
src/static/images/setting.png


BIN
src/static/images/share.png