1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

出入码下拉刷新功能;内网穿透配置文件

This commit is contained in:
2022-11-26 15:31:35 +08:00
parent 00652ee179
commit eaecc486df
11 changed files with 115 additions and 45 deletions

View File

@@ -11,7 +11,9 @@ const App = createApp({
App.use(setGlobalDataPlugin, {
globalData: {
debugMode: true, // 是否展示调试内容
baseUrl: "http://localhost", // 不带最后的 /
baseUrl: true
? "http://39.99.244.156:5203"
: "http://localhost", // 不带最后的 /
}
})

View File

@@ -62,7 +62,7 @@ export default {
title: "登录成功",
icon: 'success',
success: function () {
Taro.redirectTo({
Taro.switchTab({
url: '/pages/index/index'
})
}

View File

@@ -1,3 +1,4 @@
export default definePageConfig({
navigationBarTitleText: '身份码'
navigationBarTitleText: '身份码',
enablePullDownRefresh: true,
})

View File

@@ -5,5 +5,7 @@
#myQrcode {
display: block;
margin: 0 auto;
/* border: 20px solid red; */
margin-top: 50px;
margin-bottom: 40px;
}

View File

@@ -1,8 +1,5 @@
<template>
<view>
<view>
<image src="../../image/home.jpg" style="width: 100%;height: 150px;"></image>
</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>
@@ -15,36 +12,58 @@
import Taro from '@tarojs/taro'
import { eventCenter, getCurrentInstance } from '@tarojs/taro'
import drawQrcode from '../../utils/qrcode/index'
import utils from '../../utils/utils'
import './code.css'
export default {
data() {
return {
...Taro.getApp().globalData,
userInfo: null,
id: 'id',
name: '姓名',
time: 'time',
timeInterval: null,
id: '',
name: '',
time: '',
}
},
mounted() {
eventCenter.once(getCurrentInstance().router.onShow, () => {
console.log('onShow')
this.userInfo = Taro.getStorageSync("userInfo");
if (this.userInfo) {
console.log(this.userInfo)
this.id = this.userInfo.id
this.name = this.userInfo.realname
this.drawCode()
} else {
Taro.redirectTo({
url: '/pages/index/login'
})
}
})
// 对应 onShow
onShow() {
console.log('onShow')
setTimeout(() => {
Taro.startPullDownRefresh();
}, 100)
},
// 对应 onHide
onHide() {
console.log('onHide')
clearInterval(this.timeInterval);
},
// 对应 onPullDownRefresh
onPullDownRefresh() {
console.log('onPullDownRefresh')
Taro.showNavigationBarLoading();
clearInterval(this.timeInterval);
this.id = ''
this.name = ''
this.time = ''
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();
},
methods: {
drawCode() {
drawCode(text = 'https://www.baidu.com/', foreground = 'red') {
const query = wx.createSelectorQuery()
query.select('#myQrcode')
.fields({
@@ -61,28 +80,17 @@ export default {
width: 260,
padding: 30,
background: '#ffffff',
foreground: 'red', // '#000000',
text: '大王顶真帅',
foreground: foreground,
text: text,
})
// 获取临时路径(得到之后,想干嘛就干嘛了)
wx.canvasToTempFilePath({
canvasId: 'myQrcode',
canvas: canvas,
x: 0,
y: 0,
width: 260,
height: 260,
destWidth: 260,
destHeight: 260,
success(res) {
console.log('二维码临时路径:', res.tempFilePath)
},
fail(res) {
console.error(res)
}
})
this.timeInterval = setInterval(this.updateTime, 1000);
this.updateTime();
})
},
updateTime() {
this.time = utils.formatTime(new Date())
console.log("刷新时间")
}
}
}