parent
1ff4a694b5
commit
4f2a454416
@ -1,39 +1,39 @@
|
|||||||
//app.js
|
//app.js
|
||||||
App({
|
App({
|
||||||
onLaunch: function () {
|
onLaunch: function () {
|
||||||
// 展示本地存储能力
|
// 展示本地存储能力
|
||||||
var logs = wx.getStorageSync('logs') || []
|
var logs = wx.getStorageSync('logs') || []
|
||||||
logs.unshift(Date.now())
|
logs.unshift(Date.now())
|
||||||
wx.setStorageSync('logs', logs)
|
wx.setStorageSync('logs', logs)
|
||||||
|
|
||||||
// 登录
|
// 登录
|
||||||
wx.login({
|
wx.login({
|
||||||
success: res => {
|
success: res => {
|
||||||
// 发送 res.code 到后台换取 openId, sessionKey, unionId
|
// 发送 res.code 到后台换取 openId, sessionKey, unionId
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// 获取用户信息
|
// 获取用户信息
|
||||||
wx.getSetting({
|
wx.getSetting({
|
||||||
success: res => {
|
success: res => {
|
||||||
if (res.authSetting['scope.userInfo']) {
|
if (res.authSetting['scope.userInfo']) {
|
||||||
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
|
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
|
||||||
wx.getUserInfo({
|
wx.getUserInfo({
|
||||||
success: res => {
|
success: res => {
|
||||||
// 可以将 res 发送给后台解码出 unionId
|
// 可以将 res 发送给后台解码出 unionId
|
||||||
this.globalData.userInfo = res.userInfo
|
this.globalData.userInfo = res.userInfo
|
||||||
|
|
||||||
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
|
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
|
||||||
// 所以此处加入 callback 以防止这种情况
|
// 所以此处加入 callback 以防止这种情况
|
||||||
if (this.userInfoReadyCallback) {
|
if (this.userInfoReadyCallback) {
|
||||||
this.userInfoReadyCallback(res)
|
this.userInfoReadyCallback(res)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
globalData: {
|
globalData: {
|
||||||
userInfo: null
|
userInfo: null
|
||||||
}
|
}
|
||||||
})
|
})
|
@ -1,53 +1,53 @@
|
|||||||
{
|
{
|
||||||
"pages": [
|
"pages": [
|
||||||
"shouye/shouye",
|
"shouye/shouye",
|
||||||
"chazhao/chazhao",
|
"chazhao/chazhao",
|
||||||
"jieyue/jieyue",
|
"jieyue/jieyue",
|
||||||
"wode/wode"
|
"wode/wode"
|
||||||
],
|
],
|
||||||
"window": {
|
"window": {
|
||||||
"backgroundTextStyle": "light",
|
"backgroundTextStyle": "light",
|
||||||
"navigationBarBackgroundColor": "#fff",
|
"navigationBarBackgroundColor": "#fff",
|
||||||
"navigationBarTitleText": "WeChat",
|
"navigationBarTitleText": "WeChat",
|
||||||
"navigationBarTextStyle": "black"
|
"navigationBarTextStyle": "black"
|
||||||
},
|
},
|
||||||
"tabBar": {
|
"tabBar": {
|
||||||
"color": "#000000",
|
"color": "#000000",
|
||||||
"selectedColor": "#fd9941",
|
"selectedColor": "#fd9941",
|
||||||
"borderStyle": "white",
|
"borderStyle": "white",
|
||||||
"backgroundColor": "#ffffff",
|
"backgroundColor": "#ffffff",
|
||||||
"list": [
|
"list": [
|
||||||
{
|
{
|
||||||
"pagePath": "shouye/shouye",
|
"pagePath": "shouye/shouye",
|
||||||
"text": "首页",
|
"text": "首页",
|
||||||
"iconPath": "image/shouye.png",
|
"iconPath": "image/shouye.png",
|
||||||
"selectedIconPath": "image/shouye-hl.png"
|
"selectedIconPath": "image/shouye-hl.png"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"pagePath": "chazhao/chazhao",
|
"pagePath": "chazhao/chazhao",
|
||||||
"text": "查找",
|
"text": "查找",
|
||||||
"iconPath": "image/chazhao.png",
|
"iconPath": "image/chazhao.png",
|
||||||
"selectedIconPath": "image/chazhao-hl.png"
|
"selectedIconPath": "image/chazhao-hl.png"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"pagePath": "jieyue/jieyue",
|
"pagePath": "jieyue/jieyue",
|
||||||
"text": "借阅",
|
"text": "借阅",
|
||||||
"iconPath":"image/jieyue.png",
|
"iconPath":"image/jieyue.png",
|
||||||
"selectedIconPath":"image/jieyue-hl.png"
|
"selectedIconPath":"image/jieyue-hl.png"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"pagePath": "wode/wode",
|
"pagePath": "wode/wode",
|
||||||
"text": "我的",
|
"text": "我的",
|
||||||
"iconPath": "image/wode.png",
|
"iconPath": "image/wode.png",
|
||||||
"selectedIconPath": "image/wode-hl.png"
|
"selectedIconPath": "image/wode-hl.png"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,10 +1,10 @@
|
|||||||
/**app.wxss**/
|
/**app.wxss**/
|
||||||
.container {
|
.container {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
padding: 100rpx 0;
|
padding: 100rpx 0;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
// chazhao/chazhao.js
|
// chazhao/chazhao.js
|
||||||
Component({
|
Component({
|
||||||
/**
|
/**
|
||||||
* 组件的属性列表
|
* 组件的属性列表
|
||||||
*/
|
*/
|
||||||
properties: {
|
properties: {
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 组件的初始数据
|
* 组件的初始数据
|
||||||
*/
|
*/
|
||||||
data: {
|
data: {
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 组件的方法列表
|
* 组件的方法列表
|
||||||
*/
|
*/
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"component": true,
|
"component": true,
|
||||||
"usingComponents": {}
|
"usingComponents": {}
|
||||||
}
|
}
|
@ -1,2 +1,2 @@
|
|||||||
<!--chazhao/chazhao.wxml-->
|
<!--chazhao/chazhao.wxml-->
|
||||||
<text>chazhao/chazhao.wxml</text>
|
<text>chazhao/chazhao.wxml</text>
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
// jieyue/jieyue.js
|
// jieyue/jieyue.js
|
||||||
Component({
|
Component({
|
||||||
/**
|
/**
|
||||||
* 组件的属性列表
|
* 组件的属性列表
|
||||||
*/
|
*/
|
||||||
properties: {
|
properties: {
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 组件的初始数据
|
* 组件的初始数据
|
||||||
*/
|
*/
|
||||||
data: {
|
data: {
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 组件的方法列表
|
* 组件的方法列表
|
||||||
*/
|
*/
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"component": true,
|
"component": true,
|
||||||
"usingComponents": {}
|
"usingComponents": {}
|
||||||
}
|
}
|
@ -1,2 +1,8 @@
|
|||||||
<!--jieyue/jieyue.wxml-->
|
<!--jieyue/jieyue.wxml-->
|
||||||
<text>jieyue/jieyue.wxml</text>
|
<text>jieyue/jieyue.wxml</text>
|
||||||
|
|
||||||
|
|
||||||
|
<button class="wx-button_XgkbLE" hover-class="other-button-hover" size="default"
|
||||||
|
>
|
||||||
|
扫一扫
|
||||||
|
</button>
|
@ -1 +1,78 @@
|
|||||||
/* jieyue/jieyue.wxss */
|
/* jieyue/jieyue.wxss */
|
||||||
|
page {
|
||||||
|
background-image: url("http://qty83k.creatby.com/materials/143414/origin/e7ca84df3ecfa54f87273d3bb346aaad_origin.jpg"); background-size: contain; background-repeat: no-repeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
view,scroll-view,swiper,swiper-item,icon,text,progress,button,checkbox-group,checkbox,form,input,label,picker,radio-group,radio,slider,switch,action-sheet,action-sheet-item,action-sheet-cancel,modal,toast,loading,navigator,audio,image,video,map,canvas {
|
||||||
|
-webkit-box-sizing: border-box;
|
||||||
|
-moz-box-sizing: border-box;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
page {
|
||||||
|
height: 100%;
|
||||||
|
font-family: -apple-system-font,Helvetica Neue,Helvetica,sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
checkbox-group,
|
||||||
|
radio-group{
|
||||||
|
display:block;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
:before,
|
||||||
|
:after ,
|
||||||
|
::before,
|
||||||
|
::after{
|
||||||
|
-webkit-box-sizing: border-box;
|
||||||
|
-moz-box-sizing: border-box;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
.c-minheight {
|
||||||
|
min-height: 80px;
|
||||||
|
}
|
||||||
|
.c-full {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
.c-block {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
.c-autosize {
|
||||||
|
width: auto;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
.c-fullwidth {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.c-fullheight {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
.c-initHide{
|
||||||
|
opacity:0 !important;
|
||||||
|
}
|
||||||
|
.c-ellipse{
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
-webkit-line-clamp: 2;
|
||||||
|
overflow:hidden;
|
||||||
|
}
|
||||||
|
/* 自定义样式 */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.body_PPYMWQ{background-image: url("http://qty83k.creatby.com/materials/143414/origin/e7ca84df3ecfa54f87273d3bb346aaad_origin.jpg"); background-size: contain; background-repeat: no-repeat; }
|
||||||
|
.wx-button_FNtt93{border-style: none; border-color: transparent; margin: 230px 25px 10px; border-radius: 20px; transition: all; font-family: andale mono; background-attachment: fixed; transform: rotate(0deg) scale(1) translate(0%, -43%); background-color: rgba(253,153, 65, 0.67); }
|
||||||
|
.wx-button_MrC8rl{border-radius: 20px; margin-right: 25px; margin-left: 25px; border-bottom-right-radius: 20px; border-bottom-left-radius: 20px; border-top-right-radius: 20px; border-top-left-radius: 20px; }
|
||||||
|
.wx-button_XgkbLE{border-radius: 20px; transition: all; margin-top: 210px; margin-right: 100px; margin-left: 100px; opacity: 0.73; background-color: rgba(253,153, 65, 0.67);}
|
||||||
|
.wx-view_g5MjCx{border-radius: 200px; transition: all; transform: rotate(0deg) scale(1) translate(0%, -434%);}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
// shouye/shouye.js
|
// shouye/shouye.js
|
||||||
Component({
|
Component({
|
||||||
/**
|
/**
|
||||||
* 组件的属性列表
|
* 组件的属性列表
|
||||||
*/
|
*/
|
||||||
properties: {
|
properties: {
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 组件的初始数据
|
* 组件的初始数据
|
||||||
*/
|
*/
|
||||||
data: {
|
data: {
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 组件的方法列表
|
* 组件的方法列表
|
||||||
*/
|
*/
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"component": true,
|
"component": true,
|
||||||
"usingComponents": {}
|
"usingComponents": {}
|
||||||
}
|
}
|
@ -1,2 +1,2 @@
|
|||||||
<!--shouye/shouye.wxml-->
|
<!--shouye/shouye.wxml-->
|
||||||
<text>shouye/shouye.wxml</text>
|
<text>shouye/shouye.wxml</text>
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
const formatTime = date => {
|
const formatTime = date => {
|
||||||
const year = date.getFullYear()
|
const year = date.getFullYear()
|
||||||
const month = date.getMonth() + 1
|
const month = date.getMonth() + 1
|
||||||
const day = date.getDate()
|
const day = date.getDate()
|
||||||
const hour = date.getHours()
|
const hour = date.getHours()
|
||||||
const minute = date.getMinutes()
|
const minute = date.getMinutes()
|
||||||
const second = date.getSeconds()
|
const second = date.getSeconds()
|
||||||
|
|
||||||
return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
|
return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
|
||||||
}
|
}
|
||||||
|
|
||||||
const formatNumber = n => {
|
const formatNumber = n => {
|
||||||
n = n.toString()
|
n = n.toString()
|
||||||
return n[1] ? n : '0' + n
|
return n[1] ? n : '0' + n
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
formatTime: formatTime
|
formatTime: formatTime
|
||||||
}
|
}
|
||||||
|
@ -1,53 +1,53 @@
|
|||||||
// 首页/shouye.js
|
// 首页/shouye.js
|
||||||
const app = getApp()
|
const app = getApp()
|
||||||
|
|
||||||
Page({
|
Page({
|
||||||
data: {
|
data: {
|
||||||
motto: 'Hello',
|
motto: 'Hello',
|
||||||
userInfo: {},
|
userInfo: {},
|
||||||
hasUserInfo: false,
|
hasUserInfo: false,
|
||||||
canIUse: wx.canIUse('button.open-type.getUserInfo')
|
canIUse: wx.canIUse('button.open-type.getUserInfo')
|
||||||
},
|
},
|
||||||
//事件处理函数
|
//事件处理函数
|
||||||
bindViewTap: function() {
|
bindViewTap: function() {
|
||||||
wx.navigateTo({
|
wx.navigateTo({
|
||||||
url: '../logs/logs'
|
url: '../logs/logs'
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
onLoad: function () {
|
onLoad: function () {
|
||||||
if (app.globalData.userInfo) {
|
if (app.globalData.userInfo) {
|
||||||
this.setData({
|
this.setData({
|
||||||
userInfo: app.globalData.userInfo,
|
userInfo: app.globalData.userInfo,
|
||||||
hasUserInfo: true
|
hasUserInfo: true
|
||||||
})
|
})
|
||||||
} else if (this.data.canIUse){
|
} else if (this.data.canIUse){
|
||||||
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
|
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
|
||||||
// 所以此处加入 callback 以防止这种情况
|
// 所以此处加入 callback 以防止这种情况
|
||||||
app.userInfoReadyCallback = res => {
|
app.userInfoReadyCallback = res => {
|
||||||
this.setData({
|
this.setData({
|
||||||
userInfo: res.userInfo,
|
userInfo: res.userInfo,
|
||||||
hasUserInfo: true
|
hasUserInfo: true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 在没有 open-type=getUserInfo 版本的兼容处理
|
// 在没有 open-type=getUserInfo 版本的兼容处理
|
||||||
wx.getUserInfo({
|
wx.getUserInfo({
|
||||||
success: res => {
|
success: res => {
|
||||||
app.globalData.userInfo = res.userInfo
|
app.globalData.userInfo = res.userInfo
|
||||||
this.setData({
|
this.setData({
|
||||||
userInfo: res.userInfo,
|
userInfo: res.userInfo,
|
||||||
hasUserInfo: true
|
hasUserInfo: true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getUserInfo: function(e) {
|
getUserInfo: function(e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
app.globalData.userInfo = e.detail.userInfo
|
app.globalData.userInfo = e.detail.userInfo
|
||||||
this.setData({
|
this.setData({
|
||||||
userInfo: e.detail.userInfo,
|
userInfo: e.detail.userInfo,
|
||||||
hasUserInfo: true
|
hasUserInfo: true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"usingComponents": {}
|
"usingComponents": {}
|
||||||
|
|
||||||
}
|
}
|
@ -1,19 +1,19 @@
|
|||||||
<!--index.wxml-->
|
<!--index.wxml-->
|
||||||
<page>
|
<page>
|
||||||
<view class="container">
|
<view class="container">
|
||||||
<view class="userinfo">
|
<view class="userinfo">
|
||||||
<button wx:if="{{!hasUserInfo && canIUse}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 获取头像昵称 </button>
|
<button wx:if="{{!hasUserInfo && canIUse}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 获取头像昵称 </button>
|
||||||
<block wx:else>
|
<block wx:else>
|
||||||
<image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" mode="cover"></image>
|
<image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" mode="cover"></image>
|
||||||
<text class="userinfo-nickname">欢迎,{{userInfo.nickName}}</text>
|
<text class="userinfo-nickname">欢迎,{{userInfo.nickName}}</text>
|
||||||
</block>
|
</block>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<button class='button1'><view>个人信息</view></button>
|
<button class='button1'><view>个人信息</view></button>
|
||||||
<button class='button2'><view>借阅记录</view></button>
|
<button class='button2'><view>借阅记录</view></button>
|
||||||
<button class='button3'><view>退出登录</view></button>
|
<button class='button3'><view>退出登录</view></button>
|
||||||
|
|
||||||
|
|
||||||
</page>
|
</page>
|
||||||
|
Binary file not shown.
Loading…
Reference in new issue