123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- const { default: api } = require("../../js/api");
- Page({
-
- data: {
- date:'',
- startDate:'',
- endDate:'',
- orders:[
- {
- order:{
- nozzle:5,
- status:'已授权',
- statusColor:'#bbe06e',
- oilName:"92#",
- volume:20.0,
- amount:46.8,
- payAmount:46.8,
- discount:0.00,
- time:'2024-11-24 09:08',
- },
- bottonText2:'请尽快提枪'
- },
- ]
- },
-
- getNowDate(){
- const date = new Date();
- const year = date.getFullYear();
- const month = String(date.getMonth() + 1).padStart(2, '0');
- const day = String(date.getDate()).padStart(2, '0');
-
- return `${year}-${month}-${day}`;
- },
-
- getLastMouthDate(){
- const currentDate = new Date();
- const year = currentDate.getFullYear();
- const month = currentDate.getMonth();
- const day = currentDate.getDate();
-
- const oneMonthAgoDate = new Date(year, month - 1, day);
-
-
-
- const formattedDate = `${oneMonthAgoDate.getFullYear()}-${String(oneMonthAgoDate.getMonth() + 1).padStart(2, '0')}-${String(oneMonthAgoDate.getDate()).padStart(2, '0')}`;
- return formattedDate;
- },
-
- startCountdow(){
- this.timer = setInterval(() => {
- const countDownZeroOrders = []
- const orders = this.data.orders.map(order => {
- if(order.countdown && order.countdown != '0') {
- const currentCountDown = (Number(order.countdown) - 1);
- order.countdown = currentCountDown.toString();
- if(currentCountDown <= 0) countDownZeroOrders.push(order)
- }
- return order
- })
- this.setData({
- orders:orders
- })
- this.toUnAnthorization(countDownZeroOrders)
- },1000);
- },
-
- endCountDown(){
- if(this.timer) {
- clearInterval(this.timer)
- this.timer = null
- }
- },
-
- toUnAnthorization(orders) {
- console.log(orders)
- },
-
- onLoad(options) {
- const today = this.getNowDate();
- const lastMouthDay = this.getLastMouthDate();
- this.setData({
- date:today,
- startDate:today,
- endDate:lastMouthDay
- });
-
- },
-
- onReady() {
- },
-
- onShow() {
- },
-
- onHide() {
- },
-
- onUnload() {
- this.endCountDown()
- },
-
- onPullDownRefresh() {
- },
-
- onReachBottom() {
- },
-
- onShareAppMessage() {
- },
-
- bindDateChange(date) {
- this.setData({
- date: date.detail.value
- });
- console.log(date)
- },
-
- onOrderButtonClick1(event){
- console.log(event)
- },
-
- onOrderButtonClick2(event){
- console.log(event)
- },
-
- getOrder(){
- api.request_GetMiniProgramTransactionsUnpaidQuery(null).then(res => {
- console.log("未支付订单",res)
- }).catch(err => {
- console.log("获取未支付订单失败",err)
- })
- }
- })
|