/*
 * @Author: your name
 * @Date: 2022-03-26 11:41:08
 * @LastEditTime: 2022-04-13 14:28:30
 * @LastEditors: your name
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \MShopWeApp\packageD\pages\user\deposit\deposit.js
 */
var t = getApp(),
  a = t.request,
  o = t.globalData.setting,
  os = o,
  i = require("../../../../utils/util.js"),
  ut = i,
  s = require("../../../../utils/common.js");
var regeneratorRuntime = require('../../../../utils/runtime.js');
Page({
  data:{
    yucun_money:0,
    parameter:true,
    iurl: o.imghost,
    is_show_yckcz:0,
  },
  /**
    * 生命周期函数--监听页面显示
    */
  onShow: function () {
  //  --先判断会员状态--
    var user_info = getApp().globalData.userInfo;
    if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
      wx.navigateTo({ url: '/packageE/pages/togoin/togoin', })
      return false;
    }
    wx.setNavigationBarTitle({
      title: "储值款",
    })

    var th = this;
    getApp().getConfig2(function (ee) {
      var json_d = JSON.parse(ee.switch_list);
      th.setData({ is_show_yckcz: json_d.yckcz_switch });
    },1)
  },
 
         /**
          * 生命周期函数--监听页面初次渲染完成
          */
  onReady: function () {
    this.yuck();
  },
  //预存款
  async yuck(){
    var user_id =getApp().globalData.user_id;
    var store_id = os.stoid;
    console.log(user_id, "有进来吗银行卡", store_id);
   
    await getApp().request.promiseGet("/api/weshop/users/listYuMoney", {
      data: { user_id: user_id, store_id: store_id  }
    }).then(res => {
      var a = res.data;
      console.log("在这了",a);
     var yucun_money = a.data.yucun_money;
     var list= a.data.list1;
      if (list.length != 0){
       console.log(list, "s1w" + yucun_money);
          list=list.map(item=>{
          item['EndDate']=item['EndDate'].replace('00:00:00','23:59:59');
          return item;
       });
        this.setData({ yucun_money: yucun_money, list: list, parameter: false });
     }else{
        console.log("在这里111", list.length);
        this.setData({ parameter:true});
     }
     
    })
   
  },

  jumPage: function () {
    wx.navigateTo({
      url: 'prepaid/prepaid',

    })
  },
  /**
      * 生命周期函数--监听页面加载
      */
  onLoad: function (options) {

  },

  goto_nav: function (e) {
		var th = this;
    var itemid = e.currentTarget.dataset.itemid;
    var url="query/index?itemid="+itemid;
    console.log(url);
  	getApp().goto(url);
		
	},
})
