瀏覽代碼

1

dev_YWQ
congzc 1 年之前
父節點
當前提交
21af1eb30d
共有 9 個檔案被更改,包括 211 行新增11 行删除
  1. +3
    -1
      README.md
  2. +26
    -0
      src/api/createing.js
  3. +2
    -2
      src/pages/camera/index.vue
  4. +2
    -4
      src/pages/chooseStyle/index.vue
  5. +145
    -2
      src/pages/createing/index.vue
  6. +27
    -1
      src/pages/login/index.vue
  7. +1
    -0
      src/style/my.scss
  8. +4
    -1
      src/utils/request.js
  9. +1
    -0
      vite.config.js

+ 3
- 1
README.md 查看文件

@@ -1,7 +1,9 @@
# Suimang-wxapp

# setStorageSync 键名

SN --设备识别码
token --token
UserId --扫码登录后获取的用户id


wx-"appid": "",


+ 26
- 0
src/api/createing.js 查看文件

@@ -0,0 +1,26 @@
import { request } from "../utils/request"

/**
* @description:获取二维码
* @param {*} (appId, openId,phone,code)
* @return: list
*/
export function getQRCodeApi(data) {
return request({
url: `api/machineqrcode/getQRCode`,
method: 'POST',
data
})
}

/**
* @description:获取用户状态
* @param {*} (appId, openId,phone,code)
* @return: list
*/
export function getUserApi(UserId) {
return request({
url: `api/machineuser/getUser?tmpUserId=${UserId}`,
method: 'get',
})
}

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

@@ -57,8 +57,8 @@ onMounted(() => {
// height: 1536, //实时摄像机查看器的高度
width: 864, //实时摄像机查看器的宽度
height: 1536, //实时摄像机查看器的高度
dest_width: 392, //捕获相机图像的宽
dest_height: 698, //捕获相机图像的高
// dest_width: 392, //捕获相机图像的宽
// dest_height: 698, //捕获相机图像的高
dest_width: 720, //捕获相机图像的宽
dest_height: 720, //捕获相机图像的高
// crop_width: 700, //最终裁剪图像的宽度(以像素为单位),默认为dest_width。


+ 2
- 4
src/pages/chooseStyle/index.vue 查看文件

@@ -13,7 +13,7 @@
></u-tabs>
<view class="moreTabs">
<!-- <view class="moreIcon" @click="showPopup = true"> 更多 </view> -->
<view class="moreIcon" @click="toCreated"> 更多 </view>
<view class="moreIcon" @click="showPopup = true"> 更多 </view>
</view>
</view>
<!-- 更多tab弹出层 -->
@@ -54,7 +54,6 @@
</u-popup>
<!-- 模版选择 -->
<u-list
v-show="false"
class="styleListBox"
@scrolltolower="scrolltolower"
lowerThreshold="100"
@@ -112,7 +111,7 @@ function closePopup() {
}
function openPopup() {}
function toCreated() {
uni.navigateTo({ url: "/pages/camera/index" });
// uni.navigateTo({ url: "/pages/createing/index" });
}
//#endregion -----------------------

@@ -123,7 +122,6 @@ const pageSize = ref(20);
const styleList = ref([]);
// 得到列表
async function getList() {
return;
try {
uni.showLoading({
title: "加载中...",


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

@@ -11,18 +11,35 @@
<view class="orangeBtn" @click="createing(styleData.id)"
>开始制作写真
</view>
<view class="orangeBtn" @click="toCamera" style="margin-top: 10rpx"
>摄像头调试
</view>
<!-- 登录二维码弹出层 -->
<u-overlay
class="overlay"
:show="showQrCode"
@click="showQrCode = false"
opacity="0.9"
>
<view class="content">
<image :src="qrCode" mode="scaleToFill" />
<text>打开微信扫码登录小程序</text>
<view class="orangeBtn">取&nbsp;消</view>
</view>
</u-overlay>
</view>
</template>

<script setup>
//#region 导入
import { ref } from "vue";
import { onLoad, onShow } from "@dcloudio/uni-app";
import { ref, watch } from "vue";
import { onLoad, onShow, onUnload } from "@dcloudio/uni-app";
import {
findByIdApi,
findImageApi,
createPhotoApi,
} from "../../api/closeStyle";
import { getQRCodeApi, getUserApi } from "../../api/createing";
//#endregion

//#region 初始化
@@ -52,6 +69,11 @@ async function getInfo() {

//#region 生成写真照片
async function createing(id) {
if (!uni.getStorageSync("token")) {
showQrCode.value = true;
}
const userAgent = navigator.userAgent;
console.log("User Agent:", userAgent);
return;
try {
uni.showLoading({
@@ -83,6 +105,101 @@ async function createing(id) {
}
//#endregion ---------------------

//#region 获取二维码
const qrCode = ref(null); //二维码路径
const showQrCode = ref(false);
async function getQRCode() {
uni.showLoading({
title: "加载中",
mask: true,
});
try {
const data = {
sn: "112233",
type: 1,
};
const res = await getQRCodeApi(data);
uni.hideLoading();
if (res.code == 1013) {
uni.showToast({
title: "操作频繁,请稍等....",
icon: "none",
mask: true,
duration: 3000,
});
setTimeout(() => {
getQRCode();
}, 3000);
return;
}
if (res.data && res.data.tmpUserId) {
uni.setStorageSync("UserId", res.data.tmpUserId);
qrCode.value = res.data.qrCodeUrl;
} else if (res.code == 1013) {
uni.showToast({
title: "请勿重复操作",
icon: "error",
mask: true,
});
}
} catch (err) {
console.log(err);
uni.hideLoading();
uni.showToast({
title: "获取登录失败,请刷新页面重试",
icon: "error",
mask: true,
});
}
}
// getQRCode();
//#endregion ---------------------

//#region 获取用户信息
const timer = ref(null);
async function getUser() {
try {
const res = await getUserApi(uni.getStorageSync("UserId"));
if (res.code == 200) {
clearInterval(timer.value);
timer.value = null;
}
} catch (err) {
console.log(err);
}
}
// 监听二维码弹窗显示隐藏
watch(
() => showQrCode.value,
() => {
if (showQrCode.value == true) {
getQRCode();
timer.value = setInterval(() => {
if (uni.getStorageSync("UserId") && qrCode.value) {
getUser();
}
}, 3000);
} else if (showQrCode.value == false) {
// uni.setStorageSync("UserId", null);
qrCode.value = null;
clearInterval(timer.value);
timer.value = null;
}
}
);
onUnload(() => {
clearInterval(timer.value);
timer.value = null;
// uni.setStorageSync("UserId", null);
});
//#endregion ---------------------

//#region
function toCamera() {
uni.navigateTo({ url: "/pages/camera/index" });
}
//#endregion ---------------------

//#region

//#endregion ---------------------
@@ -123,4 +240,30 @@ async function createing(id) {
text-align: center;
}
}
.overlay {
.content {
width: 100%;
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
image {
margin-top: 200rpx;
padding: 30rpx;
width: 500rpx;
height: 500rpx;
border-radius: 30rpx;
background-color: #fff;
}
text {
margin-top: 20rpx;
font-weight: 900;
font-size: 32rpx;
}
.orangeBtn {
margin-top: 100rpx;
}
}
}
</style>

+ 27
- 1
src/pages/login/index.vue 查看文件

@@ -3,9 +3,11 @@
<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>
</view>
</template>

<script setup>
//#region 导入
import { ref } from "vue";
@@ -19,7 +21,21 @@ function toChooseStyle() {

//#endregion ----------------------------------

//#region 授权
//#region getImei
function Imei() {
getIMEI();
// cordova.exec(
// function (imei) {
// console.log("IMEI:", imei);
// },
// function (error) {
// console.error("Failed to get IMEI:", error);
// },
// "MyPlugin",
// "getIMEI",
// []
// );
}

//#endregion ----------------------------------

@@ -27,6 +43,7 @@ function toChooseStyle() {

//#endregion ----------------------------------
</script>

<style lang="scss" scoped>
.page {
padding: 0;
@@ -48,6 +65,15 @@ function toChooseStyle() {
width: 100%;
height: 400rpx;
background-color: rgba($color: #000000, $alpha: 0.5);
.IMEI {
position: absolute;
bottom: 20rpx;
right: 20rpx;
width: 40rpx;
height: 40rpx;
line-height: 40rpx;
text-align: center;
}
}
}
</style>

+ 1
- 0
src/style/my.scss 查看文件

@@ -76,6 +76,7 @@ view {
.uni-toast {
width: 280rpx;
font-size: 30rpx;
padding: 20rpx 30rpx;

.uni-toast__icon {
width: 50rpx !important;


+ 4
- 1
src/utils/request.js 查看文件

@@ -1,7 +1,10 @@

// import { userInfoModules } from "@/store/modules/userInfo";
// import { store } from '@/store/index';
const BASE_URL = 'https://test.metavatar.cc/C/';

// const BASE_URL = 'https://test.metavatar.cc/C/';
const BASE_URL = 'https://zhixiangtest.malls.iformall.com/C/';
// const BASE_URL = '192.168.1.105:7600/C/';

// const userInfoModulesPinia = userInfoModules(store);
// const BASE_URL = 'https://test.metavatar.cc/';


+ 1
- 0
vite.config.js 查看文件

@@ -20,6 +20,7 @@ export default defineConfig(({ command, mode }) => {
// 反向代理解决跨域
"/api": {
target: env.VITE_APP_BASE_URL, // 线上接口地址
// target: "https://zhixiangtest.malls.iformall.com/C", // 线上接口地址
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ""),
},


Loading…
取消
儲存