pointOrderDetailLogic.js 1.44 KB
import {observable} from 'mobx'
import {_pointOrderDetail,_sign} from "../integralMall/utils/AppService";
import { xnToast } from '../../utils/utils';
export default class pointOrderDetailLogic{
	id=""
	@observable
	phone=""
	@observable
	name=""
	@observable
	address=""
	@observable
	items=[]
	@observable
	orderNum=""
	@observable
	status=""
	rowVersion=""
	@observable
	loading=true
	@observable
	isVirtual=false
	async get(){
		try{
			const data=await _pointOrderDetail({
				id:this.id
			})
			const {errors, firstErrorMessage,orderShipping,orderLogisticsList,order} = data
			if (errors.length > 0) {
                xnToast(firstErrorMessage)
			} else {
				const {cityName,districtName,provinceName,address,contactName,contactPhone}=orderShipping
				this.name=contactName
				this.phone=contactPhone
				this.address=provinceName+cityName+districtName+address
				const {orderLineList,number,status,rowVersion}=order
				this.items.replace(orderLineList)
				this.orderNum=number
				this.status=status
				this.rowVersion=rowVersion
				this.isVirtual=order.orderLineList[0].isVirtual
			}
		}catch(e){

		}
		this.loading=false
	}
	async sign(){
		try{
			const data=await _sign({
				id:this.id,
				type:"MEMBER",
				rowVersion:this.rowVersion
			})
			const {errors, firstErrorMessage,} = data
			if (errors.length > 0) {
                xnToast(firstErrorMessage)
				return false
			} else {
				return true
			}
		}catch(e){
			console.log(e)
		}
	}
}