├── .gitignore ├── README.md ├── app.js ├── app.json ├── app.wxss ├── pages ├── detail │ ├── detail.js │ └── detail.wxml ├── index │ ├── index.js │ └── index.wxml └── templates │ └── item.wxml ├── res └── iconfont.ttf └── utils └── util.js /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TodayOnHistory 2 | 用API开发的微信小程序 -- 历史今日 3 | 4 | # 已失效 5 | 这个demo编写的时候小程序开发工具版本为`0.9`,现在运行这个demo会有问题。 6 | 7 | 此外,接入的API是非`https`,而微信要求必须使用`https`。 8 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | //app.js 2 | App({ 3 | 4 | }) -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "pages":[ 3 | "pages/index/index", 4 | "pages/detail/detail" 5 | ], 6 | "window":{ 7 | "backgroundTextStyle":"light", 8 | "navigationBarBackgroundColor": "#3e3e3e", 9 | "navigationBarTitleText": "历史今日", 10 | "navigationBarTextStyle":"white" 11 | }, 12 | "debug": true 13 | } -------------------------------------------------------------------------------- /app.wxss: -------------------------------------------------------------------------------- 1 | /**app.wxss**/ 2 | @font-face 3 | { 4 | font-family: iconfont; 5 | src: url('res/iconfont.ttf') 6 | } 7 | /* Row 8 | ----------------------------------------------*/ 9 | .flex-row { 10 | display: -webkit-box; 11 | display: -webkit-flex; 12 | display: -ms-flexbox; 13 | display: flex; 14 | -webkit-flex-wrap: wrap; 15 | -ms-flex-wrap: wrap; 16 | flex-wrap: wrap; } 17 | 18 | .flex-row:after { 19 | clear: both; } 20 | 21 | .flex-row { 22 | -webkit-box-orient: vertical; 23 | -webkit-box-direction: normal; 24 | -webkit-flex-direction: column; 25 | -ms-flex-direction: column; 26 | flex-direction: column; } 27 | 28 | /* Container 29 | ----------------------------------------------*/ 30 | .container { 31 | height: 100%; 32 | width: 100%; 33 | display: flex; 34 | flex-direction: column; 35 | align-items: center; 36 | justify-content: space-between; 37 | padding: 32rpx; 38 | box-sizing: border-box; } 39 | 40 | /* List 41 | ----------------------------------------------*/ 42 | .ui-list { 43 | background-color: #fff; 44 | width: 100%; } 45 | 46 | .ui-list-item { 47 | position: relative; 48 | margin-left: 15px; 49 | display: -webkit-box; } 50 | 51 | .ui-pure-item { 52 | display: block; 53 | position: relative; 54 | padding-top: 10px; 55 | padding-bottom: 10px; 56 | padding-right: 15px; 57 | -webkit-box-align: center; } 58 | 59 | .ui-item-content { 60 | font-size: 16px; 61 | padding-left: 32rpx; } 62 | 63 | .ui-item-span { 64 | font-size: 14px; 65 | padding-left: 32rpx; 66 | color: #777; } 67 | 68 | .ui-list-item:after { 69 | font-family: "iconfont" !important; 70 | font-size: 32px; 71 | line-height: 44px; 72 | font-style: normal; 73 | -webkit-font-smoothing: antialiased; 74 | -webkit-text-stroke-width: 0.2px; 75 | display: block; 76 | color: #c7c7c7; 77 | content: ""; 78 | position: absolute; 79 | right: 15px; 80 | top: 50%; 81 | margin-top: -22px; 82 | margin-right: -10px; } 83 | 84 | .ui-list-item { 85 | padding-right: 30px; } 86 | 87 | /* Border 88 | ----------------------------------------------*/ 89 | .ui-border-t { 90 | border-top: 1px solid #e0e0e0; } 91 | 92 | .ui-border-b { 93 | border-bottom: 1px solid #e0e0e0; } 94 | 95 | /* No Wrap 96 | ----------------------------------------------*/ 97 | .ui-nowrap { 98 | max-width: 100%; 99 | overflow: hidden; 100 | white-space: nowrap; 101 | text-overflow: ellipsis; } 102 | 103 | /* Tips 104 | ----------------------------------------------*/ 105 | .ui-tips { 106 | font-weight: normal; 107 | font-size: 14px; 108 | text-align: center; 109 | color: #c7c7c7; } 110 | 111 | /* Detail 112 | ----------------------------------------------*/ 113 | .ui-title { 114 | font-weight: normal; 115 | font-size: 24px; 116 | margin-bottom: 8px; } 117 | 118 | .ui-content { 119 | margin-bottom: 16px; 120 | } 121 | 122 | .ui-pic-title { 123 | font-size: 28rpx; 124 | font-weight: normal; 125 | text-align: center; 126 | color: #c7c7c7; } -------------------------------------------------------------------------------- /pages/detail/detail.js: -------------------------------------------------------------------------------- 1 | const util = require('../../utils/util.js') 2 | 3 | Page({ 4 | data:{ 5 | hidden: false, 6 | detail: {} 7 | }, 8 | onLoad:function(param){ 9 | // 页面初始化 param为页面跳转所带来的参数 10 | var self = this 11 | util.getDetail(param.id).then(function(result){ 12 | self.setData({ 13 | detail: result[0] 14 | }) 15 | }) 16 | }, 17 | onReady:function(){ 18 | // 页面渲染完成 19 | wx.setNavigationBarTitle({ 20 | title: this.data.detail.title 21 | }) 22 | this.setData({ 23 | hidden: true 24 | }) 25 | } 26 | }) -------------------------------------------------------------------------------- /pages/detail/detail.wxml: -------------------------------------------------------------------------------- 1 | 2 | {{detail.title}} 3 | {{detail.content}} 4 | 5 | 6 | 7 | {{item.pic_title}} 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /pages/index/index.js: -------------------------------------------------------------------------------- 1 | const util = require('../../utils/util.js') 2 | 3 | Page({ 4 | data: { 5 | hidden: false, 6 | events: [] 7 | }, 8 | onLoad:function(options){ 9 | // 页面初始化 options为页面跳转所带来的参数 10 | var self = this 11 | util.getEvents().then(function(data) { 12 | self.setData({ 13 | hidden: true, 14 | events: data 15 | }) 16 | }) 17 | } 18 | }) -------------------------------------------------------------------------------- /pages/index/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |