| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- var _request = require('../../../../utils/request.js')
- var id
- Page({
- data: {
- page: 1,
- per_page: 10,
- list: [],
- already_settle:'',
- not_settle:'',
- total_sale:'',
- // settle_price:[],
- more: true,
- num: ''
- },
- onLoad: function (options) {
- id = options.id
- // var app = getApp()
- // new app.ToastPannel()
- this.getSettleList()
- this.getSettleStat()
- this.getTime()
- },
- getSettleList () {
- var that = this
- var url = 'v1/merchant/settle/list'
- var params = {
- merchant_id: id,
- page: this.data.page,
- per_page: this.data.per_page
- }
- var success = function (res) {
- // var arr = []
- // for(var i = 0; i<data.length; i++){
- // // console.log(data[i].settle_price)
- // arr.push(that.formatNumber(data[i].settle_price))
- // console.log(arr.length)
- // }
- var result = that.data.list.concat(res.data.list || [])
- console.log(result)
- that.setData({
- list: result,
- // settle_price: arr
- })
- var listMore = res.data.list_count > that.data.list.length
- that.setData({
- more: listMore
- })
- }
- _request.$get(url, params, success, that)
- },
- getSettleStat () {
- var that = this
- var url = 'v1/merchant/settle/stat'
- var params = {
- merchant_id: id,
- }
- var success = function (res) {
- var data1 = res.data
- console.log(data1)
- that.setData({
- already_settle: that.formatNumber(data1.already_settle),
- not_settle: that.formatNumber(data1.not_settle),
- total_sale: that.formatNumber(data1.total_sale)
- })
- }
- _request.$get(url, params, success, that)
- },
- //千分位格式化
- formatNumber (num) {
- var num1 = num.toFixed(2)
- if (isNaN(num)) {
- throw new TypeError("num is not a number");
- }
- return ("" + num1).replace(/(\d{1,3})(?=(\d{3})+(?:$|\.))/g, "$1,");
- },
- toOther () {
- wx.navigateTo({
- url: '/pages/parse/parse?id=10'
- })
- },
- onReachBottom: function () {
- if (this.data.more) {
- var page = this.data.page + 1
- this.setData({
- page: page
- })
- this.getSettleList()
- }
- },
- getTime () {
- var that = this
- var date=new Date;
- var year=date.getFullYear();
- var month=date.getMonth()+1;
- month =(month<10 ? "0"+month:month);
- var mydate = (year.toString()+'/'+month.toString());
- that.setData({
- num: mydate
- })
- }
- })
|