eli 2 tahun lalu
melakukan
e09730189b

TEMPAT SAMPAH
.DS_Store


+ 31 - 0
.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
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
+  }
+})

+ 39 - 0
app.json

@@ -0,0 +1,39 @@
+{
+  "pages":[
+    "pages/index/index",
+    "pages/submitPhone/index",
+   
+    "pages/list/index",
+    "pages/record/index",
+    "pages/recharge/index",
+    "pages/bill/index"
+    
+  ],
+  "tabBar": {
+    "color": "#2c2c2c",
+    "selectedColor": "#1296db",
+    "borderStyle": "black",
+    "list": [
+      {
+        "selectedIconPath": "./utils/images/home.png",
+        "iconPath": "./utils/images/home-1.png",
+        "pagePath": "pages/index/index",
+        "text": "首页"
+      },
+      {
+        "selectedIconPath": "./utils/images/list.png",
+        "iconPath": "./utils/images/list-1.png",
+        "pagePath": "pages/list/index",
+        "text": "列表"
+      }
+    ]
+  },
+  "window":{
+    "backgroundTextStyle":"light",
+    "navigationBarBackgroundColor": "#fff",
+    "navigationBarTitleText": "电费",
+    "navigationBarTextStyle":"black"
+  },
+  "style": "v2",
+  "sitemapLocation": "sitemap.json"
+}

+ 10 - 0
app.wxss

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

TEMPAT SAMPAH
pages/.DS_Store


+ 53 - 0
pages/bill/index.js

@@ -0,0 +1,53 @@
+const app = getApp()
+const httpUtils = require('../../utils/http.js')
+const ui = require('../../utils/ui.js')
+Page({
+  data: {
+   list: [],
+   deviceid: '',
+    roomName: '',
+    deviceCode: ''
+  },
+  deviceid: '',
+  roomName: '',
+  deviceCode: '',
+  onLoad(options) {
+    this.deviceid = options.deviceid
+    this.roomName = options.roomName
+    this.deviceCode = options.deviceCode
+    this.setData({
+      deviceid: options.deviceid,
+      roomName: options.roomName,
+      deviceCode: options.deviceCode
+    })
+    this.getList(options.deviceid)
+  },
+  historyUrl(){
+    console.log(this)
+    wx.navigateTo({
+      url: '/pages/record/index?deviceid=' + this.deviceid + '&roomName=' + this.roomName + '&deviceCode=' + this.deviceCode
+    })
+  },
+  toRecharge(){
+    wx.navigateTo({
+      url: '/pages/recharge/index?deviceid=' + this.deviceid
+    })
+  },
+  getList(id){
+    let obj = {
+      url: '/api/erp/we/monthBill',
+      data: {
+        deviceId: id,
+        token: wx.getStorageSync('token'),
+      }
+    }
+    httpUtils.request(obj).then(res=>{
+      console.log(res)
+      this.setData({
+        list: res.data.data
+      })
+    }).catch(err=>{
+      console.log('ERROR')
+    });
+  }
+})

+ 4 - 0
pages/bill/index.json

@@ -0,0 +1,4 @@
+{
+  "usingComponents": {},
+  "navigationBarTitleText": "月账单"
+}

+ 28 - 0
pages/bill/index.wxml

@@ -0,0 +1,28 @@
+<view class="container_bill">
+  <view class="bill_top">
+    <p class="top_style">房号:{{roomName}}</p>
+    <p class="top_style">表号:{{deviceCode}}</p>
+  </view>
+  <view class="bill_btn">
+    <button class="btn_style1" bindtap="historyUrl">历史充值</button>
+    <button class="btn_style2" bindtap="toRecharge">充值</button>
+  </view>
+  <view class="list" wx:for="{{list}}" wx:key="index">
+    <view class="list-inner">
+      <p class="days">{{index + 1}}.月份:<span class="normal">{{item.month}}</span></p>
+      <p class="days">期末余额:<span class="blod red">{{item.balance}}</span></p>
+    </view>
+    <view class="list-inner">
+      <p class="days">期初读数: <span class="normal">{{item.prevValue}}</span></p>
+      <p class="days">期末读数: <span class="normal">{{item.currentValue}}</span></p>
+    </view>
+    <view class="list-inner">
+      <p class="days">倍率:<span class="normal">{{item.rate}}</span></p>
+      <p class="days">电量: <span class="normal">{{item.currentUse}}</span></p>
+    </view>
+    <view class="list-inner">
+      <p class="days">电价: <span class="normal">{{item.price}}</span></p>
+      <p class="days">电费: <span class="normal">{{item.amount}}</span></p>
+    </view>
+  </view>
+</view>

+ 69 - 0
pages/bill/index.wxss

@@ -0,0 +1,69 @@
+.container_bill{
+  background: #efefef;
+  padding: 5px 0;
+}
+.bill_top{
+  width: 96%;
+  margin: 0 auto;
+  font-size: 14px;
+  color: #222;
+  display: flex;
+}
+.bill_top .top_style{
+  width: 50%;
+  text-align: center;
+}
+.bill_btn{
+  display: flex;
+  margin: 10px 0;
+}
+.bill_btn .btn_style2{
+  width: 45%;
+  margin: 0 auto;
+  font-size: 14px;
+  background: #1296db;
+  color: #fff;
+}
+.bill_btn .btn_style1{
+  width: 45%;
+  margin: 0 auto;
+  font-size: 14px;
+  background: #7dc5eb;
+  color: #fff;
+}
+.container_bill .list{
+  width: 96%;
+  margin: 0 auto;
+  border-radius: 3px;
+  padding: 10px;
+  box-sizing: border-box;
+  background: #ffffff;
+  border-bottom:1px solid #e6e6e6;
+  margin-bottom: 10px;
+}
+.container_bill .list .list-inner{
+  display: flex;
+  margin-bottom: 10px;
+}
+.container_bill .list .list-inner .days{
+  width: 60%;
+  display: block;
+  color: #999;
+  font-size: 14px;
+}
+.container_bill .list .list-inner .days{
+  color: #999;
+}
+.container_bill .list .arrow{
+  width: 20px;
+  height: 15px;
+}
+.red{
+  color: red;
+}
+.blod{
+  font-weight: bold;
+}
+.normal{
+  color: #222;
+}

+ 114 - 0
pages/index/index.js

@@ -0,0 +1,114 @@
+const app = getApp()
+const httpUtils = require('../../utils/http.js')
+const ui = require('../../utils/ui.js')
+Page({
+  data: {},
+  onLoad() {},
+  getPhoneNumber(e) {
+    let that = this
+    console.log("11111111111111111")
+    console.log(e)
+    let iv = e.detail.iv 
+    let encryptedData = e.detail.encryptedData
+    if(e.detail.errMsg == 'getPhoneNumber:fail user deny'){
+      wx.showToast({
+        title: '请您授权手机号,以便提供更好服务',
+        icon:'none',
+        duration:5000
+      })
+    }else {
+      // wx.login({
+      //   success (res) {
+      //     if (res.code) {
+      //       console.log("2222222222222222")
+      //       console.log(res)
+      //       let code = res.code
+      //       // 调userinfo接口
+      //       let obj = {
+      //         url: '/api/erp/we/userInfo',
+      //         data: {
+      //           code: code
+      //         }
+      //       }
+            // httpUtils.request(obj).then(res1=>{
+            //   console.log("33333333333333")
+            //   console.log(res1)
+              //phoneinfo接口请求
+              let obj2 = {
+                url: '/api/erp/we/phoneInfo',
+                data: {
+                  encryptedData: encryptedData,
+                  iv: iv,
+                  code: wx.getStorageSync('code')
+                }
+              }
+              httpUtils.request(obj2).then(res2=>{
+                console.log("444444444444444444")
+                console.log(res2)
+                wx.setStorageSync('token', res2.data.data.token)
+                wx.setStorageSync('phone', res2.data.data.phone)
+                // 弹框提示
+                ui.showToast("登陆成功!")
+                wx.switchTab({
+                  url: '/pages/list/index',
+                })
+              }).catch(err=>{
+                console.log('ERROR')
+              });
+      //       }).catch(err=>{
+      //         console.log('ERROR')
+      //       });
+      //     }
+      //   }
+      // })
+    }
+  },
+  toLogin(){
+    wx.login({
+      success (res) {
+        if (res.code) {
+          console.log("code",res)
+          let code = res.code
+          wx.setStorageSync('code', res.code)
+          // 调userinfo接口
+          let obj = {
+            url: '/api/erp/we/userInfo',   
+            data: {
+              code: code
+            }
+          }
+          httpUtils.request(obj).then(res1=>{
+            console.log("userInfo",res1)
+            wx.setStorageSync('openId', res1.data.data)
+            wx.navigateTo({
+              url: '/pages/submitPhone/index',
+            })
+            // wx.setStorageSync('token', res2.data.data.token)
+            // phoneinfo接口请求
+            // let obj = {
+            //   url: '/api/erp/we/phoneInfo',
+            //   data: {
+            //     encryptedData: 'B',
+            //     iv: '1',
+            //     code: code
+            //   }
+            // }
+            // httpUtils.request(obj).then(res2=>{
+            //   wx.setStorageSync('token', res2.data.data.token)
+            //   // wx.setStorageSync('phone', res2.data.data.phone)
+            //   // 弹框提示
+            //   ui.showToast("登陆成功!")
+            //   wx.navigateTo({
+            //     url: '/pages/submitPhone/index',
+            //   })
+            // }).catch(err=>{
+            //   console.log('ERROR')
+            // });
+          }).catch(err=>{
+            console.log('ERROR')
+          });
+        }
+      }
+    })
+  }
+})

+ 4 - 0
pages/index/index.json

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

+ 9 - 0
pages/index/index.wxml

@@ -0,0 +1,9 @@
+<view class="container">
+  <view class="title">电费充值系统</view>
+  <view class="btn_box" bindtap="toLogin">微信授权登陆</view>
+  <!-- <input type="text" placeholder="请输入手机号码"/>
+  <button>提交</button> -->
+  <!-- <button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">授权手机号码</button> -->
+
+  
+</view>

+ 20 - 0
pages/index/index.wxss

@@ -0,0 +1,20 @@
+.title{
+  text-align: center;
+  margin-top: 30px;
+  font-size: 18px;
+  font-weight: bold;
+  color: #222;
+}
+.btn_box{
+  width: 90%;
+  margin: 0 auto;
+  background: #1296db;
+  color: #ffffff;
+  font-size: 14px;
+  text-align: center;
+  height: 35px;
+  border-radius: 3px;
+  line-height: 35px;
+  position: absolute;
+  bottom: 100px;
+}

+ 38 - 0
pages/list/index.js

@@ -0,0 +1,38 @@
+const app = getApp()
+const httpUtils = require('../../utils/http.js')
+const ui = require('../../utils/ui.js')
+Page({
+  data: {
+   list: []
+  },
+  onLoad() {
+    this.getList()
+  },
+  toUrl(e){
+    console.log(e)
+    let deviceid = e.currentTarget.dataset.deviceid
+    let roomName = e.currentTarget.dataset.roomname
+    let deviceCode = e.currentTarget.dataset.devicecode
+    wx.navigateTo({
+      url: '/pages/bill/index?deviceid=' + deviceid + '&roomName=' + roomName + '&deviceCode=' + deviceCode
+    })
+  },
+  getList(){
+    let obj = {
+      url: '/api/erp/we/roomList',
+      data: {
+        phone: wx.getStorageSync('phone'),
+        token: wx.getStorageSync('token'),
+      }
+    }
+    httpUtils.request(obj).then(res=>{
+      console.log(res)
+      this.setData({
+        list: res.data.data
+      })
+    }).catch(err=>{
+      console.log('ERROR')
+    });
+  }
+  
+})

+ 4 - 0
pages/list/index.json

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

+ 15 - 0
pages/list/index.wxml

@@ -0,0 +1,15 @@
+<view class="container_list">
+  <view class="list" bindtap="toUrl" wx:for="{{list}}" wx:key="index" data-deviceId="{{item.deviceId}}" data-roomName="{{item.roomName}}" data-deviceCode="{{item.deviceCode}}">
+    <view class="list-left">
+      <view class="list-inner">
+        <p class="house">{{index + 1}}.{{item.roomName}}</p>
+        <p class="days">余额:<span class="blod red">{{item.balance}}</span></p>
+      </view>
+      <view class="list-inner">
+        <p class="elId">电表:{{item.deviceCode}}</p>
+        <p class="days">预计可用 <span class="normal">{{item.canUse}}</span> 天</p>
+      </view>
+    </view>
+    <image class="arrow" src="../../utils/images/jiantou.png"></image>
+  </view>
+</view>

+ 50 - 0
pages/list/index.wxss

@@ -0,0 +1,50 @@
+.container_list{
+  background: #efefef;
+  padding: 10px 0;
+}
+.container_list .list{
+  width: 96%;
+  margin: 0 auto;
+  border-radius: 3px;
+  padding: 10px;
+  box-sizing: border-box;
+  background: #ffffff;
+  border-bottom:1px solid #e6e6e6;
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+  margin-bottom: 10px;
+}
+.container_list .list .list-left{
+  width: 95%;
+}
+.container_list .list .list-left .list-inner{
+  display: flex;
+  margin-bottom: 10px;
+}
+.container_list .list .list-left .list-inner p:first-child{
+  width: 60%;
+  display: block;
+  color: #222;
+  font-size: 14px;
+}
+.container_list .list .list-left .list-inner .house{
+  font-weight: bold;
+}
+.container_list .list .list-left .list-inner .days{
+  font-size: 14px;
+  color: #999;
+}
+.container_list .list .arrow{
+  width: 20px;
+  height: 15px;
+}
+.red{
+  color: red;
+}
+.blod{
+  font-weight: bold;
+}
+.normal{
+  color: #222;
+}

+ 63 - 0
pages/recharge/index.js

@@ -0,0 +1,63 @@
+const app = getApp()
+const httpUtils = require('../../utils/http.js')
+const ui = require('../../utils/ui.js')
+Page({
+  data: {
+    tab: 1,
+    money: 100
+  },
+  deviceid: '',
+  onLoad(options) {
+    this.deviceid = options.deviceid
+  },
+  changeTab(e){
+    console.log(e)
+    this.setData({
+      tab: e.target.dataset.info
+    })
+    if(e.target.dataset.info == 1){
+      this.setData({
+        money: 100
+      })
+    }else if(e.target.dataset.info == 2){
+      this.setData({
+        money: 200
+      })
+    }else if(e.target.dataset.info == 3){
+      this.setData({
+        money: 500
+      })
+    }
+  },
+  toRecharge(){
+    let obj = {
+      url: '/api/erp/we/wePhoneCharge',
+      data: {
+        deviceId: this.deviceid,
+        deposit: 100,
+        token: wx.getStorageSync('token'),
+      }
+    }
+    httpUtils.request(obj).then(res=>{
+      console.log("pay",res)
+      let payInfo = res.data.data
+
+      // 调取后端接口后微信下单
+      wx.requestPayment({
+        timeStamp: payInfo.timeStamp,
+        nonceStr: payInfo.nonceStr,
+        package: payInfo.package,
+        signType: payInfo.signType,
+        paySign: payInfo.paySign,
+        success (res1) {
+          console.log("支付",res1)
+        },
+        fail (res1) { 
+
+        }
+      })
+    }).catch(err=>{
+      console.log('ERROR')
+    });
+  }
+})

+ 4 - 0
pages/recharge/index.json

@@ -0,0 +1,4 @@
+{
+  "usingComponents": {},
+  "navigationBarTitleText": "充值"
+}

+ 19 - 0
pages/recharge/index.wxml

@@ -0,0 +1,19 @@
+<view class="container_bill">
+  <view class="bill_top">
+    <p class="top_style">房号:二区1栋3楼201</p>
+    <p class="top_style">表号:1325346576</p>
+  </view>
+  <view class="bill_top">
+    <p class="top_style">余额:100</p>
+  </view>
+  <view class="input_box">
+    <input class="input_style" type="text"/>
+  </view>
+  <view class="money_num">
+    <view class="num_inner {{ tab == 1? 'blue_style':'' }}" data-info="{{1}}" bindtap="changeTab">100</view>
+    <view class="num_inner {{ tab == 2? 'blue_style':'' }}" data-info="{{2}}" bindtap="changeTab">200</view>
+    <view class="num_inner {{ tab == 3? 'blue_style':'' }}" data-info="{{3}}" bindtap="changeTab">500</view>
+  </view>
+  <view class="btn_box" bindtap="toRecharge">充值</view>
+  
+</view>

+ 56 - 0
pages/recharge/index.wxss

@@ -0,0 +1,56 @@
+.container_bill{
+  padding: 5px 0;
+}
+.bill_top{
+  width: 90%;
+  margin: 0 auto;
+  font-size: 14px;
+  color: #222;
+  display: flex;
+  margin-bottom: 10px;
+}
+.bill_top .top_style{
+  width: 50%;
+}
+.input_style{
+  width: 90%;
+  height: 35px;
+  margin: 0 auto;
+  background: #efefef;
+  border-radius: 3px;
+  box-sizing: border-box;
+  padding: 2px 5px;
+  margin-top: 30px;
+}
+.money_num{
+  width: 90%;
+  margin: 0 auto;
+  margin-top: 25px;
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+  margin-bottom: 100px;
+}
+.num_inner{
+  width: 60px;
+  height: 35px;
+  line-height: 35px;
+  background: #ebebeb;
+  color: #ffffff;
+  text-align: center;
+  border-radius: 3px;
+}
+.blue_style{
+  background: #7dc5eb;
+}
+.btn_box{
+  width: 90%;
+  margin: 0 auto;
+  background: #1296db;
+  color: #ffffff;
+  font-size: 14px;
+  text-align: center;
+  height: 35px;
+  border-radius: 3px;
+  line-height: 35px;
+}

+ 38 - 0
pages/record/index.js

@@ -0,0 +1,38 @@
+const app = getApp()
+const httpUtils = require('../../utils/http.js')
+const ui = require('../../utils/ui.js')
+Page({
+  data: {
+   list: [],
+   deviceid: '',
+   roomName: '',
+   deviceCode: ''
+  },
+  onLoad(options) {
+    console.log(options)
+    this.setData({
+      deviceid: options.deviceid,
+      roomName: options.roomName,
+      deviceCode: options.deviceCode
+    })
+    this.getList(options.deviceid)
+  },
+  getList(id){
+    let obj = {
+      url: '/api/erp/we/chargeRecords',
+      data: {
+        deviceId: id,
+        token: wx.getStorageSync('token'),
+      }
+    }
+    httpUtils.request(obj).then(res=>{
+      console.log(res)
+      this.setData({
+        list: res.data.data
+      })
+    }).catch(err=>{
+      console.log('ERROR')
+    });
+  }
+  
+})

+ 4 - 0
pages/record/index.json

@@ -0,0 +1,4 @@
+{
+  "usingComponents": {},
+  "navigationBarTitleText": "充值记录"
+}

+ 16 - 0
pages/record/index.wxml

@@ -0,0 +1,16 @@
+<view class="container_bill">
+  <view class="bill_top">
+    <p class="top_style">房号:{{roomName}}</p>
+    <p class="top_style">表号:{{deviceCode}}</p>
+  </view>
+  <view class="list" wx:for="{{list}}" wx:key="index">
+    <view class="list-inner">
+      <p class="days">{{index + 1}}.日期:<span class="normal">{{item.createTime}}</span></p>
+    </view>
+    <view class="list-inner">
+      <p class="days">充值方式: <span class="normal">{{item.paywayName}}</span></p>
+      <p class="days">充值金额: <span class="blod red">{{item.amount}}</span></p>
+    </view>
+  </view>
+</view>
+

+ 69 - 0
pages/record/index.wxss

@@ -0,0 +1,69 @@
+.container_bill{
+  background: #efefef;
+  padding: 5px 0;
+}
+.bill_top{
+  width: 96%;
+  margin: 0 auto;
+  font-size: 14px;
+  color: #222;
+  display: flex;
+  margin-bottom: 10px;
+}
+.bill_top .top_style{
+  width: 50%;
+}
+.bill_btn{
+  display: flex;
+  margin: 10px 0;
+}
+.bill_btn .btn_style2{
+  width: 45%;
+  margin: 0 auto;
+  font-size: 14px;
+  background: #1296db;
+  color: #fff;
+}
+.bill_btn .btn_style1{
+  width: 45%;
+  margin: 0 auto;
+  font-size: 14px;
+  background: #7dc5eb;
+  color: #fff;
+}
+.container_bill .list{
+  width: 96%;
+  margin: 0 auto;
+  border-radius: 3px;
+  padding: 10px;
+  box-sizing: border-box;
+  background: #ffffff;
+  border-bottom:1px solid #e6e6e6;
+  margin-bottom: 10px;
+}
+.container_bill .list .list-inner{
+  display: flex;
+  margin-bottom: 10px;
+}
+.container_bill .list .list-inner .days{
+  width: 60%;
+  display: block;
+  color: #999;
+  font-size: 14px;
+}
+.container_bill .list .list-inner .days{
+  color: #999;
+}
+.container_bill .list .arrow{
+  width: 20px;
+  height: 15px;
+}
+.red{
+  color: red;
+}
+.blod{
+  font-weight: bold;
+}
+.normal{
+  color: #222;
+}

+ 30 - 0
pages/submitPhone/index.js

@@ -0,0 +1,30 @@
+const app = getApp()
+const httpUtils = require('../../utils/http.js')
+const ui = require('../../utils/ui.js')
+Page({
+  data: {},
+  onLoad() {},
+  
+  formSubmit(e) {
+    console.log(e)
+    let phoneNumber= e.detail.value.phoneNumber;
+    console.log("phoneNumber",phoneNumber)
+    let obj = {
+      url: '/api/erp/we/phoneInfo',   
+      data: {
+        phone: phoneNumber,
+        openId: wx.getStorageSync('openId')
+      }
+    }
+    httpUtils.request(obj).then(res=>{
+      console.log(res)
+      wx.setStorageSync('token', res.data.data.token)
+      wx.setStorageSync('phone', phoneNumber)
+      wx.switchTab({
+        url: '/pages/list/index',
+      })
+    }).catch(err=>{
+      console.log('ERROR')
+    });
+  }
+})

+ 4 - 0
pages/submitPhone/index.json

@@ -0,0 +1,4 @@
+{
+  "usingComponents": {},
+  "navigationBarTitleText": "提交手机号码"
+}

+ 9 - 0
pages/submitPhone/index.wxml

@@ -0,0 +1,9 @@
+<view class="container">
+  <!-- <view> 手机号码:</view>
+  <input type="text" name="name" placeholder="请输入手机号码"/>
+  <button bindtap="toSubmit">提交</button> -->
+  <form bindsubmit="formSubmit">
+    <input type="text" name="phoneNumber" placeholder="请输入手机号码" />
+    <button formType="submit">提交</button>
+  </form>
+</view>

+ 0 - 0
pages/submitPhone/index.wxss


+ 53 - 0
project.config.json

@@ -0,0 +1,53 @@
+{
+  "description": "项目配置文件,详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
+  "setting": {
+    "bundle": false,
+    "userConfirmedBundleSwitch": false,
+    "urlCheck": true,
+    "scopeDataCheck": false,
+    "coverView": true,
+    "es6": false,
+    "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,
+    "showShadowRootInWxmlPanel": true,
+    "packNpmManually": false,
+    "enableEngineNative": false,
+    "packNpmRelationList": [],
+    "minifyWXSS": true,
+    "showES6CompileOption": false,
+    "minifyWXML": true,
+    "useStaticServer": true,
+    "checkInvalidKey": true,
+    "babelSetting": {
+      "ignore": [],
+      "disablePlugins": [],
+      "outputPath": ""
+    },
+    "disableUseStrict": false,
+    "useCompilerPlugins": false,
+    "ignoreUploadUnusedFiles": true
+  },
+  "compileType": "miniprogram",
+  "condition": {},
+  "editorSetting": {
+    "tabIndent": "insertSpaces",
+    "tabSize": 2
+  },
+  "libVersion": "2.24.6",
+  "packOptions": {
+    "ignore": [],
+    "include": []
+  },
+  "appid": "wxc0e5a044a76b1e4b"
+}

+ 8 - 0
project.private.config.json

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

+ 7 - 0
sitemap.json

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

TEMPAT SAMPAH
utils/.DS_Store


+ 65 - 0
utils/http.js

@@ -0,0 +1,65 @@
+const ui = require('./ui');
+const BASE_URL = 'http://192.168.1.64:8080/monitor'
+// const BASE_URL = 'http://119.29.97.109:8080/monitor'
+ 
+function request(obj) {
+    return new Promise(function(resolve, reject) {
+      if(obj.showLoading){
+        ui.showLoading(obj.message? obj.message : '加载中...');
+      }
+      var data = {};
+      if(obj.data) {
+        data = obj.data;
+      }
+      var contentType = 'application/json';
+      if(obj.contentType){
+        contentType = obj.contentType;
+      } 
+  
+      var method = 'post';
+      if(obj.method){
+        method = obj.method;
+      }
+  
+      wx.request({
+        url: BASE_URL + obj.url,
+        data: data,
+        method: method,
+        //添加请求头
+        // header: {
+        //   'Content-Type': contentType ,
+        //   'token': wx.getStorageSync('token') //获取保存的token
+        // },
+        //请求成功
+        success: function(res) {
+          if (res.statusCode == 200) {
+            resolve(res);
+          } else if (res.statusCode == 500) {//授权失效
+            reject("登录已过期");
+            jumpToLogin();//跳转到登录页
+          } else {
+            //请求失败
+            reject("请求失败:" + res.statusCode)
+          }
+        },
+        fail: function(err) {
+          reject("服务器连接异常,请检查网络再试");
+        },
+        complete: function() {
+          ui.hideLoading();
+        }
+      })
+    });
+  }
+  
+ 
+  //跳转到登录页
+  function jumpToLogin(){
+    wx.reLaunch({
+      url: '/pages/index/index',
+    })
+  }
+  
+  module.exports = {
+    request,
+  }

TEMPAT SAMPAH
utils/images/.DS_Store


TEMPAT SAMPAH
utils/images/home-1.png


TEMPAT SAMPAH
utils/images/home.png


TEMPAT SAMPAH
utils/images/jiantou.png


TEMPAT SAMPAH
utils/images/list-1.png


TEMPAT SAMPAH
utils/images/list.png


+ 26 - 0
utils/ui.js

@@ -0,0 +1,26 @@
+export const showToast = function(content,duration) {
+  if(!duration) duration = 2000
+  wx.showToast({
+      title: content,
+      icon: 'none',
+      duration: duration,
+  })
+}
+
+var isShowLoading = false
+export const showLoading = function(title) {
+  if(isShowLoading) return
+  wx.showLoading({
+      title: title?title:'',
+      mask:true,
+      success:()=>{
+          isShowLoading = true
+      }
+  })
+}
+
+export const hideLoading = function() {
+  if(!isShowLoading) return
+  isShowLoading = false
+  wx.hideLoading()
+}

+ 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
+}