|
@@ -15,12 +15,12 @@ Page({
|
|
|
tips:'', //顶部tips
|
|
|
goods:[], //挡位数据
|
|
|
goods_id:'', //当前选中挡位的goods_id
|
|
|
-
|
|
|
- // card_type: 'sinopec', //油卡类型 (中石化/中石油)
|
|
|
- // card_no: '', //油卡号
|
|
|
- // cards: [],
|
|
|
+ card_type: 'sinopec', //油卡类型 (中石化/中石油)
|
|
|
+ card_no: '', //油卡号
|
|
|
+ cards: [],
|
|
|
sinopec: {},
|
|
|
petrochina: {},
|
|
|
+ phone: {},
|
|
|
firstLoad: true,
|
|
|
|
|
|
tabsData: [
|
|
@@ -35,9 +35,17 @@ Page({
|
|
|
var dataset = e.currentTarget.dataset
|
|
|
const { activeindex, cardtype } = dataset
|
|
|
const { cards } = this.data
|
|
|
+ const card = app.getValueByKey(cardtype ,cards)
|
|
|
+ const { card_no, card_type } = card
|
|
|
+ if(card_type === 'sinopec'){
|
|
|
+ this.setData({ sinopec: { ...this.data.sinopec, card_no } })
|
|
|
+ }else if(card_type === 'petrochina'){
|
|
|
+ this.setData({ petrochina: { ...this.data.petrochina, card_no } })
|
|
|
+ }
|
|
|
this.setData({
|
|
|
- currentIndex: dataset.activeindex,
|
|
|
- card_no: this.getValueBykey(cardtype ,cards).card_no
|
|
|
+ currentIndex: activeindex,
|
|
|
+ card_no,
|
|
|
+ card_type
|
|
|
});
|
|
|
},
|
|
|
|
|
@@ -80,28 +88,20 @@ Page({
|
|
|
if(res.datas && res.datas.goods){
|
|
|
const datas = res.datas
|
|
|
const { tips = '', goods = [], cards = [], } = datas
|
|
|
- const sinopec = this.getValueBykey('sinopec', cards)
|
|
|
- const petrochina = this.getValueBykey('petrochina', cards)
|
|
|
- this.setData({ tips, goods, cards, sinopec, petrochina, card_no: sinopec.card_no, goods_id: datas.goods[0].goods_id });
|
|
|
+ const phone = app.getValueByKey('phone', cards)
|
|
|
+ const petrochina = app.getValueByKey('petrochina', cards)
|
|
|
+ const sinopec = app.getValueByKey('sinopec', cards)
|
|
|
+ this.setData({ tips, goods, cards, sinopec, petrochina, phone, card_no: sinopec.card_no, goods_id: datas.goods[0].goods_id });
|
|
|
}
|
|
|
} else {
|
|
|
app.showToast(res.message)
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- // 通过键取值
|
|
|
- getValueBykey(key = '', data = [])
|
|
|
- {
|
|
|
- if(!data.length) {
|
|
|
- return {};
|
|
|
- }
|
|
|
- else {
|
|
|
- return data.filter(val => val.card_type === key);
|
|
|
- }
|
|
|
- },
|
|
|
|
|
|
// 立即充值
|
|
|
handlerRecharge(){
|
|
|
+ console.table(this.data)
|
|
|
const { goods_id, card_no, card_type } = this.data
|
|
|
if(!card_no){
|
|
|
app.showToast('卡号不能为空')
|
|
@@ -131,6 +131,11 @@ Page({
|
|
|
const { card_no = '', card_type = '' } = record
|
|
|
app.setFromSource(this.data.fromSource)
|
|
|
if (record) {
|
|
|
+ if(card_type === 'sinopec'){
|
|
|
+ this.setData({ sinopec: { ...this.data.sinopec, card_no } })
|
|
|
+ }else if(card_type === 'petrochina'){
|
|
|
+ this.setData({ petrochina: { ...this.data.petrochina, card_no } })
|
|
|
+ }
|
|
|
this.setData({ card_no, card_type })
|
|
|
}
|
|
|
}
|