123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- // pointExchange/pages/my/my.js
- const app = getApp();
- import util from '../../../utils/util.js'
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- appAssetsUrl:app.appAssetsUrl,
- typeList:[{
- name:'全部',
- value:''
- },{
- name:'未使用',
- value:1
- },{
- name:'已使用',
- value:2
- },{
- name:'已过期',
- value:3
- }],
- typeListIndex:0,
- nodata: util.nodata(),
- params: {
- sutId: util.getUserId(),
- pageNum: 1,
- pageSize: 10,
- status: ''
- },
- total:{
- currPage: 0,
- totalPage: 0
- },
- noMore:false,
- listData:[],
- itemData:{
- cdkey:'',
- needScore: '--'
- }
- },
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- if(options.index){
- this.setData({
- typeListIndex:options.index
- })
- }
- this.loadList(true);
- },
- switchType(e) {
- let index = e.currentTarget.dataset.index;
- this.setData({
- typeListIndex: index
- })
- this.loadList(true);
- },
- loadList(isRefresh) {
- let that = this;
- if (!isRefresh && this.data.noMore) {
- wx.showToast({
- title: '没有更多了~',
- icon: 'none'
- })
- return false;
- }
- this.setData({
- listData: isRefresh ? [] : this.data.listData,
- noMore: isRefresh ? false : this.data.noMore,
- params: {
- ...this.data.params,
- pageNum: isRefresh?1:this.data.params.pageNum+1,
- status: this.data.typeList[this.data.typeListIndex].value
- }
- })
- wx.showLoading({
- title: '努力加载中...',
- })
- app._post_form('productStu/page', '', this.data.params,
- function(res) {
- if (res.code == 0) {
- if(res.data.list.length>0 && that.data.listData.length>0 && res.data.list[0].id == that.data.listData[0].id){
- return ;
- }
- let listData = that.data.listData;
- listData.push(...res.data.list);
- that.setData({
- listData,
- currPage: res.data.currPage,
- totalPage: res.data.totalPage,
- noMore: res.data.totalPage == res.data.currPage
- })
- }
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- this.popup3 = this.selectComponent("#popup3");
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- this.loadList();
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
- toDatail(e){
- wx.navigateTo({
- url: `/pointExchange/pages/detail/detail?id=${e.currentTarget.dataset.id}&isApply=true`
- })
- },
- //弹窗
- showPopup(e) {
- this[e.currentTarget.dataset.name].showPopup();
- this.setData({
- itemData:{
- ...this.data.itemData,
- needScore: e.currentTarget.dataset.needscore,
- cdkey: e.currentTarget.dataset.cdkey,
- }
- })
- },
- //取消事件
- _error(e) {
- this[e.currentTarget.dataset.name].hidePopup();
- },
- //使用卡券
- applyCoupon(e){
- this.popup3.hidePopup();
- let that = this;
- wx.showLoading({
- title: '提交中...',
- })
- app._post_form('productStu/use', "", {
- cdkey: this.data.itemData.cdkey,
- stuId: util.getUserId()
- }, function(res) {
- if (res.code === 0) {
- wx.showToast({
- title:'使用成功',
- icon:'none'
- })
- that.loadList(true);
- }
- })
- }
- })
|