123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637 |
- // pages/ordermanage/ordermanage.js
- const app = getApp();
- const api = require('../../api/api');
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- navbarData: {
- showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示
- title: '订单管理', //导航栏 中间的标题,
- capsuleMode: 'navBack', //显示模式(navBack:返回上一页;navHome:返回首页)
- },
- ordertabs: [
- "全部", "待支付", "待收货", "已完成", "退款/售后"
- ],
- orderindex: 0,
- // 组件参数
- showOneClickNotice: false,
- oneClickNoticeActions: [{
- name: '发送取货通知',
- subname: '通知所有已付款用户取货',
- className: 'actions-first-child'
- },
- {
- name: '通知付款',
- subname: '通知所有未付款订单用户付款'
- }
- ],
- showUpdateState: false,
- updateStateActions: [{
- name: '团员已支付',
- className: 'actions-first-child'
- },
- {
- name: '团员已取货',
- }
- ],
- pintuan: [], //拼团列表
- pintuandetail: {}, //拼团详情
- order_list: [], //拼团订单列表
- order_info: {}, //订单信息
- updateStatusID: 0, //更新状态id
- code_result: '', //扫码返回结果
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- let that = this;
- wx.showLoading({
- title: '加载中',
- mask: true
- })
- wx.request({
- url: api.OrderManagement_selection,
- header: {
- 'Authorization': wx.getStorageSync('token')
- },
- method: 'POST',
- success(res) {
- console.log(res);
- if (res.data.code === 1) {
- that.setData({
- pintuan: res.data.data,
- pintuandetail: res.data.data[0]
- })
- that.getOrderList()
- } else {
- wx.showToast({
- title: res.data.msg,
- mask: true,
- icon: 'none'
- })
- }
- },
- fail(err) {
- wx.showToast({
- title: '发起网络请求失败',
- icon: 'none',
- mask: true
- })
- },
- complete() {
- wx.hideLoading()
- }
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- let that = this;
- let result = wx.getStorageSync('pintuan');
- if (result !== null) {
- this.setData({
- pintuandetail: result
- })
- wx.setStorageSync('pintuan', null)
- this.getOrderList()
- }
- if (that.data.code_result != '') {
- wx.showLoading({
- title: '扫码成功',
- mask: true
- })
- wx.request({
- url: api.Orderwrite,
- header: {
- 'Authorization': wx.getStorageSync('token')
- },
- data: {
- card_number: that.data.code_result,
- write_method: 0
- },
- method: 'POST',
- success(res) {
- wx.hideLoading()
- console.log(res);
- if (res.data.code === 1) {
- wx.showToast({
- title: '核销成功',
- })
- } else {
- wx.showToast({
- title: res.data.msg,
- mask: true,
- icon: 'none'
- })
- }
- },
- fail(err) {
- wx.hideLoading()
- wx.showToast({
- title: '发起网络请求失败',
- icon: 'none',
- mask: true
- })
- },
- complete() {
- that.setData({
- code_result: ''
- })
- // wx.hideLoading()
- }
- })
- }
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
- saoma() {
- wx.navigateTo({
- url: '/pages/verify/verify',
- })
- },
- // 页面跳转
- navToPage(e) {
- wx.navigateTo({
- url: e.currentTarget.dataset.url
- })
- },
- // 打开一键通知动作面板
- openOneClickNotice() {
- this.setData({
- showOneClickNotice: true
- })
- },
- // 关闭一键通知动作面板
- closeOneClickNotice() {
- this.setData({
- showOneClickNotice: false
- })
- },
- // 点击一键通知动作面板
- selectOneClickNotice(e) {
- let that = this;
- // this.setData({
- // showOneClickNotice: false
- // })
- if (e.detail.name == "发送取货通知") {
- wx.requestSubscribeMessage({
- tmplIds: ['hlRN3O8Ekh9oD10KK2Jt5_lT9zExhVVrYwi0ZHFy7Ss'],
- success(res) {
- console.log(res);
- wx.showLoading({
- title: '加载中',
- mask: true
- })
- wx.request({
- url: api.OrderManagement_pick_notice,
- header: {
- 'Authorization': wx.getStorageSync('token')
- },
- method: 'POST',
- data: {
- id: that.data.pintuandetail.id
- },
- success(res) {
- console.log(res);
- wx.hideLoading()
- if (res.data.code === 1) {
- wx.showToast({
- title: '发送成功',
- mask: true,
- success() {
- that.setData({
- showOneClickNotice: false
- })
- }
- })
- } else {
- wx.showToast({
- title: res.data.msg,
- mask: true,
- icon: 'none'
- })
- }
- },
- fail(err) {
- wx.hideLoading()
- wx.showToast({
- title: '发起网络请求失败',
- icon: 'none',
- mask: true
- })
- },
- complete() {
- // wx.hideLoading()
- }
- })
- }
- })
- } else if (e.detail.name == "通知付款") {
- wx.requestSubscribeMessage({
- tmplIds: ['0WYHpnlcJssWBW_725kZuDqw5Z6DBt8dCwjU2fQ9574'],
- success(res) {
- wx.showLoading({
- title: '加载中',
- mask: true
- })
- wx.request({
- url: api.OrderManagement_payment_order,
- header: {
- 'Authorization': wx.getStorageSync('token')
- },
- method: 'POST',
- data: {
- id: that.data.pintuandetail.id
- },
- success(res) {
- wx.hideLoading()
- console.log(res);
- if (res.data.code === 1) {
- wx.showToast({
- title: '发送成功',
- mask: true,
- success() {
- that.setData({
- showOneClickNotice: false
- })
- }
- })
- } else {
- wx.showToast({
- title: res.data.msg,
- mask: true,
- icon: 'none'
- })
- }
- },
- fail(err) {
- wx.hideLoading()
- wx.showToast({
- title: '发起网络请求失败',
- icon: 'none',
- mask: true
- })
- },
- complete() {
- // wx.hideLoading()
- }
- })
- }
- })
- }
- },
- // 打开更新状态动作面板
- openUpdateState() {
- this.setData({
- showUpdateState: true
- })
- },
- // 关闭更新状态动作面板
- closeUpdateState() {
- this.setData({
- showUpdateState: false
- })
- },
- // 点击更新状态动作面板
- selectUpdateState(e) {
- // console.log(e.detail.name);
- let that = this;
- if (e.detail.name == '团员已支付') {
- wx.showLoading({
- title: '加载中',
- mask: true
- })
- wx.request({
- url: api.OrderManagement_paid,
- header: {
- 'Authorization': wx.getStorageSync('token')
- },
- method: 'POST',
- data: {
- id: that.data.updateStatusID
- },
- success(res) {
- wx.hideLoading()
- console.log(res);
- if (res.data.code === 1) {
- wx.showToast({
- title: '发送成功',
- mask: true,
- success() {
- that.setData({
- showUpdateState: false
- })
- that.getOrderList()
- }
- })
- } else {
- wx.showToast({
- title: res.data.msg,
- mask: true,
- icon: 'none'
- })
- }
- },
- fail(err) {
- wx.hideLoading()
- wx.showToast({
- title: '发起网络请求失败',
- icon: 'none',
- mask: true
- })
- },
- complete() {
- // wx.hideLoading()
- }
- })
- } else if (e.detail.name == '团员已取货') {
- wx.showLoading({
- title: '加载中',
- mask: true
- })
- wx.request({
- url: api.OrderManagement_picked_up,
- header: {
- 'Authorization': wx.getStorageSync('token')
- },
- method: 'POST',
- data: {
- id: that.data.updateStatusID
- },
- success(res) {
- wx.hideLoading()
- console.log(res);
- if (res.data.code === 1) {
- wx.showToast({
- title: '发送成功',
- mask: true,
- success() {
- that.setData({
- showUpdateState: false
- })
- that.getOrderList()
- }
- })
- } else {
- wx.showToast({
- title: res.data.msg,
- mask: true,
- icon: 'none'
- })
- }
- },
- fail(err) {
- wx.hideLoading()
- wx.showToast({
- title: '发起网络请求失败',
- icon: 'none',
- mask: true
- })
- },
- complete() {
- // wx.hideLoading()
- }
- })
- }
- },
- // 跳转选择拼团
- navToSelectPinTuan() {
- wx.navigateTo({
- url: '/pages/pintuanchoose/pintuanchoose',
- })
- },
- // 获取订单列表
- getOrderList() {
- let that = this;
- wx.showLoading({
- title: '加载中',
- mask: true
- })
- wx.request({
- url: api.OrderManagement_list,
- header: {
- 'Authorization': wx.getStorageSync('token')
- },
- data: {
- id: that.data.pintuandetail.id
- },
- method: 'POST',
- success(res) {
- console.log(res);
- if (res.data.code === 1) {
- if (res.data.data == null) {
- that.setData({
- order_list: [],
- order_info: {}
- })
- } else {
- that.setData({
- order_list: res.data.data.order_list,
- order_info: res.data.data.order_info
- })
- }
- } else {
- wx.showToast({
- title: res.data.msg,
- mask: true,
- icon: 'none'
- })
- }
- },
- fail(err) {
- wx.showToast({
- title: '发起网络请求失败',
- icon: 'none',
- mask: true
- })
- },
- complete() {
- wx.hideLoading()
- }
- })
- },
- // 切换订单状态
- ordertap(e) {
- let that = this;
- let oid = e.currentTarget.dataset.oid; //用户选中的标签
- let order_status = 0; //对应的订单状态
- if (oid === 0) {
- // 全部
- order_status = '';
- } else if (oid === 1) {
- // 待支付
- order_status = 0;
- } else if (oid === 2) {
- // 待取货
- order_status = 1;
- } else if (oid === 3) {
- // 已完成
- order_status = 2;
- } else if (oid === 4) {
- // 退款/售后
- order_status = 4;
- }
- if (oid === 0) {
- wx.showLoading({
- title: '加载中',
- mask: true
- })
- wx.request({
- url: api.OrderManagement_list,
- header: {
- 'Authorization': wx.getStorageSync('token')
- },
- data: {
- id: that.data.pintuandetail.id
- },
- method: 'POST',
- success(res) {
- console.log(res);
- if (res.data.code === 1) {
- if (res.data.data == null) {
- that.setData({
- order_list: [],
- order_info: {},
- orderindex: oid
- })
- } else {
- that.setData({
- order_list: res.data.data.order_list,
- order_info: res.data.data.order_info,
- orderindex: oid
- })
- }
- } else {
- wx.showToast({
- title: res.data.msg,
- mask: true,
- icon: 'none'
- })
- }
- },
- fail(err) {
- wx.showToast({
- title: '发起网络请求失败',
- icon: 'none',
- mask: true
- })
- },
- complete() {
- wx.hideLoading()
- }
- })
- } else {
- wx.showLoading({
- title: '加载中',
- mask: true
- })
- wx.request({
- url: api.OrderManagement_list,
- header: {
- 'Authorization': wx.getStorageSync('token')
- },
- method: 'POST',
- data: {
- id: that.data.pintuandetail.id,
- order_status: order_status
- },
- success(res) {
- console.log(res);
- if (res.data.code === 1) {
- if (res.data.data == null) {
- that.setData({
- order_list: [],
- order_info: {},
- orderindex: oid
- })
- } else {
- that.setData({
- order_list: res.data.data.order_list,
- order_info: res.data.data.order_info,
- orderindex: oid
- })
- }
- } else {
- wx.showToast({
- title: res.data.msg,
- mask: true,
- icon: 'none'
- })
- }
- },
- fail(err) {
- wx.showToast({
- title: '发起网络请求失败',
- icon: 'none',
- mask: true
- })
- },
- complete() {
- wx.hideLoading()
- }
- })
- }
- },
- // 跳转订单详情
- navToOrderDetail(e) {
- let id = e.currentTarget.dataset.id;
- wx.navigateTo({
- url: '/pages/orderstatus/orderstatus?id=' + id,
- })
- },
- // 更新状态
- updateStatus(e) {
- this.setData({
- showUpdateState: true,
- updateStatusID: e.detail.id
- })
- }
- })
|