|
@@ -1,8 +1,12 @@
|
|
|
const app = getApp();
|
|
|
import WxValidate from '../../../utils/wxValidate';
|
|
|
+import QRCode from '../../../utils/weapp-qrcode.js';
|
|
|
+
|
|
|
Page({
|
|
|
data: {
|
|
|
frameStyle: { useTop: true, name: '裁判信息', leftArrow: true, useBar: false },
|
|
|
+ // 比赛系统用户
|
|
|
+ raceuser: {},
|
|
|
list: [],
|
|
|
total: 0,
|
|
|
page: 0,
|
|
@@ -37,14 +41,14 @@ Page({
|
|
|
content: '是否确认删除该条数据?',
|
|
|
async success(res) {
|
|
|
if (res.confirm) {
|
|
|
- // const arr = await app.$delete(`/user/${item._id}`);
|
|
|
- // if (arr.errcode == '0') {
|
|
|
- // wx.showToast({ title: `删除信息成功`, icon: 'success', duration: 2000 })
|
|
|
- // that.setData({ skip: 0, page: 0, list: [] })
|
|
|
- // that.watchLogin()
|
|
|
- // } else {
|
|
|
- // wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
|
|
|
- // }
|
|
|
+ const arr = await app.$delete(`/user/${item._id}`, {}, 'race');
|
|
|
+ if (arr.errcode == '0') {
|
|
|
+ wx.showToast({ title: `删除信息成功`, icon: 'success', duration: 2000 })
|
|
|
+ that.setData({ skip: 0, page: 0, list: [] })
|
|
|
+ that.watchLogin()
|
|
|
+ } else {
|
|
|
+ wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
})
|
|
@@ -58,12 +62,50 @@ Page({
|
|
|
coachChange: function (e) {
|
|
|
const that = this;
|
|
|
let data = that.data.coachList[e.detail.value];
|
|
|
- if (data) that.setData({ 'form.caoch_id': data.coach_id, 'form.coach_id_name': data.coach_id_name, 'form.school_id': data.school_id })
|
|
|
+ if (data) that.setData({ 'form.coach_id': data.coach_id, 'form.coach_id_name': data.coach_id_name })
|
|
|
+ },
|
|
|
+ onSubmit: async function (e) {
|
|
|
+ const that = this;
|
|
|
+ let 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 {
|
|
|
+ let arr;
|
|
|
+ arr = await app.$post(`/user/ctbj`, params, 'race');
|
|
|
+ if (arr.errcode == '0') { wx.showToast({ title: `维护信息成功`, icon: 'success', duration: 2000 }); that.back() }
|
|
|
+ else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }) }
|
|
|
+ }
|
|
|
},
|
|
|
// 添加裁判
|
|
|
- toAdd: function () {
|
|
|
- console.log('2');
|
|
|
+ toAdd: async function (e) {
|
|
|
+ const that = this;
|
|
|
+ // 生成二维码
|
|
|
+ that.makeQRCode();
|
|
|
+ that.setData({ dialog: { title: '账号绑定', show: true, type: '2' } })
|
|
|
+ },
|
|
|
+ makeQRCode(template = 0) {
|
|
|
+ const that = this;
|
|
|
+ const url = `${that.data.raceuser._id}&&2`;
|
|
|
+ var qrcode = new QRCode(`myQrcode`, {
|
|
|
+ text: url,
|
|
|
+ width: 110,
|
|
|
+ height: 110,
|
|
|
+ padding: 3,
|
|
|
+ colorDark: "#000000",
|
|
|
+ colorLight: "#ffffff",
|
|
|
+ correctLevel: QRCode.CorrectLevel.L,
|
|
|
+ });
|
|
|
},
|
|
|
+ // 关闭弹窗
|
|
|
+ toClose: function () {
|
|
|
+ const that = this;
|
|
|
+ that.setData({ 'form.coach_id': '' })
|
|
|
+ that.setData({ 'form.coach_id_name': '' })
|
|
|
+ that.setData({ dialog: { titl: '教练', show: false, type: '2' } })
|
|
|
+ },
|
|
|
+
|
|
|
// 分页
|
|
|
toPage: function () {
|
|
|
const that = this;
|
|
@@ -92,6 +134,8 @@ Page({
|
|
|
*/
|
|
|
onShow: async function () {
|
|
|
const that = this;
|
|
|
+ //验证规则函数
|
|
|
+ that.initValidate();
|
|
|
// 查询其他信息
|
|
|
await that.searchOther();
|
|
|
// 监听用户是否登录
|
|
@@ -109,16 +153,25 @@ Page({
|
|
|
watchLogin: async function () {
|
|
|
const that = this;
|
|
|
wx.getStorage({
|
|
|
- key: 'user',
|
|
|
+ key: 'raceuser',
|
|
|
success: async res => {
|
|
|
- // referee
|
|
|
- // let info = { skip: that.data.skip, limit: that.data.limit };
|
|
|
- // const arr = await app.$get(`/user`, { ...info });
|
|
|
- // if (arr.errcode == '0') {
|
|
|
- // that.setData({ list: [...that.data.list, ...arr.data] });
|
|
|
- // that.setData({ total: arr.total })
|
|
|
- // }
|
|
|
- // else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }); }
|
|
|
+ that.setData({ raceuser: res.data })
|
|
|
+ let arr;
|
|
|
+ // 查询当前用户学校,学校id存比赛系统user中的_id,查询当前用户学校与教练的关系表
|
|
|
+ arr = await app.$get(`/school`, { user_id: res.data.user_id._id })
|
|
|
+ if (arr.errcode == '0' && arr.total > 0) {
|
|
|
+ let school = arr.data[0];
|
|
|
+ that.setData({ 'form.parent_id': res.data._id })
|
|
|
+ const aee = await app.$get(`/rcs`, { school_id: school._id })
|
|
|
+ if (aee.errcode == '0') {
|
|
|
+ that.setData({ coachList: aee.data })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let info = { skip: that.data.skip, limit: that.data.limit, parent_id: res.data._id, type: '2' };
|
|
|
+ const aee = await app.$get(`/user`, { ...info }, 'race')
|
|
|
+ if (aee.errcode == '0') {
|
|
|
+ that.setData({ list: aee.data })
|
|
|
+ }
|
|
|
},
|
|
|
fail: async res => {
|
|
|
wx.redirectTo({ url: '/pages/index/index' })
|