|
@@ -2,10 +2,60 @@ const app = getApp();
|
|
Page({
|
|
Page({
|
|
data: {
|
|
data: {
|
|
frameStyle: { useTop: true, name: '组内项目', leftArrow: true, useBar: false },
|
|
frameStyle: { useTop: true, name: '组内项目', leftArrow: true, useBar: false },
|
|
|
|
+ list: [],
|
|
|
|
+ total: 0,
|
|
|
|
+ page: 0,
|
|
|
|
+ skip: 0,
|
|
|
|
+ limit: 5,
|
|
|
|
+ //性别
|
|
|
|
+ genderList: [],
|
|
|
|
+ //项目类别
|
|
|
|
+ typeList: []
|
|
},
|
|
},
|
|
// 返回
|
|
// 返回
|
|
back: function () { wx.navigateBack({ delta: 1 }) },
|
|
back: function () { wx.navigateBack({ delta: 1 }) },
|
|
-
|
|
|
|
|
|
+ //添加信息,信息维护
|
|
|
|
+ toCommon: function (e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ const { item, route } = e.currentTarget.dataset;
|
|
|
|
+ that.setData({ skip: 0, page: 0, list: [] });
|
|
|
|
+ wx.navigateTo({ url: `/pagesMatch/${route}?id=${item && item._id ? item._id : ''}` })
|
|
|
|
+ },
|
|
|
|
+ // 删除
|
|
|
|
+ toDel: function (e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ const { item } = e.currentTarget.dataset;
|
|
|
|
+ wx.showModal({
|
|
|
|
+ title: '提示',
|
|
|
|
+ content: '是否确认删除该条数据?',
|
|
|
|
+ async success(res) {
|
|
|
|
+ if (res.confirm) {
|
|
|
|
+ const arr = await app.$delete(`/matchProject/${item._id}`);
|
|
|
|
+ if (arr.errcode == '0') {
|
|
|
|
+ wx.showToast({ title: `删除信息成功`, icon: 'success', duration: 2000 })
|
|
|
|
+ that.watchLogin()
|
|
|
|
+ } else {
|
|
|
|
+ wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ // 分页
|
|
|
|
+ toPage: function () {
|
|
|
|
+ const that = this;
|
|
|
|
+ let list = that.data.list;
|
|
|
|
+ let limit = that.data.limit;
|
|
|
|
+ if (that.data.total > list.length) {
|
|
|
|
+ wx.showLoading({ title: '加载中', mask: true })
|
|
|
|
+ let page = that.data.page + 1;
|
|
|
|
+ that.setData({ page: page })
|
|
|
|
+ let skip = page * limit;
|
|
|
|
+ that.setData({ skip: skip })
|
|
|
|
+ that.watchLogin();
|
|
|
|
+ wx.hideLoading()
|
|
|
|
+ } else { wx.showToast({ title: '没有更多数据了', icon: 'none', duration: 2000 }) }
|
|
|
|
+ },
|
|
/**
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
*/
|
|
@@ -19,15 +69,40 @@ Page({
|
|
*/
|
|
*/
|
|
onShow: function () {
|
|
onShow: function () {
|
|
const that = this;
|
|
const that = this;
|
|
|
|
+ // 查询其他信息
|
|
|
|
+ that.searchOther();
|
|
// 监听用户是否登录
|
|
// 监听用户是否登录
|
|
that.watchLogin();
|
|
that.watchLogin();
|
|
},
|
|
},
|
|
|
|
+ searchOther: async function () {
|
|
|
|
+ const that = this;
|
|
|
|
+ let arr;
|
|
|
|
+ // 性别
|
|
|
|
+ arr = await app.$get(`/dict`, { code: 'gender' });
|
|
|
|
+ if (arr.errcode == '0' && arr.total > 0) that.setData({ genderList: arr.data[0].list });
|
|
|
|
+ // 项目类别
|
|
|
|
+ arr = await app.$get(`/dict`, { code: 'match_project_type' });
|
|
|
|
+ if (arr.errcode == '0' && arr.total > 0) that.setData({ typeList: arr.data[0].list });
|
|
|
|
+ },
|
|
// 监听用户是否登录
|
|
// 监听用户是否登录
|
|
watchLogin: async function () {
|
|
watchLogin: async function () {
|
|
const that = this;
|
|
const that = this;
|
|
|
|
+ let genderList = that.data.genderList;
|
|
|
|
+ let typeList = that.data.typeList;
|
|
wx.getStorage({
|
|
wx.getStorage({
|
|
key: 'user',
|
|
key: 'user',
|
|
- success: async res => { },
|
|
|
|
|
|
+ success: async res => {
|
|
|
|
+ let info = { skip: that.data.skip, limit: that.data.limit };
|
|
|
|
+ let arr = await app.$get(`/matchProject`, { ...info });
|
|
|
|
+ if (arr.errcode == '0') {
|
|
|
|
+ for (const val of arr.data) {
|
|
|
|
+ let type = typeList.find(i => i.value == val.type); if (type) val.zhType = type.label;
|
|
|
|
+ let gender = genderList.find(i => i.value == val.gender); if (gender) val.zhGender = gender.label;
|
|
|
|
+ }
|
|
|
|
+ that.setData({ list: [...that.data.list, ...arr.data] })
|
|
|
|
+ that.setData({ total: arr.total })
|
|
|
|
+ } else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }) }
|
|
|
|
+ },
|
|
fail: async res => {
|
|
fail: async res => {
|
|
wx.redirectTo({ url: '/pages/index/index' })
|
|
wx.redirectTo({ url: '/pages/index/index' })
|
|
}
|
|
}
|
|
@@ -40,7 +115,8 @@ Page({
|
|
* 生命周期函数--监听页面隐藏
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
*/
|
|
onHide: function () {
|
|
onHide: function () {
|
|
-
|
|
|
|
|
|
+ const that = this;
|
|
|
|
+ that.setData({ skip: 0, page: 0, list: [] })
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|