weirenchun 1 年之前
父節點
當前提交
ca53a2f2e8
共有 1 個文件被更改,包括 14 次插入7 次删除
  1. 14 7
      src/pages/home/takePhoto.vue

+ 14 - 7
src/pages/home/takePhoto.vue

@@ -8,10 +8,7 @@
         name="stop-circle-o"
         @click="record"
       />
-
-      <van-uploader :max-count="1" accept="image" @after-read="getImage">
-        <a class="a-xc">相册</a>
-      </van-uploader>
+      <a class="a-xc" @click="navToalbum">相册</a>
     </div>
   </div>
 </template>
@@ -30,9 +27,19 @@ export default {
         },
       });
     },
-    getImage(event) {
-      console.log("选择的相片信息:" + event.detail.file.url);
-      this.$navigator.push("detail?file=" + event.detail.file.url);
+
+    //打开相册选取
+    navToalbum() {
+      var that = this;
+      wx.chooseImage({
+        count: 1,
+        sizeType: ["original", "compressed"],
+        sourceType: ["album"],
+        success(res) {
+          console.log("所选相片路径:" + res.tempFilePaths);
+          that.$navigator.push("detail?file=" + res.tempFilePaths);
+        },
+      });
     },
   },
 };