From d796875e4dee22341c48469973d03e1015db61e8 Mon Sep 17 00:00:00 2001
From: zuoxiao <470321431@qq.com>
Date: 星期五, 05 七月 2024 11:40:28 +0800
Subject: [PATCH] 首页添加扫码

---
 pages/home/home.js   |   20 ++++++++++++++++----
 images/scen_code.svg |    1 +
 pages/home/home.json |    8 ++++++--
 pages/home/home.wxml |    6 +++++-
 pages/home/home.wxss |   10 ++++++++++
 5 files changed, 38 insertions(+), 7 deletions(-)

diff --git a/images/scen_code.svg b/images/scen_code.svg
new file mode 100644
index 0000000..fa05585
--- /dev/null
+++ b/images/scen_code.svg
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><svg width="16" height="16" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6 15V6H15" stroke="#ffffff" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M15 42H6V33" stroke="#ffffff" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M42 33V42H33" stroke="#ffffff" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M33 6H42V15" stroke="#ffffff" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M10 24H38" stroke="#ffffff" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/></svg>
\ No newline at end of file
diff --git a/pages/home/home.js b/pages/home/home.js
index fb5c516..5c6dad9 100644
--- a/pages/home/home.js
+++ b/pages/home/home.js
@@ -314,12 +314,24 @@
     const maskedPhoneNumber = phoneNumber.replace(/^(\d{3})\d{4}(\d{4})$/, "$1****$2");
     return maskedPhoneNumber;
   },
+
   closeDialog() {
     this.setData({
-      showErrorDialog:false
+      showErrorDialog: false
+    })
+  },
+  scenCode() {
+    wx.scanCode({
+      success(res) {
+        console.log(res.result); // 褰撲笖浠呭綋鎵爜涓洪潪寰俊浜岀淮鐮佹椂锛屼細杩斿洖result  
+        // 濡傛灉鎵爜缁撴灉涓篣RL锛屼細鑷姩灏濊瘯鎵撳紑  
+        // 濡傛灉鎵爜缁撴灉涓哄井淇″皬绋嬪簭鐨勭爜锛屼細鐩存帴璺宠浆鍒板搴旂殑灏忕▼搴忛〉闈�  
+        // 濡傛灉鎵爜缁撴灉涓哄叕浼楀彿浜岀淮鐮侊紝鍒欎細鍦ㄦ墜鏈轰笂鎵撳紑寰俊骞惰烦杞埌瀵瑰簲鐨勫叕浼楀彿  
+      },
+      fail(err) {
+        console.error(err);
+      }
+
     })
   }
-
-
-
 })
\ No newline at end of file
diff --git a/pages/home/home.json b/pages/home/home.json
index fe0e2c0..eefd2a2 100644
--- a/pages/home/home.json
+++ b/pages/home/home.json
@@ -6,6 +6,10 @@
     "t-dialog": "tdesign-miniprogram/dialog/dialog"
   },
   "navigationBarTitleText": "澶х鑺傛按",
-  "navigationBarTextStyle": "white"
-
+  "navigationBarTextStyle": "white",
+  "permission": {  
+    "scope.camera": {  
+      "desc": "浣跨敤鎽勫儚澶存壂鎻忎簩缁寸爜"
+    } 
+  }
 }
\ No newline at end of file
diff --git a/pages/home/home.wxml b/pages/home/home.wxml
index c2bc9c0..b4f283b 100644
--- a/pages/home/home.wxml
+++ b/pages/home/home.wxml
@@ -1,5 +1,6 @@
 <!--pages/home/home.wxml-->
 <view class="base-wrapper">
+
   <view class="head-wrapper">
     <view class="head-top">
       <t-avatar class="avatar-example" image="{{image}}" size="120rpx" />
@@ -11,6 +12,7 @@
         <text class="unbind" bind:tap="feedBack">瑙g粦</text>
         <text class="head-bottom" bind:tap="feedBack">鑱旂郴瀹㈡湇</text>
       </view>
+      <image class="scen-code" src="/images/scen_code.svg" bind:tap="scenCode"/>
     </view>
   </view>
 
@@ -47,7 +49,7 @@
       <view class="dot"></view>
     </view>
     <view class="scroll-bg">
-      <view  wx:if="{{listData.length > 0}}" class="list-item" wx:for="{{listData}}" wx:for-item="item" wx:for-index="index">
+      <view wx:if="{{listData.length > 0}}" class="list-item" wx:for="{{listData}}" wx:key="index">
         <view class="item-left">
           <!-- <image class="item-img" src="/images/pipeline.svg" /> -->
           <text>{{item.intakeNum}}</text>
@@ -64,6 +66,8 @@
       <text class="noMore-text">娌℃湁寮�娉佃褰�</text>
     </view>
   </scroll-view>
+
   <t-dialog class="dialog" visible="{{showConfirm}}" content="纭鍏抽棴{{waterIntakeName}}鍚楋紵" confirm-btn="{{ { content: '纭', variant: 'base', theme: 'danger' } }}" close-on-overlay-click="false" cancel-btn="鍙栨秷"  bind:confirm="confirmDialog" bind:cancel="closeDialog" />
   <t-dialog class="error-dialog"  title="鍏抽榾閿欒" visible="{{showErrorDialog}}" content="{{errorData}}" confirm-btn="{{ confirmBtn }}" bind:confirm="closeDialog" />
+
 </view>
\ No newline at end of file
diff --git a/pages/home/home.wxss b/pages/home/home.wxss
index ccf84a2..ee43aa4 100644
--- a/pages/home/home.wxss
+++ b/pages/home/home.wxss
@@ -317,7 +317,17 @@
   /* background-color: #e0e0e0; */
 }
 
+
 .error-dialog{
   --td-dialog-title-color:red;
   --td-dialog-title-font-size:40rpx;
+}
+
+.scen-code{
+  width: 40rpx;
+  height: 40rpx;
+  position: absolute; /* 娣诲姞杩欒 */
+  top: 15rpx; /* 鏍规嵁闇�瑕佽皟鏁磋窛绂婚《閮ㄧ殑璺濈 */
+  right: 30rpx; /* 鏍规嵁闇�瑕佽皟鏁磋窛绂诲彸渚х殑璺濈 */
+
 }
\ No newline at end of file

--
Gitblit v1.8.0