Browse Source

小程序

e 9 months ago
parent
commit
e18123e4d3

+ 23 - 12
小程序/app.json

@@ -2,37 +2,48 @@
   "pages": [
     "pages/list/list",
     "pages/home/home",
-    "pages/my/my"
+    "pages/my/my",
+    "components/header/header"
   ],
   "window": {
     "navigationBarTextStyle": "white",
     "navigationBarTitleText": "哈哈哈",
     "navigationBarBackgroundColor": "#ff0000"
   },
-    "tabBar": {
-      "custom": false,
-      "color": "#000000",
-      "selectedColor": "#ff0000",
-      "backgroundColor": "#ffffff",
-      "list": [{
+  "tabBar": {
+    "custom": false,
+    "color": "#000000",
+    "selectedColor": "#ff0000",
+    "backgroundColor": "#ffffff",
+    "list": [
+      {
         "pagePath": "pages/list/list",
         "text": "购物车",
         "iconPath": "./icon/shop.png",
         "selectedIconPath": "./icon/shop1.png"
-      }, {
+      },
+      {
         "pagePath": "pages/home/home",
         "text": "首页",
         "iconPath": "./icon/home.png",
         "selectedIconPath": "./icon/home1.png"
-      }, {
+      },
+      {
         "pagePath": "pages/my/my",
         "text": "我的",
         "iconPath": "./icon/my.png",
         "selectedIconPath": "./icon/my1.png"
-      }]
-    },
-    "usingComponents": {},
+      }
+    ]
+  },
+  "usingComponents": {},
   "style": "v2",
+  "networkTimeout": {
+    "request": 20000,
+    "connectSocket": 20000,
+    "uploadFile": 20000,
+    "downloadFile": 20000
+  },
   "componentFramework": "glass-easel",
   "sitemapLocation": "sitemap.json",
   "lazyCodeLoading": "requiredComponents"

+ 66 - 0
小程序/components/header/header.js

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

+ 4 - 0
小程序/components/header/header.json

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

+ 6 - 0
小程序/components/header/header.wxml

@@ -0,0 +1,6 @@
+<!--components/header/header.wxml-->
+<view>
+  <view class="head">
+    头部模块
+  </view>
+</view>

+ 10 - 0
小程序/components/header/header.wxss

@@ -0,0 +1,10 @@
+/* components/header/header.wxss */
+.head {
+  width: 100%;
+  height: 50px;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  color: #f00;
+  background: #ff0;
+}

+ 14 - 2
小程序/pages/home/home.js

@@ -23,10 +23,18 @@ Page({
         name:"小蓝",
         age: 30
       },
-    ]
+    ],
+    
+    background: ['demo-text-1', 'demo-text-2', 'demo-text-3'],
+    indicatorDots: true,
+    vertical: false,
+    autoplay: false,
+    interval: 2000,
+    duration: 500
   },
   getMain:function() {
-    console.log("你好")
+
+    console.log("你好",wx.getStorageSync('name'))
   },
   getAA:function() {
     console.log("11")
@@ -41,6 +49,7 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad(options) {
+    wx.setStorageSync('name', "笑笑")
     setTimeout(()=>{
       // 原生小程序中
       // this.setData({})
@@ -51,6 +60,9 @@ Page({
           age: 29
         }
       })
+      wx.showToast({
+        title: '更新成功',
+      })
     },4000)
   },
 

+ 3 - 1
小程序/pages/home/home.json

@@ -1,4 +1,6 @@
 {
   "enablePullDownRefresh": true,
-  "usingComponents": {}
+  "usingComponents": {
+    "header1":"../../components/header/header"
+  }
 }

+ 34 - 0
小程序/pages/home/home.wxml

@@ -1,4 +1,5 @@
 <!--pages/home/home.wxml-->
+<header1></header1>
 <view>
   今天星期{{week}}
   <text>
@@ -28,4 +29,37 @@
 </template>
 <view class="aa" catch:tap="getAA">
   <view class="bb" catch:tap="getBB"></view>
+</view>
+<!-- swiper -->
+<view class="swiper">
+  <swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}">
+    <block wx:for="{{background}}" wx:key="*this">
+      <swiper-item>
+        <view class="swiper-item {{item}}"></view>
+      </swiper-item>
+    </block>
+  </swiper>
+</view>
+<!-- scroll-x 横滚 -->
+<view class="page-section-spacing">
+  <scroll-view class="scroll-view_H" scroll-x="true" bindscroll="scroll" style="width: 100%">
+    <view id="demo1" class="scroll-view-item_H demo-text-4"></view>
+    <view id="demo2" class="scroll-view-item_H demo-text-5"></view>
+    <view id="demo3" class="scroll-view-item_H demo-text-6"></view>
+    <view id="demo1" class="scroll-view-item_H demo-text-4"></view>
+    <view id="demo2" class="scroll-view-item_H demo-text-5"></view>
+    <view id="demo3" class="scroll-view-item_H demo-text-6"></view>
+  </scroll-view>
+</view>
+<!-- scroll-y 竖滚 -->
+
+<view class="page-section-spacing">
+  <scroll-view scroll-y="true" style="height: 300rpx;" bindscrolltoupper="upper" bindscrolltolower="lower" bindscroll="scroll" scroll-into-view="{{toView}}" scroll-top="{{scrollTop}}">
+    <view id="demo1" class="scroll-view-item demo-text-7"></view>
+    <view id="demo2" class="scroll-view-item demo-text-8"></view>
+    <view id="demo3" class="scroll-view-item demo-text-9"></view>
+    <view id="demo1" class="scroll-view-item demo-text-7"></view>
+    <view id="demo2" class="scroll-view-item demo-text-8"></view>
+    <view id="demo3" class="scroll-view-item demo-text-9"></view>
+  </scroll-view>
 </view>

+ 64 - 1
小程序/pages/home/home.wxss

@@ -15,4 +15,67 @@
   width: 200rpx;
   height: 200rpx;
   background: #f00;
-}
+}
+.swiper {
+  margin: 30rpx;
+}
+.demo-text-1 {
+  width: 100%;
+  height: 300rpx;
+  background-color: red;
+}
+.demo-text-2 {
+  width: 100%;
+  height: 300rpx;
+  background-color: plum;
+}
+.demo-text-3 {
+  width: 100%;
+  height: 300rpx;
+  background-color: orange;
+}
+
+
+.scroll-view-item_H{
+  display: inline-block;
+  width: 100%;
+  height: 300rpx;
+}
+
+.scroll-view_H{
+  white-space: nowrap;
+}
+.demo-text-4 {
+  width: 30%;
+  margin-left: 20rpx;
+  background-color: red;
+}
+.demo-text-5 {
+  width: 30%;
+  margin-left: 20rpx;
+  background-color: plum;
+}
+.demo-text-6 {
+  width: 30%;
+  margin-left: 20rpx;
+  background-color: orange;
+}
+
+.scroll-view-item{
+  height: 300rpx;
+}
+.demo-text-7 {
+  width: 30%;
+  margin-left: 20rpx;
+  background-color: red;
+}
+.demo-text-8 {
+  width: 30%;
+  margin-left: 20rpx;
+  background-color: plum;
+}
+.demo-text-9 {
+  width: 30%;
+  margin-left: 20rpx;
+  background-color: orange;
+}

+ 40 - 0
小程序/utils/request.js

@@ -0,0 +1,40 @@
+/**
+ * 封封微信的的request
+ */
+function request(url, data = {}, method = "GET") {
+  return new Promise(function(resolve, reject) {
+    wx.request({
+      url: url,
+      data: data,
+      method: method,
+      header: {
+        'Content-Type': 'application/json',
+        'X-Dts-Token': wx.getStorageSync('token')
+      },
+      success: function(res) {
+        if (res.statusCode == 200) {
+          if (res.data.errno == 501) {
+            // 清除登录相关内容
+            try {
+              wx.removeStorageSync('userInfo');
+              wx.removeStorageSync('token');
+            } catch (e) {
+              // Do something when catch error
+            }
+            // 切换到登录页面
+            wx.navigateTo({
+              url: '/pages/auth/login/login'
+            });
+          } else {
+            resolve(res.data);
+          }
+        } else {
+          reject(res.errMsg);
+        }
+      },
+      fail: function(err) {
+        reject(err)
+      }
+    })
+  });
+}