出入码小程序刷新请求完成;优化调试输出;添加出入码接口mock;配置业务域名SSL证书
This commit is contained in:
@@ -12,7 +12,7 @@ App.use(setGlobalDataPlugin, {
|
||||
globalData: {
|
||||
debugMode: true, // 是否展示调试内容
|
||||
baseUrl: true
|
||||
? "http://39.99.244.156:5203"
|
||||
? "https://epp.only4.work"
|
||||
: "http://localhost", // 不带最后的 /
|
||||
}
|
||||
})
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<view v-if="debugMode">
|
||||
<button @tap='debugCleanCache'>清除缓存</button>
|
||||
<textarea maxlength="-1" disabled="true" auto-height="true" :value="debugText"></textarea>
|
||||
<textarea maxlength="-1" disabled="true" auto-height="true" style="width: 100%" :value="debugText"></textarea>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -12,22 +12,25 @@ import { eventCenter, getCurrentInstance } from '@tarojs/taro'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
userInfo: null,
|
||||
debugMode: Taro.getApp().globalData.debugMode,
|
||||
debugText: "",
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
eventCenter.once(getCurrentInstance().router.onShow, () => {
|
||||
this.userInfo = Taro.getStorageSync("userInfo");
|
||||
this.displayUsername = this.userInfo?.username ?? "请登录";
|
||||
const res = Taro.getStorageInfoSync()
|
||||
let storage = {};
|
||||
res.keys.forEach(key => storage[key] = Taro.getStorageSync(key))
|
||||
this.debugText = JSON.stringify({
|
||||
"TARO_ENV": process.env.TARO_ENV,
|
||||
// "isVisitor": this.isVisitor,
|
||||
// "isUser": this.isUser,
|
||||
// "isAdmin": this.isAdmin,
|
||||
"userInfo": this.userInfo || 'null'
|
||||
}, null, 4)
|
||||
TARO_ENV: process.env.TARO_ENV,
|
||||
globalData: Taro.getApp().globalData,
|
||||
storage: storage,
|
||||
// storageInfo: {
|
||||
// keys: res.keys,
|
||||
// currentSize: res.currentSize,
|
||||
// limitSize: res.limitSize
|
||||
// },
|
||||
}, null, 8)
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
|
@@ -1,11 +1,30 @@
|
||||
.time-text {
|
||||
#codeView {
|
||||
text-align: center;
|
||||
margin-top: 100px;
|
||||
}
|
||||
|
||||
#user-text {
|
||||
font-size: 35px;
|
||||
}
|
||||
|
||||
#time-text {
|
||||
font-weight: bold;
|
||||
font-size: 40px;
|
||||
margin-top: 50px;
|
||||
}
|
||||
|
||||
#myQrcode {
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
|
||||
margin-top: 50px;
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
#show-text {
|
||||
font-weight: bold;
|
||||
font-size: 45px;
|
||||
}
|
||||
|
||||
#small-text {
|
||||
margin-top: 80px;
|
||||
color: grey;
|
||||
font-size: small;
|
||||
}
|
||||
|
@@ -1,10 +1,10 @@
|
||||
<template>
|
||||
<view>
|
||||
<view style="text-align: center; margin-top: 100px;">
|
||||
<view><text>{{ id }} | {{ name }}</text></view>
|
||||
<canvas type="2d" style="width: 70vw; height: 70vw;" id="myQrcode"></canvas>
|
||||
<view><text class="time-text">{{ time }}</text></view>
|
||||
</view>
|
||||
<view id="codeView" :style="{ display: isShow }">
|
||||
<view id="user-text"><text>{{ userText }}</text></view>
|
||||
<view id="time-text"><text>{{ time }}</text></view>
|
||||
<canvas type="2d" style="width: 70vw; height: 70vw;" id="myQrcode"></canvas>
|
||||
<view id="show-text"><text :style="{ color: showTextColor }">{{ showText }}</text></view>
|
||||
<view id="small-text"><text>下拉可刷新</text></view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -21,13 +21,14 @@ export default {
|
||||
...Taro.getApp().globalData,
|
||||
userInfo: null,
|
||||
timeInterval: null,
|
||||
id: '',
|
||||
name: '',
|
||||
isShow: 'none',
|
||||
userText: '',
|
||||
showText: '',
|
||||
showTextColor: '',
|
||||
time: '',
|
||||
}
|
||||
},
|
||||
|
||||
// 对应 onShow
|
||||
onShow() {
|
||||
console.log('onShow')
|
||||
setTimeout(() => {
|
||||
@@ -35,31 +36,65 @@ export default {
|
||||
}, 100)
|
||||
},
|
||||
|
||||
// 对应 onHide
|
||||
onHide() {
|
||||
console.log('onHide')
|
||||
clearInterval(this.timeInterval);
|
||||
this.isShow = 'none'
|
||||
},
|
||||
|
||||
// 对应 onPullDownRefresh
|
||||
onPullDownRefresh() {
|
||||
console.log('onPullDownRefresh')
|
||||
Taro.showNavigationBarLoading();
|
||||
clearInterval(this.timeInterval);
|
||||
this.id = ''
|
||||
this.name = ''
|
||||
this.time = ''
|
||||
this.isShow = 'none'
|
||||
this.userInfo = Taro.getStorageSync("userInfo");
|
||||
if (!this.userInfo) {
|
||||
Taro.redirectTo({
|
||||
url: '/pages/index/login'
|
||||
})
|
||||
}
|
||||
this.id = this.userInfo.id
|
||||
this.name = this.userInfo.realname
|
||||
this.drawCode()
|
||||
Taro.stopPullDownRefresh();
|
||||
Taro.hideNavigationBarLoading();
|
||||
Taro.showLoading({ title: '加载中' })
|
||||
var that = this;
|
||||
Taro.request({
|
||||
url: `${this.baseUrl}/access/getCodeInfo`,
|
||||
method: "POST",
|
||||
header: {
|
||||
"Content-Type": "application/x-www-form-urlencoded" //用于post
|
||||
},
|
||||
data: {
|
||||
id: this.userInfo.id,
|
||||
},
|
||||
success: function (d) {
|
||||
Taro.hideLoading()
|
||||
let result = d.data;
|
||||
if (result.success) {
|
||||
console.log(result.data);
|
||||
that.userText = `${that.userInfo.id} | ${that.userInfo.realname}`
|
||||
that.showText = result.data.infoText
|
||||
that.showTextColor = result.data.infoTextColor
|
||||
that.drawCode(`https://epp.cxyxiaomo.com/access/validCode?id=${result.data.id}&t=${Date.now()}`, result.data.qrcodeColor)
|
||||
} else {
|
||||
Taro.showToast({
|
||||
title: result.msg,
|
||||
icon: 'error',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
that.isShow = ''
|
||||
},
|
||||
fail: function () {
|
||||
Taro.hideLoading()
|
||||
Taro.showToast({
|
||||
title: "请求失败",
|
||||
icon: 'error',
|
||||
duration: 2000
|
||||
})
|
||||
},
|
||||
complete: function () {
|
||||
Taro.stopPullDownRefresh();
|
||||
Taro.hideNavigationBarLoading();
|
||||
}
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
drawCode(text = 'https://www.baidu.com/', foreground = 'red') {
|
||||
|
Reference in New Issue
Block a user