소스 검색

小程序案例:轮播图*分类标题

大侠 2 년 전
부모
커밋
1ced7b7229
30개의 변경된 파일358개의 추가작업 그리고 0개의 파일을 삭제
  1. 31 0
      16_miniapp/day-5/video-list/.eslintrc.js
  2. 19 0
      16_miniapp/day-5/video-list/app.js
  3. 36 0
      16_miniapp/day-5/video-list/app.json
  4. 1 0
      16_miniapp/day-5/video-list/app.wxss
  5. BIN
      16_miniapp/day-5/video-list/images/1.png
  6. BIN
      16_miniapp/day-5/video-list/images/2.png
  7. BIN
      16_miniapp/day-5/video-list/images/3.png
  8. BIN
      16_miniapp/day-5/video-list/images/home_active_icon.png
  9. BIN
      16_miniapp/day-5/video-list/images/home_icon.png
  10. BIN
      16_miniapp/day-5/video-list/images/more.png
  11. BIN
      16_miniapp/day-5/video-list/images/my_active_icon.png
  12. BIN
      16_miniapp/day-5/video-list/images/my_icon.png
  13. BIN
      16_miniapp/day-5/video-list/images/search_active_icon.png
  14. BIN
      16_miniapp/day-5/video-list/images/search_icon.png
  15. 14 0
      16_miniapp/day-5/video-list/pages/index/index.js
  16. 4 0
      16_miniapp/day-5/video-list/pages/index/index.json
  17. 22 0
      16_miniapp/day-5/video-list/pages/index/index.wxml
  18. 38 0
      16_miniapp/day-5/video-list/pages/index/index.wxss
  19. 66 0
      16_miniapp/day-5/video-list/pages/me/me.js
  20. 4 0
      16_miniapp/day-5/video-list/pages/me/me.json
  21. 2 0
      16_miniapp/day-5/video-list/pages/me/me.wxml
  22. 1 0
      16_miniapp/day-5/video-list/pages/me/me.wxss
  23. 18 0
      16_miniapp/day-5/video-list/pages/search/search.js
  24. 4 0
      16_miniapp/day-5/video-list/pages/search/search.json
  25. 6 0
      16_miniapp/day-5/video-list/pages/search/search.wxml
  26. 8 0
      16_miniapp/day-5/video-list/pages/search/search.wxss
  27. 51 0
      16_miniapp/day-5/video-list/project.config.json
  28. 7 0
      16_miniapp/day-5/video-list/project.private.config.json
  29. 7 0
      16_miniapp/day-5/video-list/sitemap.json
  30. 19 0
      16_miniapp/day-5/video-list/utils/util.js

+ 31 - 0
16_miniapp/day-5/video-list/.eslintrc.js

@@ -0,0 +1,31 @@
+/*
+ * Eslint config file
+ * Documentation: https://eslint.org/docs/user-guide/configuring/
+ * Install the Eslint extension before using this feature.
+ */
+module.exports = {
+  env: {
+    es6: true,
+    browser: true,
+    node: true,
+  },
+  ecmaFeatures: {
+    modules: true,
+  },
+  parserOptions: {
+    ecmaVersion: 2018,
+    sourceType: 'module',
+  },
+  globals: {
+    wx: true,
+    App: true,
+    Page: true,
+    getCurrentPages: true,
+    getApp: true,
+    Component: true,
+    requirePlugin: true,
+    requireMiniProgram: true,
+  },
+  // extends: 'eslint:recommended',
+  rules: {},
+}

+ 19 - 0
16_miniapp/day-5/video-list/app.js

@@ -0,0 +1,19 @@
+// app.js
+App({
+  onLaunch() {
+    // 展示本地存储能力
+    const logs = wx.getStorageSync('logs') || []
+    logs.unshift(Date.now())
+    wx.setStorageSync('logs', logs)
+
+    // 登录
+    wx.login({
+      success: res => {
+        // 发送 res.code 到后台换取 openId, sessionKey, unionId
+      }
+    })
+  },
+  globalData: {
+    userInfo: null
+  }
+})

+ 36 - 0
16_miniapp/day-5/video-list/app.json

@@ -0,0 +1,36 @@
+{
+  "pages": [
+    "pages/index/index",
+    "pages/search/search",
+    "pages/me/me"
+  ],
+  "window": {
+    "backgroundTextStyle": "light",
+    "navigationBarBackgroundColor": "#2E8B57",
+    "navigationBarTitleText": "主页",
+    "navigationBarTextStyle": "white"
+  },
+  "tabBar": {
+    "color": "#ccc",
+    "list": [{
+      "pagePath": "pages/index/index",
+      "text": "主页",
+      "iconPath": "images/home_icon.png",
+      "selectedIconPath": "images/home_active_icon.png"
+    },
+    {
+      "pagePath": "pages/search/search",
+      "text": "搜索",
+      "iconPath": "images/search_icon.png",
+      "selectedIconPath": "images/search_active_icon.png"
+    },
+    {
+      "pagePath": "pages/me/me",
+      "text": "我的",
+      "iconPath": "images/my_icon.png",
+      "selectedIconPath": "images/my_active_icon.png"
+    }]
+  },
+  "style": "v2",
+  "sitemapLocation": "sitemap.json"
+}

+ 1 - 0
16_miniapp/day-5/video-list/app.wxss

@@ -0,0 +1 @@
+

BIN
16_miniapp/day-5/video-list/images/1.png


BIN
16_miniapp/day-5/video-list/images/2.png


BIN
16_miniapp/day-5/video-list/images/3.png


BIN
16_miniapp/day-5/video-list/images/home_active_icon.png


BIN
16_miniapp/day-5/video-list/images/home_icon.png


BIN
16_miniapp/day-5/video-list/images/more.png


BIN
16_miniapp/day-5/video-list/images/my_active_icon.png


BIN
16_miniapp/day-5/video-list/images/my_icon.png


BIN
16_miniapp/day-5/video-list/images/search_active_icon.png


BIN
16_miniapp/day-5/video-list/images/search_icon.png


+ 14 - 0
16_miniapp/day-5/video-list/pages/index/index.js

@@ -0,0 +1,14 @@
+// index.js
+// 获取应用实例
+const app = getApp()
+
+Page({
+  data: {
+    // 轮播图片
+    imgs: ['../../images/1.png','../../images/2.png','../../images/3.png']
+  },
+  
+  onLoad() {
+    
+  },
+})

+ 4 - 0
16_miniapp/day-5/video-list/pages/index/index.json

@@ -0,0 +1,4 @@
+{
+  "usingComponents": {},
+  "navigationBarTitleText": "主页"
+}

+ 22 - 0
16_miniapp/day-5/video-list/pages/index/index.wxml

@@ -0,0 +1,22 @@
+<view>
+  <!-- 录播图 -->
+  <swiper class="lunbo" autoplay indicator-dots circular interval="3000">
+    <swiper-item wx:for="{{imgs}}" wx:key="*this">
+      <image src="{{item}}" mode="scaleToFill"/>
+    </swiper-item>
+  </swiper>
+  <!-- 热播国剧 -->
+  <view class="guoju">
+    <view class="cate">
+      <text class="cate-title">近期热播国剧</text>
+      <view style="display: inline-flex; align-items: center;" >
+        <text class="cate-more">更多</text>
+        <view class="more">
+        </view>
+      </view>
+      
+    </view>
+  </view>
+  <!-- 热门综艺 -->
+  <!-- 热播美剧 -->
+</view>

+ 38 - 0
16_miniapp/day-5/video-list/pages/index/index.wxss

@@ -0,0 +1,38 @@
+.lunbo {
+  width: 750rpx;
+  height: 280rpx;
+}
+
+.lunbo image {
+  width: 100%;
+  height: 100%;
+}
+
+
+.guoju {
+  padding:  10px;
+}
+
+.cate {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+}
+
+.cate .cate-title {
+  font-size: 18px;
+  font-weight: 700;
+}
+
+.cate .cate-more {
+  color: #8B8B83;
+  font-size: 14px;
+}
+
+.more {
+  margin-left: 2px;
+  display: inline-block;
+  width: 14px;
+  height: 14px;
+  background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAAAXNSR0IArs4c6QAAAHpJREFUOE9jZCATMJKpj2Goauzv7xcoLCz8gM3f6HJwP3Z3Ny9gYGCIZ2RkCCwpqd3Q3d38HmRAaWmtYE9Pc8D//wzrGRgYFpaW1iaAxOEae3qaJ/z/z5CPpBFsc2lprQBMIyMjw8SSktoCFI0gDllOJTU+h2o8kuJPAGeqMg84G4VeAAAAAElFTkSuQmCC');
+}

+ 66 - 0
16_miniapp/day-5/video-list/pages/me/me.js

@@ -0,0 +1,66 @@
+// pages/me/me.js
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad(options) {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage() {
+
+  }
+})

+ 4 - 0
16_miniapp/day-5/video-list/pages/me/me.json

@@ -0,0 +1,4 @@
+{
+  "usingComponents": {},
+  "navigationBarTitleText": "我的"
+}

+ 2 - 0
16_miniapp/day-5/video-list/pages/me/me.wxml

@@ -0,0 +1,2 @@
+<!--pages/me/me.wxml-->
+<text>pages/me/me.wxml</text>

+ 1 - 0
16_miniapp/day-5/video-list/pages/me/me.wxss

@@ -0,0 +1 @@
+/* pages/me/me.wxss */

+ 18 - 0
16_miniapp/day-5/video-list/pages/search/search.js

@@ -0,0 +1,18 @@
+// logs.js
+const util = require('../../utils/util.js')
+
+Page({
+  data: {
+    logs: []
+  },
+  onLoad() {
+    this.setData({
+      logs: (wx.getStorageSync('logs') || []).map(log => {
+        return {
+          date: util.formatTime(new Date(log)),
+          timeStamp: log
+        }
+      })
+    })
+  }
+})

+ 4 - 0
16_miniapp/day-5/video-list/pages/search/search.json

@@ -0,0 +1,4 @@
+{
+  "navigationBarTitleText": "影视搜索",
+  "usingComponents": {}
+}

+ 6 - 0
16_miniapp/day-5/video-list/pages/search/search.wxml

@@ -0,0 +1,6 @@
+<!--logs.wxml-->
+<view class="container log-list">
+  <block wx:for="{{logs}}" wx:key="timeStamp" wx:for-item="log">
+    <text class="log-item">{{index + 1}}. {{log.date}}</text>
+  </block>
+</view>

+ 8 - 0
16_miniapp/day-5/video-list/pages/search/search.wxss

@@ -0,0 +1,8 @@
+.log-list {
+  display: flex;
+  flex-direction: column;
+  padding: 40rpx;
+}
+.log-item {
+  margin: 10rpx;
+}

+ 51 - 0
16_miniapp/day-5/video-list/project.config.json

@@ -0,0 +1,51 @@
+{
+  "description": "项目配置文件",
+  "packOptions": {
+    "ignore": [],
+    "include": []
+  },
+  "setting": {
+    "bundle": false,
+    "userConfirmedBundleSwitch": false,
+    "urlCheck": true,
+    "scopeDataCheck": false,
+    "coverView": true,
+    "es6": true,
+    "postcss": true,
+    "compileHotReLoad": false,
+    "lazyloadPlaceholderEnable": false,
+    "preloadBackgroundData": false,
+    "minified": true,
+    "autoAudits": false,
+    "newFeature": false,
+    "uglifyFileName": false,
+    "uploadWithSourceMap": true,
+    "useIsolateContext": true,
+    "nodeModules": false,
+    "enhance": true,
+    "useMultiFrameRuntime": true,
+    "useApiHook": true,
+    "useApiHostProcess": true,
+    "showShadowRootInWxmlPanel": true,
+    "packNpmManually": false,
+    "enableEngineNative": false,
+    "packNpmRelationList": [],
+    "minifyWXSS": true,
+    "showES6CompileOption": false,
+    "minifyWXML": true,
+    "babelSetting": {
+      "ignore": [],
+      "disablePlugins": [],
+      "outputPath": ""
+    }
+  },
+  "compileType": "miniprogram",
+  "libVersion": "2.19.4",
+  "appid": "wxb7f9a42f0b768006",
+  "projectname": "miniprogram-92",
+  "condition": {},
+  "editorSetting": {
+    "tabIndent": "insertSpaces",
+    "tabSize": 2
+  }
+}

+ 7 - 0
16_miniapp/day-5/video-list/project.private.config.json

@@ -0,0 +1,7 @@
+{
+  "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
+  "projectname": "video-list",
+  "setting": {
+    "compileHotReLoad": true
+  }
+}

+ 7 - 0
16_miniapp/day-5/video-list/sitemap.json

@@ -0,0 +1,7 @@
+{
+  "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
+  "rules": [{
+  "action": "allow",
+  "page": "*"
+  }]
+}

+ 19 - 0
16_miniapp/day-5/video-list/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
+}