Browse Source

fix: 扫码

chenzhen2 2 years ago
parent
commit
1a1be366ba

+ 2 - 1
app.json

@@ -10,7 +10,8 @@
     "pages/feedback/index",
     "pages/spacelist/index",
     "pages/adjustlog/index",
-    "pages/spacelog/index"
+    "pages/spacelog/index",
+    "pages/ipdauth/index"
   ],
   "window": {
     "backgroundTextStyle": "light",

+ 42 - 0
pages/adjust/index.js

@@ -168,6 +168,48 @@ Page({
     goBack() {
         router.pop();
     },
+     // 获取扫码结果
+     getScancode: function () {
+        // if (!$.storage.get('logined')) {
+        //   router.push('auth');
+        //   return
+        // }
+        // 只允许从相机扫码
+        wx.scanCode({
+            onlyFromCamera: true,
+            complete: (res) => {
+                if (res.errMsg === '"scanCode:fail cancel"') {
+                    Toast.fail("已取消扫描");
+                }
+            },
+            success: (res) => {
+                this.checkCode(res.result);
+            },
+            fail: (res) => {
+                Toast.fail("未扫描到结果");
+            },
+        });
+    },
+     // 检查二维码
+     async checkCode(value) {
+        console.log(value, 381);
+        let scanArr = value.split("?");
+        let domain = scanArr[0];
+        let qualifiedUrl = [
+            "http://meos.sagacloud.cn/scan",
+            "https://duoduoenv.sagacloud.cn/scan",
+        ];
+        if (qualifiedUrl.includes(domain)) {
+            let md = scanArr[1].split("=") || [];
+            let md1 = md[1];
+            console.log("扫码了====")
+            // router.push("adjust", { md1 });
+            // debugger
+            router.push("ipdauth",{ spaceid: this.data.spaceDetail.id})
+        } else {
+            Toast.fail("无效的二维码");
+        }
+    },
     changeMode() {
         if (this.data.spaceDetail.isClose.toString() !== "true") {
             this.setData({ StandardMode: !this.data.StandardMode }, () => {

+ 4 - 1
pages/adjust/index.wxml

@@ -37,8 +37,11 @@
         </view>
         <view class="space_msg">
             <view class="msg_left">
-                <text class="spacename">{{spaceDetail.localName}}</text>
+                <view class="msg_left_text">
+                  <text class="spacename">{{spaceDetail.localName}}</text>
                 <text wx:if="{{spaceDetail.isPassengerPassShow}}" class="peoplestate {{spaceDetail.isPassengerPass=='有人'?'activepeople':''}}">{{spaceDetail.isPassengerPass}}</text>
+                <image class="scan_img" bindtap="getScancode"  src="../../static/images/scan.svg"></image>
+                </view>
                 <view class="spacestate flex_row">
                     {{spaceDetail.state}}
                     <view>

+ 9 - 0
pages/adjust/index.wxss

@@ -129,6 +129,15 @@ page {
   justify-content: space-between;
   align-items: center;
 }
+.adjust_main .space_msg .msg_left_text{
+ 
+}
+.adjust_main .scan_img {
+  vertical-align:middle;
+  margin-left:20rpx;
+  width:30rpx;
+  height:30rpx;
+}
 .adjust_main .space_msg .msg_left .spacename {
   height: 56rpx;
   font-size: 40rpx;

+ 5 - 1
pages/index/index.js

@@ -512,6 +512,7 @@ Page({
     },
     gotoSpacelist() {
         router.push("spacelist");
+        // router.push("ipdauth")
     },
     // 检查二维码
     async checkCode(value) {
@@ -525,7 +526,10 @@ Page({
         if (qualifiedUrl.includes(domain)) {
             let md = scanArr[1].split("=") || [];
             let md1 = md[1];
-            router.push("adjust", { md1 });
+            console.log("扫码了====")
+            // router.push("adjust", { md1 });
+            // debugger
+            router.push("ipdauth")
         } else {
             Toast.fail("无效的二维码");
         }

+ 39 - 0
pages/ipdauth/index.js

@@ -0,0 +1,39 @@
+import $ from "./../../utils/Tool";
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    spaceId:'',
+    projectId:''
+  },
+  // 确认登录
+  confirmLogin(){
+    let projectId=$.store.get("projectId") || $.storage.get("projectId")
+    console.log("获取项目id")
+    console.log(projectId)
+  },
+  // 取消登录
+  cancelLoginn(){
+
+  },
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    options = JSON.parse(decodeURIComponent(JSON.stringify(options)))
+    let {spaceid} = options
+    let projectId=$.store.get("projectId") || $.storage.get("projectId")
+    this.setData({spaceId:spaceid,projectId:projectId})
+    console.log("projectid==="+projectid)
+    console.log("spaceid===="+spaceid)
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+
+  }
+})

+ 4 - 0
pages/ipdauth/index.json

@@ -0,0 +1,4 @@
+{
+    "usingComponents": {},
+    "navigationBarTitleText": "登录确认"
+  }

+ 8 - 0
pages/ipdauth/index.wxml

@@ -0,0 +1,8 @@
+<view class="ipad_auth">
+ <view class="ipad_auth_content">
+   <image src="../../static/images/computer.svg" class="computer_img"></image>
+   <text>登录Pad端SagaCare</text>
+   <button class="com-btn comfirm-btn" bindtap="confirmLogin">登录</button>
+   <button class="com-btn cancel-btn" bindtap="cancelLoginn">取消登录</button>
+ </view>
+</view>

+ 44 - 0
pages/ipdauth/index.wxss

@@ -0,0 +1,44 @@
+page {
+  width:100%;
+  height: 100%;
+}
+.ipad_auth {
+    width:100%;
+    height: 100%;
+}
+.ipad_auth_content {
+    padding-top:240rpx;
+    text-align:center;
+}
+.computer_img {
+    width:256rpx;
+    height:204rpx;
+    margin:0 auto;
+    margin-bottom:60rpx;
+}
+text {
+    display: block;
+    font-family: 'PingFang SC';
+    font-style: normal;
+    font-weight: 400;
+    font-size: 40rpx;
+    line-height: 56rpx; 
+    margin-bottom:80rpx;
+}
+.com-btn {
+    width:85% !important;
+    height:80rpx;
+    font-family: 'PingFang SC';
+    font-style: normal;
+    font-weight: 400;
+    font-size: 32rpx;
+    line-height: 44rpx;
+    text-align:center;
+}
+.comfirm-btn {
+    background: #04B49C;
+    font-size: 32rpx;
+    line-height: 44rpx; 
+    color: #FFFFFF;
+    margin-bottom:60rpx;
+}

File diff suppressed because it is too large
+ 3 - 0
static/images/computer.svg


File diff suppressed because it is too large
+ 3 - 0
static/images/scan.svg


+ 1 - 0
utils/router.js

@@ -11,6 +11,7 @@ const pages = {
     search:'/pages/search/index',
     adjustlog:'/pages/adjustlog/index',
     spacelog:'/pages/spacelog/index',
+    ipdauth:'/pages/ipdauth/index'
   }
 
   function to(page, data) {