| | |
| | | <text class="qrcode-title">我的回收码</text> |
| | | <text class="qrcode-desc">向回收员出示此码完成回收</text> |
| | | <view class="qrcode-image-wrap"> |
| | | <image class="qrcode-image" :src="qrcodeUrl" mode="aspectFit" /> |
| | | |
| | | <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> |
| | |
| | | }); |
| | | |
| | | const showQrcode = ref(false); |
| | | const userCode = ref(""); |
| | | const qrcodeUrl = ref(""); |
| | | |
| | | // ========== 初始化加载 ========== |
| | |
| | | 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); |
| | | } |
| | |
| | | |
| | | /** 加载用户回收码 */ |
| | | 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); |
| | | userCode.value = phone; |
| | | qrcodeUrl.value = res; |
| | | qrcodeUrl.value = await generateRecycleQrcode(phone); |
| | | } catch (e) { |
| | | console.error("【回收码加载失败】", e); |
| | | // 兜底:没有接口时给个默认值 |
| | | userCode.value = "RC-LOADING"; |
| | | uni.showToast({ title: "回收码生成失败", icon: "none" }); |
| | | } |
| | | } |
| | | |
| | |
| | | .qrcode-image { |
| | | width: 100%; |
| | | height: 100%; |
| | | } |
| | | |
| | | .qrcode-code { |
| | | font-size: 26rpx; |
| | | color: #666; |
| | | letter-spacing: 2rpx; |
| | | } |
| | | |
| | | .qrcode-close { |