|
|
|
|
import common from "../../utils/https/common";
|
|
|
|
|
// pages/user/user.js
|
|
|
|
|
import userApi from "../../utils/https/user"
|
|
|
|
|
import util from '../../utils/util'
|
|
|
|
|
import commonApi from "../../utils/https/common"
|
|
|
|
|
let app = getApp()
|
|
|
|
|
Page({
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 页面的初始数据
|
|
|
|
|
*/
|
|
|
|
|
data: {
|
|
|
|
|
height: 0,
|
|
|
|
|
info: null,
|
|
|
|
|
list: [], //待付款列表
|
|
|
|
|
orderList: [],//订单列表
|
|
|
|
|
timeList: [],//倒计时
|
|
|
|
|
timerOut: null,//定时器
|
|
|
|
|
formatTime:[],
|
|
|
|
|
showModel:false
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
|
*/
|
|
|
|
|
onLoad: function (options) {
|
|
|
|
|
let rect = wx.getMenuButtonBoundingClientRect();
|
|
|
|
|
this.setData({
|
|
|
|
|
height: rect.top + rect.height
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
supplier:function(){
|
|
|
|
|
let url = "https://m.cloud.sz-trip.com/ShoppingUnit"
|
|
|
|
|
app.globalData.weburl = "https://m.cloud.sz-trip.com/ShoppingUnit"
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: '/pages/pbService/web/index?weburl='+ encodeURIComponent(url)
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
retail: function () {
|
|
|
|
|
common.user_post('commission/getCommissionUser', {}).then(res => {
|
|
|
|
|
if (res.code == 0) {
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: 'retail/apply/index',
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
else if (res.data.status == 0) {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '正在审核中,请联系管理员',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
else if (res.data.status == 2) {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '审核拒绝,请联系管理员',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
else if (res.data.status == 1) {
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: 'retail/index',
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
closeModel(){
|
|
|
|
|
this.setData({
|
|
|
|
|
showModel:false
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
|
*/
|
|
|
|
|
onReady: function () {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
|
*/
|
|
|
|
|
onShow: function () {
|
|
|
|
|
userApi.user_post("user/getMyInfo").then(res => {
|
|
|
|
|
if (res && res.data) {
|
|
|
|
|
this.setData({
|
|
|
|
|
info: res.data
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
util.pagePoint({
|
|
|
|
|
event:'mine_view'
|
|
|
|
|
},1)
|
|
|
|
|
this.getList()
|
|
|
|
|
app.globalData.isCartBuy = false
|
|
|
|
|
},
|
|
|
|
|
pagePoint: function(e){
|
|
|
|
|
util.pagePoint(e)
|
|
|
|
|
},
|
|
|
|
|
phoneCall:function(){
|
|
|
|
|
this.setData({
|
|
|
|
|
showModel:true
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
getList:function(){
|
|
|
|
|
commonApi.user_post("order/list",{
|
|
|
|
|
state:'WAIT_PAYMENT',
|
|
|
|
|
offset:0,
|
|
|
|
|
limit:10,
|
|
|
|
|
keywords:''
|
|
|
|
|
}).then(res=>{
|
|
|
|
|
console.log(res);
|
|
|
|
|
|
|
|
|
|
if (res && res.data && res.data.length>0){
|
|
|
|
|
let arr = []
|
|
|
|
|
let trr = []
|
|
|
|
|
let yrr = []
|
|
|
|
|
let reslist = res.data.list
|
|
|
|
|
this.setData({})
|
|
|
|
|
let nowDateTime = parseInt(new Date().getTime() / 1000)
|
|
|
|
|
for (let i = 0; i < reslist.length; i++) {
|
|
|
|
|
let del = nowDateTime - this.strtotime(reslist[i].create_time)
|
|
|
|
|
if (del < reslist[i].auto_close_time) {
|
|
|
|
|
trr.push(reslist[i].auto_close_time - del)
|
|
|
|
|
yrr.push(this.formatSeconds(reslist[i].auto_close_time - del))
|
|
|
|
|
arr.push(reslist[i].order_product_list[0])
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.setData({
|
|
|
|
|
list: arr,
|
|
|
|
|
orderList: reslist,
|
|
|
|
|
timeList: trr,
|
|
|
|
|
formatTime:yrr
|
|
|
|
|
})
|
|
|
|
|
this.timer(this.data.timeList)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
strtotime(str) {
|
|
|
|
|
var _arr = str.split(' ');
|
|
|
|
|
var _day = _arr[0].split('-');
|
|
|
|
|
_arr[1] = (_arr[1] == null) ? '0:0:0' : _arr[1];
|
|
|
|
|
var _time = _arr[1].split(':');
|
|
|
|
|
for (let i = _day.length - 1; i >= 0; i--) {
|
|
|
|
|
_day[i] = isNaN(parseInt(_day[i])) ? 0 : parseInt(_day[i]);
|
|
|
|
|
}
|
|
|
|
|
for (let i = _time.length - 1; i >= 0; i--) {
|
|
|
|
|
_time[i] = isNaN(parseInt(_time[i])) ? 0 : parseInt(_time[i]);
|
|
|
|
|
}
|
|
|
|
|
let _temp = new Date(_day[0], _day[1] - 1, _day[2], _time[0], _time[1], _time[2]);
|
|
|
|
|
return _temp.getTime() / 1000;
|
|
|
|
|
},
|
|
|
|
|
formatSeconds(value) {
|
|
|
|
|
let secondTime = parseInt(value);
|
|
|
|
|
let minuteTime = 0;
|
|
|
|
|
let hourTime = 0;
|
|
|
|
|
if (secondTime >= 60) {
|
|
|
|
|
minuteTime = parseInt(secondTime / 60);
|
|
|
|
|
secondTime = parseInt(secondTime % 60);
|
|
|
|
|
if (minuteTime >= 60) {
|
|
|
|
|
hourTime = parseInt(minuteTime / 60);
|
|
|
|
|
minuteTime = parseInt(minuteTime % 60);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 补0
|
|
|
|
|
hourTime = hourTime < 10 ? "0" + hourTime : hourTime;
|
|
|
|
|
minuteTime = minuteTime < 10 ? "0" + minuteTime : minuteTime;
|
|
|
|
|
secondTime = secondTime < 10 ? "0" + secondTime : secondTime;
|
|
|
|
|
let res = hourTime + ":" + minuteTime + ":" + secondTime;
|
|
|
|
|
return res;
|
|
|
|
|
},
|
|
|
|
|
timer(arr) {
|
|
|
|
|
let trr = []
|
|
|
|
|
let list = this.data.list
|
|
|
|
|
this.data.timerOut = setInterval(() => {
|
|
|
|
|
for (let i = 0; i < arr.length; i++) {
|
|
|
|
|
arr[i]--
|
|
|
|
|
trr[i] = this.formatSeconds(arr[i])
|
|
|
|
|
if (arr[i] == 0) {
|
|
|
|
|
arr.splice(i, 1)
|
|
|
|
|
list.splice(i, 1)
|
|
|
|
|
trr.splice(i, 1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.setData({
|
|
|
|
|
timeList: arr,
|
|
|
|
|
formatTime:trr,
|
|
|
|
|
list:list
|
|
|
|
|
})
|
|
|
|
|
}, 1000)
|
|
|
|
|
},
|
|
|
|
|
gotoDetail:function(e){
|
|
|
|
|
let item = e.currentTarget.dataset.item;
|
|
|
|
|
console.log(item);
|
|
|
|
|
item = this.getChild(item)
|
|
|
|
|
util.gotoOrder(item)
|
|
|
|
|
},
|
|
|
|
|
getChild(list){
|
|
|
|
|
console.log(list);
|
|
|
|
|
let arr = {order_product_list:[]}
|
|
|
|
|
for (let i = 0; i < list.order_product_list.length; i++) {
|
|
|
|
|
if (list.order_product_list[i].product_model=="ticket") {
|
|
|
|
|
arr.order_product_list.push(list.order_product_list[i])
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (arr.order_product_list.length>0) {
|
|
|
|
|
list.order_product_list = []
|
|
|
|
|
list.order_product_list.push(arr.order_product_list[0])
|
|
|
|
|
console.log(list);
|
|
|
|
|
return list
|
|
|
|
|
}else{
|
|
|
|
|
return list
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
|
*/
|
|
|
|
|
onHide: function () {
|
|
|
|
|
let that = this
|
|
|
|
|
clearInterval(that.data.timerOut);
|
|
|
|
|
this.setData({
|
|
|
|
|
list: [], //待付款列表
|
|
|
|
|
orderList: [],//订单列表
|
|
|
|
|
timeList: [],//倒计时
|
|
|
|
|
formatTime:[]
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
|
*/
|
|
|
|
|
onUnload: function () {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
|
*/
|
|
|
|
|
onPullDownRefresh: function () {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
|
*/
|
|
|
|
|
onReachBottom: function () {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
})
|