pointDetailLogic.js 1.74 KB
import {observable} from 'mobx'
import {_getPointDetail,_getMemberPoint} from "../integralMall/utils/AppService";
import {Text} from 'react-native'
import {AsyncStorage} from 'react-native'
import {systemSite} from "../../index";
import { xnToast } from '../../utils/utils';
export default class pointDetailLogic{
	@observable
	pics=[]
	@observable
	info={
		name:"",
		showPrice:"",
		suggestedPrice:"",
		showPrice1:""
	}
	@observable
	detail=""
	@observable
	memberId=""
	@observable
	myPoint=0
	id=""
	itemId=""
	@observable
	hasPrice=false
	@observable
	quantity=0
	async get(id){
		try{
			const data=await _getPointDetail({
				id,
				operatingUnitId:systemSite.operatingUnitId,
				systemType:"POINT"
			})
			const {errors, firstErrorMessage,commodity,itemList,pictureList,commodityText,balanceList} = data
			if (errors.length > 0) {
                xnToast(firstErrorMessage)
			} else {
				const {name,showPoint,suggestedPrice,showPrice}=commodity
					this.pics.replace(pictureList)
				if(!!showPrice){
					this.hasPrice=true
				}else{
					this.hasPrice=false
				}
				this.info.name=name
				this.info.showPrice=`${showPoint}积分${!!showPrice?("+"+showPrice+"元"):""}`
				console.log(!!showPrice)
				this.info.showPrice1=showPoint
				this.info.suggestedPrice=suggestedPrice
				this.detail=commodityText
				this.id=itemList[0].commodityId
				this.itemId=itemList[0].id
				this.quantity=balanceList[0].quantity
			}
		}catch(e){
			console.log(e)
		}
	}
	async getMemberPoint(){
		try{
			const data=await _getMemberPoint({memberId:this.memberId})
			const {errors, firstErrorMessage,point} = data
			if (errors.length > 0) {
                xnToast(firstErrorMessage)
			} else {
				this.myPoint=point
			}

		}catch(e){
			console.log(e)
		}
	}
}