|
@@ -14,9 +14,8 @@ Page({
|
|
|
tips:'', //顶部tips
|
|
|
goods:[], //挡位数据
|
|
|
goods_id:'', //当前选中挡位的goods_id
|
|
|
- card_type: '', //油卡类型 (中石化/中石油)
|
|
|
- card_no: '', //油卡号
|
|
|
- firstLoad: true,
|
|
|
+ card_type: 'phone',
|
|
|
+ card_no: '',
|
|
|
fromSource: ''
|
|
|
},
|
|
|
|
|
@@ -56,19 +55,20 @@ Page({
|
|
|
getReq(app,{
|
|
|
act: 'index',
|
|
|
op: 'card_goods',
|
|
|
- page_type: 'oil',
|
|
|
+ page_type: 'mobile',
|
|
|
from: fromSource
|
|
|
- }, function (res) {
|
|
|
- self.setData({
|
|
|
- firstLoad: false
|
|
|
- });
|
|
|
+ },
|
|
|
+ function (res) {
|
|
|
if (res.code == 200) {
|
|
|
if(res.datas && res.datas.goods){
|
|
|
var datas = res.datas
|
|
|
+ var card = self.findCard(res.datas.cards,'phone')
|
|
|
+ console.log('card no:',card.card_no)
|
|
|
self.setData({
|
|
|
tips: datas.tips,
|
|
|
goods: datas.goods,
|
|
|
- goods_id: datas.goods[0].goods_id
|
|
|
+ goods_id: datas.goods[0].goods_id,
|
|
|
+ card_no: card.card_no
|
|
|
});
|
|
|
}
|
|
|
}else {
|
|
@@ -80,7 +80,14 @@ Page({
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
-
|
|
|
+ findCard(cards,card_type) {
|
|
|
+ for (const card of cards) {
|
|
|
+ if (card.card_type == card_type) {
|
|
|
+ return card;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return {};
|
|
|
+ },
|
|
|
// 立即充值
|
|
|
handlerRecharge()
|
|
|
{
|
|
@@ -89,12 +96,12 @@ Page({
|
|
|
// title: `goods_id: ${this.data.goods_id}, card_no: ${this.data.card_no}`,
|
|
|
// duration: 2000
|
|
|
// })
|
|
|
- const { goods_id, card_no } = this.data
|
|
|
+ const { goods_id, card_no, card_type } = this.data
|
|
|
if(!card_no){
|
|
|
app.showToast('卡号不能为空')
|
|
|
return
|
|
|
}
|
|
|
- buyVGoods(app,goods_id,1,{ card_no }, (res) => {
|
|
|
+ buyVGoods(app, goods_id, 1, { card_no, card_type}, (res) => {
|
|
|
}, (err) => {
|
|
|
})
|
|
|
},
|
|
@@ -110,15 +117,12 @@ Page({
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
onShow: function () {
|
|
|
- if(!this.data.firstLoad) {
|
|
|
- const record = app.globalData.record || {}
|
|
|
- console.log('record',record)
|
|
|
- const { card_no = '' } = record
|
|
|
- app.setFromSource(this.data.fromSource)
|
|
|
- if (record) {
|
|
|
- this.setData({ card_no })
|
|
|
- }
|
|
|
+ const record = app.globalData.record || {}
|
|
|
+ const { card_no = '' } = record
|
|
|
+ if (card_no) {
|
|
|
+ this.setData({ card_no })
|
|
|
}
|
|
|
+ app.setFromSource(this.data.fromSource)
|
|
|
},
|
|
|
|
|
|
/**
|