|
@@ -67,6 +67,7 @@ Page({
|
|
|
fromSource: app.globalData.fromSource,
|
|
|
// card_no: this.data.tabsData[0].card_no
|
|
|
});
|
|
|
+
|
|
|
getReq({
|
|
|
act: 'index',
|
|
|
op: 'card_goods',
|
|
@@ -79,9 +80,11 @@ Page({
|
|
|
if (res.code == 200) {
|
|
|
if(res.datas && res.datas.goods){
|
|
|
const datas = res.datas
|
|
|
- const { tips = '', goods = [], cards = [], } = datas
|
|
|
+ const { tips = '', goods = [], cards = [], } = datas || {}
|
|
|
const sinopec = this.getValueBykey('sinopec', cards)
|
|
|
const petrochina = this.getValueBykey('petrochina', cards)
|
|
|
+ console.log('sinopec',sinopec)
|
|
|
+ console.log('petrochina',petrochina)
|
|
|
this.setData({ tips, goods, cards, sinopec, petrochina, card_no: sinopec.card_no, goods_id: datas.goods[0].goods_id });
|
|
|
}
|
|
|
} else {
|
|
@@ -91,6 +94,9 @@ Page({
|
|
|
},
|
|
|
// 通过键取值
|
|
|
getValueBykey(key = '', data = []){
|
|
|
+ if(!data.length){
|
|
|
+ return {}
|
|
|
+ }
|
|
|
return data.filter(val => val.card_type === key)[0]
|
|
|
},
|
|
|
|