| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- // pages/order/order.js
- const app = getApp()
- import http from "../../utils/http"
- import util from "../../utils/util"
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- unread:2,
- tabList:['接单池','待派单','待接单','进行中/待核销','已完成','售后订单'],
- orderState:1,
- list:[],
- finish: false,
- loading: false,
- page: 1,
- active: 0,
- token: wx.getStorageSync('token')
- },
- notice(){
-
- },
- orderBtnTap(e){
- if(e.detail.type == 1){
- wx.requestSubscribeMessage({
- tmplIds: [app.globalData.templateconfig.shop_order_template,app.globalData.templateconfig.shop_finish_template,app.globalData.templateconfig.shop_sales_template],
- complete :(res) =>{
- http.post('order/shopaccept', {
- id: e.detail.info.id
- }, true, false).then(res => {
- this.setData({
- active: 1
- })
- this.reload()
- util.toast('抢单成功,请派单')
- }).catch(e => {
- let data = e.data
- if(data.code === 2){
- util.toast(data.msg)
- setTimeout(()=>{
- util.skip('/service/earnestMoney/earnestMoney')
- },1000)
- }else if(data.code === 0){
- util.toast(data.msg)
- }
- })
- }
- })
-
- }else if(e.detail.type == 2){
- util.skip('/pages/allocation/allocation?id='+e.detail.info.id)
- }else if(e.detail.type == 3){
- wx.openLocation({
- latitude : Number(e.detail.info.address.lat),
- longitude : Number(e.detail.info.address.lng),
- name: e.detail.info.address.area,
- scale: 18
- })
- }
- },
- orderTap(e){
- util.skip('/pages/orderDetail/orderDetail?order_id='+e.detail.id)
- },
- reload(){
- this.setData({
- list: [],
- page: 1,
- finish: false
- })
- this.getList()
- },
- more(){
- this.setData({
- page: ++this.data.page
- })
- this.getList()
- },
- getList(){
- if(!wx.getStorageSync('token')) return
- if(this.data.finish){
- return
- }
- if(this.data.loading){
- return
- }
- this.setData({
- loading: true
- })
- let data = {
- page: this.data.page,
- }
- if(this.data.active === 0){
- data['is_pool'] = 1
- }else if(this.data.active === 1){
- data['not_allocation'] = 1
- }else if(this.data.active === 2){
- data['not_accept'] = 1
- }else if(this.data.active === 3){
- data['not_finish'] = 1
- }else if(this.data.active === 4){
- data['finish'] = 1
- }else if(this.data.active === 5){
- data['in_service'] = 1
- }
- http.post('order/shoporderlist', data).then(res => {
- if(res.data.length === 0){
- this.setData({
- finish: true
- })
- }
- let arr = this.data.list.concat(res.data)
- this.setData({
- list: arr
- })
-
- }).finally(res => {
- this.setData({
- loading: false
- })
- })
- },
- //派单
- toallocation(){
- wx.navigateTo({
- url: '/pages/allocation/allocation',
- })
- },
- toDetail(){
- wx.navigateTo({
- url: '../orderDetail/orderDetail',
- })
- },
- onChange(event) {
- this.setData({
- active: event.detail.index
- })
- this.reload()
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
-
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- this.setData({
- token: wx.getStorageSync('token')
- })
- this.reload()
- },
- })
|