| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- var _request = require('../../../../utils/request.js')
- var rid
- Page({
- data: {
- tabLeft: '0%',
- type: '',
- page: 1,
- per_page: 10,
- list: [],
- more: true,
- tabChange: false
- },
- onLoad: function (options) {
- rid = options.type
- if (rid) {
- if (rid === 'unpay') {
- this.tabUnpay()
- } else if (rid === 'processing') {
- this.tabProcessing()
- } else if (rid === 'dispatch') {
- this.tabDispatch()
- } else if (rid === 'complete') {
- this.tabComplete()
- } else {
- this.getOrderList()
- }
- } else {
- this.getOrderList()
- }
- },
- onShow () {
- if (getApp().globalData.order) {
- this.typeList()
- getApp().globalData.order = false
- }
-
- this.setData({
- list: [],
- tabChange: false
- })
-
- if (rid) {
- if (rid === 'unpay') {
- this.tabUnpay()
- } else if (rid === 'processing') {
- this.tabProcessing()
- } else if (rid === 'dispatch') {
- this.tabDispatch()
- } else if (rid === 'complete') {
- this.tabComplete()
- } else {
- this.getOrderList()
- }
- } else {
- this.getOrderList()
- }
-
- },
- tabAll: function () {
- if (this.data.type !== '') {
- this.setData({
- tabLeft: '0%',
- type: '',
- more: true,
- page: 1,
- tabChange: true
- })
- this.getOrderList()
- } else {
- }
- },
- tabUnpay: function () {
- if (this.data.type !== 'unpay') {
- this.setData({
- tabLeft: '16.6%',
- type: 'unpay',
- more: true,
- page: 1,
- tabChange: true
- })
- this.getOrderList()
- }
- },
- tabProcessing: function () {
- if (this.data.type !== 'processing') {
- this.setData({
- tabLeft: '33.2%',
- type: 'processing',
- more: true,
- page: 1,
- tabChange: true
- })
- this.getOrderList()
- }
- },
- tabDispatch: function () {
- if (this.data.type !== 'dispatch') {
- this.setData({
- tabLeft: '49.8%',
- type: 'dispatch',
- more: true,
- page: 1,
- tabChange: true
- })
- this.getOrderList()
- }
- },
- tabComment: function () {
- if (this.data.type !== 'waitcommen') {
- this.setData({
- tabLeft: '66.4%',
- type: 'waitcommen',
- more: true,
- page: 1,
- tabChange: true
- })
- this.getOrderList()
- }
- },
- tabComplete: function () {
- if (this.data.type !== 'complete') {
- this.setData({
- tabLeft: '83%',
- type: 'complete',
- more: true,
- page: 1,
- tabChange: true
- })
- this.getOrderList()
- }
- },
- confirmPopup (val) {
- var that = this
- var id = val.currentTarget.dataset.val
- wx.showModal({
- title: '提示',
- content: '是否确认收货?',
- success: function(res) {
- if (res.confirm) {
- that.confirmOrder(id)
- } else if (res.cancel) {
- }
- }
- })
- },
- CancelPopup (val) {
- var that = this
- var id = val.currentTarget.dataset.val
- wx.showModal({
- title: '提示',
- content: '确定取消该订单?',
- success: function(res) {
- if (res.confirm) {
- that.CancelOrder(id)
- } else if (res.cancel) {
- }
- }
- })
- },
- confirmOrder: function (val) {
- var id = val
- var that = this
- var url = 'v1/order/' + id + '/confirm'
- var params = {
- }
- var success = function (res) {
- that.typeList()
- wx.showToast({
- title: '确认收货成功',
- icon: 'none',
- duration: 2000
- })
- }
- _request.$put(url, params, success)
- },
- CancelOrder: function (val) {
- var id = val
- var that = this
- var url = 'v1/order/' + id + '/cancel'
- var params = {
- }
- var success = function (res) {
- that.typeList()
- wx.showToast({
- title: '取消订单成功',
- icon: 'none',
- duration: 2000
- })
- }
- _request.$put(url, params, success)
- },
- getOrderList () {
- var that = this
- var url = 'v1/orders'
- var params = {
- status: this.data.type,
- page: this.data.page,
- per_page: this.data.per_page
- }
- var success = function (res) {
- if (that.data.tabChange) {
- that.setData({
- list: [],
- tabChange: false
- })
- }
- var result = that.data.list.concat(res.data.list || [])
- console.log('orderlist',result);
- that.setData({
- list: result
- })
- var listMore = res.data.list_count > that.data.list.length
- that.setData({
- more: listMore
- })
- }
- _request.$get(url, params, success)
- },
- onReachBottom: function () {
- if (this.data.more) {
- var page = this.data.page + 1
- this.setData({
- page: page
- })
- this.getOrderList()
- }
- },
- typeList: function () {
- this.setData({
- more: true,
- page: 1,
- tabChange: true
- })
- this.getOrderList()
- },
- onShareAppMessage: function (val) {
- return _request.share({
- sc: 'xcx_user_orders'
- })
- },
- toCommend:function(e){
- let that = this;
- let id = e.currentTarget.dataset.id;
- let pid = e.currentTarget.dataset.pid;
- wx.navigateTo({
- url:'../comment/comment?id='+id+'&pid='+pid
- })
- }
- })
|