You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
2.1 KiB
85 lines
2.1 KiB
// pages/home/qrcode/index.js
|
|
const request = require('../../../utils/request') //导入模块
|
|
const util = require('../../../utils/util')
|
|
const app = getApp()
|
|
|
|
Page({
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
fgColor: 'black',
|
|
userInfo: null,
|
|
avatarUrl: null,
|
|
screenBrightness: ''
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.fetchUserInfo()
|
|
var that = this
|
|
// 获取屏幕亮度
|
|
wx.getScreenBrightness({
|
|
success: function (res) {
|
|
that.setData({
|
|
screenBrightness: res.value
|
|
})
|
|
}
|
|
})
|
|
//设置屏幕亮度
|
|
wx.setScreenBrightness({
|
|
value: 1, //屏幕亮度值,范围 0~1,0 最暗,1 最亮
|
|
})
|
|
},
|
|
|
|
fetchUserInfo: function () {
|
|
// /user/userInfo 获取用户信息
|
|
request.get('/user-centre/front/customer/myInfo').then(result => {
|
|
app.globalData.userInfo = result.data
|
|
if (!this.data.avatarUrl) {
|
|
this.setData({
|
|
avatarUrl: util.isEmpty(app.globalData.userInfo.avatar) ? '/assets/image/ygImg.png' : app.globalData.userInfo.avatar,
|
|
userInfo: app.globalData.userInfo,
|
|
value: app.globalData.userInfo.userId,
|
|
userName: app.globalData.userInfo.userName.substring(0, 14)
|
|
})
|
|
} else {
|
|
this.setData({
|
|
userInfo: app.globalData.userInfo,
|
|
value: app.globalData.userInfo.userId,
|
|
userName: app.globalData.userInfo.userName.substring(0, 14)
|
|
})
|
|
}
|
|
}).catch((e) => {
|
|
|
|
})
|
|
},
|
|
|
|
previewImage: function() {
|
|
// 在自定义组件下,当前组件实例的 this,以操作组件内 <canvas> 组件
|
|
const that = this.selectComponent('#qrcode')
|
|
wx.canvasToTempFilePath({
|
|
canvasId: 'wux-qrcode',
|
|
success: (res) => {
|
|
wx.previewImage({
|
|
urls: [res.tempFilePath]
|
|
})
|
|
}
|
|
}, that)
|
|
},
|
|
toCardInfo: function(){
|
|
wx.navigateTo({
|
|
url: '/pages/home/instructions/index'
|
|
})
|
|
},
|
|
// 监听页面卸载
|
|
onUnload: function () {
|
|
//设置屏幕亮度为原来亮度
|
|
wx.setScreenBrightness({
|
|
value: this.data.screenBrightness,
|
|
})
|
|
}
|
|
|
|
})
|