From d562019fb252aff01915ce71f00e9a48de182535 Mon Sep 17 00:00:00 2001 From: SelfRidicule Date: Wed, 13 Mar 2024 18:27:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=8F=E8=BF=B0:=E6=89=AB=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- miniprogram/api/common/scan.js | 13 ++++++ miniprogram/api/selfRequest.js | 6 +++ miniprogram/pages/index/index.js | 61 +++++++++++++++++++++++++++++ miniprogram/pages/index/index.json | 5 ++- miniprogram/pages/index/index.wxml | 11 +++--- miniprogram/pages/my/my.js | 63 +++++++++++++++++++++++++++++- miniprogram/pages/my/my.json | 3 +- miniprogram/pages/my/my.wxml | 14 ++++++- miniprogram/pages/my/my.wxss | 2 +- 9 files changed, 167 insertions(+), 11 deletions(-) create mode 100644 miniprogram/api/common/scan.js diff --git a/miniprogram/api/common/scan.js b/miniprogram/api/common/scan.js new file mode 100644 index 0000000..1fc3d0c --- /dev/null +++ b/miniprogram/api/common/scan.js @@ -0,0 +1,13 @@ +import { + request +} from '../selfRequest'; + + +// 用户信息 +export function callScanUrl(url, paramUrl) { + return request({ + url: url + paramUrl, + method: "get", + urlIsAll: true + }); +} \ No newline at end of file diff --git a/miniprogram/api/selfRequest.js b/miniprogram/api/selfRequest.js index 1b32b6d..2653276 100644 --- a/miniprogram/api/selfRequest.js +++ b/miniprogram/api/selfRequest.js @@ -2,7 +2,13 @@ const app = getApp() export function request(params) { // 初始化参数 + let urlIsAll = params.urlIsAll; let url = app.DOMAIN_NAME + params.url; + if (urlIsAll) { + url = params.url; + } else { + url = app.DOMAIN_NAME + params.url; + } let header = params.header || {}; let data = params.data || {}; let method = params.method || "GET"; diff --git a/miniprogram/pages/index/index.js b/miniprogram/pages/index/index.js index 63dc808..7224d10 100644 --- a/miniprogram/pages/index/index.js +++ b/miniprogram/pages/index/index.js @@ -1,4 +1,12 @@ const app = getApp() + +import Notify from '@vant/weapp/notify/notify'; + +import { + callScanUrl +} from "../../api/common/scan.js" + + Page({ onShareAppMessage(res) {}, data: { @@ -186,4 +194,57 @@ Page({ } }, + + // 扫一扫 + jumpScan() { + let _this = this; + wx.scanCode({ + scanType: 'qrCode', + success(res) { + console.log('success', res) + let url = res.result; + // 扫码调用地址 + _this.scanCallUrl(url) + }, + fail(res) { + console.log('fail', res) + // 危险通知 + _this.showErrMsg('扫码失败!') + } + }) + }, + + // 扫码调用地址 + scanCallUrl(url) { + let _this = this; + let paramUrl = '&userId=' + wx.getStorageSync('userId') + callScanUrl(url, paramUrl).then(res => { + if (res.code == 0) { + // 成功通知 + _this.showSuccessMsg(res.msg) + } else { + // 危险通知 + _this.showErrMsg(res.msg) + } + }) + }, + + // 成功通知 + showSuccessMsg(msg) { + Notify({ + type: 'success', + top: '160rpx', + message: msg + }); + }, + + // 危险通知 + showErrMsg(msg) { + Notify({ + type: 'danger', + top: '160rpx', + message: msg + }); + }, + }) \ No newline at end of file diff --git a/miniprogram/pages/index/index.json b/miniprogram/pages/index/index.json index 1d9aaf5..ec2ed9e 100644 --- a/miniprogram/pages/index/index.json +++ b/miniprogram/pages/index/index.json @@ -1,4 +1,7 @@ { "navigationBarTitleText": "中电郑州数据创新中心", - "navigationStyle": "custom" + "navigationStyle": "custom", + "usingComponents": { + "van-notify": "@vant/weapp/notify/index" + } } \ No newline at end of file diff --git a/miniprogram/pages/index/index.wxml b/miniprogram/pages/index/index.wxml index 47a93cf..e8a4b41 100644 --- a/miniprogram/pages/index/index.wxml +++ b/miniprogram/pages/index/index.wxml @@ -1,8 +1,5 @@ - - - 当前园区:{{parkName? parkName:'请先选择园区'}} @@ -10,7 +7,7 @@ - + 中电郑州数据创新中心 @@ -44,4 +41,8 @@ {{item.text}} - \ No newline at end of file + + + + + \ No newline at end of file diff --git a/miniprogram/pages/my/my.js b/miniprogram/pages/my/my.js index 0e9cb20..d760496 100644 --- a/miniprogram/pages/my/my.js +++ b/miniprogram/pages/my/my.js @@ -1,9 +1,15 @@ let app = getApp() +import Notify from '@vant/weapp/notify/notify'; + import { userProfile } from "../../api/user/user.js" +import { + callScanUrl +} from "../../api/common/scan.js" + Page({ /** @@ -41,6 +47,10 @@ Page({ }, ], customerPages: [{ + name: "预约记录", + url: "/pages/meeting/reservationRecord/reservationRecord", + }, + { name: "我的活动", url: "/pages/myActivities/myActivities", }, @@ -107,8 +117,9 @@ Page({ navigateTo(e) { if (wx.getStorageSync('userId')) { + let dataset = e.currentTarget.dataset; wx.navigateTo({ - url: e.currentTarget.dataset.url, + url: dataset.url + "?name=" + dataset.name, }) } else { app.getlogin() @@ -127,4 +138,54 @@ Page({ } }, + // 扫一扫 + jumpScan() { + let _this = this; + wx.scanCode({ + scanType: 'qrCode', + success(res) { + console.log('success', res) + let url = res.result; + // 扫码调用地址 + _this.scanCallUrl(url) + }, + fail(res) { + console.log('fail', res) + // 危险通知 + _this.showErrMsg('扫码失败!') + } + }) + }, + + // 扫码调用地址 + scanCallUrl(url) { + let _this = this; + let paramUrl = '&userId=' + wx.getStorageSync('userId') + callScanUrl(url, paramUrl).then(res => { + if (res.code == 0) { + // 成功通知 + _this.showSuccessMsg(res.msg) + } else { + // 危险通知 + _this.showErrMsg(res.msg) + } + }) + }, + + // 成功通知 + showSuccessMsg(msg) { + Notify({ + type: 'success', + message: msg + }); + }, + + // 危险通知 + showErrMsg(msg) { + Notify({ + type: 'danger', + message: msg + }); + }, + }) \ No newline at end of file diff --git a/miniprogram/pages/my/my.json b/miniprogram/pages/my/my.json index 546980f..4672ced 100644 --- a/miniprogram/pages/my/my.json +++ b/miniprogram/pages/my/my.json @@ -1,6 +1,7 @@ { "navigationBarTitleText": "我的", "usingComponents": { - "van-icon": "@vant/weapp/icon/index" + "van-icon": "@vant/weapp/icon/index", + "van-notify": "@vant/weapp/notify/index" } } \ No newline at end of file diff --git a/miniprogram/pages/my/my.wxml b/miniprogram/pages/my/my.wxml index 195af41..5ac5086 100644 --- a/miniprogram/pages/my/my.wxml +++ b/miniprogram/pages/my/my.wxml @@ -12,7 +12,14 @@ - + + + 扫一扫 + + + + + {{item.name}} @@ -27,4 +34,7 @@ {{item.text}} - \ No newline at end of file + + + + \ No newline at end of file diff --git a/miniprogram/pages/my/my.wxss b/miniprogram/pages/my/my.wxss index d431183..3564d7d 100644 --- a/miniprogram/pages/my/my.wxss +++ b/miniprogram/pages/my/my.wxss @@ -16,7 +16,7 @@ justify-content: flex-start; align-items: center; padding: 28rpx 24rpx; - border-bottom: 1px solid rgb(126, 126, 126, 0.2); + border-bottom: 1px solid rgb(241, 241, 241, 0.8); } .itemView .itemData:last-of-type {