mirror of
https://gitee.com/elegant_wings/dbd-meeting-wx-small.git
synced 2025-06-21 04:59:37 +08:00
描述:扫一扫
This commit is contained in:
parent
bccb12a3c1
commit
0524e11e69
@ -4,10 +4,10 @@ import {
|
||||
|
||||
|
||||
// 用户信息
|
||||
export function callScanUrl(url, paramUrl) {
|
||||
export function callScanUrl(data) {
|
||||
return request({
|
||||
url: url + paramUrl,
|
||||
url: '/api/equipment/scanOpenDoor',
|
||||
method: "get",
|
||||
urlIsAll: true
|
||||
data
|
||||
});
|
||||
}
|
@ -2,12 +2,15 @@ App({
|
||||
// 郑州小程序配置信息
|
||||
APPID: 'wx5582a07c1fbbcf06',
|
||||
APPSECRET: 'ad24130a8919c613efd9538f69abafd3',
|
||||
tenantId : '1', // 地区-郑州
|
||||
// 本地测试时不用加/api
|
||||
tenantId : '10', // 地区-郑州
|
||||
// 域名
|
||||
DOMAIN_NAME_PREFIX: 'https://chuangzhidasha.haxy.com.cn',
|
||||
// 本地测试
|
||||
DOMAIN_NAME: 'http://192.168.0.11:9227', //接口域名
|
||||
IMG_NAME: 'http://192.168.0.11:9227',
|
||||
// DOMAIN_NAME: 'http://222.184.49.22:9227', //接口域名
|
||||
// IMG_NAME: 'http://222.184.49.22:9227',
|
||||
// 生产
|
||||
// DOMAIN_NAME: 'https://chuangzhidasha.haxy.com.cn/saas-ics', //接口域名
|
||||
// IMG_NAME: 'https://chuangzhidasha.haxy.com.cn/saas-ics',
|
||||
globals: {
|
||||
refreshMyPages: false,
|
||||
homedata: {},
|
||||
|
@ -15,6 +15,9 @@ import {
|
||||
getParkRq
|
||||
} from "../../api/index/index.js"
|
||||
|
||||
import {
|
||||
getUrlParamsObj
|
||||
} from "../../utils/util.js"
|
||||
|
||||
Page({
|
||||
data: {
|
||||
@ -155,12 +158,23 @@ Page({
|
||||
],
|
||||
bannerList: [],
|
||||
userDetail: {},
|
||||
parkName: '首页'
|
||||
parkName: '首页',
|
||||
qrcodeParam: null,
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
console.log('onLoad options', options);
|
||||
let _this = this;
|
||||
// 获取到二维码原始链接内容
|
||||
if (options.q) {
|
||||
let url = decodeURIComponent(options.q)
|
||||
let urlParam = getUrlParamsObj(url);
|
||||
if (!urlParam.noParam) {
|
||||
_this.setData({
|
||||
qrcodeParam: urlParam
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 切换tabbar
|
||||
@ -220,6 +234,11 @@ Page({
|
||||
bannerList
|
||||
})
|
||||
})
|
||||
// 判断是否扫码
|
||||
if (_this.data.qrcodeParam) {
|
||||
// 扫码调用地址
|
||||
_this.scanCallUrl()
|
||||
}
|
||||
} else {
|
||||
wx.navigateTo({
|
||||
url: '/pages/index/parkList/parkList',
|
||||
@ -227,6 +246,8 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
// 跳转园区
|
||||
jumpPark() {
|
||||
wx.navigateTo({
|
||||
@ -260,8 +281,24 @@ Page({
|
||||
success(res) {
|
||||
console.log('success', res)
|
||||
let url = res.result;
|
||||
// 扫码调用地址
|
||||
_this.scanCallUrl(url)
|
||||
// 判断二维码是否符合规范
|
||||
if (url.indexOf(app.DOMAIN_NAME_PREFIX) != -1) {
|
||||
let urlParam = getUrlParamsObj(url);
|
||||
// 判断是否有设备参数
|
||||
if (!urlParam.noParam) {
|
||||
_this.setData({
|
||||
qrcodeParam: urlParam
|
||||
})
|
||||
// 扫码调用地址
|
||||
_this.scanCallUrl()
|
||||
} else {
|
||||
// 危险通知
|
||||
_this.showErrMsg('请预约会议!')
|
||||
}
|
||||
} else {
|
||||
// 危险通知
|
||||
_this.showErrMsg('二维码不正确!')
|
||||
}
|
||||
},
|
||||
fail(res) {
|
||||
console.log('fail', res)
|
||||
@ -272,10 +309,15 @@ Page({
|
||||
},
|
||||
|
||||
// 扫码调用地址
|
||||
scanCallUrl(url) {
|
||||
scanCallUrl() {
|
||||
let _this = this;
|
||||
let paramUrl = '&userId=' + wx.getStorageSync('userId')
|
||||
callScanUrl(url, paramUrl).then(res => {
|
||||
let qrcodeParam = _this.data.qrcodeParam;
|
||||
qrcodeParam.userId = wx.getStorageSync('userId')
|
||||
callScanUrl(qrcodeParam).then(res => {
|
||||
// 清空扫码数据
|
||||
_this.setData({
|
||||
qrcodeParam: null
|
||||
})
|
||||
if (res.code == 0) {
|
||||
// 成功通知
|
||||
_this.showSuccessMsg(res.msg)
|
||||
|
@ -10,6 +10,10 @@ import {
|
||||
callScanUrl
|
||||
} from "../../api/common/scan.js"
|
||||
|
||||
import {
|
||||
getUrlParamsObj
|
||||
} from "../../utils/util.js"
|
||||
|
||||
Page({
|
||||
|
||||
/**
|
||||
@ -75,6 +79,7 @@ Page({
|
||||
url: "/pages/parkRepair/parkRepair",
|
||||
}
|
||||
],
|
||||
qrcodeParam: null,
|
||||
},
|
||||
|
||||
// 切换tabbar
|
||||
@ -146,8 +151,24 @@ Page({
|
||||
success(res) {
|
||||
console.log('success', res)
|
||||
let url = res.result;
|
||||
// 扫码调用地址
|
||||
_this.scanCallUrl(url)
|
||||
// 判断二维码是否符合规范
|
||||
if (url.indexOf(app.DOMAIN_NAME_PREFIX) != -1) {
|
||||
let urlParam = getUrlParamsObj(url);
|
||||
// 判断是否有设备参数
|
||||
if (!urlParam.noParam) {
|
||||
_this.setData({
|
||||
qrcodeParam: urlParam
|
||||
})
|
||||
// 扫码调用地址
|
||||
_this.scanCallUrl()
|
||||
} else {
|
||||
// 危险通知
|
||||
_this.showErrMsg('请预约会议!')
|
||||
}
|
||||
} else {
|
||||
// 危险通知
|
||||
_this.showErrMsg('二维码不正确!')
|
||||
}
|
||||
},
|
||||
fail(res) {
|
||||
console.log('fail', res)
|
||||
@ -158,10 +179,15 @@ Page({
|
||||
},
|
||||
|
||||
// 扫码调用地址
|
||||
scanCallUrl(url) {
|
||||
scanCallUrl() {
|
||||
let _this = this;
|
||||
let paramUrl = '&userId=' + wx.getStorageSync('userId')
|
||||
callScanUrl(url, paramUrl).then(res => {
|
||||
let qrcodeParam = _this.data.qrcodeParam;
|
||||
qrcodeParam.userId = wx.getStorageSync('userId')
|
||||
callScanUrl(qrcodeParam).then(res => {
|
||||
// 清空扫码数据
|
||||
_this.setData({
|
||||
qrcodeParam: null
|
||||
})
|
||||
if (res.code == 0) {
|
||||
// 成功通知
|
||||
_this.showSuccessMsg(res.msg)
|
||||
|
@ -215,6 +215,22 @@ function selfArrSum(list) {
|
||||
return count
|
||||
}
|
||||
|
||||
// 返回url参数对象
|
||||
function getUrlParamsObj(url) {
|
||||
// 通过 ? 分割获取后面的参数字符串
|
||||
let urlStr = url.split('?')[1]
|
||||
// 创建空对象存储参数
|
||||
let obj = {};
|
||||
// 再通过 & 将每一个参数单独分割出来
|
||||
let paramsArr = urlStr.split('&')
|
||||
for(let i = 0,len = paramsArr.length;i < len;i++){
|
||||
// 再通过 = 将每一个参数分割为 key:value 的形式
|
||||
let arr = paramsArr[i].split('=')
|
||||
obj[arr[0]] = arr[1];
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
formatTime: formatTime,
|
||||
formatDate: formatDate,
|
||||
@ -230,5 +246,6 @@ module.exports = {
|
||||
selfFormatTimeYMDH,
|
||||
twoTimeInterval,
|
||||
twoTimeIntervalReturnHours,
|
||||
selfArrSum
|
||||
selfArrSum,
|
||||
getUrlParamsObj
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user