Browse Source

add to local

stanley-king 4 years ago
parent
commit
d2bb5e18f5

+ 67 - 66
app.json

@@ -1,68 +1,69 @@
 {
-  "pages": [
-    "pages/index/index",
-    "pages/postage/postage",
-    "pages/ence_push/ence_push",
-    "pages/postageManage/postageManage",
-    "pages/address/address",
-    "pages/discover/discover",
-    "pages/shopCart/shopCart",
-    "pages/person/person",
-    "pages/details/details",
-    "pages/webView/webView",
-    "pages/special/special",
-    "pages/brand/brand",
-    "pages/comments/comments",
-    "pages/search/search",
-    "pages/confirmOrder/confirmOrder",
-    "pages/confirmVOrder/confirmVOrder",
-    "pages/vorderList/orderTabs",
-    "pages/addAddress/addAddress",
-    "pages/orderPaySn/orderPaySn",
-    "pages/fcode/fcode",
-    "pages/login/login",
-    "pages/shareBonus/shareBonus",
-    "pages/handOutBonus/handOutBonus",
-    "pages/auth/auth",
-    "pages/phoneCharges/phoneCharges",
-    "pages/invitees/invitees",
-    "pages/postageDetail/postageDetail",	
-    "pages/myhome/myhome"
-  ],
-  "window": {
-    "backgroundTextStyle": "dark",
-    "navigationBarBackgroundColor": "#fff",
-    "navigationBarTitleText": "椰子充值",
-    "navigationBarTextStyle": "black",
-    "onReachBottomDistance": 200
-  },
-  "tabBar": {
-    "selectedColor": "#2B2B2B",
-    "backgroundColor": "#ffffff",
-    "borderStyle": "black",
-    "list": [
-      {
-        "iconPath": "./image/tabbar/index.png",
-        "selectedIconPath": "./image/tabbar/indexed.png",
-        "pagePath": "pages/index/index",
-        "text": "首页"
-      },
-      {
-        "iconPath": "./image/tabbar/oil.png",
-        "selectedIconPath": "./image/tabbar/oiled.png",
-        "pagePath": "pages/postage/postage",
-        "text": "加油"
-      },
-      {
-        "iconPath": "./image/tabbar/me.png",
-        "selectedIconPath": "./image/tabbar/med.png",
-        "pagePath": "pages/myhome/myhome",
-        "text": "我的"
-      }
-    ]
-  },
-  "networkTimeout": {
-    "request": 20000
-  },
-  "sitemapLocation": "sitemap.json"
+ "pages": [
+  "pages/index/index",    
+  "pages/home/home",
+  "pages/postage/postage",
+  "pages/ence_push/ence_push",
+  "pages/postageManage/postageManage",
+  "pages/address/address",
+  "pages/discover/discover",
+  "pages/shopCart/shopCart",
+  "pages/person/person",
+  "pages/details/details",
+  "pages/webView/webView",
+  "pages/special/special",
+  "pages/brand/brand",
+  "pages/comments/comments",
+  "pages/search/search",
+  "pages/confirmOrder/confirmOrder",
+  "pages/confirmVOrder/confirmVOrder",
+  "pages/vorderList/orderTabs",
+  "pages/addAddress/addAddress",
+  "pages/orderPaySn/orderPaySn",
+  "pages/fcode/fcode",
+  "pages/login/login",
+  "pages/shareBonus/shareBonus",
+  "pages/handOutBonus/handOutBonus",
+  "pages/auth/auth",
+  "pages/phoneCharges/phoneCharges",
+  "pages/invitees/invitees",
+  "pages/postageDetail/postageDetail",
+  "pages/myhome/myhome"
+ ],
+ "window": {
+  "backgroundTextStyle": "dark",
+  "navigationBarBackgroundColor": "#fff",
+  "navigationBarTitleText": "椰子直充",
+  "navigationBarTextStyle": "black",
+  "onReachBottomDistance": 200
+ },
+ "tabBar": {
+  "selectedColor": "#2B2B2B",
+  "backgroundColor": "#ffffff",
+  "borderStyle": "black",
+  "list": [
+   {
+    "iconPath": "./image/tabbar/index.png",
+    "selectedIconPath": "./image/tabbar/indexed.png",
+    "pagePath": "pages/home/home",
+    "text": "首页"
+   },
+   {
+    "iconPath": "./image/tabbar/oil.png",
+    "selectedIconPath": "./image/tabbar/oiled.png",
+    "pagePath": "pages/postage/postage",
+    "text": "加油"
+   },
+   {
+    "iconPath": "./image/tabbar/me.png",
+    "selectedIconPath": "./image/tabbar/med.png",
+    "pagePath": "pages/myhome/myhome",
+    "text": "我的"
+   }
+  ]
+ },
+ "networkTimeout": {
+  "request": 20000
+ },
+ "sitemapLocation": "sitemap.json"
 }

+ 1 - 1
pages/components/auth/auth.wxml

@@ -16,4 +16,4 @@
           style='margin-top:160rpx;width:580rpx;height: 80rpx;  background-color: #fe7124; background: linear-gradient(to right, #ff7a21 0%,#feb25a 100%);color: #fff;'
           open-type="getPhoneNumber" 
     		  bindgetphonenumber="userPhoneHandler">授权手机号码</button>
-</view>
+</view> 

+ 192 - 0
pages/home/home.js

@@ -0,0 +1,192 @@
+
+import recordSource from '../../utils/recordSource';
+import bonusUp from '../../utils/bonusUp';
+const getReq = require('../../config.js').getReq;
+const getTypeSn = require('../../utils/util.js').getTypeSn;
+
+let app = getApp();
+Page({
+  data: {
+    tabs: [],
+    prop_special: [],
+    surplus_special: [],
+    special_datas: {},
+    summery: [],
+    isScroll: false,
+    isSendProp: false,
+    firstLoad: true,
+    fromSource: '',
+    tipsFlag: false,
+    tipsDatas: null,
+    daliy_bonus: ''
+  },
+
+  onShow: function () 
+  {
+    this.closeTips()
+    if (!this.data.firstLoad) {
+      app.setFromSource(this.data.fromSource)
+    }
+
+    // if (app.globalData.userInfo) {
+    //   setTimeout(() => {
+    //     bonusUp((tipsFlag, tipsDatas) => {
+    //       this.setData({
+    //         tipsFlag,
+    //         tipsDatas
+    //       })
+    //     })
+    //   }, 0);
+    // }
+  },
+
+  onLoad: function (options) {
+    console.log('onLoad options:',options)
+    if (options && options.relay_id) {
+      app.globalData.relay_id = options.relay_id
+      console.log('options.relay_id:', options.relay_id)
+    }
+    if (options && options.channel) {
+      app.globalData.channel_num = options.channel
+      console.log('options.channel:', options.channel)
+    }
+    this.getDatas(1039)
+  },
+  freeBonus() {
+    if (this.data.daliy_bonus) {
+      let type_sn = getTypeSn(this.data.daliy_bonus)
+      if (type_sn) {
+        app.navigateto(`/pages/shareBonus/shareBonus?type_sn=${type_sn}`)
+        return
+      }
+    }
+  },
+  getDatas(special_id) {
+    let fromSource = recordSource(app, 'act=index&op=index&special_id=0&page=10&curpage=1&client_type=mini')
+    wx.showLoading({
+      title: '加载中'
+    });
+    let self = this;
+    console.log('fromSource =' + fromSource)
+    getReq(app,{
+      act: 'index',
+      op: 'mini_index',
+      page: 10,
+      curpage: 1,
+      from: fromSource
+    }, 
+    // getReq(app,{
+    //   act: 'special',
+    //   op: 'index',
+    //   special_id:special_id
+    // }, 
+    function (res) {
+      wx.stopPullDownRefresh()
+      if (res.code == 200) {
+        console.log(res)
+        let prop_special = res.datas.special_list;
+        let sent_down_special = prop_special.splice(0, 8);
+        self.setData({
+          surplus_special: prop_special,
+          prop_special: sent_down_special,
+          special_datas: res.datas,
+          summery: res.datas.summary,
+          firstLoad: false,
+          fromSource: app.globalData.fromSource
+        });
+      }
+      setTimeout(function () {
+        wx.hideLoading()
+      }, 1000)
+    })
+  },
+  req_tabs() {
+    let self = this
+    getReq(app,{
+      act: 'index',
+      op: 'tabs'
+    }, function (res) {
+      if (res.code == 200) {
+        self.getDatas(res.datas.tabs[0].special_id);
+        self.setData({
+          tabs: res.datas.tabs,
+          daliy_bonus: res.datas.daliy_bonus
+        });
+      }
+    })
+  },
+  onMyEvent: function (e) {
+    this.setData({
+      prop_special: [],
+      surplus_special: [],
+      special_datas: {},
+      summery: []
+    });
+    this.getDatas(e.detail.item.special_id)
+  },
+  closeTips() {
+    this.setData({
+      tipsFlag: false,
+      tipsDatas: null
+    })
+  },
+  onPageScroll(e) {
+    clearTimeout(this.showTop);
+    this.showTop = setTimeout(() => {
+      let scrollTop = e.scrollTop;
+      if (scrollTop >= 300) {
+        this.setData({
+          isScroll: true
+        })
+      }
+      else {
+        this.setData({
+          isScroll: false
+        })
+      }
+    }, 100);
+  },
+  backTop() {
+    wx.pageScrollTo({
+      scrollTop: 0,
+      duration: 300
+    })
+  },
+  onShareAppMessage: function () {
+    return app.cardShareInfo();
+  },
+  onReachBottom: function () {
+    if (this.data.isSendProp) {
+      return;
+    }
+    
+    let surplus_special_num = this.data.surplus_special.length;
+    if (surplus_special_num > 0) {
+      wx.showLoading({
+        title: '加载中'
+      });
+      this.setData({
+        isSendProp: true
+      });
+      this.data.isSendProp = true;
+      let prop_special = this.data.surplus_special;
+      let sent_down_special = prop_special.splice(0, 8);
+      this.setData({
+        surplus_special: prop_special,
+        prop_special: this.data.prop_special.concat(sent_down_special)
+      })
+      this.setData({
+        isSendProp: false
+      });
+      setTimeout(function () {
+        wx.hideLoading()
+      }, 1500)
+    }
+    else {
+      return;
+    }
+  },
+  onPullDownRefresh(){
+    this.getDatas()
+  }
+})

+ 9 - 0
pages/home/home.json

@@ -0,0 +1,9 @@
+{
+  "enablePullDownRefresh":true,
+  "usingComponents": {
+    "tabs" : "../components/blocks/tabs/tabs",
+    "blockList" : "../components/blockList/blockList",
+    "searchBox": "../components/blocks/search/search" ,
+    "bonusTips": "../components/bonusTips/bonusTips"   
+  }
+}

+ 25 - 0
pages/home/home.wxml

@@ -0,0 +1,25 @@
+<!--index.wxml-->
+<view style="max-width: 750rpx;margin: auto;overflow-x: hidden;">
+  <bonusTips wx:if="{{tipsFlag}}" tipsDatas="{{tipsDatas}}" bind:closeTips="closeTips"></bonusTips>
+  <!-- <view style="height: 140rpx;overflow: hidden;background:#2b2b2b;">
+      <searchBox></searchBox>
+      <block wx:if="{{tabs.length}}">
+        <tabs tabs="{{tabs}}" bind:myevent="onMyEvent" num="123"></tabs>
+      </block>
+  </view> -->
+  <!-- <view class='clear_fixed'></view>  -->
+
+  <blockList prop_special="{{prop_special}}" 
+             summery="{{summery}}" special_datas="{{special_datas}}"> </blockList>
+  <image  class="free_bonus" 
+          wx:if="{{daliy_bonus}}" 
+          catchtap="freeBonus" 
+          src="../../image/shidian.png">
+  </image>
+  <image bindtap='backTop' 
+         style="display:{{isScroll?'block':'none'}}" 
+         mode='widthFix' 
+         class='back_top_btn' 
+         src='../../image/back_top.png'>
+  </image>
+</view>

+ 32 - 0
pages/home/home.wxss

@@ -0,0 +1,32 @@
+/**index.wxss**/
+.userinfo {
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+}
+
+.userinfo-avatar {
+  width: 128rpx;
+  height: 128rpx;
+  margin: 20rpx;
+  border-radius: 50%;
+}
+
+.userinfo-nickname {
+  color: #aaa;
+}
+
+.usermotto {
+  margin-top: 200px;
+}
+.clear_fixed {
+  height: 140rpx;
+}
+.free_bonus {
+  position: fixed;
+  z-index: 99;
+  right: 4rpx;
+  bottom: 228rpx;
+  width: 86rpx;
+  height: 108rpx;
+}

+ 160 - 181
pages/index/index.js

@@ -1,192 +1,171 @@
-
+// pages/index/index.js
 import recordSource from '../../utils/recordSource';
-import bonusUp from '../../utils/bonusUp';
 const getReq = require('../../config.js').getReq;
-const getTypeSn = require('../../utils/util.js').getTypeSn;
-
 let app = getApp();
+
 Page({
-  data: {
-    tabs: [],
-    prop_special: [],
-    surplus_special: [],
-    special_datas: {},
-    summery: [],
-    isScroll: false,
-    isSendProp: false,
-    firstLoad: true,
-    fromSource: '',
-    tipsFlag: false,
-    tipsDatas: null,
-    daliy_bonus: ''
-  },
 
-  onShow: function () 
-  {
-    this.closeTips()
-    if (!this.data.firstLoad) {
-      app.setFromSource(this.data.fromSource)
-    }
+    /**
+     * 页面的初始数据
+     */
+    data: {
+        tabs: [],
+        prop_special: [],
+        surplus_special: [],
+        special_datas: {},
+        summery: [],
+        isScroll: false,
+        isSendProp: false,
+        firstLoad: true,
+        fromSource: '',
+        tipsFlag: false,
+        tipsDatas: null,
+        daliy_bonus: ''
+    },
 
-    // if (app.globalData.userInfo) {
-    //   setTimeout(() => {
-    //     bonusUp((tipsFlag, tipsDatas) => {
-    //       this.setData({
-    //         tipsFlag,
-    //         tipsDatas
-    //       })
-    //     })
-    //   }, 0);
-    // }
-  },
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    onLoad: function (options) {
+        console.log('onLoad options:', options)
+        if (options && options.relay_id) {
+            app.globalData.relay_id = options.relay_id
+            console.log('options.relay_id:', options.relay_id)
+        }
+        if (options && options.channel) {
+            app.globalData.channel_num = options.channel
+            console.log('options.channel:', options.channel)
+        }
+        this.getDatas(1040)
+    },
 
-  onLoad: function (options) {
-    console.log('onLoad options:',options)
-    if (options && options.relay_id) {
-      app.globalData.relay_id = options.relay_id
-      console.log('options.relay_id:', options.relay_id)
-    }
-    if (options && options.channel) {
-      app.globalData.channel_num = options.channel
-      console.log('options.channel:', options.channel)
-    }
-    this.getDatas(1039)
-  },
-  freeBonus() {
-    if (this.data.daliy_bonus) {
-      let type_sn = getTypeSn(this.data.daliy_bonus)
-      if (type_sn) {
-        app.navigateto(`/pages/shareBonus/shareBonus?type_sn=${type_sn}`)
-        return
-      }
-    }
-  },
-  getDatas(special_id) {
-    let fromSource = recordSource(app, 'act=index&op=index&special_id=0&page=10&curpage=1&client_type=mini')
-    // wx.showLoading({
-    //   title: '加载中'
-    // });
-    let self = this;
-    console.log('fromSource =' + fromSource)
-    // getReq(app,{
-    //   act: 'index',
-    //   op: 'mini_index',
-    //   page: 10,
-    //   curpage: 1,
-    //   from: fromSource
-    // }, 
-    getReq(app,{
-      act: 'special',
-      op: 'index',
-      special_id:special_id
-    }, 
-    function (res) {
-      wx.stopPullDownRefresh()
-      if (res.code == 200) {
-        console.log(res)
-        let prop_special = res.datas.special_list;
-        let sent_down_special = prop_special.splice(0, 8);
-        self.setData({
-          surplus_special: prop_special,
-          prop_special: sent_down_special,
-          special_datas: res.datas,
-          summery: res.datas.summary,
-          firstLoad: false,
-          fromSource: app.globalData.fromSource
-        });
-      }
-      setTimeout(function () {
-        wx.hideLoading()
-      }, 1000)
-    })
-  },
-  req_tabs() {
-    let self = this
-    getReq(app,{
-      act: 'index',
-      op: 'tabs'
-    }, function (res) {
-      if (res.code == 200) {
-        self.getDatas(res.datas.tabs[0].special_id);
-        self.setData({
-          tabs: res.datas.tabs,
-          daliy_bonus: res.datas.daliy_bonus
+    /**
+     * 生命周期函数--监听页面初次渲染完成
+     */
+    onReady: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面显示
+     */
+    onShow: function () {
+        if (!this.data.firstLoad) {
+            app.setFromSource(this.data.fromSource)
+        }
+    },
+
+    /**
+     * 生命周期函数--监听页面隐藏
+     */
+    onHide: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面卸载
+     */
+    onUnload: function () {
+
+    },
+    getDatas(special_id) {
+        let fromSource = recordSource(app, 'act=special&op=index&special_id=0&page=10&curpage=1&client_type=mini')
+        wx.showLoading({
+            title: '加载中'
         });
-      }
-    })
-  },
-  onMyEvent: function (e) {
-    this.setData({
-      prop_special: [],
-      surplus_special: [],
-      special_datas: {},
-      summery: []
-    });
-    this.getDatas(e.detail.item.special_id)
-  },
-  closeTips() {
-    this.setData({
-      tipsFlag: false,
-      tipsDatas: null
-    })
-  },
-  onPageScroll(e) {
-    clearTimeout(this.showTop);
-    this.showTop = setTimeout(() => {
-      let scrollTop = e.scrollTop;
-      if (scrollTop >= 300) {
-        this.setData({
-          isScroll: true
+        let self = this;
+        console.log('fromSource =' + fromSource)
+        getReq(app, {
+            act: 'special',
+            op: 'index',
+            special_id: special_id
+        }, function (res) {
+            wx.stopPullDownRefresh()
+            if (res.code == 200) {
+                console.log(res)
+                let prop_special = res.datas.special_list;
+                let sent_down_special = prop_special.splice(0, 8);
+                self.setData({
+                    surplus_special: prop_special,
+                    prop_special: sent_down_special,
+                    special_datas: res.datas,
+                    summery: res.datas.summary,
+                    firstLoad: false,
+                    fromSource: app.globalData.fromSource
+                });
+            }
+            setTimeout(function () {
+                wx.hideLoading()
+            }, 1000)
         })
-      }
-      else {
-        this.setData({
-          isScroll: false
+    },
+    /**
+     * 页面相关事件处理函数--监听用户下拉动作
+     */
+    onPullDownRefresh: function () {
+        this.getDatas()
+    },
+    onPageScroll(e) {
+        clearTimeout(this.showTop);
+        this.showTop = setTimeout(() => {
+            let scrollTop = e.scrollTop;
+            if (scrollTop >= 300) {
+                this.setData({
+                    isScroll: true
+                })
+            }
+            else {
+                this.setData({
+                    isScroll: false
+                })
+            }
+        }, 100);
+    },
+    backTop() {
+        wx.pageScrollTo({
+            scrollTop: 0,
+            duration: 300
         })
-      }
-    }, 100);
-  },
-  backTop() {
-    wx.pageScrollTo({
-      scrollTop: 0,
-      duration: 300
-    })
-  },
-  onShareAppMessage: function () {
-    return app.cardShareInfo();
-  },
-  onReachBottom: function () {
-    if (this.data.isSendProp) {
-      return;
-    }
-    
-    let surplus_special_num = this.data.surplus_special.length;
-    if (surplus_special_num > 0) {
-      wx.showLoading({
-        title: '加载中'
-      });
-      this.setData({
-        isSendProp: true
-      });
-      this.data.isSendProp = true;
-      let prop_special = this.data.surplus_special;
-      let sent_down_special = prop_special.splice(0, 8);
-      this.setData({
-        surplus_special: prop_special,
-        prop_special: this.data.prop_special.concat(sent_down_special)
-      })
-      this.setData({
-        isSendProp: false
-      });
-      setTimeout(function () {
-        wx.hideLoading()
-      }, 1500)
-    }
-    else {
-      return;
+    },
+    /**
+     * 页面上拉触底事件的处理函数
+     */
+    onReachBottom: function () {
+        if (this.data.isSendProp) {
+            return;
+        }
+
+        let surplus_special_num = this.data.surplus_special.length;
+        if (surplus_special_num > 0) {
+            wx.showLoading({
+                title: '加载中'
+            });
+            this.setData({
+                isSendProp: true
+            });
+            this.data.isSendProp = true;
+            let prop_special = this.data.surplus_special;
+            let sent_down_special = prop_special.splice(0, 8);
+            this.setData({
+                surplus_special: prop_special,
+                prop_special: this.data.prop_special.concat(sent_down_special)
+            })
+            this.setData({
+                isSendProp: false
+            });
+            setTimeout(function () {
+                wx.hideLoading()
+            }, 1500)
+        }
+        else {
+            return;
+        }
+    },
+
+    /**
+     * 用户点击右上角分享
+     */
+    onShareAppMessage: function () {
+        return app.cardShareInfo();
     }
-  },
-  onPullDownRefresh(){
-    this.getDatas()
-  }
-})
+})

+ 4 - 5
pages/index/index.json

@@ -1,9 +1,8 @@
 {
-  "enablePullDownRefresh":true,
   "usingComponents": {
-    "tabs" : "../components/blocks/tabs/tabs",
-    "blockList" : "../components/blockList/blockList",
-    "searchBox": "../components/blocks/search/search" ,
-    "bonusTips": "../components/bonusTips/bonusTips"   
+        "tabs": "../components/blocks/tabs/tabs",
+        "blockList": "../components/blockList/blockList",
+        "searchBox": "../components/blocks/search/search",
+        "bonusTips": "../components/bonusTips/bonusTips"
   }
 }

+ 6 - 24
pages/index/index.wxml

@@ -1,25 +1,7 @@
-<!--index.wxml-->
+<!-- pages/index/index.wxml -->
 <view style="max-width: 750rpx;margin: auto;overflow-x: hidden;">
-  <bonusTips wx:if="{{tipsFlag}}" tipsDatas="{{tipsDatas}}" bind:closeTips="closeTips"></bonusTips>
-  <!-- <view style="height: 140rpx;overflow: hidden;background:#2b2b2b;">
-      <searchBox></searchBox>
-      <block wx:if="{{tabs.length}}">
-        <tabs tabs="{{tabs}}" bind:myevent="onMyEvent" num="123"></tabs>
-      </block>
-  </view> -->
-  <!-- <view class='clear_fixed'></view>  -->
-
-  <blockList prop_special="{{prop_special}}" 
-             summery="{{summery}}" special_datas="{{special_datas}}"> </blockList>
-  <image  class="free_bonus" 
-          wx:if="{{daliy_bonus}}" 
-          catchtap="freeBonus" 
-          src="../../image/shidian.png">
-  </image>
-  <image bindtap='backTop' 
-         style="display:{{isScroll?'block':'none'}}" 
-         mode='widthFix' 
-         class='back_top_btn' 
-         src='../../image/back_top.png'>
-  </image>
-</view>
+    <blockList prop_special="{{prop_special}}" summery="{{summery}}" special_datas="{{special_datas}}"></blockList>
+    <image  bindtap='backTop' 
+            style="display:{{isScroll?'block':'none'}}" 
+            mode='widthFix' class='back_top_btn' src='../../image/back_top.png'></image>
+</view>

+ 2 - 0
pages/index/index.wxss

@@ -1,3 +1,5 @@
+/* pages/index/index.wxss */
+
 /**index.wxss**/
 .userinfo {
   display: flex;