Kaynağa Gözat

upload

dev_YWQ
HolyKnightIX 1 yıl önce
ebeveyn
işleme
6d2f991045
2 değiştirilmiş dosya ile 29 ekleme ve 12 silme
  1. +7
    -9
      src/api/camera.js
  2. +22
    -3
      src/pages/camera/index.vue

+ 7
- 9
src/api/camera.js Dosyayı Görüntüle

@@ -15,17 +15,15 @@ export function getImageQrcode(machineQrcodeId) {
})
}

/**
* @description:生成画报
* @param {appId,img}
* @return: data
/**
* @description:轮询-获取扫码上传照片
* @param id
* @return: imgUrl
*/
export function getUserQrcodeApi(data) {
export function findImage(id) {
return request({
url: `/api/miniApp/getUserQrcode`,
method: 'POST',
responseType: "arraybuffer",
data
url: `/api/screenImg/findImage?id=${id}`,
method: 'get'
})
}


+ 22
- 3
src/pages/camera/index.vue Dosyayı Görüntüle

@@ -67,7 +67,7 @@
<view class="imageBox">
<image :src="QRCodeUrl" mode="scaleToFill" />
</view>
<text>打开微信扫码登录小程序</text>
<text>打开微信扫码上传照片</text>
<view class="orangeBtn" style="margin-top: 100rpx">取&nbsp;消</view>
</view>
</u-overlay>
@@ -78,7 +78,7 @@
import { ref, onMounted } from "vue";
import { onLoad, onShow, onUnload } from "@dcloudio/uni-app";

import { getImageQrcode } from "../../api/camera.js";
import { getImageQrcode, findImage } from "../../api/camera.js";

let imgSrc = ref("");
let isSuccess = ref(false);
@@ -88,6 +88,8 @@ let modelUrl = ref("");
let QRCodeUrl = ref("");
let showQrCode = ref(false);

let timer = ref(null);

const startCamera = () => {
function getUserMedia(constraints, success, error) {
if (navigator.mediaDevices.getUserMedia) {
@@ -184,8 +186,10 @@ const takePicture = () => {
console.log("Take Picture !");
};

// 确认照片
const confirmPhoto = () => {};

// 不满意,重新拍一张
const reTry = () => {
isSuccess.value = false;
isShowCanvas.value = true;
@@ -202,6 +206,21 @@ const uploadImg = async () => {
const res = await getImageQrcode(UserId);
QRCodeUrl.value = res.data.wxQrcode;
showQrCode.value = true;

// 成功展示二维码之后,轮询获取上传照片状态
timer.value = setInterval(() => {
refreshUploadStatus(UserId);
}, 1000);
console.log(res, "res");
} catch (error) {
console.log(error, "error");
}
};

// 刷新状态,直到返回用户上传的图片url
const refreshUploadStatus = async (id) => {
try {
const res = await findImage(id);
console.log(res, "res");
} catch (error) {
console.log(error, "error");
@@ -215,7 +234,7 @@ onLoad((options) => {

onMounted(() => {
console.log(this);
clearInterval(timer.value);
startCamera();
});
</script>


Yükleniyor…
İptal
Kaydet