123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 |
- const util = require('../../../utils/util.js');
- const app = getApp();
- Page({
- data: {
- img: util.config.imgPath,
- queryData: {
- otype: 0,
- pageIndex: 1,
- pageSize: 20
- },
- stat: {},
- list: [],
- loadMore: true,
- modalInfo: {
- show: false,
- aid: '',
- orderid: ''
- },
- // ——inviteFbtn 是否显示邀请海报按钮
- },
- onLoad(options) {
- console.log(options)
- this.data.queryData.otype = options.otype || 0;
- this.setData({
- queryData: this.data.queryData
- });
- },
- onShow() {
- this.stat();
- this.getList(false);
- },
- setTabbar(e) {
- let index = e.currentTarget.dataset.index;
- this.data.queryData.otype = index;
- this.data.queryData.pageIndex = 1;
- this.setData({
- queryData: this.data.queryData,
- list: []
- });
- this.getList(true);
- },
- stat() {
- let that = this;
- util.ajax({
- func: 'v2/user/stat',
- load: false
- }, data => {
- if (data.code == 0) {
- that.setData({
- stat: data.data
- });
- }
- });
- },
- getList(load) {
- let that = this;
- util.ajax({
- func: "v2/order/list",
- data: that.data.queryData,
- load: load
- }, function (res) {
- if (res.code == 0) {
- let newData = res.data.list || [];
- if (newData.length > 0) {
- newData.forEach(el => {
- if (el.presellPaymentDeadline && el.presellPaymentDeadline > 0) {
- el.failureTime = util.formatDate(util.formatUnixtimestamp(el.presellPaymentDeadline), 'MM月dd日 hh:mm', false);
- }
- el.timeContrast = util.timeContrast(el.stopBuy);
- });
- }
- let loadMore = true,
- oldData = !load ? newData : [...that.data.list, ...newData];
- if (newData.length < that.data.queryData.pageSize && oldData.length > that.data.queryData.pageSize) loadMore = false;
- that.setData({
- list: oldData,
- loadMore
- });
- } else
- util.showTips(res.reason);
- });
- },
- cancelOrder(e) {
- let that = this,
- orderid = e.currentTarget.dataset.orderid;
- util.ajax({
- func: "order/cancel",
- data: {
- orderid
- }
- }, function (res) {
- if (res.code == 0) {
- that.data.queryData.pageIndex = 1;
- that.setData({
- queryData: that.data.queryData
- });
- that.getList(false);
- } else {
- util.showTips(res.reason);
- }
- })
- },
- cancelRefund(e) {
- let that = this,
- orderid = e.currentTarget.dataset.orderid;
- util.ajax({
- func: "order/cancel_refund",
- data: {
- orderid,
- password: ''
- }
- }, function (res) {
- if (res.code == 0) {
- that.data.queryData.pageIndex = 1;
- that.setData({
- queryData: that.data.queryData
- });
- that.getList(false);
- } else {
- util.showTips(res.reason);
- }
- })
- },
- comment(e) {
- let orderid = e.currentTarget.dataset.orderid;
- wx.navigateTo({
- url: '/pages/order/comment/comment?orderid=' + orderid + '&otype=' + this.data.queryData.otype,
- })
- },
- // 跳转至表单详情页(支付尾款)
- jumpBalancePayment(e) {
- console.log(e)
- let data = e.currentTarget.dataset;
- wx.navigateTo({
- url: '/pages/product/balancePayment/balancePayment?aid=' + data.aid + '&otype=' + data.otype + '&orderid=' + data.orderid + '&presellstatus=' + data.presellstatus + '&campsex=' + data.campsex + '&military=' + data.military,
- })
- },
- // 立即支付(支付尾款) --待付款状态
- pay(e) {
- let that = this;
- console.log(e)
- let presellstatus = e.currentTarget.dataset.presellstatus;
- util.WXPay({
- orderid: e.target.dataset.orderid,
- btype: presellstatus == 2 ? 0 : presellstatus
- }, that.data.aid, that.data.title).then(function () {
- that.getList(false);
- }, function (res) {
- if (res.code != 0) util.showTips(res.reason);
- });
- },
- errorImg(e) {
- this.data.list[e.currentTarget.dataset.index].logo = "/images/noimg.png";
- this.setData({
- list: this.data.list
- });
- },
- onPullDownRefresh() {
- var self = this;
- wx.showNavigationBarLoading();
- setTimeout(function () {
- self.data.queryData.pageIndex = 1;
- self.setData({
- queryData: self.data.queryData
- });
- self.getList(false);
- wx.hideNavigationBarLoading();
- wx.stopPullDownRefresh();
- }, 1000);
- },
- onReachBottom() {
- var self = this;
- if (self.data.loadMore == false) return false;
- setTimeout(function () {
- self.data.queryData.pageIndex = self.data.queryData.pageIndex + 1;
- self.setData({
- queryData: self.data.queryData
- });
- self.getList(true);
- }, 1000);
- },
- // 邀请拼团
- inviteGroup(ev) {
- console.log(ev)
- let data = ev.currentTarget.dataset.info;
- let obj = {
- show: true,
- aid: data.aid,
- orderid: data.orderid,
- sid: data.sid,
- pid: data.pid,
- logo: data.logo,
- title: data.atitle,
- status: data.status,
- invite: app.globalData.userInfo.code,
- from: 'button',
- sharer: app.globalData.userInfo.nickname,
- groupbook: data.groupbook,
- invitefbtn: ev.currentTarget.dataset.invitefbtn == '0' ? true : false
- }
- if (!util.isEmpty(data.groupid) && data.groupid != 'null' && data.groupid != 'undefined' && data.status != 15) {
- obj.groupid = data.groupid
- }
- this.setData({
- modalInfo: obj
- })
- },
- onShareAppMessage() {
- console.log(this.data.modalInfo)
- let title = '个人订单信息',
- url = '/pages/index/order',
- logo = "../images/share.png";
- if (this.data.modalInfo.from === 'button') {
- let data = this.data.modalInfo,
- str = [];
- if (!util.isEmpty(data.sid) && !util.isEmpty(data.pid) && util.isEmpty(data.groupid)) {
- title = data.sharer + '已报名并邀请你一起参与' + data.title;
- } else {
- title = "约吗?快来和我家孩子一起拼团挑战" + data.title;
- }
- str.push('aid=' + data.aid)
- str.push('orderid=' + data.orderid)
- str.push('invite=' + data.invite)
- str.push('sharesid=' + data.sid)
- str.push('sharepid=' + data.pid)
- str.push('sharer=' + data.sharer)
- if (!util.isEmpty(data.groupid) && data.groupid != 'null' && data.groupid != 'undefined' && data.groupbook == 1) {
- str.push('groupid=' + data.groupid)
- }
- url = "/pages/product/activity/index?" + str.join('&');
- logo = data.logo.indexOf("noimg.png") == -1 ? data.logo + '@!logo' : logo;
- }
- console.log(url)
- return {
- title: title,
- path: url,
- imageUrl: logo
- }
- },
- })
|