electricity_bill_calc_wx/components/aid/index.js
2024-11-28 17:33:29 +08:00

78 lines
1.4 KiB
JavaScript

import { getAidList } from "../../service/system";
import { alertInfo, alertSuccess } from "../../utils/index";
import request from '../../utils/request'
const { OK } = request;
// components/aid/index.js
Component({
/**
* 组件的属性列表
*/
properties: {
type: Number,
bannerType: Number,
},
lifetimes: {
attached() {
this.init();
}
},
/**
* 组件的初始数据
*/
data: {
park: {},
list: [],
total: 0,
page: 1,
size: 20,
},
lifetimes: {
attached() {
this.init()
}
},
/**
* 组件的方法列表
*/
methods: {
async init() {
const { type, page, size } = this.data;
const { code, message, data = [], total } = await getAidList(page, size, type);
console.log('data', data)
if (code !== OK) {
alertInfo(message)
return
}
this.setData({
list: data,
total
}, () => {
console.log("this.data", this.data)
})
},
onRefresh() {
const that = this;
this.setData({
page: 1,
}, () => {
that.init();
})
},
jumpToDetail(e) {
const { id = "" } = e.currentTarget.dataset;
const { type } = this.data;
wx.navigateTo({
url: `/pages/aid/detail/index?id=${id}&type=${type}`,
})
},
consult() {
wx.navigateTo({
url: `/pages/aid/consult/index?id=${this.data.type}`,
})
}
}
})