haomingming 97a504c6d2 优化
2023-05-05 11:44:37 +08:00

124 lines
3.2 KiB
JavaScript

import { API } from './../../../utils/network/api'
const util = require('./../../../utils/util')
let api = new API()
const app = getApp()
Page({
data: {
navbarData: {
showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示
title: '我的账户', //导航栏 中间的标题
},
height: app.globalData.height,
dateVisible: false,
dateText: "",
dateValue: ['2023','3'],
select_date: "",
balance_account: "",
amount_total_month: "",
withdrawal_amount_month: "",
bill: [],
years: [],
seasons: [
{ label: '1月', value: '1' },
{ label: '2月', value: '2' },
{ label: '3月', value: '3' },
{ label: '4月', value: '4' },
{ label: '5月', value: '5' },
{ label: '6月', value: '6' },
{ label: '7月', value: '7' },
{ label: '8月', value: '8' },
{ label: '9月', value: '9' },
{ label: '10月', value: '10' },
{ label: '11月', value: '11' },
{ label: '12月', value: '12' },
]
},
onLoad(){
let now_year = (new Date()).Format("yyyy");
let begin_year = 2022;
let years = [];
for(let i=begin_year;i<=now_year;i++){
years.push({label: i+"年", value: i+""})
}
this.setData({
years: years
})
},
onShow(){
let now_date = new Date();
let now_datearr = util.getDateArr(now_date);
console.log(now_datearr);
let year = now_datearr[0];
let month = now_datearr[1];
let mmdateValue = [''+year+'',''+month+''];
this.setData({
dateValue: mmdateValue,
dateText: month+"月"
})
let date = this.data.dateValue.join("-");
this.getDoctorCenterAccount(date);
},
onColumnChange(e) {
console.log('picker onColumnChange:', e);
},
onPickerChange(e) {
const { key } = e.currentTarget.dataset;
const { value } = e.detail;
console.log('picker onPickerChange:', e.detail);
this.setData({
[`${key}Visible`]: false,
[`${key}Value`]: value,
[`${key}Text`]: value[1]+"月",
});
let date = value.join("-");
this.getDoctorCenterAccount(date);
},
onPickerCancel(e) {
const { key } = e.currentTarget.dataset;
console.log(e, '取消');
console.log('picker1 onPickerCancel:');
this.setData({
[`${key}Visible`]: false,
});
},
onSeasonPicker() {
this.setData({ dateVisible: true });
},
showPop(){
this.setData({
dateVisible: true
});
},
getDoctorCenterAccount(date){
//获取医生我的账户数据
api.getDoctorCenterAccount({date:date}).then(response => {
console.log(response);
this.setData({
balance_account: response.data.balance_account,
amount_total_month: response.data.amount_total_month,
withdrawal_amount_month: response.data.withdrawal_amount_month,
bill: response.data.bill,
})
}).catch(errors => {console.error(errors);})
},
goDetail(e){
let url = e.currentTarget.dataset.url;
let md = e.currentTarget.dataset.md;
let date = this.data.dateValue[0]+"-"+md;
console.log(date);
app.go(url+"?date="+date);
},
go(e){
let url = e.currentTarget.dataset.url;
app.go(url);
},
})