123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- import store from '../../store'
- import create from '../../utils/create'
- import fetch from '../../utils/http'
- import {
- get as getApi
- } from '../../config/api'
-
- const app = getApp()
-
- create(store, {
- onShow() {
- wx.setNavigationBarTitle({
- title: '我的福利社'
- })
- },
- onLoad() {
- let _self = this
- wx.getSystemInfo({
- success(res) {
- _self.setData({
- WindowHeight: res.windowHeight
- })
- }
- })
- this.GetList()
- },
- data: {
- list: [],
- DeleteIndex: null,
- IsNull: false,
- WindowHeight: 0,
- PostData: {
- pageNum: 1,
- pageSize: 10
- },
- IsLock: false,
- Total: 1
- },
- GetList() {
- if (!this.data.IsLock && this.data.list.length < this.data.Total) {
- this.setData({
- IsLock: true
- })
- let userInfo = app.globalData.UserInfo
- fetch({
- ...getApi('user.signUpList', {
- openid: userInfo.openid
- }),
- query: {
- ...this.data.PostData
- },
- }).then((res) => {
- let list = res.data.records || []
- let aArr = this.data.list || []
- list.map((item) => {
- aArr.push({ ...item, activityDate: item.activityDate.split(' ')[0]})
- })
- this.setData({
- list: aArr,
- Total: res.data.total,
- PostData: {
- ...this.data.PostData,
- pageNum: this.data.PostData.pageNum + 1
- }
- })
- this.setData({
- IsNull: !this.data.list.length
- })
- setTimeout(() => {
- this.setData({
- IsLock: false
- })
- }, 300)
- }).catch((err) => {
- wx.showToast({
- title: '获取列表失败',
- icon: 'none',
- })
- setTimeout(() => {
- this.setData({
- IsLock: false
- })
- }, 300)
- })
- }
- },
- ShowDeleteItem(e) { // 长按显示删除
- this.setData({
- DeleteIndex: e.target.dataset.index
- })
- },
- ResetDeleteIndex() { // 重置删除状态
- this.setData({
- DeleteIndex: null
- })
- },
- DeleteItem() { // 确认删除逻辑
- const delId = this.data.DeleteIndex
- this.ResetDeleteIndex()
-
- const _self = this
-
- wx.showModal({
- title: '确认',
- content: '确认要删除当前记录?',
- success(res) {
- if (res.confirm) {
-
- fetch({
- ...getApi('user.delAppointment', {
- id: delId
- }),
- }).then(() => {
- const list = _self.data.list.filter(x => x.appointmentId !== delId)
-
- _self.setData({
- list
- })
- }).catch((err) => {
- wx.showToast({
- title: '删除失败',
- icon: 'none',
- })
- })
-
-
- } else if (res.cancel) {
- console.log('用户点击取消')
- }
- }
- })
- },
- onShareAppMessage: function () {
- return app.globalData.ShareDate
- }
- })
|