123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- const util = require('../../../utils/util.js');
- const app = getApp();
- Component({
- properties:{
- show: {
- type: Boolean,
- observer: function (val) {
- this.setData({ show: val });
- }
- },
- info:{
- type:Object,
- observer:function(options){
- if (util.isObjEmpty(options)) {
- return false;
- }
- if (options.packIds && options.aid && options.sid) {
- let data = {};
- data.meals = options.packIds;
- data.aid = options.aid;
- data.sid = options.sid;
- data.cid = options.cid;
- data.vid = options.vid != -1 ? options.vid : "";
- this.setData({ data: data });
- }
- this.getlist(false);
- }
- },
- status:{
- type: Number,
- observer: function (val) {
- this.setData({ presellstatus : val });
- }
- },
- type:{
- type: Number,
- observer: function (val) {
- this.setData({ type: val });
- }
- }
- },
- data: {
- show:false,
- list: [],
- data: Object,
- selectId: 0,
- isLoadMore: true,
- pageIndex: 1,
- pageSize: 10,
- tabStatus:1,
- presellstatus:0,
- type:0,
- },
- methods:{
- getlist: function (load) {
- var self = this,
- url = "v2/order/pay_vouchers",
- data = { "pageIndex": self.data.pageIndex, "pageSize": self.data.pageSize };
- if (self.data.data.meals) {
- url = "v2/order/pay_vouchers";
- data = self.data.data;
- data.pageIndex = self.data.pageIndex;
- data.pageSize = self.data.pageSize;
- data.status = self.data.tabStatus;
- if (self.data.presellstatus != 0) {
- data.otype = self.data.type == 1 ? 2 : 1;
- }else{
- data.otype = 0
- }
- }
- util.ajax({
- func: url,
- data: data,
- load: load
- }, function (res) {
- if (res.code == 0) {
- let isLoadMore = true;
- let newData = self.data.data.meals ? res.data.list : res.data.collects;
- let oldData = !load ? newData : [...self.data.list, ...newData];
- if (newData.length < self.data.pageSize && oldData.length > self.data.pageSize) {
- isLoadMore = false;
- }
- for (let i = 0; i < oldData.length; i++) {
- oldData[i].description = oldData[i].description.replace("<b>", "<b class='b'>");
- }
- self.setData({ list: oldData, isLoadMore: isLoadMore, selectId: data.vid || '' });
- } else
- util.showTips(res.reason);
- });
- },
- onbottom() {
- var self = this;
- if (self.data.isLoadMore == false) return false;
- setTimeout(function () {
- self.setData({ pageIndex: self.data.pageIndex + 1 });
- self.getlist(true);
- }, 1000);
- },
- radioChange: function (e) {
- if (!this.data.data.meals) return false;
- this.setData({ show:false})
- this.triggerEvent("change", e.detail.value)
- },
- notUse(){
- this.setData({ show: false });
- this.triggerEvent("close", this.data.show);
- this.triggerEvent("change", -1);
- },
- tabsChange(e) {
- let tabStatus = e.currentTarget.dataset.status;
- if (tabStatus == this.data.tabStatus) return false;
- this.setData({ tabStatus, list: [], pageIndex:1});
- this.getlist(false)
- },
- close() {
- this.setData({ show: false });
- this.triggerEvent("close", this.data.show);
- }
- },
- })
|