@@ -1,7 +1,9 @@ | |||||
# Suimang-wxapp | # Suimang-wxapp | ||||
# setStorageSync 键名 | # setStorageSync 键名 | ||||
SN --设备识别码 | |||||
token --token | |||||
UserId --扫码登录后获取的用户id | |||||
wx-"appid": "", | wx-"appid": "", | ||||
@@ -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', | |||||
}) | |||||
} |
@@ -57,8 +57,8 @@ onMounted(() => { | |||||
// height: 1536, //实时摄像机查看器的高度 | // height: 1536, //实时摄像机查看器的高度 | ||||
width: 864, //实时摄像机查看器的宽度 | width: 864, //实时摄像机查看器的宽度 | ||||
height: 1536, //实时摄像机查看器的高度 | height: 1536, //实时摄像机查看器的高度 | ||||
dest_width: 392, //捕获相机图像的宽 | |||||
dest_height: 698, //捕获相机图像的高 | |||||
// dest_width: 392, //捕获相机图像的宽 | |||||
// dest_height: 698, //捕获相机图像的高 | |||||
dest_width: 720, //捕获相机图像的宽 | dest_width: 720, //捕获相机图像的宽 | ||||
dest_height: 720, //捕获相机图像的高 | dest_height: 720, //捕获相机图像的高 | ||||
// crop_width: 700, //最终裁剪图像的宽度(以像素为单位),默认为dest_width。 | // crop_width: 700, //最终裁剪图像的宽度(以像素为单位),默认为dest_width。 | ||||
@@ -13,7 +13,7 @@ | |||||
></u-tabs> | ></u-tabs> | ||||
<view class="moreTabs"> | <view class="moreTabs"> | ||||
<!-- <view class="moreIcon" @click="showPopup = true"> 更多 </view> --> | <!-- <view class="moreIcon" @click="showPopup = true"> 更多 </view> --> | ||||
<view class="moreIcon" @click="toCreated"> 更多 </view> | |||||
<view class="moreIcon" @click="showPopup = true"> 更多 </view> | |||||
</view> | </view> | ||||
</view> | </view> | ||||
<!-- 更多tab弹出层 --> | <!-- 更多tab弹出层 --> | ||||
@@ -54,7 +54,6 @@ | |||||
</u-popup> | </u-popup> | ||||
<!-- 模版选择 --> | <!-- 模版选择 --> | ||||
<u-list | <u-list | ||||
v-show="false" | |||||
class="styleListBox" | class="styleListBox" | ||||
@scrolltolower="scrolltolower" | @scrolltolower="scrolltolower" | ||||
lowerThreshold="100" | lowerThreshold="100" | ||||
@@ -112,7 +111,7 @@ function closePopup() { | |||||
} | } | ||||
function openPopup() {} | function openPopup() {} | ||||
function toCreated() { | function toCreated() { | ||||
uni.navigateTo({ url: "/pages/camera/index" }); | |||||
// uni.navigateTo({ url: "/pages/createing/index" }); | |||||
} | } | ||||
//#endregion ----------------------- | //#endregion ----------------------- | ||||
@@ -123,7 +122,6 @@ const pageSize = ref(20); | |||||
const styleList = ref([]); | const styleList = ref([]); | ||||
// 得到列表 | // 得到列表 | ||||
async function getList() { | async function getList() { | ||||
return; | |||||
try { | try { | ||||
uni.showLoading({ | uni.showLoading({ | ||||
title: "加载中...", | title: "加载中...", | ||||
@@ -11,18 +11,35 @@ | |||||
<view class="orangeBtn" @click="createing(styleData.id)" | <view class="orangeBtn" @click="createing(styleData.id)" | ||||
>开始制作写真 | >开始制作写真 | ||||
</view> | </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">取 消</view> | |||||
</view> | |||||
</u-overlay> | |||||
</view> | </view> | ||||
</template> | </template> | ||||
<script setup> | <script setup> | ||||
//#region 导入 | //#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 { | import { | ||||
findByIdApi, | findByIdApi, | ||||
findImageApi, | findImageApi, | ||||
createPhotoApi, | createPhotoApi, | ||||
} from "../../api/closeStyle"; | } from "../../api/closeStyle"; | ||||
import { getQRCodeApi, getUserApi } from "../../api/createing"; | |||||
//#endregion | //#endregion | ||||
//#region 初始化 | //#region 初始化 | ||||
@@ -52,6 +69,11 @@ async function getInfo() { | |||||
//#region 生成写真照片 | //#region 生成写真照片 | ||||
async function createing(id) { | async function createing(id) { | ||||
if (!uni.getStorageSync("token")) { | |||||
showQrCode.value = true; | |||||
} | |||||
const userAgent = navigator.userAgent; | |||||
console.log("User Agent:", userAgent); | |||||
return; | return; | ||||
try { | try { | ||||
uni.showLoading({ | uni.showLoading({ | ||||
@@ -83,6 +105,101 @@ async function createing(id) { | |||||
} | } | ||||
//#endregion --------------------- | //#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 | //#region | ||||
//#endregion --------------------- | //#endregion --------------------- | ||||
@@ -123,4 +240,30 @@ async function createing(id) { | |||||
text-align: center; | 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> | </style> |
@@ -3,9 +3,11 @@ | |||||
<image src="../../assets/img/homeImg.jpg" mode="scaleToFill" /> | <image src="../../assets/img/homeImg.jpg" mode="scaleToFill" /> | ||||
<view class="bottomBox"> | <view class="bottomBox"> | ||||
<view class="orangeBtn" @click="toChooseStyle">开始体验</view> | <view class="orangeBtn" @click="toChooseStyle">开始体验</view> | ||||
<view class="IMEI" @click="Imei">i</view> | |||||
</view> | </view> | ||||
</view> | </view> | ||||
</template> | </template> | ||||
<script setup> | <script setup> | ||||
//#region 导入 | //#region 导入 | ||||
import { ref } from "vue"; | import { ref } from "vue"; | ||||
@@ -19,7 +21,21 @@ function toChooseStyle() { | |||||
//#endregion ---------------------------------- | //#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 ---------------------------------- | //#endregion ---------------------------------- | ||||
@@ -27,6 +43,7 @@ function toChooseStyle() { | |||||
//#endregion ---------------------------------- | //#endregion ---------------------------------- | ||||
</script> | </script> | ||||
<style lang="scss" scoped> | <style lang="scss" scoped> | ||||
.page { | .page { | ||||
padding: 0; | padding: 0; | ||||
@@ -48,6 +65,15 @@ function toChooseStyle() { | |||||
width: 100%; | width: 100%; | ||||
height: 400rpx; | height: 400rpx; | ||||
background-color: rgba($color: #000000, $alpha: 0.5); | 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> | </style> |
@@ -76,6 +76,7 @@ view { | |||||
.uni-toast { | .uni-toast { | ||||
width: 280rpx; | width: 280rpx; | ||||
font-size: 30rpx; | font-size: 30rpx; | ||||
padding: 20rpx 30rpx; | |||||
.uni-toast__icon { | .uni-toast__icon { | ||||
width: 50rpx !important; | width: 50rpx !important; | ||||
@@ -1,7 +1,10 @@ | |||||
// import { userInfoModules } from "@/store/modules/userInfo"; | // import { userInfoModules } from "@/store/modules/userInfo"; | ||||
// import { store } from '@/store/index'; | // 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 userInfoModulesPinia = userInfoModules(store); | ||||
// const BASE_URL = 'https://test.metavatar.cc/'; | // const BASE_URL = 'https://test.metavatar.cc/'; | ||||
@@ -20,6 +20,7 @@ export default defineConfig(({ command, mode }) => { | |||||
// 反向代理解决跨域 | // 反向代理解决跨域 | ||||
"/api": { | "/api": { | ||||
target: env.VITE_APP_BASE_URL, // 线上接口地址 | target: env.VITE_APP_BASE_URL, // 线上接口地址 | ||||
// target: "https://zhixiangtest.malls.iformall.com/C", // 线上接口地址 | |||||
changeOrigin: true, | changeOrigin: true, | ||||
rewrite: (path) => path.replace(/^\/api/, ""), | rewrite: (path) => path.replace(/^\/api/, ""), | ||||
}, | }, | ||||