增加借阅界面

在我的界面基础上增加了借阅界面
master
zxy19971014 6 years ago
parent 1ff4a694b5
commit 4f2a454416

@ -1,39 +1,39 @@
//app.js
App({
onLaunch: function () {
// 展示本地存储能力
var logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
// 登录
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
}
})
// 获取用户信息
wx.getSetting({
success: res => {
if (res.authSetting['scope.userInfo']) {
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
wx.getUserInfo({
success: res => {
// 可以将 res 发送给后台解码出 unionId
this.globalData.userInfo = res.userInfo
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
if (this.userInfoReadyCallback) {
this.userInfoReadyCallback(res)
}
}
})
}
}
})
},
globalData: {
userInfo: null
}
//app.js
App({
onLaunch: function () {
// 展示本地存储能力
var logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
// 登录
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
}
})
// 获取用户信息
wx.getSetting({
success: res => {
if (res.authSetting['scope.userInfo']) {
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
wx.getUserInfo({
success: res => {
// 可以将 res 发送给后台解码出 unionId
this.globalData.userInfo = res.userInfo
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
if (this.userInfoReadyCallback) {
this.userInfoReadyCallback(res)
}
}
})
}
}
})
},
globalData: {
userInfo: null
}
})

@ -1,53 +1,53 @@
{
"pages": [
"shouye/shouye",
"chazhao/chazhao",
"jieyue/jieyue",
"wode/wode"
],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "WeChat",
"navigationBarTextStyle": "black"
},
"tabBar": {
"color": "#000000",
"selectedColor": "#fd9941",
"borderStyle": "white",
"backgroundColor": "#ffffff",
"list": [
{
"pagePath": "shouye/shouye",
"text": "首页",
"iconPath": "image/shouye.png",
"selectedIconPath": "image/shouye-hl.png"
},
{
"pagePath": "chazhao/chazhao",
"text": "查找",
"iconPath": "image/chazhao.png",
"selectedIconPath": "image/chazhao-hl.png"
},
{
"pagePath": "jieyue/jieyue",
"text": "借阅",
"iconPath":"image/jieyue.png",
"selectedIconPath":"image/jieyue-hl.png"
},
{
"pagePath": "wode/wode",
"text": "我的",
"iconPath": "image/wode.png",
"selectedIconPath": "image/wode-hl.png"
}
]
}
{
"pages": [
"shouye/shouye",
"chazhao/chazhao",
"jieyue/jieyue",
"wode/wode"
],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "WeChat",
"navigationBarTextStyle": "black"
},
"tabBar": {
"color": "#000000",
"selectedColor": "#fd9941",
"borderStyle": "white",
"backgroundColor": "#ffffff",
"list": [
{
"pagePath": "shouye/shouye",
"text": "首页",
"iconPath": "image/shouye.png",
"selectedIconPath": "image/shouye-hl.png"
},
{
"pagePath": "chazhao/chazhao",
"text": "查找",
"iconPath": "image/chazhao.png",
"selectedIconPath": "image/chazhao-hl.png"
},
{
"pagePath": "jieyue/jieyue",
"text": "借阅",
"iconPath":"image/jieyue.png",
"selectedIconPath":"image/jieyue-hl.png"
},
{
"pagePath": "wode/wode",
"text": "我的",
"iconPath": "image/wode.png",
"selectedIconPath": "image/wode-hl.png"
}
]
}
}

@ -1,10 +1,10 @@
/**app.wxss**/
.container {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
padding: 100rpx 0;
box-sizing: border-box;
}
/**app.wxss**/
.container {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
padding: 100rpx 0;
box-sizing: border-box;
}

@ -1,23 +1,23 @@
// chazhao/chazhao.js
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
}
})
// chazhao/chazhao.js
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
}
})

@ -1,4 +1,4 @@
{
"component": true,
"usingComponents": {}
{
"component": true,
"usingComponents": {}
}

@ -1,2 +1,2 @@
<!--chazhao/chazhao.wxml-->
<text>chazhao/chazhao.wxml</text>
<!--chazhao/chazhao.wxml-->
<text>chazhao/chazhao.wxml</text>

@ -1,23 +1,23 @@
// jieyue/jieyue.js
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
}
})
// jieyue/jieyue.js
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
}
})

@ -1,4 +1,4 @@
{
"component": true,
"usingComponents": {}
{
"component": true,
"usingComponents": {}
}

@ -1,2 +1,8 @@
<!--jieyue/jieyue.wxml-->
<text>jieyue/jieyue.wxml</text>
<!--jieyue/jieyue.wxml-->
<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%);}

@ -13,7 +13,7 @@
"compileType": "miniprogram",
"libVersion": "2.4.0",
"appid": "wxb280d1925541c356",
"projectname": "%E7%9C%9F%E9%A6%99%E5%9B%BE%E4%B9%A6%E7%AE%A1%E7%90%86%E7%B3%BB%E7%BB%9F",
"projectname": "%E7%9C%9F%E9%A6%99",
"debugOptions": {
"hidedInDevtools": []
},

@ -1,23 +1,23 @@
// shouye/shouye.js
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
}
})
// shouye/shouye.js
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
}
})

@ -1,4 +1,4 @@
{
"component": true,
"usingComponents": {}
{
"component": true,
"usingComponents": {}
}

@ -1,2 +1,2 @@
<!--shouye/shouye.wxml-->
<text>shouye/shouye.wxml</text>
<!--shouye/shouye.wxml-->
<text>shouye/shouye.wxml</text>

@ -1,19 +1,19 @@
const formatTime = date => {
const year = date.getFullYear()
const month = date.getMonth() + 1
const day = date.getDate()
const hour = date.getHours()
const minute = date.getMinutes()
const second = date.getSeconds()
return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}
const formatNumber = n => {
n = n.toString()
return n[1] ? n : '0' + n
}
module.exports = {
formatTime: formatTime
}
const formatTime = date => {
const year = date.getFullYear()
const month = date.getMonth() + 1
const day = date.getDate()
const hour = date.getHours()
const minute = date.getMinutes()
const second = date.getSeconds()
return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}
const formatNumber = n => {
n = n.toString()
return n[1] ? n : '0' + n
}
module.exports = {
formatTime: formatTime
}

@ -1,53 +1,53 @@
// 首页/shouye.js
const app = getApp()
Page({
data: {
motto: 'Hello',
userInfo: {},
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo')
},
//事件处理函数
bindViewTap: function() {
wx.navigateTo({
url: '../logs/logs'
})
},
onLoad: function () {
if (app.globalData.userInfo) {
this.setData({
userInfo: app.globalData.userInfo,
hasUserInfo: true
})
} else if (this.data.canIUse){
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
app.userInfoReadyCallback = res => {
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
} else {
// 在没有 open-type=getUserInfo 版本的兼容处理
wx.getUserInfo({
success: res => {
app.globalData.userInfo = res.userInfo
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
})
}
},
getUserInfo: function(e) {
console.log(e)
app.globalData.userInfo = e.detail.userInfo
this.setData({
userInfo: e.detail.userInfo,
hasUserInfo: true
})
}
})
// 首页/shouye.js
const app = getApp()
Page({
data: {
motto: 'Hello',
userInfo: {},
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo')
},
//事件处理函数
bindViewTap: function() {
wx.navigateTo({
url: '../logs/logs'
})
},
onLoad: function () {
if (app.globalData.userInfo) {
this.setData({
userInfo: app.globalData.userInfo,
hasUserInfo: true
})
} else if (this.data.canIUse){
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
app.userInfoReadyCallback = res => {
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
} else {
// 在没有 open-type=getUserInfo 版本的兼容处理
wx.getUserInfo({
success: res => {
app.globalData.userInfo = res.userInfo
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
})
}
},
getUserInfo: function(e) {
console.log(e)
app.globalData.userInfo = e.detail.userInfo
this.setData({
userInfo: e.detail.userInfo,
hasUserInfo: true
})
}
})

@ -1,4 +1,4 @@
{
"usingComponents": {}
{
"usingComponents": {}
}

@ -1,19 +1,19 @@
<!--index.wxml-->
<page>
<view class="container">
<view class="userinfo">
<button wx:if="{{!hasUserInfo && canIUse}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 获取头像昵称 </button>
<block wx:else>
<image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" mode="cover"></image>
<text class="userinfo-nickname">欢迎,{{userInfo.nickName}}</text>
</block>
</view>
</view>
<button class='button1'><view>个人信息</view></button>
<button class='button2'><view>借阅记录</view></button>
<button class='button3'><view>退出登录</view></button>
</page>
<!--index.wxml-->
<page>
<view class="container">
<view class="userinfo">
<button wx:if="{{!hasUserInfo && canIUse}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 获取头像昵称 </button>
<block wx:else>
<image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" mode="cover"></image>
<text class="userinfo-nickname">欢迎,{{userInfo.nickName}}</text>
</block>
</view>
</view>
<button class='button1'><view>个人信息</view></button>
<button class='button2'><view>借阅记录</view></button>
<button class='button3'><view>退出登录</view></button>
</page>

Binary file not shown.
Loading…
Cancel
Save