pointDetailLogic.js
1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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)
}
}
}