调整首页样式,增加联通专项业务
This commit is contained in:
247
pages/unicom/unicom.js
Normal file
247
pages/unicom/unicom.js
Normal file
@@ -0,0 +1,247 @@
|
||||
|
||||
const api = require("../../api/api"),
|
||||
app = getApp()
|
||||
|
||||
Page({
|
||||
data: {
|
||||
listArr : [],
|
||||
identity_id : "",
|
||||
permissions : false,
|
||||
year : "",
|
||||
month : "",
|
||||
searchIndex : 0,
|
||||
typeArr : [
|
||||
{id: "" , name:"全部"},
|
||||
{id: "0" , name:"待审核"},
|
||||
{id: "1" , name:"已通过"},
|
||||
{id: "2" , name:"已驳回"}
|
||||
],
|
||||
typeIndex : 0,
|
||||
num : "",
|
||||
settleAmount: "",
|
||||
settleMonth : "",
|
||||
atNum : "",
|
||||
atAmount : "",
|
||||
endDate : "",
|
||||
isNowMonth : false,
|
||||
page : 1,
|
||||
meta : {},
|
||||
isLogin : false
|
||||
},
|
||||
|
||||
// 页面加载
|
||||
onLoad() {
|
||||
const date = new Date()
|
||||
|
||||
let year = date.getFullYear(),
|
||||
month = date.getMonth() + 1
|
||||
|
||||
if(month < 10){
|
||||
month = '0' + month
|
||||
}
|
||||
|
||||
this.setData({
|
||||
identity_id: app.globalData.userInfo.identity_id,
|
||||
permissions: app.globalData.userInfo.perferential,
|
||||
year : year,
|
||||
month : month,
|
||||
endDate : year + "-" + month
|
||||
})
|
||||
},
|
||||
|
||||
// 页面显示
|
||||
onShow(){
|
||||
this.setData({
|
||||
listArr: []
|
||||
})
|
||||
this.welfareList()
|
||||
my.showLoading();
|
||||
my.showNavigationBarLoading();
|
||||
},
|
||||
|
||||
// 列表
|
||||
welfareList(tel){
|
||||
let url = "unicom/lists",
|
||||
dateYear = this.data.year + '-' + this.data.month
|
||||
|
||||
if(this.data.searchIndex == 1){
|
||||
dateYear = "today"
|
||||
} else if(this.data.searchIndex == 2){
|
||||
dateYear = "yesterday"
|
||||
}
|
||||
|
||||
api.request({
|
||||
url : url,
|
||||
header: {
|
||||
"Authorization": app.globalData.token
|
||||
},
|
||||
data : {
|
||||
date : dateYear,
|
||||
mobile : tel || "",
|
||||
status : this.data.typeArr[this.data.typeIndex].id,
|
||||
page : this.data.page
|
||||
}
|
||||
}).then(res=>{
|
||||
let atArr = this.data.listArr,
|
||||
newArr = []
|
||||
|
||||
newArr = atArr.concat(res.data)
|
||||
|
||||
this.setData({
|
||||
listArr : newArr,
|
||||
num : res.num,
|
||||
success : res.success,
|
||||
atNum : res.atNum,
|
||||
atSuccess : res.atSuccess,
|
||||
isNowMonth : res.isNowMonth
|
||||
})
|
||||
my.hideLoading();
|
||||
my.hideNavigationBarLoading();
|
||||
my.stopPullDownRefresh();
|
||||
})
|
||||
},
|
||||
|
||||
// 选择日期
|
||||
selectTime(){
|
||||
my.datePicker({
|
||||
currentDate : this.data.year + "-" + this.data.month,
|
||||
endDate : this.data.endDate,
|
||||
format : "yyyy-MM",
|
||||
success : res=>{
|
||||
let dateString = String(res.date),
|
||||
yearString = dateString.substring(0,4),
|
||||
monthString = dateString.substring(5,7)
|
||||
|
||||
this.setData({
|
||||
year : yearString,
|
||||
month : monthString,
|
||||
page : 1,
|
||||
listArr: []
|
||||
})
|
||||
|
||||
this.welfareList()
|
||||
my.showLoading();
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 筛选日期
|
||||
searchTab(e){
|
||||
this.setData({
|
||||
page : 1,
|
||||
listArr : []
|
||||
})
|
||||
|
||||
if(e.target.dataset.index != this.data.searchIndex){
|
||||
this.setData({
|
||||
searchIndex: e.target.dataset.index
|
||||
})
|
||||
|
||||
this.welfareList()
|
||||
my.showLoading();
|
||||
}
|
||||
|
||||
if(e.target.dataset.index == 0 && !this.data.isNowMonth){
|
||||
const date = new Date()
|
||||
|
||||
let year = date.getFullYear(),
|
||||
month = date.getMonth() + 1
|
||||
|
||||
if(month < 10){
|
||||
month = '0' + month
|
||||
}
|
||||
|
||||
this.setData({
|
||||
year : year,
|
||||
month : month
|
||||
})
|
||||
|
||||
this.welfareList()
|
||||
my.showLoading();
|
||||
}
|
||||
},
|
||||
|
||||
// 类型筛选
|
||||
screenClass(e){
|
||||
this.setData({
|
||||
typeIndex: e.detail.value,
|
||||
page : 1,
|
||||
listArr : []
|
||||
})
|
||||
this.welfareList()
|
||||
my.showLoading();
|
||||
},
|
||||
|
||||
// 搜索手机号码
|
||||
searchForm(e){
|
||||
this.setData({
|
||||
page : 1,
|
||||
listArr : []
|
||||
})
|
||||
|
||||
let tel = e.detail.value.searchValue
|
||||
this.welfareList(tel)
|
||||
},
|
||||
|
||||
// 分页
|
||||
onReachBottom(){
|
||||
let meta = this.data.meta,
|
||||
atPage = this.data.page
|
||||
|
||||
this.setData({
|
||||
isLogin: true
|
||||
})
|
||||
|
||||
if(meta.current_page < meta.last_page){
|
||||
this.setData({
|
||||
page: atPage + 1
|
||||
})
|
||||
this.welfareList()
|
||||
my.showLoading();
|
||||
}
|
||||
},
|
||||
|
||||
// 下拉刷新
|
||||
onPullDownRefresh(){
|
||||
this.setData({
|
||||
listArr : []
|
||||
})
|
||||
this.welfareList()
|
||||
},
|
||||
|
||||
// 取消订单
|
||||
reomveOrder(e){
|
||||
if(e.currentTarget.dataset.id){
|
||||
my.showLoading()
|
||||
api.request({
|
||||
url : "unicom/"+ e.currentTarget.dataset.id +"/cancel",
|
||||
header: {
|
||||
"Authorization": app.globalData.token
|
||||
},
|
||||
method: "POST",
|
||||
}).then(res=>{
|
||||
my.showToast({
|
||||
type : "none",
|
||||
content : res.data.message
|
||||
});
|
||||
my.hideLoading()
|
||||
this.setData({
|
||||
listArr : []
|
||||
})
|
||||
this.welfareList()
|
||||
my.showLoading();
|
||||
}).catch(err => {
|
||||
my.showToast({
|
||||
type : "fail",
|
||||
content: err.data.message
|
||||
})
|
||||
my.hideLoading();
|
||||
})
|
||||
}else{
|
||||
my.showToast({
|
||||
type : "none",
|
||||
content : "订单id不存在"
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user