├── joke
├── app.wxss
├── pages
│ ├── index
│ │ ├── index.json
│ │ ├── index.wxml
│ │ ├── index.wxss
│ │ └── index.js
│ ├── pictures
│ │ ├── main.json
│ │ ├── main.wxml
│ │ ├── main.wxss
│ │ └── main.js
│ ├── imgs
│ │ ├── joke.png
│ │ ├── pic.png
│ │ ├── pic2.png
│ │ └── joke2.png
│ └── templates
│ │ ├── pic-tpl.wxml
│ │ └── joke-tpl.wxml
├── README.md
├── app.json
├── utils
│ └── util.js
└── app.js
├── .gitignore
├── robot
├── pages
│ ├── index
│ │ ├── index.json
│ │ ├── index.wxml
│ │ ├── index.wxss
│ │ └── index.js
│ ├── imgs
│ │ ├── me.png
│ │ └── robot.png
│ └── templates
│ │ ├── me-tpl.wxml
│ │ └── robot-tpl.wxml
├── app.wxss
├── README.md
├── app.json
├── utils
│ └── util.js
└── app.js
├── video
├── pages
│ ├── index
│ │ ├── index.json
│ │ ├── index.wxss
│ │ ├── index.js
│ │ └── index.wxml
│ └── video
│ │ ├── index.json
│ │ ├── index.wxss
│ │ ├── index.wxml
│ │ └── index.js
├── app.wxss
├── app.json
├── utils
│ └── util.js
└── app.js
├── constellation
├── pages
│ ├── index
│ │ ├── index.json
│ │ ├── index.wxss
│ │ ├── index.js
│ │ └── index.wxml
│ ├── qq
│ │ ├── index.json
│ │ ├── index.wxml
│ │ ├── index.wxss
│ │ └── index.js
│ ├── history
│ │ ├── index.json
│ │ ├── index.wxml
│ │ ├── index.wxss
│ │ └── index.js
│ ├── constellation-detail
│ │ ├── index.json
│ │ ├── index.wxss
│ │ ├── index.js
│ │ └── index.wxml
│ └── imgs
│ │ ├── chunv.png
│ │ ├── juxie.png
│ │ ├── mojie.png
│ │ ├── qq1.png
│ │ ├── qq2.png
│ │ ├── shizi.png
│ │ ├── xz1.png
│ │ ├── xz2.png
│ │ ├── xzbg.jpg
│ │ ├── baiyang.png
│ │ ├── jinniu.png
│ │ ├── sheshou.png
│ │ ├── tianxie.png
│ │ ├── history1.png
│ │ ├── history2.png
│ │ ├── historybg.jpg
│ │ ├── shuangyu.png
│ │ ├── shuangzi.png
│ │ ├── shuiping.png
│ │ └── tianping.png
├── utils
│ ├── myDate.js
│ └── util.js
├── app.wxss
├── app.js
└── app.json
├── weather
├── pages
│ ├── detail
│ │ ├── detail.json
│ │ ├── detail.wxml
│ │ ├── detail.wxss
│ │ └── detail.js
│ ├── index
│ │ ├── index.json
│ │ ├── index.wxml
│ │ ├── index.wxss
│ │ └── index.js
│ ├── img
│ │ └── bg.jpg
│ └── templates
│ │ ├── index-detail-tpl.wxml
│ │ ├── index-tpl.wxml
│ │ ├── forecast-tpl.wxml
│ │ └── today-tpl.wxml
├── app.wxss
├── app.json
├── README.md
├── utils
│ └── util.js
└── app.js
└── README.md
/joke/app.wxss:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | animation/
2 | canvas/
--------------------------------------------------------------------------------
/joke/pages/index/index.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/joke/pages/pictures/main.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/robot/pages/index/index.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/video/pages/index/index.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/video/pages/video/index.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/constellation/pages/index/index.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/constellation/pages/qq/index.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/weather/pages/detail/detail.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/constellation/pages/history/index.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/weather/pages/index/index.json:
--------------------------------------------------------------------------------
1 | {
2 |
3 | }
--------------------------------------------------------------------------------
/constellation/pages/constellation-detail/index.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/joke/pages/imgs/joke.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zsl131/wx-app-study/HEAD/joke/pages/imgs/joke.png
--------------------------------------------------------------------------------
/joke/pages/imgs/pic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zsl131/wx-app-study/HEAD/joke/pages/imgs/pic.png
--------------------------------------------------------------------------------
/joke/pages/imgs/pic2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zsl131/wx-app-study/HEAD/joke/pages/imgs/pic2.png
--------------------------------------------------------------------------------
/robot/pages/imgs/me.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zsl131/wx-app-study/HEAD/robot/pages/imgs/me.png
--------------------------------------------------------------------------------
/weather/pages/img/bg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zsl131/wx-app-study/HEAD/weather/pages/img/bg.jpg
--------------------------------------------------------------------------------
/joke/pages/imgs/joke2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zsl131/wx-app-study/HEAD/joke/pages/imgs/joke2.png
--------------------------------------------------------------------------------
/robot/pages/imgs/robot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zsl131/wx-app-study/HEAD/robot/pages/imgs/robot.png
--------------------------------------------------------------------------------
/constellation/pages/imgs/chunv.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zsl131/wx-app-study/HEAD/constellation/pages/imgs/chunv.png
--------------------------------------------------------------------------------
/constellation/pages/imgs/juxie.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zsl131/wx-app-study/HEAD/constellation/pages/imgs/juxie.png
--------------------------------------------------------------------------------
/constellation/pages/imgs/mojie.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zsl131/wx-app-study/HEAD/constellation/pages/imgs/mojie.png
--------------------------------------------------------------------------------
/constellation/pages/imgs/qq1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zsl131/wx-app-study/HEAD/constellation/pages/imgs/qq1.png
--------------------------------------------------------------------------------
/constellation/pages/imgs/qq2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zsl131/wx-app-study/HEAD/constellation/pages/imgs/qq2.png
--------------------------------------------------------------------------------
/constellation/pages/imgs/shizi.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zsl131/wx-app-study/HEAD/constellation/pages/imgs/shizi.png
--------------------------------------------------------------------------------
/constellation/pages/imgs/xz1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zsl131/wx-app-study/HEAD/constellation/pages/imgs/xz1.png
--------------------------------------------------------------------------------
/constellation/pages/imgs/xz2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zsl131/wx-app-study/HEAD/constellation/pages/imgs/xz2.png
--------------------------------------------------------------------------------
/constellation/pages/imgs/xzbg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zsl131/wx-app-study/HEAD/constellation/pages/imgs/xzbg.jpg
--------------------------------------------------------------------------------
/constellation/pages/imgs/baiyang.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zsl131/wx-app-study/HEAD/constellation/pages/imgs/baiyang.png
--------------------------------------------------------------------------------
/constellation/pages/imgs/jinniu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zsl131/wx-app-study/HEAD/constellation/pages/imgs/jinniu.png
--------------------------------------------------------------------------------
/constellation/pages/imgs/sheshou.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zsl131/wx-app-study/HEAD/constellation/pages/imgs/sheshou.png
--------------------------------------------------------------------------------
/constellation/pages/imgs/tianxie.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zsl131/wx-app-study/HEAD/constellation/pages/imgs/tianxie.png
--------------------------------------------------------------------------------
/constellation/pages/imgs/history1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zsl131/wx-app-study/HEAD/constellation/pages/imgs/history1.png
--------------------------------------------------------------------------------
/constellation/pages/imgs/history2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zsl131/wx-app-study/HEAD/constellation/pages/imgs/history2.png
--------------------------------------------------------------------------------
/constellation/pages/imgs/historybg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zsl131/wx-app-study/HEAD/constellation/pages/imgs/historybg.jpg
--------------------------------------------------------------------------------
/constellation/pages/imgs/shuangyu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zsl131/wx-app-study/HEAD/constellation/pages/imgs/shuangyu.png
--------------------------------------------------------------------------------
/constellation/pages/imgs/shuangzi.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zsl131/wx-app-study/HEAD/constellation/pages/imgs/shuangzi.png
--------------------------------------------------------------------------------
/constellation/pages/imgs/shuiping.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zsl131/wx-app-study/HEAD/constellation/pages/imgs/shuiping.png
--------------------------------------------------------------------------------
/constellation/pages/imgs/tianping.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zsl131/wx-app-study/HEAD/constellation/pages/imgs/tianping.png
--------------------------------------------------------------------------------
/video/pages/video/index.wxss:
--------------------------------------------------------------------------------
1 | /* pages/video/index.wxss */
2 | .title {
3 | height:50px; line-height: 50px; text-align:center;
4 | }
--------------------------------------------------------------------------------
/video/pages/video/index.wxml:
--------------------------------------------------------------------------------
1 |
2 | 视频播放
3 |
4 |
5 |
--------------------------------------------------------------------------------
/joke/pages/templates/pic-tpl.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{item.content}}
5 |
6 |
--------------------------------------------------------------------------------
/joke/pages/index/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/joke/pages/pictures/main.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/video/pages/index/index.wxss:
--------------------------------------------------------------------------------
1 | /* pages/index/index.wxss */
2 |
3 | .my-view {
4 | text-align: center; height:120px; margin:10px; background:#fafafa;
5 | border:1px #ddd solid; border-radius:5px; line-height: 120px;
6 | }
--------------------------------------------------------------------------------
/weather/pages/templates/index-detail-tpl.wxml:
--------------------------------------------------------------------------------
1 |
2 | {{idx}}-{{item.name}}:{{item.index}}
3 | {{item.details}}
4 |
--------------------------------------------------------------------------------
/weather/pages/templates/index-tpl.wxml:
--------------------------------------------------------------------------------
1 |
2 | {{idx}}-{{item.name}}:{{item.index}}
3 |
4 |
--------------------------------------------------------------------------------
/joke/pages/templates/joke-tpl.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{index+1}}{{item.updatetime}}
4 | {{item.content}}
5 |
6 |
--------------------------------------------------------------------------------
/robot/app.wxss:
--------------------------------------------------------------------------------
1 | /**app.wxss**/
2 | .container {
3 | height: 100%;
4 | display: flex;
5 | flex-direction: column;
6 | align-items: center;
7 | justify-content: space-between;
8 | padding: 200rpx 0;
9 | box-sizing: border-box;
10 | }
11 |
--------------------------------------------------------------------------------
/video/app.wxss:
--------------------------------------------------------------------------------
1 | /**app.wxss**/
2 | .container {
3 | height: 100%;
4 | display: flex;
5 | flex-direction: column;
6 | align-items: center;
7 | justify-content: space-between;
8 | padding: 200rpx 0;
9 | box-sizing: border-box;
10 | }
11 |
--------------------------------------------------------------------------------
/weather/app.wxss:
--------------------------------------------------------------------------------
1 | /**app.wxss**/
2 | .container {
3 | height: 100%;
4 | display: flex;
5 | flex-direction: column;
6 | align-items: center;
7 | justify-content: space-between;
8 | padding: 200rpx 0;
9 | box-sizing: border-box;
10 | }
11 |
--------------------------------------------------------------------------------
/robot/README.md:
--------------------------------------------------------------------------------
1 | # 微信小程序 - 问答机器人
2 |
3 | 这个实例主要使用了以下知识点:
4 |
5 | + 微信小程序布局flex
6 | + 模板使用及引用,多模板选择
7 | + 本地数据存储-setStorage
8 | + 本地缓存数据读取-getStorage,要程序初始化时读取数据
9 |
10 | 截图:
11 |
12 | 
13 |
--------------------------------------------------------------------------------
/robot/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "pages":[
3 | "pages/index/index"
4 | ],
5 | "window":{
6 | "backgroundTextStyle":"light",
7 | "navigationBarBackgroundColor": "#fff",
8 | "navigationBarTitleText": "问答机器人",
9 | "navigationBarTextStyle":"black"
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/robot/pages/templates/me-tpl.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {{item.date}}
6 | {{item.text}}
7 |
8 |
9 |
--------------------------------------------------------------------------------
/weather/pages/templates/forecast-tpl.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{item.date}} {{item.week}}
4 | {{item.type}}
5 | {{item.lowtemp}} / {{item.hightemp}}
6 |
7 |
--------------------------------------------------------------------------------
/video/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "pages":[
3 | "pages/index/index",
4 | "pages/video/index"
5 | ],
6 | "window":{
7 | "backgroundTextStyle":"light",
8 | "navigationBarBackgroundColor": "#fff",
9 | "navigationBarTitleText": "WeChat",
10 | "navigationBarTextStyle":"black"
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/weather/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "pages":[
3 | "pages/index/index",
4 | "pages/detail/detail"
5 | ],
6 | "window":{
7 | "backgroundTextStyle":"light",
8 | "navigationBarBackgroundColor": "#775b79",
9 | "navigationBarTitleText": "天气-小程序",
10 | "navigationBarTextStyle":"white"
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/joke/README.md:
--------------------------------------------------------------------------------
1 | # 微信小程序学习实例 - 笑话大全
2 |
3 | 这个微信小程序学习实例主要的知识点有:
4 |
5 | + tabbar的使用,在底部显示导航菜单
6 | + tempate模板应用
7 | + 下拉在底部时刷新数据
8 | + 数据组合显示
9 |
10 | 截图:
11 |
12 | 
13 |
14 | 
15 |
--------------------------------------------------------------------------------
/robot/pages/templates/robot-tpl.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {{item.date}}
6 | {{item.text}}
7 |
8 |
9 |
--------------------------------------------------------------------------------
/constellation/pages/index/index.wxss:
--------------------------------------------------------------------------------
1 | /* pages/index/index.wxss */
2 | .single-view {
3 | width:19%; border:1px #dfdfdf solid; float:left; margin: 19px 0px 5px 2.2%; padding:5px; border-radius:5px; text-align: center; align-items: center;
4 |
5 | }
6 | .single-view image {
7 | width:100%;
8 | }
9 | .single-view text {
10 | font-size:30rpx; color:brown;
11 | }
--------------------------------------------------------------------------------
/joke/pages/pictures/main.wxss:
--------------------------------------------------------------------------------
1 | .container {
2 | width:96%; margin-left:2%; margin-top:10px;
3 | }
4 |
5 | .single-pic {
6 | width:100%; border-bottom:1px #ddd solid;
7 | align-items: center;
8 | display: flex; flex-direction: column; padding-top:8px; margin-top:10px;
9 | }
10 |
11 | .single-pic text {
12 | font-size:32rpx; padding-bottom:10px; padding-top:7px;
13 | }
--------------------------------------------------------------------------------
/weather/pages/templates/today-tpl.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{city}}
4 | {{curWd.date}} {{curWd.week}}
5 |
6 | {{curWd.curTemp}}
7 | {{curWd.type}} {{curWd.lowtemp}}/{{curWd.hightemp}}
8 | {{curWd.wd}}
9 |
10 |
--------------------------------------------------------------------------------
/constellation/utils/myDate.js:
--------------------------------------------------------------------------------
1 | function buildDay(flag) {
2 | var a = newDate(flag);
3 | var month = a.getMonth()+1;
4 | var day = a.getDate();
5 | return month+"/"+day;
6 | }
7 |
8 | //添减天
9 | function newDate(flag) {
10 | var a = new Date();
11 | var long = a.valueOf();
12 | long = long + flag * 24 * 60 * 60 * 1000;
13 | a = new Date(long);
14 | return a;
15 | }
16 |
17 | module.exports = {
18 | buildDay: buildDay
19 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # [微信小程序学习示例](http://www.zslin.com/web/article/detail/67)
2 |
3 | 这个仓库主要用来学习微信小程序的开发。
4 |
5 | 在这里放置的都是自己学习微信小程序开发的一些例子。
6 |
7 | + weather:[这是我的第一个微信小程序- 天气实例](http://www.zslin.com/web/article/detail/68)
8 | + robot:[这是一个问答机器人的小例子](http://www.zslin.com/web/article/detail/69)
9 | + joke:[这是笑话大全实例,有纯文字的笑话,也有图片信息](http://www.zslin.com/web/article/detail/70)
10 | + constellation:[这是一个集星座运势、历史上的今天、QQ吉凶查询为一体的小程序](http://www.zslin.com/web/article/detail/71)
--------------------------------------------------------------------------------
/video/pages/video/index.js:
--------------------------------------------------------------------------------
1 | // pages/video/index.js
2 | Page({
3 | data:{
4 | url: ''
5 | },
6 | onLoad:function(options){
7 | // 页面初始化 options为页面跳转所带来的参数
8 | var url = options.url;
9 | this.setData({url: url});
10 | },
11 | onReady:function(){
12 | // 页面渲染完成
13 | },
14 | onShow:function(){
15 | // 页面显示
16 | },
17 | onHide:function(){
18 | // 页面隐藏
19 | },
20 | onUnload:function(){
21 | // 页面关闭
22 | }
23 | })
--------------------------------------------------------------------------------
/weather/README.md:
--------------------------------------------------------------------------------
1 | # 微信小程序学习实例-天气实例
2 |
3 | 作为第一个实例主要搞清楚微信小程序的开发思路及流程。
4 |
5 | 在这个例子中所用到的功能大致有:
6 |
7 | + 自动定位获取经纬度
8 | + 根据经纬度获取所在城市及城市id
9 | + 根据城市名称和城市id获取当地天气情况
10 | + 模板template的使用(多数据传递)
11 | + wx.request的使用(用来调用远程服务端的数据)
12 | + 数据绑定(和AngularJS的双向数据绑定类似)
13 | + wx.navigateTo(在首页点击当天气温即可跳转到详情页面)
14 |
15 | 截图如下:
16 |
17 | 
18 |
19 | 
--------------------------------------------------------------------------------
/constellation/pages/history/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 历史上的今天({{day}}){{today.length}}条
5 |
6 |
7 |
8 |
9 | {{item.date}}
10 | {{item.title}}
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/constellation/pages/history/index.wxss:
--------------------------------------------------------------------------------
1 | /* pages/history/index.wxss */
2 | page {
3 | height: 100%;
4 | }
5 | .history-container {
6 | width:100%; height: 100%; background: url("../imgs/historybg.jpg"); background-size: cover;
7 | }
8 |
9 | .title-part {
10 | color: #000;
11 | }
12 | .single {
13 | margin:20rpx 10px;
14 | }
15 | .single text {
16 | font-size:32rpx; line-height:40rpx;
17 | }
18 | .single view {
19 | font-size:32rpx;
20 | }
21 |
22 | .footer-part {
23 | padding-bottom:30px;
24 | }
--------------------------------------------------------------------------------
/constellation/app.wxss:
--------------------------------------------------------------------------------
1 | /**app.wxss**/
2 | .container {
3 | height: 100%;
4 | display: flex;
5 | flex-direction: column;
6 | align-items: center;
7 | justify-content: space-between;
8 | padding: 200rpx 0;
9 | box-sizing: border-box;
10 | }
11 |
12 | .title-part {
13 | width:100%; text-align: center; margin-top:12px; border-bottom:1px #ddd solid; padding-bottom: 10px; color:brown; font-weight: bold;
14 | }
15 |
16 | .footer-part {
17 | font-size:28rpx; text-align: center; margin-top:12px; padding-bottom:10px; color:#aaa; float:left; width:100%;
18 | }
--------------------------------------------------------------------------------
/robot/utils/util.js:
--------------------------------------------------------------------------------
1 | function formatTime(date) {
2 | var year = date.getFullYear()
3 | var month = date.getMonth() + 1
4 | var day = date.getDate()
5 |
6 | var hour = date.getHours()
7 | var minute = date.getMinutes()
8 | var second = date.getSeconds()
9 |
10 |
11 | return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
12 | }
13 |
14 | function formatNumber(n) {
15 | n = n.toString()
16 | return n[1] ? n : '0' + n
17 | }
18 |
19 | module.exports = {
20 | formatTime: formatTime
21 | }
22 |
--------------------------------------------------------------------------------
/video/utils/util.js:
--------------------------------------------------------------------------------
1 | function formatTime(date) {
2 | var year = date.getFullYear()
3 | var month = date.getMonth() + 1
4 | var day = date.getDate()
5 |
6 | var hour = date.getHours()
7 | var minute = date.getMinutes()
8 | var second = date.getSeconds()
9 |
10 |
11 | return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
12 | }
13 |
14 | function formatNumber(n) {
15 | n = n.toString()
16 | return n[1] ? n : '0' + n
17 | }
18 |
19 | module.exports = {
20 | formatTime: formatTime
21 | }
22 |
--------------------------------------------------------------------------------
/weather/utils/util.js:
--------------------------------------------------------------------------------
1 | function formatTime(date) {
2 | var year = date.getFullYear()
3 | var month = date.getMonth() + 1
4 | var day = date.getDate()
5 |
6 | var hour = date.getHours()
7 | var minute = date.getMinutes()
8 | var second = date.getSeconds()
9 |
10 |
11 | return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
12 | }
13 |
14 | function formatNumber(n) {
15 | n = n.toString()
16 | return n[1] ? n : '0' + n
17 | }
18 |
19 | module.exports = {
20 | formatTime: formatTime
21 | }
22 |
--------------------------------------------------------------------------------
/constellation/pages/qq/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | QQ吉凶查询
4 |
5 |
6 |
7 |
8 |
9 |
10 | 结果:{{result}}
11 | 分析:{{detail}}
12 |
13 |
16 |
--------------------------------------------------------------------------------
/constellation/utils/util.js:
--------------------------------------------------------------------------------
1 | function formatTime(date) {
2 | var year = date.getFullYear()
3 | var month = date.getMonth() + 1
4 | var day = date.getDate()
5 |
6 | var hour = date.getHours()
7 | var minute = date.getMinutes()
8 | var second = date.getSeconds()
9 |
10 |
11 | return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
12 | }
13 |
14 | function formatNumber(n) {
15 | n = n.toString()
16 | return n[1] ? n : '0' + n
17 | }
18 |
19 | module.exports = {
20 | formatTime: formatTime
21 | }
22 |
--------------------------------------------------------------------------------
/weather/pages/detail/detail.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/constellation/pages/index/index.js:
--------------------------------------------------------------------------------
1 | // pages/index/index.js
2 | Page({
3 | data:{},
4 | onLoad:function(options){
5 | // 页面初始化 options为页面跳转所带来的参数
6 | },
7 | onReady:function(){
8 | // 页面渲染完成
9 | },
10 | onShow:function(){
11 | // 页面显示
12 | },
13 | onHide:function(){
14 | // 页面隐藏
15 | },
16 | onUnload:function(){
17 | // 页面关闭
18 | },
19 | showDetail: function(e) {
20 | var name = e.currentTarget.dataset.name
21 | console.log(name);
22 | wx.navigateTo({
23 | url: '/pages/constellation-detail/index?name='+name
24 | })
25 | }
26 | })
--------------------------------------------------------------------------------
/joke/pages/index/index.wxss:
--------------------------------------------------------------------------------
1 | .container {
2 | padding:15rpx 15px 0px 20rpx; text-align: left; width:100%;
3 |
4 | display: flex; flex-direction: column;
5 | }
6 |
7 | .single-joke {
8 | margin-top:1.5%; border-bottom:1px #ddd solid; padding-bottom:7px; width:97%;
9 | }
10 |
11 | .single-joke view {
12 | color:#777; font-size: 30rpx;
13 | }
14 | .single-joke view.num {
15 | float:left; width:18px; height:18px; background:#3ba20d; border-radius:15px; text-align: center; margin-right:3px; color:#FFF;
16 | }
17 | .single-joke text {
18 | font-size:31rpx; margin-top:5px; line-height:44rpx; color:#444;
19 | }
--------------------------------------------------------------------------------
/constellation/pages/qq/index.wxss:
--------------------------------------------------------------------------------
1 | page {
2 | height: 100%;
3 | }
4 | .qq-container {
5 | width:100%; height:100%; background: #fef2f9;
6 | }
7 |
8 | .query {
9 | display: flex; flex-direction: row; padding:12rpx 10px;
10 | }
11 | .query input {
12 | flex-grow: 1; border:1px #ddd solid; border-radius:5px; margin-right:10px; height:35px; line-height: 35px; padding-left:5px;
13 | }
14 |
15 | .query button {
16 | line-height:35px; height:35px;
17 | }
18 |
19 | .result {
20 | padding:10rpx; font-size:32rpx; line-height:40rpx;
21 | }
22 | .detail {
23 | font-size:32rpx; line-height:40rpx; color: #888; padding:10rpx;
24 | }
--------------------------------------------------------------------------------
/video/pages/index/index.js:
--------------------------------------------------------------------------------
1 | // pages/index/index.js
2 | Page({
3 | data:{ },
4 | onLoad:function(options){
5 | // 页面初始化 options为页面跳转所带来的参数
6 | },
7 | onReady:function(){
8 | // 页面渲染完成
9 | },
10 | onShow:function(){
11 | // 页面显示
12 | },
13 | onHide:function(){
14 | // 页面隐藏
15 | },
16 | onUnload:function(){
17 | // 页面关闭
18 | },
19 | showVideo: function(e) {
20 | var url = e.currentTarget.dataset.url;
21 | url = escape(url);
22 | console.log(url);
23 | //console.log(e);
24 | wx.navigateTo({
25 | url: '/pages/video/index?url='+url
26 | })
27 | },
28 | EventHandle: function(e) {
29 | console.log(e);
30 | }
31 | })
--------------------------------------------------------------------------------
/video/pages/index/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 视频一
4 |
5 |
6 |
7 | 视频二
8 |
9 |
--------------------------------------------------------------------------------
/joke/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "pages":[
3 | "pages/index/index",
4 | "pages/pictures/main"
5 | ],
6 | "window":{
7 | "backgroundTextStyle":"light",
8 | "navigationBarBackgroundColor": "#deab00",
9 | "navigationBarTitleText": "笑语大全",
10 | "navigationBarTextStyle":"white"
11 | },
12 | "tabBar": {
13 | "color": "#888",
14 | "selectedColor": "#444",
15 | "list": [{
16 | "pagePath": "pages/index/index",
17 | "text": "笑话",
18 | "iconPath": "pages/imgs/joke.png",
19 | "selectedIconPath": "pages/imgs/joke2.png"
20 | }, {
21 | "pagePath": "pages/pictures/main",
22 | "text": "趣图",
23 | "iconPath": "pages/imgs/pic.png",
24 | "selectedIconPath": "pages/imgs/pic2.png"
25 | }]
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/joke/utils/util.js:
--------------------------------------------------------------------------------
1 | function formatTime(date) {
2 | var year = date.getFullYear()
3 | var month = date.getMonth() + 1
4 | var day = date.getDate()
5 |
6 | var hour = date.getHours()
7 | var minute = date.getMinutes()
8 | var second = date.getSeconds()
9 |
10 |
11 | return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
12 | }
13 |
14 | function formatNumber(n) {
15 | n = n.toString()
16 | return n[1] ? n : '0' + n
17 | }
18 |
19 | function replaceAll(source, oldStr, newStr) {
20 | while (source.indexOf(oldStr) >= 0){
21 | source = source.replace(oldStr, newStr);
22 | }
23 | return source;
24 | }
25 |
26 | module.exports = {
27 | formatTime: formatTime,
28 | replaceAll: replaceAll
29 | }
30 |
--------------------------------------------------------------------------------
/robot/pages/index/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/robot/app.js:
--------------------------------------------------------------------------------
1 | //app.js
2 | App({
3 | onLaunch: function () {
4 | //调用API从本地缓存中获取数据
5 | var logs = wx.getStorageSync('logs') || []
6 | logs.unshift(Date.now())
7 | wx.setStorageSync('logs', logs)
8 | },
9 | getUserInfo:function(cb){
10 | var that = this
11 | if(this.globalData.userInfo){
12 | typeof cb == "function" && cb(this.globalData.userInfo)
13 | }else{
14 | //调用登录接口
15 | wx.login({
16 | success: function () {
17 | wx.getUserInfo({
18 | success: function (res) {
19 | that.globalData.userInfo = res.userInfo
20 | typeof cb == "function" && cb(that.globalData.userInfo)
21 | }
22 | })
23 | }
24 | })
25 | }
26 | },
27 | globalData:{
28 | userInfo:null
29 | }
30 | })
--------------------------------------------------------------------------------
/video/app.js:
--------------------------------------------------------------------------------
1 | //app.js
2 | App({
3 | onLaunch: function () {
4 | //调用API从本地缓存中获取数据
5 | var logs = wx.getStorageSync('logs') || []
6 | logs.unshift(Date.now())
7 | wx.setStorageSync('logs', logs)
8 | },
9 | getUserInfo:function(cb){
10 | var that = this
11 | if(this.globalData.userInfo){
12 | typeof cb == "function" && cb(this.globalData.userInfo)
13 | }else{
14 | //调用登录接口
15 | wx.login({
16 | success: function () {
17 | wx.getUserInfo({
18 | success: function (res) {
19 | that.globalData.userInfo = res.userInfo
20 | typeof cb == "function" && cb(that.globalData.userInfo)
21 | }
22 | })
23 | }
24 | })
25 | }
26 | },
27 | globalData:{
28 | userInfo:null
29 | }
30 | })
--------------------------------------------------------------------------------
/constellation/app.js:
--------------------------------------------------------------------------------
1 | //app.js
2 | App({
3 | onLaunch: function () {
4 | //调用API从本地缓存中获取数据
5 | var logs = wx.getStorageSync('logs') || []
6 | logs.unshift(Date.now())
7 | wx.setStorageSync('logs', logs)
8 | },
9 | getUserInfo:function(cb){
10 | var that = this
11 | if(this.globalData.userInfo){
12 | typeof cb == "function" && cb(this.globalData.userInfo)
13 | }else{
14 | //调用登录接口
15 | wx.login({
16 | success: function () {
17 | wx.getUserInfo({
18 | success: function (res) {
19 | that.globalData.userInfo = res.userInfo
20 | typeof cb == "function" && cb(that.globalData.userInfo)
21 | }
22 | })
23 | }
24 | })
25 | }
26 | },
27 | globalData:{
28 | userInfo:null
29 | }
30 | })
--------------------------------------------------------------------------------
/weather/pages/index/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/joke/app.js:
--------------------------------------------------------------------------------
1 | //app.js
2 | App({
3 | onLaunch: function () {
4 | //调用API从本地缓存中获取数据
5 | var logs = wx.getStorageSync('logs') || []
6 | logs.unshift(Date.now())
7 | wx.setStorageSync('logs', logs)
8 | },
9 | getUserInfo:function(cb){
10 | var that = this
11 | if(this.globalData.userInfo){
12 | typeof cb == "function" && cb(this.globalData.userInfo)
13 | }else{
14 | //调用登录接口
15 | wx.login({
16 | success: function () {
17 | wx.getUserInfo({
18 | success: function (res) {
19 | that.globalData.userInfo = res.userInfo
20 | typeof cb == "function" && cb(that.globalData.userInfo)
21 | }
22 | })
23 | }
24 | })
25 | }
26 | },
27 | globalData:{
28 | appkey:'53efd70e85818958f140184c22b25eb4',
29 | userInfo:null
30 | }
31 | })
--------------------------------------------------------------------------------
/weather/app.js:
--------------------------------------------------------------------------------
1 | //app.js
2 | App({
3 | onLaunch: function () {
4 | //调用API从本地缓存中获取数据
5 | var logs = wx.getStorageSync('logs') || []
6 | logs.unshift(Date.now())
7 | wx.setStorageSync('logs', logs)
8 | },
9 | getUserInfo:function(cb){
10 | var that = this
11 | if(this.globalData.userInfo){
12 | typeof cb == "function" && cb(this.globalData.userInfo)
13 | }else{
14 | //调用登录接口
15 | wx.login({
16 | success: function () {
17 | wx.getUserInfo({
18 | success: function (res) {
19 | that.globalData.userInfo = res.userInfo
20 | typeof cb == "function" && cb(that.globalData.userInfo)
21 | }
22 | })
23 | }
24 | })
25 | }
26 | },
27 | globalData:{ //全局变量
28 | weatherApikey : "77c92a1703a2d96a86b9a60c593481a4",
29 | userInfo:null
30 | }
31 | })
--------------------------------------------------------------------------------
/weather/pages/detail/detail.wxss:
--------------------------------------------------------------------------------
1 | page {
2 | height:100%;
3 | }
4 | .main-container {
5 | height:100%;
6 | background: url("../img/bg.jpg") ;
7 | background-size: cover;
8 | color: #FFFFFF;
9 | text-align: center;
10 | padding-top:10px;
11 | }
12 | .today {
13 | border:1px #aaadaa solid; width:90%; margin-left:5%; padding:10rpx 0rpx; border-radius:10rpx; background:rgba(255, 255, 255, 0.1);
14 | }
15 |
16 | .city, .date {
17 | color:#aaadaa; font-weight: bold;
18 | }
19 | .temp {
20 | font-size: 120rpx; padding:20rpx;
21 | }
22 |
23 | .weather, .wd {
24 | color:#ddd; font-weight: bold;
25 | }
26 |
27 | .index-content {
28 | text-align: left;
29 | padding:40rpx 10rpx;
30 | width:100%;
31 | }
32 |
33 | .index-content view {
34 | font-size:26rpx; line-height:40rpx; color:#eee;
35 | }
36 | .index-name {
37 | padding-top:10rpx;
38 | }
39 | .index-detail {
40 | border-bottom:1px #999 solid; padding-bottom:8rpx; font-size:18rpx;
41 | }
42 |
--------------------------------------------------------------------------------
/constellation/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "pages":[
3 | "pages/index/index",
4 | "pages/history/index",
5 | "pages/qq/index",
6 | "pages/constellation-detail/index"
7 | ],
8 | "window":{
9 | "backgroundTextStyle":"light",
10 | "navigationBarBackgroundColor": "#99322d",
11 | "navigationBarTitleText": "综合小娱乐",
12 | "navigationBarTextStyle":"white"
13 | },
14 | "tabBar": {
15 | "selectedColor": "#99322d",
16 | "list": [{
17 | "pagePath": "pages/index/index",
18 | "text": "星座运势",
19 | "iconPath": "pages/imgs/xz2.png",
20 | "selectedIconPath": "pages/imgs/xz1.png"
21 | }, {
22 | "pagePath": "pages/history/index",
23 | "text": "历史今天",
24 | "iconPath": "pages/imgs/history2.png",
25 | "selectedIconPath": "pages/imgs/history1.png"
26 | }, {
27 | "pagePath": "pages/qq/index",
28 | "text": "QQ吉凶",
29 | "iconPath": "pages/imgs/qq2.png",
30 | "selectedIconPath": "pages/imgs/qq1.png"
31 | }]
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/constellation/pages/constellation-detail/index.wxss:
--------------------------------------------------------------------------------
1 | page {
2 | height:100%;
3 | }
4 | .detail-container {
5 | height:100%; background: url("../imgs/xzbg.jpg"); background-size: cover; color:#FFF; padding: 8px;
6 | }
7 | .detail-container .title {
8 | width:100%; text-align: center; padding-bottom:15px;
9 | }
10 |
11 |
12 | .name {
13 | font-size:28rpx; color:#FFFF00; font-weight: bold;
14 | }
15 | .index {
16 | display: flex; flex-direction: row; margin-top:18rpx;
17 | }
18 | .summary {
19 | font-size:26rpx; text-indent: 2em; line-height:38rpx; margin-top:8px;
20 | }
21 |
22 | .index text {
23 | font-size:22rpx;
24 | }
25 | .index text.value {
26 | font-size:28rpx; color: #FFFF00;
27 | }
28 |
29 | .index progress {
30 | flex-grow: 1;
31 | }
32 |
33 | .today {
34 | margin-right:10px;
35 | }
36 | .year {
37 | margin-top:18px; margin-right:10px;
38 | }
39 | .year .con {
40 | font-size:26rpx; text-indent: 2em; line-height:38rpx; margin-top:8px;
41 | }
42 | .year .con text {
43 | font-weight:bold;
44 | }
--------------------------------------------------------------------------------
/constellation/pages/history/index.js:
--------------------------------------------------------------------------------
1 | // pages/history/index.js
2 | var util = require("../../utils/myDate.js");
3 | Page({
4 | data:{
5 | day:'',
6 | today:{}
7 | },
8 | onLoad:function(options){
9 | // 页面初始化 options为页面跳转所带来的参数
10 | var day = options.day;
11 | if(!day) {
12 | day = util.buildDay(0); //今天
13 | }
14 | this.setData({day: day});
15 | this.loadData(day);
16 | },
17 | onReady:function(){
18 | // 页面渲染完成
19 | },
20 | onShow:function(){
21 | // 页面显示
22 | },
23 | onHide:function(){
24 | // 页面隐藏
25 | },
26 | onUnload:function(){
27 | // 页面关闭
28 | },
29 | loadData: function(day) {
30 | var that = this;
31 | var key = "03d6f756332d667e8446c4f1be4cf39b";
32 | var url = "http://v.juhe.cn/todayOnhistory/queryEvent.php";
33 | wx.request({
34 | url: url,
35 | data: {
36 | key: key,
37 | date: day
38 | },
39 | method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
40 | // header: {}, // 设置请求的 header
41 | success: function(res){
42 | // success
43 | console.log(res);
44 | that.setData({today: res.data.result});
45 | }
46 | })
47 | }
48 | })
--------------------------------------------------------------------------------
/weather/pages/index/index.wxss:
--------------------------------------------------------------------------------
1 | page {
2 | height:100%;
3 | }
4 | .main-container {
5 | height:100%;
6 | background: url("../img/bg.jpg") ;
7 | background-size: cover;
8 | color: #FFFFFF;
9 | text-align: center;
10 | padding-top:10px;
11 | }
12 | .today {
13 | border:1px #aaadaa solid; width:90%; margin-left:5%; padding:10rpx 0rpx; border-radius:10rpx; background:rgba(255, 255, 255, 0.1);
14 | }
15 |
16 | .city, .date {
17 | color:#aaadaa; font-weight: bold;
18 | }
19 | .temp {
20 | font-size: 120rpx; padding:20rpx;
21 | }
22 |
23 | .weather, .wd {
24 | color:#ddd; font-weight: bold;
25 | }
26 |
27 | .index-content {
28 | text-align: left;
29 | padding:40rpx 10rpx;
30 | width:100%;
31 | }
32 |
33 | .index-content view {
34 | font-size:26rpx; line-height:40rpx; color:#eee;
35 | }
36 | .index-name {
37 | padding-top:10rpx; width:42%; margin-left:5%; float:left;
38 | }
39 | .index-detail {
40 | border-bottom:1px #999 solid; padding-bottom:8rpx; font-size:18rpx;
41 | }
42 |
43 | .forecast {
44 | width:100%; float:left; margin-top:40rpx;
45 | display: flex; flex-direction: row;
46 | }
47 |
48 | .forecast-item {
49 | width:23.25%; margin-left:1%; border:1px #bbb solid; border-radius: 5px;
50 | box-shadow: 5px 5px 5px #888888;
51 | }
52 | .forecast-item view {
53 | font-size:26rpx; line-height:50rpx;
54 | }
--------------------------------------------------------------------------------
/constellation/pages/qq/index.js:
--------------------------------------------------------------------------------
1 | Page({
2 | data:{
3 | qq:'',
4 | result:'请输入QQ号码查询',
5 | detail:'----'
6 | },
7 | onLoad:function(options){
8 | // 生命周期函数--监听页面加载
9 |
10 | },
11 | onShareAppMessage: function() {
12 | // 用户点击右上角分享
13 | return {
14 | title: 'title', // 分享标题
15 | desc: 'desc', // 分享描述
16 | path: 'path' // 分享路径
17 | }
18 | },
19 | loadData: function(qq) {
20 | var that = this;
21 | var key = "e32c2619ad9beec999e729afcfb3cce7";
22 | var url = "http://japi.juhe.cn/qqevaluate/qq";
23 | wx.request({
24 | url: url,
25 | data: {
26 | key: key,
27 | qq: qq
28 | },
29 | method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
30 | // header: {}, // 设置请求的 header
31 | success: function(res){
32 | // success
33 | console.log(res);
34 | that.setData({
35 | qq: qq,
36 | result: res.data.result.data.conclusion,
37 | detail: res.data.result.data.analysis
38 | });
39 | }
40 | })
41 | },
42 | changeQQ: function(e) {
43 | var qq = e.detail.value;
44 | //console.log(qq);
45 | this.setData({qq: qq});
46 | },
47 | queryData: function(e) {
48 | var qq = this.data.qq;
49 | if(qq=='') {
50 | wx.showToast({title: 'QQ号码为空!', icon:"loading"});
51 | } else {
52 | this.loadData(qq);
53 | }
54 | }
55 | })
--------------------------------------------------------------------------------
/robot/pages/index/index.wxss:
--------------------------------------------------------------------------------
1 | page {
2 | height:100%;
3 | }
4 | .main-container {
5 | height:100%;
6 | }
7 |
8 | .content {
9 | height:100%; padding-bottom:60px; background: #fafafa;
10 | padding:0px 5px 60px 5px;
11 | }
12 |
13 | .robot {
14 | width:70%; display: flex; flex-direction: row; margin-top:12rpx; float:left; margin-left:8px; margin-bottom:9px;
15 | }
16 |
17 | .robot image {
18 | width:100rpx; height:100rpx; border-radius: 50px;
19 | }
20 | .robot view {
21 | display: flex; flex-direction: column;
22 | }
23 | .robot view text {
24 | color:#777; font-size:28rpx; margin-left:12rpx; line-height:42rpx;
25 | }
26 | .robot view text.date {
27 | color:#aaa;
28 | }
29 |
30 | .me {
31 | width:70%; display: flex; flex-direction: row-reverse; margin-top:12rpx; float: right; margin-right:10px;
32 | }
33 |
34 | .me image {
35 | width:100rpx; height:100rpx; border-radius: 50px;
36 | }
37 | .me view {
38 | display: flex; flex-direction: column;
39 | }
40 | .me view text {
41 | color:#777; font-size:28rpx; margin-left:12rpx; line-height:42rpx;
42 | }
43 | .me view text.date {
44 | color:#aaa;
45 | }
46 |
47 | .sender-container {
48 | width:100%; border-top:1px #FFF solid; height:50px; position: fixed; bottom:0px;
49 | background: #FFF; padding:8px 10px 0px 8px; display: flex; flex-direction: row;
50 | }
51 |
52 | .sender-container input {
53 | border:1px #ddd solid; border-radius:5px; height:40px; line-height:40px;
54 | }
55 | .sender-container button {
56 | width:90px; margin-right:12px; margin-left:5px; height:40px; line-height: 40px;
57 | }
--------------------------------------------------------------------------------
/joke/pages/pictures/main.js:
--------------------------------------------------------------------------------
1 | var app = getApp();
2 | Page({
3 | data:{
4 | pics:[],
5 | page:1,
6 | pagesize:15
7 | },
8 | onLoad:function(options){
9 | // 生命周期函数--监听页面加载
10 | console.log(app.globalData.appkey);
11 | this.loadPics();
12 | },
13 | onReady:function(){
14 | // 生命周期函数--监听页面初次渲染完成
15 |
16 | },
17 | onShow:function(){
18 | // 生命周期函数--监听页面显示
19 |
20 | },
21 | onHide:function(){
22 | // 生命周期函数--监听页面隐藏
23 |
24 | },
25 | onUnload:function(){
26 | // 生命周期函数--监听页面卸载
27 |
28 | },
29 | onPullDownRefresh: function() {
30 | // 页面相关事件处理函数--监听用户下拉动作
31 |
32 | },
33 | onReachBottom: function() {
34 | // 页面上拉触底事件的处理函数
35 | this.setData({page: this.data.page+1});
36 | this.loadPics();
37 | },
38 | onShareAppMessage: function() {
39 | // 用户点击右上角分享
40 | return {
41 | title: 'title', // 分享标题
42 | desc: 'desc', // 分享描述
43 | path: 'path' // 分享路径
44 | }
45 | },
46 |
47 | loadPics: function() {
48 | var that = this;
49 | var key = app.globalData.appkey;
50 | var url = "http://japi.juhe.cn/joke/img/text.from";
51 | wx.request({
52 | url: url,
53 | data: {
54 | key: key,
55 | page: that.data.page,
56 | pagesize: that.data.pagesize
57 | },
58 | method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
59 | // header: {}, // 设置请求的 header
60 | success: function(res){
61 | // success
62 | console.log(res);
63 | that.setData({pics: that.data.pics.concat(res.data.result.data)});
64 | }
65 | })
66 | }
67 | })
--------------------------------------------------------------------------------
/weather/pages/detail/detail.js:
--------------------------------------------------------------------------------
1 | Page({
2 | data:{
3 | city:'',
4 | cityid:'',
5 | weatherApikey:'',
6 | curWd:{},
7 | indexs:{}
8 | },
9 | onLoad:function(options){
10 | // 生命周期函数--监听页面加载
11 | // console.log(options.city+"======="+options.query);
12 | this.setData({city:options.city, cityid:options.cityid, weatherApikey:getApp().globalData.weatherApikey});
13 |
14 | this.loadWeather(this.data.city, this.data.cityid);
15 | },
16 | onReady:function(){
17 | // 生命周期函数--监听页面初次渲染完成
18 | },
19 | onShow:function(){
20 | // 生命周期函数--监听页面显示
21 | },
22 | onHide:function(){
23 | // 生命周期函数--监听页面隐藏
24 | },
25 | onUnload:function(){
26 | // 生命周期函数--监听页面卸载
27 | },
28 | onPullDownRefresh: function() {
29 | // 页面相关事件处理函数--监听用户下拉动作
30 | },
31 | onReachBottom: function() {
32 | // 页面上拉触底事件的处理函数
33 | },
34 | onShareAppMessage: function() {
35 | // 用户点击右上角分享
36 | return {
37 | title: 'title', // 分享标题
38 | desc: 'desc', // 分享描述
39 | path: 'path' // 分享路径
40 | }
41 | },
42 | loadWeather: function(city, cityid) {
43 | var page = this;
44 | var url = "http://apis.baidu.com/apistore/weatherservice/recentweathers";
45 | wx.request({
46 | url: url,
47 | data: {
48 | cityname:city,
49 | cityid:cityid
50 | },
51 | method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
52 | header: {
53 | apikey: page.data.weatherApikey
54 | }, // 设置请求的 header
55 | success: function(res){
56 | // success
57 | console.log(res);
58 | page.setData({curWd : res.data.retData.today, indexs: res.data.retData.today.index});
59 | }
60 | })
61 | }
62 | })
--------------------------------------------------------------------------------
/constellation/pages/constellation-detail/index.js:
--------------------------------------------------------------------------------
1 | Page({
2 | data:{
3 | name:'',
4 | today:{},
5 | year:{}
6 | },
7 | onLoad:function(options){
8 | // 生命周期函数--监听页面加载
9 | var name = options.name;
10 | this.setData({name: name});
11 | this.loadData(name, "today");
12 | this.loadData(name, "year");
13 | },
14 | onShareAppMessage: function() {
15 | // 用户点击右上角分享
16 | return {
17 | title: 'title', // 分享标题
18 | desc: 'desc', // 分享描述
19 | path: 'path' // 分享路径
20 | }
21 | },
22 |
23 | loadData: function(name, type) {
24 | var that = this;
25 | var key = "057d56db14bcf4dc5d6f8f5736b0df95";
26 | var url = "http://web.juhe.cn:8080/constellation/getAll";
27 | wx.request({
28 | url: url,
29 | data: {
30 | consName: name,key:key,
31 | type:type
32 | },
33 | method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
34 | // header: {}, // 设置请求的 header
35 | success: function(res){
36 | // success
37 | if("today"==type) {
38 | var data = res.data;
39 | that.setData({
40 | today: {
41 | datetime:data.datetime,
42 | all:data.all.replace("%", ""),
43 | color:data.color,
44 | health: data.health.replace("%", ""),
45 | love: data.love.replace("%", ""),
46 | money: data.money.replace("%", ""),
47 | number:data.number,
48 | QFriend: data.QFriend,
49 | summary: data.summary,
50 | work: data.work.replace("%", "")
51 | }
52 | });
53 | } else if("year"==type) {
54 | console.log(res);
55 | that.setData({year: res.data});
56 | }
57 | }
58 | })
59 | },
60 | goBack: function() {
61 | wx.navigateBack({
62 | delta: 1 // 回退前 delta(默认为1) 页面
63 | })
64 | }
65 | })
--------------------------------------------------------------------------------
/joke/pages/index/index.js:
--------------------------------------------------------------------------------
1 | var util = require("../../utils/util.js");
2 | var app = getApp();
3 | Page({
4 | data:{
5 | jokes:[],
6 | page: 1,
7 | pagesize:15
8 | },
9 | onLoad:function(options){
10 | // 生命周期函数--监听页面加载
11 | this.loadJokes();
12 | },
13 | onReady:function(){
14 | // 生命周期函数--监听页面初次渲染完成
15 |
16 | },
17 | onShow:function(){
18 | // 生命周期函数--监听页面显示
19 |
20 | },
21 | onHide:function(){
22 | // 生命周期函数--监听页面隐藏
23 |
24 | },
25 | onUnload:function(){
26 | // 生命周期函数--监听页面卸载
27 |
28 | },
29 | onPullDownRefresh: function() {
30 | // 页面相关事件处理函数--监听用户下拉动作
31 |
32 | },
33 | onReachBottom: function() {
34 | // 页面上拉触底事件的处理函数
35 | this.setData({page: this.data.page+1});
36 | this.loadJokes();
37 | },
38 | onShareAppMessage: function() {
39 | // 用户点击右上角分享
40 | return {
41 | title: 'title', // 分享标题
42 | desc: 'desc', // 分享描述
43 | path: 'path' // 分享路径
44 | }
45 | },
46 |
47 | loadJokes: function() {
48 | var that = this;
49 | var key = app.globalData.appkey;
50 | var url = "http://japi.juhe.cn/joke/content/text.from";
51 |
52 | wx.request({
53 | url: url,
54 | data: {
55 | key: key,
56 | page: that.data.page,
57 | pagesize: that.data.pagesize
58 | },
59 | method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
60 | // header: {}, // 设置请求的 header
61 | success: function(res){
62 | // success
63 | //console.log(res);
64 |
65 | that.rebuildData(res.data.result.data);
66 | }
67 | })
68 | },
69 |
70 | rebuildData: function(data) {
71 | var tmp_data = [];
72 | for(var i=0; i
2 | {{name}}
3 |
4 |
5 | 今日运势({{today.datetime}})
6 |
7 | 综合指数:
8 |
9 |
10 |
11 | 健康指数:
12 |
13 |
14 | 爱情指数:
15 |
16 |
17 | 财运指数:
18 |
19 |
20 | 工作指数:
21 |
22 |
23 |
24 | 幸运颜色:{{today.color}}
25 |
26 |
27 | 幸运数字:{{today.number}}
28 |
29 |
30 | {{today.summary}}
31 |
32 |
33 |
34 | 年度运势({{year.date}})
35 | 年度密码:{{year.mima.info}}
36 | {{year.mima.text}}
37 |
38 | 事业运:{{year.career[0]}}
39 |
40 | 情感运:{{year.love[0]}}
41 |
42 | 财运:{{year.finance[0]}}
43 |
44 | 健康运:{{year.health[0]}}
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/constellation/pages/index/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 星座运势
5 |
6 |
7 |
8 |
9 |
10 | 白羊座
11 |
12 |
13 |
14 | 金牛座
15 |
16 |
17 |
18 | 双子座
19 |
20 |
21 |
22 | 巨蟹座
23 |
24 |
25 |
26 | 狮子座
27 |
28 |
29 |
30 | 处女座
31 |
32 |
33 |
34 | 天秤座
35 |
36 |
37 |
38 | 天蝎座
39 |
40 |
41 |
42 | 射手座
43 |
44 |
45 |
46 | 摩羯座
47 |
48 |
49 |
50 | 水瓶座
51 |
52 |
53 |
54 | 双鱼座
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/robot/pages/index/index.js:
--------------------------------------------------------------------------------
1 | var util = require("../../utils/util.js");
2 | Page({
3 | data:{
4 | q:'', //
5 | content:[]
6 | },
7 | onLoad:function(options){
8 | // 生命周期函数--监听页面加载
9 | //console.log(util.formatTime(new Date()));
10 | this.loadContent();
11 | },
12 | onReady:function(){
13 | // 生命周期函数--监听页面初次渲染完成
14 |
15 | },
16 | onShow:function(){
17 | // 生命周期函数--监听页面显示
18 |
19 | },
20 | onHide:function(){
21 | // 生命周期函数--监听页面隐藏
22 |
23 | },
24 | onUnload:function(){
25 | // 生命周期函数--监听页面卸载
26 |
27 | },
28 | onPullDownRefresh: function() {
29 | // 页面相关事件处理函数--监听用户下拉动作
30 |
31 | },
32 | onReachBottom: function() {
33 | // 页面上拉触底事件的处理函数
34 |
35 | },
36 | onShareAppMessage: function() {
37 | // 用户点击右上角分享
38 | return {
39 | title: 'title', // 分享标题
40 | desc: 'desc', // 分享描述
41 | path: 'path' // 分享路径
42 | }
43 | },
44 |
45 | inputEvent: function(event) {
46 | var value = event.detail.value;
47 | this.setData({q:value});
48 | },
49 |
50 | queryAnswer: function() {
51 | var page = this;
52 | var q = this.data.q;
53 | if(q==null || q==='') {
54 | wx.showToast({
55 | title: '请输入您的问题',
56 | icon: 'loading'
57 | });
58 | } else {
59 | var appkey = "147c3451003239dcb1ac1dda32660d4e";
60 |
61 | var datas = page.data.content;
62 | datas.push({"isRobot":false, "date": util.formatTime(new Date()), "text":q});
63 |
64 | page.setData({q:'', content:datas});
65 |
66 | var url = "http://op.juhe.cn/robot/index?key="+appkey+"&info="+q;
67 | wx.request({
68 | url: url,
69 | data: {},
70 | method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
71 | // header: {}, // 设置请求的 header
72 | success: function(res){
73 | // success
74 | if(res.data.error_code=='0') {
75 | var con = res.data.result.text;
76 | var datas = page.data.content;
77 | datas.push({"isRobot":true, "date": util.formatTime(new Date()), "text":con});
78 |
79 | console.log(datas);
80 | page.setData({content:datas});
81 |
82 | page.setContent2Storage(datas);
83 | } else {
84 | wx.showToast({
85 | title:res.data.reason, icon:'loading'
86 | });
87 | }
88 | console.log(res);
89 | }
90 | })
91 | }
92 | },
93 |
94 | setContent2Storage: function(data) {
95 | wx.setStorage({
96 | key: 'content',
97 | data: data,
98 | success: function(res){
99 | // success
100 | //console.log("=====保存成功=====");
101 | }
102 | })
103 | },
104 |
105 | loadContent: function() {
106 | var page = this;
107 | wx.getStorage({
108 | key: 'content',
109 | success: function(res){
110 | // success
111 | console.log(res);
112 | page.setData({content:res.data});
113 | }
114 | })
115 | }
116 | })
--------------------------------------------------------------------------------
/weather/pages/index/index.js:
--------------------------------------------------------------------------------
1 | //var weatherApikey = "77c92a1703a2d96a86b9a60c593481a4";
2 | Page({
3 |
4 | data:{
5 | weatherApikey:'', //天气apikey,在http://apistore.baidu.com 上申请
6 | city:'', //城市名称
7 | areaid:'', //城市对应的id
8 | curWd:{}, //当天天气情况
9 | indexs:{}, //当天天气详情说明
10 | forecast:{} //未来4天的天气情况
11 | },
12 | onLoad:function(options){
13 | // 生命周期函数--监听页面加载
14 | this.setData({weatherApikey:getApp().globalData.weatherApikey});
15 | this.loadLocation();
16 | },
17 | onReady:function(){
18 | // 生命周期函数--监听页面初次渲染完成
19 |
20 | },
21 | onShow:function(){
22 | // 生命周期函数--监听页面显示
23 |
24 | },
25 | onHide:function(){
26 | // 生命周期函数--监听页面隐藏
27 |
28 | },
29 | onUnload:function(){
30 | // 生命周期函数--监听页面卸载
31 |
32 | },
33 | onPullDownRefresh: function() {
34 | // 页面相关事件处理函数--监听用户下拉动作
35 |
36 | },
37 | onReachBottom: function() {
38 | // 页面上拉触底事件的处理函数
39 |
40 | },
41 | onShareAppMessage: function() {
42 | // 用户点击右上角分享
43 | return {
44 | title: '天气-小程序', // 分享标题
45 | desc: '今天天气怎么样?', // 分享描述
46 | path: 'path' // 分享路径
47 | }
48 | },
49 | //获取当前的位置信息,即经纬度
50 | loadLocation: function() {
51 | var page = this;
52 | wx.getLocation({
53 | type: 'gcj02', // 默认为 wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标
54 | success: function(res){
55 | // success
56 | var latitude = res.latitude;
57 | var longitude = res.longitude;
58 |
59 | //获取城市
60 | page.loadCity(latitude, longitude);
61 | }
62 | })
63 | },
64 |
65 | //通过经纬度获取城市
66 | loadCity: function(latitude, longitude) {
67 | var page = this;
68 | var url = "http://apis.map.qq.com/ws/geocoder/v1/?location="+latitude+","+longitude+"&key=XSWBZ-EVQ3V-UMLPA-U4TP6-6MQFZ-UUFSL&get_poi=1";
69 | wx.request({
70 | url: url,
71 | data: {},
72 | method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
73 | // header: {}, // 设置请求的 header
74 | success: function(res){
75 | // success
76 | var city = res.data.result.address_component.city;
77 | city = city.replace("市", ""); //将“市”去掉,要不然取不了
78 | page.setData({city: city});
79 | page.loadId(city);
80 | }
81 | })
82 | },
83 |
84 | //通过城市名称获取城市的唯一ID
85 | loadId: function(city) {
86 | var page = this;
87 | var url = "http://apis.baidu.com/apistore/weatherservice/citylist";
88 | wx.request({
89 | url: url,
90 | data: {
91 | cityname: city
92 | },
93 | header: {
94 | apikey:page.data.weatherApikey
95 | },
96 | method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
97 | success: function(res){
98 | // success
99 | var cityid = res.data.retData[0].area_id;
100 |
101 | page.setData({areaid: cityid});
102 | page.loadWeather(city, cityid);
103 | }
104 | })
105 | },
106 |
107 | //通过城市名称和城市ID获取天气情况
108 | loadWeather: function(city, areaId) {
109 | var page = this;
110 | var url = "http://apis.baidu.com/apistore/weatherservice/recentweathers";
111 | wx.request({
112 | url: url,
113 | data: {
114 | cityname:city,
115 | cityid: areaId
116 | },
117 | header: {
118 | apikey: page.data.weatherApikey
119 | },
120 | method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
121 | success: function(res){
122 | // success
123 | page.setData({curWd : res.data.retData.today, indexs: res.data.retData.today.index, forecast:res.data.retData.forecast});
124 | }
125 | })
126 | },
127 |
128 | gotoDetail: function(event) {
129 | // console.log(this.data.areaid+"==在这里跳转=="+this.data.city);
130 | wx.navigateTo({
131 | url: '../detail/detail?city='+this.data.city+"&cityid="+this.data.areaid
132 | })
133 | }
134 | })
--------------------------------------------------------------------------------