瀏覽代碼

第一次提交

Rorschach 6 年之前
當前提交
7d4adb28d3

+ 39 - 0
app.js

@@ -0,0 +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
+  }
+})

+ 12 - 0
app.json

@@ -0,0 +1,12 @@
+{
+  "pages": [
+    "pages/index/index"
+  ],
+  "window": {
+    "backgroundTextStyle": "light",
+    "navigationBarBackgroundColor": "#61CA54",
+    "navigationBarTitleText": "小学语文课文朗读",
+    "navigationBarTextStyle": "white",
+    "backgroundColor": "#61CA54"
+  }
+}

+ 12 - 0
app.wxss

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

+ 0 - 0
component/follow/fllow.wxss


+ 17 - 0
component/follow/follow.js

@@ -0,0 +1,17 @@
+//index.js
+//获取应用实例
+const app = getApp()
+let template = require('../../template/template.js');
+
+Page({
+  data: {
+
+  },
+  onReady: function(res){
+    
+  },
+  //事件处理函数
+  onLoad: function () {
+    template.tabbar("tabBar", 1, this)//0表示第一个tabbar
+  }
+})

+ 11 - 0
component/follow/follow.wxml

@@ -0,0 +1,11 @@
+<view >
+<import src="../../template/template.wxml"></import>
+<template is="tabBar" data="{{tabBar:bindData.tabBar}}"></template>
+<h2>关注</h2>
+<h2>关注</h2>
+<h2>关注</h2>
+<h2>关注</h2>
+<h2>关注</h2>
+<h2>关注</h2>
+<h2>关注</h2>
+</view>

+ 17 - 0
component/my/index.js

@@ -0,0 +1,17 @@
+//index.js
+//获取应用实例
+const app = getApp()
+let template = require('../../template/template.js');
+
+Page({
+  data: {
+
+  },
+  onReady: function(res){
+    
+  },
+  //事件处理函数
+  onLoad: function () {
+    template.tabbar("tabBar", 2, this)//0表示第一个tabbar
+  }
+})

+ 11 - 0
component/my/index.wxml

@@ -0,0 +1,11 @@
+<view >
+<import src="../../template/template.wxml"></import>
+<template is="tabBar" data="{{tabBar:bindData.tabBar}}"></template>
+<h1>我的</h1>
+<h1>我的</h1>
+<h1>我的</h1>
+<h1>我的</h1>
+<h1>我的</h1>
+<h1>我的</h1>
+<h1>我的</h1>
+</view>

+ 31 - 0
pages/README.md

@@ -0,0 +1,31 @@
+#小学课文朗读
+### 卡密
+小程序账号:sunzhilei8@163.com
+小程序密码:efunbox@3366
+https://mp.weixin.qq.com/
+###目录结构
+```
+├── package.json            
+├── app.js              
+├── app.json                     
+├── app.wxss                     
+├── pages           
+      ├── main                      // 首页热门相关
+	      ├── books                 // 所有课本
+          ├── classes               // 课程
+          ├── ware                  // 课件页(朗读)
+          ├── reading               // 我要朗读页面
+          └── index                 // 热门首页
+      ├── social                      // 关注页面相关
+          ├── works                 // 用户作品页
+          ├── stars                 // 其他用户主页
+          └── follow                // 关注页首页
+      ├── user                      // 我的页面相关
+          ├── index                 // 我的页面首页
+          ├── myCollects            // 我的收藏
+          ├── myWorks               // 我的作品
+          ├── wallet                // 钱包
+          └── myEdit                // 编辑信息
+      └── template                  // 自定义tabbar
+└── utils
+```

+ 87 - 0
pages/index/index.js

@@ -0,0 +1,87 @@
+//index.js
+//获取应用实例
+const app = getApp()
+import { lookInit } from '../../component/look/look';
+import { myInit } from '../../component/mys/mys';
+import { searchInit } from '../../component/search/search';
+import httpRequestApi from '../../utils/APIRequest';
+import httputil from '../../utils/httputil';
+Page({
+  data: {
+    tab:[
+      {
+        name: '看',
+        templates: 'look',
+        img: '../../static/image/look1.png',
+        selectimg: '../../static/image/look2.png'
+      },  
+      {
+        name: '搜',
+        templates: 'search',
+        img: '../../static/image/sou1.png',
+        selectimg: '../../static/image/sou2.png'
+      },  {
+        name: '我的',
+        templates: 'mys',
+        img: '../../static/image/my1.png',
+        selectimg: '../../static/image/my2.png'
+      }
+    ],
+    ind: 0,
+    templates: 'look',
+    jurisdictionFlag: true
+  },
+  //tab点击
+  switcher: function({currentTarget}) {
+    let ind = currentTarget.dataset.ind;
+    let templates = this.data.tab[ind].templates;
+    //console.log(this.data[ind])
+    this.setData({
+      ind,
+      templates
+    })
+    if (ind == 1) {
+      searchInit(this);
+    }
+    if (ind == 2) {
+      myInit(this);
+    }
+  },
+  jurisdiction: function () {
+    setTimeout(()=>{
+      this.init();
+    },1000)
+  },
+  onLoad: function (options) {
+    if(options.ind) {
+      let ind = options.ind;
+      let templates = this.data.tab[ind].templates;
+      this.setData({
+        templates,
+        ind,
+      })
+      if (ind == 1) {
+        searchInit(this);
+      }
+      if (ind == 2) {
+        myInit(this);
+      }
+    }
+    this.init();
+  },
+  //初始化数据
+  init: function () {
+    httputil.getOpenidSessionKey((res) => {
+      console.log('微信的用户信息', res);
+      this.setData({
+        jurisdictionFlag: true
+      })
+      lookInit(this);
+    },(error) => {
+      console.log(error);
+      this.setData({
+        jurisdictionFlag: false
+      })
+    });
+  }
+})

+ 1 - 0
pages/index/index.json

@@ -0,0 +1 @@
+{}

+ 27 - 0
pages/index/index.wxml

@@ -0,0 +1,27 @@
+<!--index.wxml-->
+<view class="container">
+  <!-- 引入组件 -->
+  <import src="/component/look/look.wxml"/>
+  <import src="/component/search/search.wxml"/> 
+  <import src="/component/mys/mys.wxml"/>  
+  <!--调用组件-->
+  <!--<template is="{{templates}}" data="{{lookData: lookData, searchData: searchData, myData: myData}}"></template>-->
+  <view class="template" wx:if="{{templates == 'look'}}">
+    <template is="{{templates}}" data="{{lookData: lookData}}"></template>
+  </view>
+  <view class="template" wx:elif="{{templates == 'search'}}">
+    <template is="{{templates}}" data="{{searchData: searchData}}"></template>
+  </view>
+  <view class="template" wx:else="{{templates == 'mys'}}">
+    <template is="{{templates}}" data="{{myData: myData}}"></template>
+  </view>
+  <button class="jurisdiction" hidden="{{jurisdictionFlag}}" open-type="getUserInfo" bindtap="jurisdiction">点击授权</button>
+  <view class="bottom-tab">
+      <block  wx:for="{{tab}}" wx:key="{{index}}">
+      <view class="tabbar {{index == ind ? 'select':' '}}" bindtap="switcher" data-ind="{{index}}">
+          <image src="{{index == ind ? item.selectimg : item.img}}"></image>
+          <text>{{item.name}}</text>
+      </view>
+      </block>            
+  </view>
+</view>

+ 56 - 0
pages/index/index.wxss

@@ -0,0 +1,56 @@
+/**index.wxss**/
+/*看*/
+@import "/component/look/look.wxss";
+/*搜索*/
+@import "/component/search/search.wxss";
+/*我的*/
+@import "/component/mys/mys.wxss";
+.template {
+  height: 100%;
+}
+.scroll-view {
+  height: 100%;
+}
+.bottom-tab {
+  position: fixed;
+  bottom: 28rpx;
+  left: 5%;
+  width: 90%;
+  height: 152rpx;
+  background: #fff;
+  color: #6a6a6a;
+  border-radius: 152rpx;
+  box-sizing: border-box;
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  box-shadow: 0 3px 6px 0 rgba(0, 0, 0, 0.2), 0 3px 6px 0 rgba(0, 0, 0, .2);
+}
+
+.tabbar {
+  flex: 1;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  height: 100%;
+  font-size: 48rpx;
+  border-radius: 152rpx;
+}
+
+.select {
+  background: #fece00;
+  color: #000;
+}
+
+.bottom-tab image {
+  width: 54rpx;
+  height: 54rpx;
+  margin-right: 20rpx;
+}
+
+.jurisdiction {
+  position: absolute;
+  left: 50%;
+  top: 50%;
+  transform: translate(-50%,-50%);
+}

+ 39 - 0
project.config.json

@@ -0,0 +1,39 @@
+{
+	"description": "项目配置文件",
+	"packOptions": {
+		"ignore": []
+	},
+	"setting": {
+		"urlCheck": true,
+		"es6": true,
+		"postcss": true,
+		"minified": true,
+		"newFeature": true
+	},
+	"compileType": "miniprogram",
+	"libVersion": "2.3.0",
+	"appid": "wxd9a2b1d38b9046ef",
+	"projectname": "reading",
+	"debugOptions": {
+		"hidedInDevtools": []
+	},
+	"isGameTourist": false,
+	"condition": {
+		"search": {
+			"current": -1,
+			"list": []
+		},
+		"conversation": {
+			"current": -1,
+			"list": []
+		},
+		"game": {
+			"currentL": -1,
+			"list": []
+		},
+		"miniprogram": {
+			"current": -1,
+			"list": []
+		}
+	}
+}

+ 19 - 0
utils/util.js

@@ -0,0 +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
+}