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.
228 lines
5.8 KiB
228 lines
5.8 KiB
// pages/user/user.js
|
|
import common from "../../utils/https/common";
|
|
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,
|
|
dfkTotal: 0, // 待付款总数
|
|
isShowGroup: false // 是否显示团购
|
|
},
|
|
|
|
onLoad: function (options) {
|
|
let rect = wx.getMenuButtonBoundingClientRect();
|
|
this.setData({
|
|
height: rect.top + rect.height
|
|
})
|
|
|
|
// 获取是否显示团购入口
|
|
common.user_post('multimedia/detail', { id: 2579 }).then(res => {
|
|
if (res && res.data) {
|
|
this.setData({
|
|
isShowGroup: res.data.company_name == 1
|
|
})
|
|
}
|
|
})
|
|
},
|
|
|
|
onShow: function () {
|
|
userApi.user_post("user/getMyInfo").then(res => {
|
|
if (res && res.data) {
|
|
this.setData({
|
|
info: res.data
|
|
})
|
|
} else {
|
|
this.setData({ info: null })
|
|
}
|
|
})
|
|
util.pagePoint({ event: 'mine_view' }, 1)
|
|
this.getList()
|
|
app.globalData.isCartBuy = false
|
|
},
|
|
|
|
pagePoint: function (e) {
|
|
let event = e.currentTarget ? e.currentTarget.dataset.event : e;
|
|
util.pagePoint({ event: event })
|
|
},
|
|
|
|
// 人工客服
|
|
phoneCall: function () {
|
|
this.setData({
|
|
showModel: true
|
|
})
|
|
},
|
|
|
|
closeModel() {
|
|
this.setData({
|
|
showModel: false
|
|
})
|
|
},
|
|
|
|
// 防止冒泡
|
|
stopBubble: function() {},
|
|
|
|
// 商户入驻
|
|
supplier: function () {
|
|
let url = "https://m.cloud.sz-trip.com/ShoppingUnit"
|
|
app.globalData.weburl = url
|
|
wx.navigateTo({
|
|
url: '/pages/pbService/web/index?weburl=' + encodeURIComponent(url)
|
|
})
|
|
},
|
|
|
|
// 获取待付款列表
|
|
getList: function () {
|
|
commonApi.user_post("order/list", {
|
|
state: 'WAIT_PAYMENT',
|
|
offset: 0,
|
|
limit: 10,
|
|
keywords: ''
|
|
}).then(res => {
|
|
if (res && res.data) {
|
|
let arr = []
|
|
let trr = []
|
|
let yrr = []
|
|
let reslist = res.data.list || []
|
|
|
|
// 设置总数
|
|
this.setData({ dfkTotal: res.data.total || 0 })
|
|
|
|
if (reslist.length > 0) {
|
|
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)
|
|
} else {
|
|
this.setData({
|
|
list: [],
|
|
orderList: [],
|
|
timeList: [],
|
|
formatTime: []
|
|
})
|
|
}
|
|
}
|
|
})
|
|
},
|
|
|
|
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);
|
|
}
|
|
}
|
|
hourTime = hourTime < 10 ? "0" + hourTime : hourTime;
|
|
minuteTime = minuteTime < 10 ? "0" + minuteTime : minuteTime;
|
|
secondTime = secondTime < 10 ? "0" + secondTime : secondTime;
|
|
return hourTime + ":" + minuteTime + ":" + secondTime;
|
|
},
|
|
|
|
timer(arr) {
|
|
clearInterval(this.data.timerOut);
|
|
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)
|
|
i--
|
|
}
|
|
}
|
|
this.setData({
|
|
timeList: arr,
|
|
formatTime: trr,
|
|
list: list
|
|
})
|
|
if (arr.length === 0) {
|
|
clearInterval(this.data.timerOut);
|
|
}
|
|
}, 1000)
|
|
},
|
|
|
|
gotoDetail: function (e) {
|
|
let item = e.currentTarget.dataset.item;
|
|
item = this.getChild(item)
|
|
util.gotoOrder(item)
|
|
},
|
|
|
|
getChild(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])
|
|
return list
|
|
} else {
|
|
return list
|
|
}
|
|
},
|
|
|
|
onHide: function () {
|
|
let that = this
|
|
clearInterval(that.data.timerOut);
|
|
this.setData({
|
|
list: [],
|
|
orderList: [],
|
|
timeList: [],
|
|
formatTime: []
|
|
})
|
|
},
|
|
|
|
onPullDownRefresh: function () {
|
|
this.onShow();
|
|
wx.stopPullDownRefresh();
|
|
},
|
|
|
|
onReachBottom: function () { }
|
|
})
|
|
|