// components/report/index.js var myRequest = require("../../utils/api.js"); var utils = require("../../utils/util.js"); Component({ /** * 组件的属性列表 */ properties: { }, /** * 组件的初始数据 */ data: { user:{}, list:[], latitude: '', longitude:'', active:'all', orderStatus:{ 1:{ label:'待接单', type:'warning' }, 2:{ label:'待签到', type:'warning' }, 3:{ label:'待反馈', type:'warning' }, 4:{ label:'待客户评价', type:'warning' }, 5:{ label:'待主管评价', type:'warning' }, 6:{ label:'待打款', type:'warning' }, 7:{ label:'已结算', type:'success' }, } }, attached(){ this.setData({ user:wx.getStorageSync('userInfo') }) let that =this; wx.getLocation({//调用API得到经纬度 type: 'gcj02', isHighAccuracy: true, success: function (res) { console.log(res) that.setData({ latitude: res.latitude, longitude: res.longitude }) that.init() } }) }, /** * 组件的方法列表 */ methods: { init(){ this.setData({ user:wx.getStorageSync('userInfo') }) this.data.active=='all'? this.getList():this.getMylist() }, checkTab(e){ console.log(e) this.setData({ active:e.target.dataset.val }) if(e.target.dataset.val=='all'){ this.getList() }else{ this.getMylist() } }, getList(){ let that =this; myRequest.myRequest( 'deviceRepairOrder/supporter/list/unAccepted', {}, 'get' ).then(res=>{ let rows = res.rows rows.forEach(item=>{ let distance =utils.getDistances(item.device.latitude,item.device.longitude,that.data.latitude,that.data.longitude) item.distance = distance.km }) this.setData({ list:rows }) }) }, getMylist(){ let that =this; myRequest.myRequest( 'deviceRepairOrder/supporter/list/accepted', {}, 'get' ).then(res=>{ let rows = res.rows rows.forEach(item=>{ let distance =utils.getDistances(item.device.latitude,item.device.longitude,that.data.latitude,that.data.longitude) item.distance = distance.km }) this.setData({ list:res.rows }) }) }, clickItem(e){ console.log(e) wx.navigateTo({ url: '../../pages/mainprogress/index?id='+e.currentTarget.dataset.item.orderId, }) } } })