|
@@ -18,42 +18,32 @@ Page({
|
|
|
wx.navigateBack({ delta: 1 })
|
|
|
},
|
|
|
// 查询
|
|
|
- search: function (e) { console.log('查询'); },
|
|
|
+ search: function (e) {
|
|
|
+ const that = this;
|
|
|
+ that.setData({ 'searchInfo.name': e.detail.value });
|
|
|
+ that.watchLogin()
|
|
|
+ },
|
|
|
// 查看
|
|
|
toView: async function (e) {
|
|
|
const that = this;
|
|
|
const { item } = e.currentTarget.dataset;
|
|
|
- const arr = await app.$get(`/newCourt/api/enroll/${item._id}`);
|
|
|
- if (arr.errcode == '0') {
|
|
|
- // 用户信息
|
|
|
- const user = await app.$get(`/newCourt/api/user/${arr.data.openid}`);
|
|
|
- if (user.errcode = '0') { arr.data.user_name = user.data.name };
|
|
|
- // 赛事信息
|
|
|
- const match = await app.$get(`/newCourt/api/match/${arr.data.match_id}`);
|
|
|
- if (match.errcode = '0') { arr.data.match_name = match.data.name };
|
|
|
- // 赛事组别
|
|
|
- let group = match.data.grouping.find((i) => i._id == arr.data.grouping_id);
|
|
|
- if (group) { arr.data.grouping_name = group.name; arr.data.project_type = group.type }
|
|
|
- // 赛事项目
|
|
|
- const project = await app.$get(`/newCourt/api/matchProject/${arr.data.project_id}`)
|
|
|
- if (project.errcode = '0') { arr.data.project_name = project.data.name };
|
|
|
- that.setData({ info: arr.data })
|
|
|
- that.setData({ dialog: { title: '详细信息', show: true, type: '1' } })
|
|
|
- }
|
|
|
+ that.setData({ info: item })
|
|
|
+ that.setData({ dialog: { title: '详细信息', show: true, type: '1' } })
|
|
|
},
|
|
|
// 组队申请
|
|
|
toTeam: function (e) {
|
|
|
const { item } = e.currentTarget.dataset;
|
|
|
- wx.navigateTo({ url: `/pages/usermyteam/add?id=${item._id}` })
|
|
|
+ wx.navigateTo({ url: `/pages/usermyteam/add?id=${item.enroll_id}` })
|
|
|
},
|
|
|
// 支付
|
|
|
toPay: async function (e) {
|
|
|
const that = this;
|
|
|
- const id = e.currentTarget.dataset?.item?._id;
|
|
|
+ const enroll_id = e.currentTarget.dataset?.item?.enroll_id;
|
|
|
+ debugger
|
|
|
wx.getStorage({
|
|
|
key: 'user',
|
|
|
success: async (res) => {
|
|
|
- let obj = { openid: res.data.openid, money: 0.1, enroll_id: id, type: '报名' }
|
|
|
+ let obj = { openid: res.data.openid, money: 0.1, enroll_id: enroll_id, type: '报名' }
|
|
|
const arr = await app.$post(`/newCourt/api/payOrder`, obj)
|
|
|
if (arr.errcode == '0') {
|
|
|
wx.requestPayment({
|
|
@@ -79,6 +69,18 @@ Page({
|
|
|
},
|
|
|
});
|
|
|
},
|
|
|
+ // 退款
|
|
|
+ toOut: async function (e) {
|
|
|
+ const that = this;
|
|
|
+ const { item } = e.currentTarget.dataset;
|
|
|
+ const arr = await app.$post('/newCourt/api/payOrder/toRefund', { id: item.pay_id })
|
|
|
+ if (arr.errcode == '0') {
|
|
|
+ wx.showToast({ title: `退款成功`, icon: 'success', duration: 2000 });
|
|
|
+ that.watchLogin();
|
|
|
+ } else {
|
|
|
+ wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 });
|
|
|
+ }
|
|
|
+ },
|
|
|
// 关闭弹框
|
|
|
toClose: function () {
|
|
|
const that = this;
|
|
@@ -94,10 +96,13 @@ Page({
|
|
|
// 监听用户是否登录
|
|
|
watchLogin: async function () {
|
|
|
const that = this;
|
|
|
+ let searchInfo = that.data.searchInfo;
|
|
|
wx.getStorage({
|
|
|
key: 'user',
|
|
|
success: async res => {
|
|
|
- const arr = await app.$get(`/newCourt/api/enroll/`, { openid: res.data.openid });
|
|
|
+ let info = {};
|
|
|
+ if (searchInfo && searchInfo.name) info.match_name = searchInfo.name;
|
|
|
+ const arr = await app.$get(`/newCourt/api/view/myMatchList/`, { openid: res.data.openid, ...info });
|
|
|
if (arr.errcode == '0') {
|
|
|
for (const val of arr.data) {
|
|
|
// 赛事信息
|
|
@@ -105,6 +110,7 @@ Page({
|
|
|
if (match.errcode = '0') { val.match_name = match.data.name };
|
|
|
}
|
|
|
that.setData({ list: arr.data })
|
|
|
+ console.log(arr.data);
|
|
|
}
|
|
|
},
|
|
|
fail: res => {
|