From db685b04e52efd75213ef7540fdc0bed7dccfd9e Mon Sep 17 00:00:00 2001
From: wangrong <wangrong@shsening.com>
Date: 星期一, 26 十月 2026 21:13:37 +0800
Subject: [PATCH] 更新小程序
---
pages/recycle/home.vue | 50 +++++++++++++++++++++-----------------------------
1 files changed, 21 insertions(+), 29 deletions(-)
diff --git a/pages/recycle/home.vue b/pages/recycle/home.vue
index cded755..e3b8601 100644
--- a/pages/recycle/home.vue
+++ b/pages/recycle/home.vue
@@ -72,14 +72,8 @@
<text class="qrcode-title">鎴戠殑鍥炴敹鐮�</text>
<text class="qrcode-desc">鍚戝洖鏀跺憳鍑虹ず姝ょ爜瀹屾垚鍥炴敹</text>
<view class="qrcode-image-wrap">
- <!--<image class="qrcode-image" :src="qrcodeUrl" mode="aspectFit" /> -->
- <canvas
- canvas-id="recycleQrcode"
- id="recycleQrcode"
- style="width: 300px; height: 300px;"
- />
+ <image v-if="qrcodeUrl" class="qrcode-image" :src="qrcodeUrl" mode="aspectFit" />
</view>
- <text class="qrcode-code">鍥炴敹鐮侊細{{ userCode }}</text>
<view class="qrcode-close" @tap="showQrcode = false">
<cl-icon name="close" :size="36" color="#999" />
</view>
@@ -120,7 +114,6 @@
});
const showQrcode = ref(false);
- const userCode = ref("");
const qrcodeUrl = ref("");
// ========== 鍒濆鍖栧姞杞� ==========
@@ -132,14 +125,18 @@
async function loadDashboard() {
try {
const unionid = user.info?.phone||"18918594752";
- service.user.info.dashboard({ unionid:unionid }).then((res) => {
- console.log("銆愬啀鐢熻祫婧愮湅鏉挎暟鎹��", res);
- dashboard.value = {
- carbonPoints: res.carbonPoints ?? 0,
- recycleCount: res.recycleCount ?? 0,
- overPercent: res.overPercent ?? 0,
- };
- });
+ service.user.info
+ .dashboard({ unionid })
+ .then((res) => {
+ dashboard.value = {
+ carbonPoints: res.carbonPoints ?? 0,
+ recycleCount: res.recycleCount ?? 0,
+ overPercent: res.overPercent ?? 0,
+ };
+ })
+ .catch((err) => {
+ console.error("銆愬啀鐢熻祫婧愮湅鏉垮姞杞藉け璐ャ��", err);
+ });
} catch (e) {
console.error("銆愬啀鐢熻祫婧愮湅鏉垮姞杞藉け璐ャ��", e);
}
@@ -147,16 +144,17 @@
/** 鍔犺浇鐢ㄦ埛鍥炴敹鐮� */
async function loadMyCode() {
+ const phone = user.info?.phone;
+ if (!phone) {
+ uni.showToast({ title: "璇峰厛鎺堟潈鎵嬫満鍙�", icon: "none" });
+ showQrcode.value = false;
+ return;
+ }
try {
- const phone = user.info?.phone ?? "18918594752";
- const res = await generateRecycleQrcode(phone);
- console.log("銆愭垜鐨勫洖鏀剁爜銆�", res);
- userCode.value = phone;
- qrcodeUrl.value = res;
+ qrcodeUrl.value = await generateRecycleQrcode(phone);
} catch (e) {
console.error("銆愬洖鏀剁爜鍔犺浇澶辫触銆�", e);
- // 鍏滃簳锛氭病鏈夋帴鍙f椂缁欎釜榛樿鍊�
- userCode.value = "RC-LOADING";
+ uni.showToast({ title: "鍥炴敹鐮佺敓鎴愬け璐�", icon: "none" });
}
}
@@ -354,12 +352,6 @@
.qrcode-image {
width: 100%;
height: 100%;
- }
-
- .qrcode-code {
- font-size: 26rpx;
- color: #666;
- letter-spacing: 2rpx;
}
.qrcode-close {
--
Gitblit v1.9.1