This repository has been archived on 2024-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
yoshop-wechat/pages/sharing/order/refund/index.js

174 lines
3.6 KiB
JavaScript
Raw Normal View History

2020-04-25 22:59:04 +08:00
const App = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
applyStatus: [],
dataType: -1,
2020-04-25 23:04:41 +08:00
submsgSetting: {}, // 订阅消息配置
list: [], // 列表数据
page: 1, // 当前页码
isLoading: true, // 是否正在加载中
isLastPage: false, // 当前是最后一页
2020-04-25 22:59:04 +08:00
},
/**
* 生命周期函数--监听页面加载
*/
2020-04-25 23:04:41 +08:00
onLoad(options) {
let _this = this;
2020-04-25 22:59:04 +08:00
// 设置swiper的高度
2020-04-25 23:04:41 +08:00
_this.setSwiperHeight();
// 获取订阅消息配置
_this.getSubmsgSetting();
2020-04-25 22:59:04 +08:00
},
/**
* 生命周期函数--监听页面显示
*/
2020-04-25 23:04:41 +08:00
onShow() {
let _this = this;
2020-04-25 22:59:04 +08:00
// 获取退款/售后单列表
2020-04-25 23:04:41 +08:00
_this.getRefundList();
2020-04-25 22:59:04 +08:00
},
/**
* 获取退款/售后单列表
*/
2020-04-25 23:04:41 +08:00
getRefundList(isNextPage, page) {
2020-04-25 22:59:04 +08:00
let _this = this;
App._get('sharing.refund/lists', {
state: _this.data.dataType,
page: page || 1,
2020-04-25 23:04:41 +08:00
}, (result) => {
2020-04-25 22:59:04 +08:00
// 创建页面数据
_this.setData(_this.createData(result.data, isNextPage));
});
},
2020-04-25 23:04:41 +08:00
/**
* 获取订阅消息配置
*/
getSubmsgSetting() {
let _this = this;
App._get('wxapp.submsg/setting', {}, (result) => {
_this.setData({
submsgSetting: result.data.setting
});
});
},
2020-04-25 22:59:04 +08:00
/**
* 创建页面数据
*/
2020-04-25 23:04:41 +08:00
createData(data, isNextPage) {
2020-04-25 22:59:04 +08:00
data['isLoading'] = false;
// 列表数据
let dataList = this.data.list;
if (isNextPage == true && (typeof dataList !== 'undefined')) {
data.list.data = dataList.data.concat(data.list.data)
}
// 导航栏数据
data['tabList'] = [{
value: -1,
text: '全部'
}, {
value: 0,
text: '待处理'
}];
return data;
},
/**
* 设置swiper的高度
*/
2020-04-25 23:04:41 +08:00
setSwiperHeight() {
2020-04-25 22:59:04 +08:00
// 获取系统信息(拿到屏幕宽度)
let systemInfo = wx.getSystemInfoSync(),
rpx = systemInfo.windowWidth / 750, // 计算rpx
tapHeight = Math.floor(rpx * 82), // tap高度
swiperHeight = systemInfo.windowHeight - tapHeight; // swiper高度
this.setData({
swiperHeight
});
},
/**
* 点击tab切换
*/
2020-04-25 23:04:41 +08:00
swichNav(e) {
2020-04-25 22:59:04 +08:00
let _this = this,
current = e.target.dataset.current;
if (_this.data.dataType == current) {
return false;
}
_this.setData({
dataType: current,
list: {},
page: 1,
2020-04-25 23:04:41 +08:00
isLastPage: false,
2020-04-25 22:59:04 +08:00
isLoading: true,
2020-04-25 23:04:41 +08:00
}, () => {
2020-04-25 22:59:04 +08:00
// 获取退款/售后单列表
_this.getRefundList();
});
},
/**
* 下拉到底加载数据
*/
2020-04-25 23:04:41 +08:00
onPageDown() {
let _this = this;
2020-04-25 22:59:04 +08:00
// 已经是最后一页
2020-04-25 23:04:41 +08:00
if (_this.data.page >= _this.data.list.last_page) {
_this.setData({
isLastPage: true
2020-04-25 22:59:04 +08:00
});
return false;
}
// 获取退款/售后单列表
2020-04-25 23:04:41 +08:00
_this.getRefundList(true, ++_this.data.page);
2020-04-25 22:59:04 +08:00
},
/**
* 跳转售后详情页
*/
2020-04-25 23:04:41 +08:00
onTargetDetail(e) {
let _this = this;
// 跳转售后详情页
const onCallback = () => {
wx.navigateTo({
url: `./detail/detail?order_refund_id=${e.currentTarget.dataset.id}`
});
};
// 请求用户订阅消息
_this._onRequestSubscribeMessage(onCallback);
},
/**
* 订阅消息 => [售后状态通知]
*/
_onRequestSubscribeMessage(callback) {
let _this = this;
let tmplItem = _this.data.submsgSetting.order.refund.template_id;
2020-08-28 10:49:15 +08:00
if (tmplItem.length == 0) {
callback && callback();
return;
2020-04-25 23:04:41 +08:00
}
2020-08-28 10:49:15 +08:00
wx.requestSubscribeMessage({
tmplIds: [tmplItem],
success(res) {},
fail(res) {},
complete(res) {
callback && callback();
},
});
2020-04-25 22:59:04 +08:00
},
})