|
@@ -1,4 +1,7 @@
|
|
const app = getApp();
|
|
const app = getApp();
|
|
|
|
+import { bill_type } from '../../../utils/dict';
|
|
|
|
+import WxValidate from '../../../utils/wxValidate';
|
|
|
|
+
|
|
Page({
|
|
Page({
|
|
data: {
|
|
data: {
|
|
frameStyle: { useTop: true, name: '收益信息', leftArrow: true, useBar: false },
|
|
frameStyle: { useTop: true, name: '收益信息', leftArrow: true, useBar: false },
|
|
@@ -10,23 +13,57 @@ Page({
|
|
page: 0,
|
|
page: 0,
|
|
skip: 0,
|
|
skip: 0,
|
|
limit: 5,
|
|
limit: 5,
|
|
|
|
+ dialog: { title: '查询条件', show: false, type: '1' },
|
|
|
|
+ form: {},
|
|
|
|
+ typeList: bill_type,
|
|
|
|
+ },
|
|
|
|
+ initValidate() {
|
|
|
|
+ const rules = { match_id: { required: true } }
|
|
|
|
+ // 验证字段的提示信息,若不传则调用默认的信息
|
|
|
|
+ const messages = { match_id: { required: '赛事名称' } };
|
|
|
|
+ this.WxValidate = new WxValidate(rules, messages)
|
|
},
|
|
},
|
|
// 返回
|
|
// 返回
|
|
back: function () { wx.navigateBack({ delta: 1 }) },
|
|
back: function () { wx.navigateBack({ delta: 1 }) },
|
|
|
|
+
|
|
|
|
+ toSearch: function (e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ that.setData({ dialog: { title: '查询条件', show: true, type: '1' } })
|
|
|
|
+ },
|
|
// 选择赛事
|
|
// 选择赛事
|
|
matchChange: function (e) {
|
|
matchChange: function (e) {
|
|
const that = this;
|
|
const that = this;
|
|
let data = that.data.matchList[e.detail.value];
|
|
let data = that.data.matchList[e.detail.value];
|
|
if (data) {
|
|
if (data) {
|
|
- that.setData({ 'match.id': data._id, 'match.name': data.name });
|
|
|
|
|
|
+ that.setData({ 'form.match_id': data._id, 'form.match_name': data.name });
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ // 账单来源
|
|
|
|
+ typeChange: function (e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ let data = that.data.typeList[e.detail.value];
|
|
|
|
+ if (data) {
|
|
|
|
+ that.setData({ 'form.type': data.value, 'form.type_name': data.label });
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ //自动生成
|
|
|
|
+ onSubmit: async function (e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ const params = e.detail.value;
|
|
|
|
+ if (!this.WxValidate.checkForm(params)) {
|
|
|
|
+ const error = this.WxValidate.errorList[0];
|
|
|
|
+ wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
|
|
|
|
+ return false
|
|
|
|
+ } else {
|
|
that.setData({ skip: 0, page: 0, list: [] })
|
|
that.setData({ skip: 0, page: 0, list: [] })
|
|
- that.search(data);
|
|
|
|
|
|
+ that.search(); that.toClose();
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+
|
|
search: async function (e) {
|
|
search: async function (e) {
|
|
const that = this;
|
|
const that = this;
|
|
- let match = that.data.match;
|
|
|
|
- let info = { skip: that.data.skip, limit: that.data.limit, match_id: match.id };
|
|
|
|
|
|
+ let form = that.data.form;
|
|
|
|
+ let info = { skip: that.data.skip, limit: that.data.limit, ...form };
|
|
const arr = await app.$get(`/bill`, { ...info }, 'race');
|
|
const arr = await app.$get(`/bill`, { ...info }, 'race');
|
|
if (arr.errcode == '0') {
|
|
if (arr.errcode == '0') {
|
|
let list = [...that.data.list, ...arr.data]
|
|
let list = [...that.data.list, ...arr.data]
|
|
@@ -34,6 +71,12 @@ Page({
|
|
that.setData({ total: arr.total })
|
|
that.setData({ total: arr.total })
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ // 关闭弹框
|
|
|
|
+ toClose: function () {
|
|
|
|
+ const that = this;
|
|
|
|
+ that.setData({ form: {} })
|
|
|
|
+ that.setData({ dialog: { title: '查询条件', show: false, type: '1' } })
|
|
|
|
+ },
|
|
// 分页
|
|
// 分页
|
|
toPage: function () {
|
|
toPage: function () {
|
|
const that = this;
|
|
const that = this;
|
|
@@ -62,6 +105,8 @@ Page({
|
|
*/
|
|
*/
|
|
onShow: async function () {
|
|
onShow: async function () {
|
|
const that = this;
|
|
const that = this;
|
|
|
|
+ //验证规则函数
|
|
|
|
+ that.initValidate();
|
|
// 监听用户是否登录
|
|
// 监听用户是否登录
|
|
await that.watchLogin();
|
|
await that.watchLogin();
|
|
},
|
|
},
|