217 lines
5.8 KiB
JavaScript
Raw Normal View History

2024-02-21 17:43:11 +08:00
let app = getApp()
2024-03-13 15:14:37 +08:00
2024-03-13 18:27:17 +08:00
import Notify from '@vant/weapp/notify/notify';
2024-03-13 15:14:37 +08:00
import {
userProfile
} from "../../api/user/user.js"
2024-03-13 18:27:17 +08:00
import {
callScanUrl
} from "../../api/common/scan.js"
2024-05-06 15:24:42 +08:00
import {
getUrlParamsObj
} from "../../utils/util.js"
2024-02-21 17:43:11 +08:00
Page({
2024-02-22 18:57:41 +08:00
/**
* 页面的初始数据
*/
data: {
2024-03-13 15:14:37 +08:00
DOMAIN_NAME: app.IMG_NAME,
userDetail: {},
2024-02-22 18:57:41 +08:00
// tabBar param
tabBarParam: {
selected: 2,
color: "#515151",
selectedColor: "#217CFF",
backgroundColor: "#ffffff",
2024-02-21 17:43:11 +08:00
},
2024-02-22 18:57:41 +08:00
// tabBar menu
tabBarList: [{
"pagePath": "pages/index/index",
"iconPath": "/images/tabbar/home.png",
"selectedIconPath": "/images/tabbar/home-select.png",
"text": "首页"
},
{
2024-06-25 17:33:04 +08:00
"pagePath": "pages/meeting/meetingReservation/meetingReservation",
2024-02-22 18:57:41 +08:00
"iconPath": "/images/tabbar/openDoor.png",
"selectedIconPath": "/images/tabbar/openDoor.png",
2024-06-25 17:33:04 +08:00
"text": "预约",
2024-02-22 18:57:41 +08:00
"bulge": true,
},
{
"pagePath": "pages/my/my",
"iconPath": "/images/tabbar/my.png",
"selectedIconPath": "/images/tabbar/my-select.png",
"text": "我的"
},
],
2024-03-13 15:14:37 +08:00
customerPages: [{
2024-03-13 18:27:17 +08:00
name: "预约记录",
2024-06-25 17:33:04 +08:00
url: "/pages/meeting/reservationRecord/meetingRecord/meetingRecord",
2024-03-13 15:14:37 +08:00
},
2024-03-13 15:32:05 +08:00
// {
2024-06-25 17:33:04 +08:00
// name: "我的活动",
// url: "/pages/myActivities/myActivities",
// },
// {
// name: "我的入驻",
// url: "/pages/my/serviceApply/serviceApply"
// },
// {
// name: "我的建议",
// url: "/pages/complaint/complaint",
// },
// {
2024-03-13 15:32:05 +08:00
// name: "账号设置",
// url: "/pages/my/accountSetting/accountSetting",
// },
2024-06-25 17:33:04 +08:00
// {
// name: "我的服务",
// url: "/pages/enterpriseServices/myServiceList/myServiceList"
// },
// {
// name: "我的报修",
// url: "/pages/parkRepair/parkRepair",
// }
2024-02-22 18:57:41 +08:00
],
2024-05-06 15:24:42 +08:00
qrcodeParam: null,
2024-02-22 18:57:41 +08:00
},
2024-02-21 17:43:11 +08:00
2024-03-13 15:14:37 +08:00
// 切换tabbar
switchTab(e) {
2024-02-22 18:57:41 +08:00
const data = e.currentTarget.dataset
console.log('switchTab', data)
const url = data.path
2024-06-25 17:33:04 +08:00
if (url == 'pages/meeting/meetingReservation/meetingReservation') {
2024-02-23 15:15:37 +08:00
wx.navigateTo({
url: '/' + url
})
2024-03-13 15:14:37 +08:00
} else {
2024-02-23 15:15:37 +08:00
wx.switchTab({
url: '/' + url
})
}
2024-02-22 18:57:41 +08:00
},
/**
* 生命周期函数--监听页面加载
*/
2024-03-13 15:14:37 +08:00
onLoad(options) {
},
2024-02-22 18:57:41 +08:00
onShow() {
2024-03-13 15:14:37 +08:00
let _this = this
let userId = wx.getStorageSync('userId');
if (userId) {
userProfile(userId).then(res => {
console.log('userProfile', res);
_this.setData({
userDetail: res.data
2024-02-22 18:57:41 +08:00
})
})
} else {
app.getlogin()
}
},
2024-03-13 15:14:37 +08:00
2024-02-22 18:57:41 +08:00
navigateTo(e) {
2024-03-13 15:14:37 +08:00
if (wx.getStorageSync('userId')) {
2024-03-13 18:27:17 +08:00
let dataset = e.currentTarget.dataset;
2024-03-13 15:32:05 +08:00
wx.navigateTo({
2024-03-13 18:27:17 +08:00
url: dataset.url + "?name=" + dataset.name,
2024-03-13 15:32:05 +08:00
})
2024-02-22 18:57:41 +08:00
} else {
app.getlogin()
}
},
2024-03-13 15:14:37 +08:00
2024-02-22 18:57:41 +08:00
navpersonalData() {
2024-03-13 15:14:37 +08:00
if (wx.getStorageSync('userId')) {
2024-02-22 18:57:41 +08:00
wx.navigateTo({
2024-03-13 15:14:37 +08:00
url: '/pages/my/personalData/personalData',
2024-02-22 18:57:41 +08:00
})
} else {
wx.navigateTo({
url: '/pages/login/login',
})
}
2024-03-13 15:14:37 +08:00
},
2024-03-13 18:27:17 +08:00
// 扫一扫
jumpScan() {
let _this = this;
wx.scanCode({
scanType: 'qrCode',
success(res) {
console.log('success', res)
let url = res.result;
2024-05-06 15:24:42 +08:00
// 判断二维码是否符合规范
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('二维码不正确!')
}
2024-03-13 18:27:17 +08:00
},
fail(res) {
console.log('fail', res)
// 危险通知
_this.showErrMsg('扫码失败!')
}
})
},
// 扫码调用地址
2024-05-06 15:24:42 +08:00
scanCallUrl() {
2024-03-13 18:27:17 +08:00
let _this = this;
2024-05-06 15:24:42 +08:00
let qrcodeParam = _this.data.qrcodeParam;
qrcodeParam.userId = wx.getStorageSync('userId')
callScanUrl(qrcodeParam).then(res => {
// 清空扫码数据
_this.setData({
qrcodeParam: null
})
2024-03-13 18:27:17 +08:00
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
});
},
2024-02-21 17:43:11 +08:00
})