代码拉取完成,页面将自动刷新
同步操作将从 ganshisheng/247_数独小游戏小程序模板 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
//app.js
import { degree } from './utils/config.js'
App({
globalData: {
deviceInfo: null,
// 遮挡率
shadeDegree: .3,
// 性能优化
optimization: false,
requestHost: 'https://www.easy-mock.com/mock/59d100919cabc90bb5e5743c/sudoLite',
share: null,
degree: degree,
},
onLaunch: function () {
wx.getSystemInfo({
success: res => {
this.globalData.deviceInfo = res
},
})
this.globalData.shadeDegree = wx.getStorageSync('shadeDegree') || .3
// wx.getStorage({
// key: 'shadeDegree',
// success: res => {
// this.globalData.shadeDegree = res.data
// },
// })
this.globalData.optimization = wx.getStorageSync('optimization') || false
// wx.getStorage({
// key: 'optimization',
// success: res => {
// this.globalData.optimization = res.data
// },
// })
wx.request({
url: this.globalData.requestHost + '/degree',
method: 'GET',
success: res => {
if (res.data.code === 201) {
this.globalData.degree = res.data.result
}
}
})
},
onShow: function () {
wx.request({
url: this.globalData.requestHost + '/notice',
method: 'GET',
success: res => {
if (res.data.code === 201) {
if (res.data.result.showOnce) {
let hasShow = wx.getStorageSync('noticeShowOnce')
if (hasShow === '' || res.data.result.id !== hasShow) {
wx.showModal({
title: res.data.result.title,
content: res.data.result.content,
showCancel: false,
success: e => {
if (e.confirm) {
wx.setStorage({
key: 'noticeShowOnce',
data: res.data.result.id,
})
}
}
})
}
} else {
wx.showModal({
title: res.data.result.title,
content: res.data.result.content,
showCancel: false,
})
}
}
},
})
wx.request({
url: this.globalData.requestHost + '/share',
method: 'GET',
success: res => {
if (res.data.code === 201) {
this.globalData.share = res.data.result
}
}
})
},
adapterDegree(shadeDegree, returnType = 'title') {
let setDegree = parseInt(shadeDegree * 100)
let title, range
this.globalData.degree.map(item => {
if (setDegree >= item.range[0] && setDegree <= item.range[1]) {
title = item.title
range = item.range
// 好像并不会跳过剩余的循环
return
}
})
if (returnType === 'range') {
return range
}
return title
}
})
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。