update:优化机构扫码页

This commit is contained in:
2026-08-17 14:05:52 +08:00
parent 63fb4ae85a
commit d60c32506f
3 changed files with 145 additions and 33 deletions
+144 -32
View File
@@ -1,16 +1,35 @@
<script setup> <script setup>
import { ref } from "vue"; import { computed, ref } from "vue";
import { onLoad } from "@dcloudio/uni-app"; import { onLoad } from "@dcloudio/uni-app";
import Signin from "@/components/Signin.vue"; import Signin from "@/components/Signin.vue";
import SButton from "@/components/SButton.vue"; import SButton from "@/components/SButton.vue";
import Avatar from "@/components/Avatar.vue";
import AppBackground from "@/components/AppBackground.vue";
import DeviceChargingDialog from "@/components/DeviceChargingDialog.vue"; import DeviceChargingDialog from "@/components/DeviceChargingDialog.vue";
import { tempBindOrgAPI } from "@/apis"; import { tempBindOrgAPI } from "@/apis";
import useStore from "@/store";
import { storeToRefs } from "pinia";
const store = useStore();
const { user } = storeToRefs(store);
const scene = ref(""); const scene = ref("");
const status = ref("idle"); const status = ref("idle");
const errorMessage = ref(""); const errorMessage = ref("");
const showSignin = ref(false); const showSignin = ref(false);
const binding = ref(false); const binding = ref(false);
const bindInfo = ref({});
const successInfo = computed(() => {
const result = bindInfo.value || {};
return {
avatar: user.value.avatar,
nickName: user.value.nickName || "--",
mobile: result.mobile || "--",
storeName: result.storeName || "--",
};
});
const getToken = () => { const getToken = () => {
try { try {
@@ -40,9 +59,17 @@ const bindOrg = async () => {
binding.value = true; binding.value = true;
status.value = "binding"; status.value = "binding";
errorMessage.value = ""; errorMessage.value = "";
bindInfo.value = {};
try { try {
await tempBindOrgAPI(scene.value); const result = (await tempBindOrgAPI(scene.value)) || {};
if (result.success !== true) {
status.value = "failed";
errorMessage.value = result.msg || "授权登录失败,请稍后重试。";
return;
}
bindInfo.value = result;
status.value = "success"; status.value = "success";
} catch (error) { } catch (error) {
if (error?.type === "AUTH_INVALID") { if (error?.type === "AUTH_INVALID") {
@@ -83,45 +110,69 @@ onLoad((options) => {
<template> <template>
<view class="page"> <view class="page">
<AppBackground :type="6" bgColor="#20202c" />
<view class="content"> <view class="content">
<text class="title">机构设备绑定</text> <text class="title">登录门店Pad端</text>
<view v-if="status === 'idle' || status === 'binding'" class="state"> <view
<text class="state-title">正在绑定</text> v-if="status === 'idle' || status === 'binding'"
<text class="description">正在绑定机构设备请稍候</text> class="state message-state"
>
<text class="state-title">正在授权登录</text>
<text class="description">正在登录门店Pad端请稍候</text>
</view> </view>
<view v-else-if="status === 'login'" class="state"> <view v-else-if="status === 'login'" class="state login-state">
<text class="state-title">请先登录</text> <image
<text class="description"> class="login-icon"
{{ src="../static/org-bind/login-icon.png"
errorMessage || mode="aspectFit"
"登录后即可绑定当前机构设备。关闭登录窗口后,也可以再次点击下方按钮继续。" />
}} <text class="login-title">{{
</text> errorMessage || "请先登录小程序"
<SButton width="560rpx" :rounded="20" :onClick="openSignin"> }}</text>
<text>立即登录</text> <SButton width="600rpx" :rounded="22" :onClick="openSignin">
<text>微信授权登录</text>
</SButton> </SButton>
</view> </view>
<view v-else-if="status === 'success'" class="state"> <view v-else-if="status === 'success'" class="state success-state">
<text class="state-title">绑定成功</text> <view class="avatar-wrap">
<text class="description"> <Avatar
您的账号已成功绑定机构设备请返回 iPad 继续操作 :src="successInfo.avatar"
:size="176"
sizeUnit="rpx"
imageMode="aspectFill"
/>
<image
class="success-badge"
src="../static/org-bind/green-gou.png"
mode="aspectFit"
/>
</view>
<text class="success-title">已成功授权登录射灵星球门店Pad端</text>
<view class="account-info">
<text>登录账号{{ successInfo.nickName }}</text>
<text>手机号{{ successInfo.mobile }}</text>
<text>登录门店{{ successInfo.storeName }}</text>
<text class="warm-tip">
温馨提示离开门店时候记得在Pad退出登录哦
</text> </text>
</view> </view>
</view>
<view v-else-if="status === 'failed'" class="state"> <view v-else-if="status === 'failed'" class="state message-state">
<text class="state-title">绑定失败</text> <text class="state-title">授权登录失败</text>
<text class="description">{{ errorMessage }}</text> <text class="description">{{ errorMessage }}</text>
<SButton width="560rpx" :rounded="20" :onClick="bindOrg"> <SButton width="600rpx" :rounded="22" :onClick="bindOrg">
<text>重新绑定</text> <text>重新登录</text>
</SButton> </SButton>
</view> </view>
<view v-else class="state"> <view v-else class="state message-state">
<text class="state-title">二维码无效</text> <text class="state-title">二维码无效</text>
<text class="description">请重新扫描机构设备上的小程序码</text> <text class="description">请重新扫描门店Pad端上的小程序码</text>
</view> </view>
</view> </view>
@@ -139,32 +190,93 @@ onLoad((options) => {
box-sizing: border-box; box-sizing: border-box;
width: 100%; width: 100%;
min-height: 100vh; min-height: 100vh;
padding: calc(var(--status-bar-height) + 120rpx) 48rpx 80rpx; padding: calc(var(--status-bar-height) + 64rpx) 48rpx 80rpx;
background-color: #000;
color: #fff; color: #fff;
} }
.content { .content {
position: relative;
z-index: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
} }
.title { .title {
font-size: 44rpx; color: #d8ad69;
font-weight: 600; font-size: 30rpx;
font-weight: 500;
} }
.state { .state {
width: 100%; width: 100%;
margin-top: 120rpx;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
} }
.login-state,
.success-state {
margin-top: 320rpx;
}
.message-state {
margin-top: 240rpx;
}
.login-icon {
width: 176rpx;
height: 176rpx;
border-radius: 50%;
}
.login-title {
margin: 28rpx 0 60rpx;
font-size: 40rpx;
font-weight: 500;
}
.avatar-wrap {
position: relative;
}
.success-badge {
position: absolute;
right: -2rpx;
bottom: 4rpx;
width: 40rpx;
height: 40rpx;
}
.success-title {
width: 572rpx;
margin-top: 28rpx;
color: #fed847;
font-size: 34rpx;
font-weight: 500;
line-height: 48rpx;
}
.account-info {
box-sizing: border-box;
width: 572rpx;
margin-top: 20rpx;
display: flex;
flex-direction: column;
color: #FFFFFF;
font-size: 28rpx;
line-height: 52rpx;
}
.warm-tip {
margin-top: 40rpx;
color: #b8b8bd;
font-size: 24rpx;
line-height: 40rpx;
}
.state-title { .state-title {
font-size: 36rpx; font-size: 38rpx;
font-weight: 600; font-weight: 600;
} }
Binary file not shown.

After

Width:  |  Height:  |  Size: 492 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB