| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- import request from '../utils/RequestUtils';
- import { toastShow, toastInfo, toastSuccess } from '../utils/SystemUtils';
- import MapModel from '../map/model';
- const OrderMap = (now) => ({
- receiverOrder(orderId, successEvent) {
- toastShow();
- request
- .get('/rider/receiver', {
- params: {
- orderId,
- pass: true,
- },
- })
- .then((res) => {
- if (successEvent) {
- successEvent(res);
- }
- })
- .catch((e) => {
- toastInfo(e.error);
- });
- },
- changeStatus(orderId, status, successEvent, errorEvent, pickImg) {
- toastShow();
- const { pickupPhotos } = now();
- if (status === 'TAKE_MEAL') {
- pickupPhotos(orderId, status, successEvent, errorEvent, pickImg);
- return;
- }
- const { getNowLocation } = now(MapModel);
- getNowLocation()
- .then((res) => {
- const { location } = res;
- return request.post('/orderInfo/riderStatus', {
- data: {
- orderId,
- status,
- longitude: location.lng,
- latitude: location.lat,
- },
- requestType: 'form',
- });
- })
- .then((res) => {
- if (successEvent) {
- successEvent(res);
- }
- })
- .catch((e) => {
- if (e.error && errorEvent) {
- errorEvent();
- } else {
- toastInfo(e.error);
- }
- });
- },
- pickupPhotos(orderId, status, successEvent, errorEvent, pickImg) {
- request
- .get('/orderInfo/pickupPhotos', {
- params: {
- orderId,
- status,
- img: pickImg,
- },
- })
- .then((res) => {
- if (successEvent) {
- successEvent(res);
- }
- })
- .catch((e) => {
- toastInfo(e.error);
- });
- },
- changeStatusAll(orderId, status, successEvent) {
- toastShow();
- request
- .get('/orderInfo/mandatory', {
- params: {
- orderId,
- status,
- },
- })
- .then((res) => {
- if (successEvent) {
- successEvent(res);
- }
- })
- .catch((e) => {
- toastInfo(e.error);
- });
- },
- });
- export default OrderMap;
|