You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
255 lines
6.0 KiB
255 lines
6.0 KiB
// pages/user/order/list.js
|
|
import commonApi from "../../../utils/https/common"
|
|
import util from "../../../utils/util"
|
|
let app = getApp()
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
list:[],
|
|
keywords:"",
|
|
orderState:app.globalData.orderState,
|
|
type:"",
|
|
lon:"",
|
|
lat:""
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.setData({
|
|
type:options.type
|
|
})
|
|
wx.getLocation({
|
|
type: 'gcj02',
|
|
success: (r)=>{
|
|
this.setData({
|
|
lon:r.longitude,
|
|
lat:r.latitude
|
|
})
|
|
this.getList();
|
|
}
|
|
})
|
|
|
|
},
|
|
gotoWeb:function(e){
|
|
let web = e.currentTarget.dataset.web;
|
|
app.globalData.weburl = web;
|
|
wx.navigateTo({
|
|
url: '/pages/pbService/web/index',
|
|
})
|
|
},
|
|
changeKeyword:function(e){
|
|
this.setData({
|
|
keywords:e.detail.value
|
|
})
|
|
},
|
|
refundInfo:function(e){
|
|
let id = e.currentTarget.dataset.id;
|
|
wx.navigateTo({
|
|
url: 'refundInfo/index?id='+id,
|
|
})
|
|
},
|
|
gotoComment:function(e){
|
|
let id = e.currentTarget.dataset.id;
|
|
wx.navigateTo({
|
|
url: '/pages/order/comment/index?id='+id,
|
|
})
|
|
},
|
|
// 再次预定
|
|
order:function(e){
|
|
let item = e.currentTarget.dataset.item;
|
|
util.orderMoreTime(item)
|
|
},
|
|
pay:function(e){
|
|
let id = e.currentTarget.dataset.id;
|
|
wx.navigateTo({
|
|
url: '/pages/order/pay/index?id='+id,
|
|
})
|
|
},
|
|
search:function(){
|
|
this.setData({
|
|
realKeyword:this.data.keywords,
|
|
list:[],
|
|
total:1
|
|
})
|
|
this.getList()
|
|
},
|
|
getList:function(){
|
|
let list = this.data.list;
|
|
if(list.length>=this.data.total) return;
|
|
commonApi.user_post("order/list",{
|
|
state:this.data.type,
|
|
offset:this.data.list.length,
|
|
limit:10,
|
|
keywords:this.data.keywords
|
|
}).then(res=>{
|
|
let ajaxes = [],indexes=[]
|
|
res.data.list.map((item,index)=>{
|
|
let orderNum = 0;
|
|
item.order_product_list.map(order=>{
|
|
orderNum = orderNum + order.product_num;
|
|
// 景点线路场馆酒店四类产品的订单 如果是已支付未出票的显示出票中
|
|
if(order.state=='PAID' && (order.product_model=='venue' || order.product_model=='ticket' || order.product_model=='hotel' || order.product_model=='line')){
|
|
item.orderStateText="出票中"
|
|
}
|
|
})
|
|
if(item.order_product_list.length==1 && item.order_product_list[0].scene_id && item.state!='UNPAID' && item.state!='CLOSED' && item.state.indexOf("REFUND")==-1 && this.data.lon && this.data.lat){
|
|
let ajax = commonApi.user_post("order/tripplan",{
|
|
point_type: "gd",
|
|
child_order_id:item.order_product_list[0].child_order_id,
|
|
lat:this.data.lat,
|
|
lon:this.data.lon
|
|
})
|
|
ajaxes.push(ajax);
|
|
indexes.push(index);
|
|
}
|
|
item.orderNum = orderNum;
|
|
})
|
|
console.log(ajaxes)
|
|
if(ajaxes.length==0){
|
|
this.setData({
|
|
total:res.data.total,
|
|
list:list.concat(res.data.list)
|
|
})
|
|
return;
|
|
}
|
|
Promise.all(ajaxes).then((r)=>{
|
|
r.map((item,index)=>{
|
|
if(item && item.data && item.data.url){
|
|
res.data.list[indexes[index]].guihuaUrl = item.data.url
|
|
}
|
|
})
|
|
this.setData({
|
|
total:res.data.total,
|
|
list:list.concat(res.data.list)
|
|
})
|
|
})
|
|
|
|
})
|
|
},
|
|
gotoDetail:function(e){
|
|
let item = e.currentTarget.dataset.item;
|
|
util.gotoOrder(item)
|
|
},
|
|
gotoProductDetail:function(e){
|
|
let item = e.currentTarget.dataset.item;
|
|
util.orderMoreTime({order_product_list:[item]})
|
|
},
|
|
changeType:function(e){
|
|
let type = e.currentTarget.dataset.type;
|
|
this.setData({
|
|
type:type,
|
|
list:[],
|
|
total:1
|
|
})
|
|
this.getList()
|
|
},
|
|
refund:function(e){
|
|
let index = e.currentTarget.dataset.index,list = this.data.list,item = list[index],that = this;
|
|
wx.showModal({
|
|
title:"提示",
|
|
content:"确定取消吗?",
|
|
success:function(res){
|
|
if(res.confirm){
|
|
// 确定取消
|
|
commonApi.user_post("order/refund",{
|
|
order_id:item.order_id
|
|
}).then(res=>{
|
|
if(res.code==1){
|
|
wx.showToast({
|
|
title: '已取消',
|
|
icon:'success'
|
|
})
|
|
if(that.data.type){
|
|
list.splice(index,1);
|
|
}
|
|
else {
|
|
list[index].state='WAIT_REFUND';
|
|
}
|
|
that.setData({
|
|
list:list
|
|
})
|
|
}
|
|
})
|
|
}
|
|
}
|
|
})
|
|
},
|
|
cancel:function(e){
|
|
let index = e.currentTarget.dataset.index,list = this.data.list,item = list[index],that = this;
|
|
wx.showModal({
|
|
title:"提示",
|
|
content:"确定取消吗?",
|
|
success:function(res){
|
|
if(res.confirm){
|
|
// 确定取消
|
|
commonApi.user_post("order/close",{
|
|
order_id:item.order_id
|
|
}).then(res=>{
|
|
if(res.code==1){
|
|
wx.showToast({
|
|
title: '已取消',
|
|
icon:'success'
|
|
})
|
|
if(that.data.type){
|
|
list.splice(index,1);
|
|
}
|
|
else {
|
|
list[index].state='CLOSED';
|
|
}
|
|
that.setData({
|
|
list:list
|
|
})
|
|
}
|
|
})
|
|
}
|
|
}
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
this.getList()
|
|
}
|
|
})
|