瀏覽代碼

1

dev_czc
congzc 1 年之前
父節點
當前提交
62e99e0896
共有 6 個檔案被更改,包括 139 行新增47 行删除
  1. +1
    -0
      README.md
  2. +6
    -0
      index.html
  3. 二進制
      src/assets/img/c867236efb4fc5707257ef8daf26db4.png
  4. +101
    -40
      src/pages/camera/index.vue
  5. +2
    -1
      src/pages/createing/index.vue
  6. +29
    -6
      src/pages/login/index.vue

+ 1
- 0
README.md 查看文件

@@ -3,6 +3,7 @@
# setStorageSync 键名

SN --设备识别码
androidId --安卓识别码
token --token
UserId --扫码登录后获取的用户id
createTimes --用户剩余生成次数


+ 6
- 0
index.html 查看文件

@@ -13,6 +13,12 @@
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
(coverSupport ? ', viewport-fit=cover' : '') + '" />')
</script>
<script>
function androidCallback(name, result_str) {
window.localStorage.setItem('androidIdByWindow', result_str)
// alert("callBack " + name + " : " + result_str + "\n");
}
</script>
<title></title>
<!--preload-links-->
<!--app-context-->


二進制
src/assets/img/c867236efb4fc5707257ef8daf26db4.png 查看文件

Before After
Width: 2400  |  Height: 2200  |  Size: 1.8 MiB

+ 101
- 40
src/pages/camera/index.vue 查看文件

@@ -7,6 +7,7 @@
muted
autoplay="autoplay"
:controls="false"
:enable-progress-gesture="false"
></video>

<div v-if="!isSuccess">
@@ -27,8 +28,12 @@
</div>

<div class="confirm" @click="confirmPhoto">
<img src="../../assets/img/success.png" />
<div class="uploadText">就这张了</div>
<!-- <img src="../../assets/img/success.png" /> -->
<div class="sure">确定</div>

<div class="uploadText">
就这张了 <img src="../../assets/img/success.png" />
</div>
</div>

<div class="reTry" @click="reTry">
@@ -51,7 +56,7 @@

<div class="top">
<div class="example">
<div>文案与模板提示区域</div>
<img src="../../assets/img/c867236efb4fc5707257ef8daf26db4.png" />
</div>
<div class="model" @click="goSelectModel">
<img :src="modelUrl" alt="" />
@@ -104,8 +109,12 @@ const startCamera = () => {
audio: false,
video: {
facingMode: "user",
width: 240,
height: 350,
// width: 1000,
// height: 1000,
width: 1080,
height: 1305,
// width: 2100,
// height: 2100,
},
})
.then(success)
@@ -152,7 +161,15 @@ const startCamera = () => {
getUserMedia(
{
audio: false,
video: true,
video: {
facingMode: "user",
// width: 240,
// height: 450,
width: 1080,
height: 1305,
// width: 2100,
// height: 2100,
},
},
success,
error
@@ -179,10 +196,12 @@ const startCamera = () => {

setTimeout(() => {
uni.hideLoading();
canvas.width = 1530;
canvas.height = 950;
// canvas.width = 1530;
// canvas.height = 950;
canvas.width = 2400;
canvas.height = 2400;
context.drawImage(video, 0, 0);
const dataURL = canvas.toDataURL("image/png");
let dataURL = canvas.toDataURL("image/png");
CimgSrc.value = dataURL;
UimgSrc.value = "";
setTimeout(() => {
@@ -221,24 +240,36 @@ const goSelectModel = () => {

// 确认照片
const confirmPhoto = () => {
// 用户上传的照片,已通过校验,直接放行
if (UimgSrc.value) {
uni.navigateTo({
url: `/pages/createing/index?imageUrl=${UimgSrc.value}&id=${modelId.value}`,
});
} else if (CimgSrc.value) {
// 本地存储中的拍照照片
const CimageUrl = uni.getStorageSync("CcurrentUrl");
// 用户上一次使用相机拍照的照片,从本地回显,已通过校验,直接放行
if (CimageUrl) {
// alert("点击确定");
// alert(UimgSrc.value, "UimgSrc.value");
// alert(CimgSrc.value, "CimgSrc.value");
try {
if (UimgSrc.value) {
uni.navigateTo({
url: `/pages/createing/index?imageUrl=${CimgSrc.value}&id=${modelId.value}`,
url: `/pages/createing/index?imageUrl=${UimgSrc.value}&id=${modelId.value}`,
});
// 用户使用相机拍照的照片,未校验,走完校验流程放行
} else {
} else if (CimgSrc.value) {
// 本地存储中的拍照照片
// alert(uni.getStorageSync("CcurrentUrl"), "CcurrentUrl");
// // let CimageUrl = uni.getStorageSync("CcurrentUrl");
// // 用户上一次使用相机拍照的照片,从本地回显,已通过校验,直接放行
// if (uni.getStorageSync("CcurrentUrl")) {
// uni.navigateTo({
// url: `/pages/createing/index?imageUrl=${CimgSrc.value}&id=${modelId.value}`,
// });
// // 用户使用相机拍照的照片,未校验,走完校验流程放行
// } else {
// }
dealImage(CimgSrc.value);
}
} catch (e) {
uni.showToast({
title: e,
icon: "success",
mask: true,
});
}
// 用户上传的照片,已通过校验,直接放行
};

const dealImage = (imageUrl) => {
@@ -507,12 +538,16 @@ onUnload(() => {
.top {
display: flex;
width: 100%;
height: 25%;
height: 32%;
.example {
width: 60%;
height: 100%;
color: #000;
background-color: #fff;
img {
width: 100%;
height: 100%;
}
}
.model {
position: relative;
@@ -540,12 +575,21 @@ onUnload(() => {
.bottom {
position: relative;
width: 100%;
height: 75%;
height: 68%;
overflow: hidden;
video {
width: 100%;
height: 100%;
// width: 1080px;
// height: 1305px;
:deep(.uni-video-video) {
position: absolute;
left: 0;
top: -50px;
width: 100% !important;
height: 720px !important;
}
}

.selectImg {
position: absolute;
left: 65rpx;
@@ -600,27 +644,44 @@ onUnload(() => {
position: absolute;
left: 50%;
bottom: 75rpx;
width: 80rpx;
width: 180rpx;
height: 80rpx;
// border: 5rpx solid #ffffff;
transform: translateX(-50%);
border-radius: 60rpx;
z-index: 99;
z-index: 9999999;
img {
position: absolute;
left: 50%;
bottom: 50%;
transform: translate(-50%, 50%);
// position: absolute;
// left: 50%;
// bottom: 50%;
// transform: translate(-50%, 50%);
width: 100%;
height: 100%;
width: 30rpx;
height: 30rpx;
vertical-align: text-top;
}
.sure {
margin-top: 30rpx;
text-align: center;
width: 100%;
height: 50rpx;
line-height: 50rpx;
background-color: #2ba245;
border-radius: 15rpx;
}
.uploadText {
position: absolute;
left: 50%;
bottom: -40rpx;
width: 150%;
// position: absolute;
// left: 50%;
// bottom: -40rpx;
// width: 150%;

width: 100%;
height: 30rpx;
line-height: 30rpx;
font-size: 20rpx;
transform: translateX(-32%);
// transform: translateX(-32%);
text-align: center;
}
}

@@ -657,10 +718,10 @@ onUnload(() => {
height: 100%;
z-index: 1;
.fromCamera {
position: absolute;
top: 110rpx;
left: 130rpx;
width: 200%;
// position: absolute;
// top: 110rpx;
// left: 130rpx;
width: 100%;
}
.fromUpload {
position: absolute;


+ 2
- 1
src/pages/createing/index.vue 查看文件

@@ -175,8 +175,9 @@ async function getQRCode() {
});
try {
const data = {
sn: "112233",
// sn: "112233",
// sn: window.android.getIMEI(),
sn: window.localStorage.getItem("androidIdByWindow"),
type: 1,
};
const res = await getQRCodeApi(data);


+ 29
- 6
src/pages/login/index.vue 查看文件

@@ -3,7 +3,9 @@
<image src="../../assets/img/homeImg.jpg" mode="scaleToFill" />
<view class="bottomBox">
<view class="orangeBtn" @click="toChooseStyle">拍摄数码写真</view>
<view class="IMEI" @click="Imei">i</view>
<view class="IMEI" @click="Imei">1.0.5i</view>
<view style="margin-top: 20rpx" @click="reFresh">刷新</view>
<view style="margin-top: 20rpx" @click="runGetAndroidId()">获取</view>
</view>
</view>
</template>
@@ -11,6 +13,7 @@
<script setup>
//#region 导入
import { ref } from "vue";
import { onLoad, onUnload } from "@dcloudio/uni-app";
//#endregion ----------------------------------

function toChooseStyle() {
@@ -18,20 +21,25 @@ function toChooseStyle() {
}

//#region 初始化

onLoad(() => {
runGetAndroidId();
});
//#endregion ----------------------------------

//#region getImei
//#region app交互
const IMEI = ref(null);
function Imei() {
try {
const IMEI = window.webview.raiseEvent("getIMEI", "test_params");
runGetAndroidId();
// window.webview.raiseEvent("getSerial", "test_params");
// window.webview.raiseEvent("getTestStr", "test_params");
// const IMEI = window.android.getIMEI();
// const IMEI = window.android.getSerial();
// const IMEI = window.android.getTestStr();

uni.showToast({
title: IMEI,
// title: uni.getStorageSync("androidId"),
title: window.localStorage.getItem("androidIdByWindow"),
icon: "success",
});
} catch (error) {
@@ -53,7 +61,22 @@ function Imei() {
// []
// );
}
function runGetAndroidId() {
window.webview.raiseEvent("getAndroidId", "test_params");
// alert("获取成功");
}
// function androidCallback(name, result_str) {
// IMEI.value = result_str;
// alert(result_str);
// alert("callBack " + name + " : " + result_str + "\n");
// // document.getElementById("text").value +=
// }

function reFresh() {
console.log("刷新");
window.webview.raiseEvent("pageRefresh", "test_params"); //刷新页面
// alert("刷新成功");
}
//#endregion ----------------------------------

//#region 登录
@@ -85,7 +108,7 @@ function Imei() {
.IMEI {
position: absolute;
bottom: 20rpx;
right: 20rpx;
right: 30rpx;
width: 40rpx;
height: 40rpx;
line-height: 40rpx;


Loading…
取消
儲存