Ver a proveniência

[我的卡券核销][修改]:我的卡券核销

tags/2.2.4
meo há 6 anos
ascendente
cometimento
d6acc4c5c6
5 ficheiros alterados com 191 adições e 155 eliminações
  1. +2
    -1
      pages/coupon/detail/index.wxml
  2. +38
    -4
      pages/couponorder/detail/index.js
  3. +10
    -2
      pages/couponorder/index/index.js
  4. +0
    -4
      pages/index/coupons/index.js
  5. +141
    -144
      pages/passCar/passCar.js

+ 2
- 1
pages/coupon/detail/index.wxml Ver ficheiro

@@ -7,7 +7,8 @@
<view class='coupons_info'> <view class='coupons_info'>
<view> <view>
<text>{{data.title}}<text>限购{{data.useLimitQuantity}}件</text></text> <text>{{data.title}}<text>限购{{data.useLimitQuantity}}件</text></text>
<text wx:if="{{data.endTime!=undefined&&data.type!=5}}">剩余时间:<text>{{endtime}}</text></text>
<text wx:if="{{data.endTime!=undefined&&data.endTime>=0&&data.type!=5}}">剩余时间:<text>{{endtime}}</text></text>
<text wx:if="{{data.endTime!=undefined&&0>=data.endTime&&data.type!=5}}">剩余时间:<text>即将到期</text></text>
<text wx:if="{{data.type==5}}"><text>当次有效</text></text> <text wx:if="{{data.type==5}}"><text>当次有效</text></text>
<text>剩余件数:<text>{{data.remainInventory}}件</text></text> <text>剩余件数:<text>{{data.remainInventory}}件</text></text>
</view> </view>


+ 38
- 4
pages/couponorder/detail/index.js Ver ficheiro

@@ -21,7 +21,8 @@ Page({
console.log(options); console.log(options);
let that = this; let that = this;
that.setData({ that.setData({
code: options.quancode
code: options.quancode,
couponorderstatus: options.couponorderstatus
}); });


//获得优惠券的详情 //获得优惠券的详情
@@ -30,7 +31,7 @@ Page({
options.quancode != null && options.quancode != null &&
options.quancode != "" && options.quancode != "" &&
options.quancode != undefined && options.quancode != undefined &&
options.couponorderstatus == 0
that.data.couponorderstatus == 0
) { ) {
Http.get({ Http.get({
url: config.api.couponOrderDetail, url: config.api.couponOrderDetail,
@@ -40,8 +41,20 @@ Page({
}).then(res => { }).then(res => {
console.log(res); console.log(res);
that.setData({ that.setData({
couponorderstatus: res.data.couponOrderStatus,
data: res.data data: res.data
}); });
if (res.data.couponOrderStatus == 1) {
/**
* 动态改变上一级页面的核销状态
*/
var pages = getCurrentPages();
var prevPage = pages[pages.length - 2]; //上一个页面
//直接调用上一个页面的setData()方法,把数据存到上一个页面中去
prevPage.setData({
mystatus: res.data.couponOrderStatus
});
}
that.setData({ that.setData({
expiredTime: util.fmtDate(that.data.data.expiredTime), expiredTime: util.fmtDate(that.data.data.expiredTime),
updateDate: util.fmtDate(that.data.data.updateDate), updateDate: util.fmtDate(that.data.data.updateDate),
@@ -51,7 +64,9 @@ Page({
} }
}, 2000); }, 2000);


// if (options.couponorderstatus != "0") {
/**
* 页面需要初始渲染的效果
*/
Http.get({ Http.get({
url: config.api.couponOrderDetail, url: config.api.couponOrderDetail,
data: { data: {
@@ -60,6 +75,7 @@ Page({
}).then(res => { }).then(res => {
console.log(res); console.log(res);
that.setData({ that.setData({
couponorderstatus: res.data.couponOrderStatus,
data: res.data data: res.data
}); });
that.setData({ that.setData({
@@ -70,7 +86,25 @@ Page({
util.barcode("barcode", options.quancode, 510, 100); util.barcode("barcode", options.quancode, 510, 100);
util.qrcode("qrcode", options.quancode, 350, 350); util.qrcode("qrcode", options.quancode, 350, 350);
}); });
// }

// Http.get({
// url: config.api.couponOrderDetail,
// data: {
// couponOrderId: options.quancode
// }
// }).then(res => {
// console.log(res);
// that.setData({
// data: res.data
// });
// that.setData({
// expiredTime: util.fmtDate(that.data.data.expiredTime),
// updateDate: util.fmtDate(that.data.data.updateDate),
// createDate: util.fmtDate(that.data.data.createDate)
// });
// util.barcode("barcode", options.quancode, 510, 100);
// util.qrcode("qrcode", options.quancode, 350, 350);
// });
}, },
phone: function() { phone: function() {
let that = this; let that = this;


+ 10
- 2
pages/couponorder/index/index.js Ver ficheiro

@@ -27,7 +27,8 @@ Page({
page: 1, page: 1,
allow_load: true, allow_load: true,
loading: true, //"上拉加载"的变量,默认false,隐藏 loading: true, //"上拉加载"的变量,默认false,隐藏
content: ""
content: "",
mystatus:''
}, },
onLoad() { onLoad() {
this.getList(0, 0); this.getList(0, 0);
@@ -37,9 +38,16 @@ Page({
gotouse: function(e) { gotouse: function(e) {
console.log(e.currentTarget.dataset.couponorderstatus); console.log(e.currentTarget.dataset.couponorderstatus);
console.log("点击跳转到券详情"); console.log("点击跳转到券详情");
if(this.data.mystatus==''||this.data.mystatus=='undefined'){
var mystatus = e.currentTarget.dataset.couponorderstatus;
}else{
var mystatus = this.data.mystatus;
}
console.log(mystatus);
wx.navigateTo({ wx.navigateTo({
url: `/pages/couponorder/detail/index?quancode=${ url: `/pages/couponorder/detail/index?quancode=${
e.currentTarget.dataset.quancode}&couponorderstatus=${e.currentTarget.dataset.couponorderstatus}`
e.currentTarget.dataset.quancode}&couponorderstatus=${mystatus}`
}); });
}, },
getList(key, pageNum) { getList(key, pageNum) {


+ 0
- 4
pages/index/coupons/index.js Ver ficheiro

@@ -46,11 +46,8 @@ Component({
list: [], list: [],
allow_load: true allow_load: true
}); });

this.getList(detail.key, 1); this.getList(detail.key, 1);

var val = detail.key; var val = detail.key;

//通过这个传递数据 //通过这个传递数据
var myEventDetail = { var myEventDetail = {
val: val, val: val,
@@ -62,7 +59,6 @@ Component({


getList(key, pageNum) { getList(key, pageNum) {
var that = this; var that = this;

app.couponListCallback = token => { app.couponListCallback = token => {
Http.setToken(token); Http.setToken(token);




+ 141
- 144
pages/passCar/passCar.js Ver ficheiro

@@ -1,6 +1,6 @@
// pages/passCar/passCar.js // pages/passCar/passCar.js
let config = require('../../config/config.js')
let Http = require('../../utils/HttpBasics')
let config = require("../../config/config.js");
let Http = require("../../utils/HttpBasics");
const app = getApp(); const app = getApp();
Page({ Page({
data: { data: {
@@ -9,63 +9,62 @@ Page({
payList: [], payList: [],
addCar: null, addCar: null,
tcq: 2, tcq: 2,
flag: '',
extraData:{}
flag: "",
extraData: {}
}, },
/*车牌动态样式 */ /*车牌动态样式 */
changeStyle: function () {
var height = this.data.dataHeight == '150rpx' ? '80rpx' : '150rpx';
var lineHeight = this.data.dataHeight == '150rpx' ? '80rpx' : '150rpx';
var fontWeight = this.data.fontWeight == '600' ? '500' : '600';
changeStyle: function() {
var height = this.data.dataHeight == "150rpx" ? "80rpx" : "150rpx";
var lineHeight = this.data.dataHeight == "150rpx" ? "80rpx" : "150rpx";
var fontWeight = this.data.fontWeight == "600" ? "500" : "600";
this.setData({ this.setData({
dataHeight: height, dataHeight: height,
dataLineHeight: lineHeight, dataLineHeight: lineHeight,
dataFontWeight: fontWeight dataFontWeight: fontWeight
}); });
}, },
onLoad: function (options) {
var that = this
onLoad: function(options) {
var that = this;
that.getList(); that.getList();
}, },


onShow: function (options) {
onShow: function(options) {
var that = this; var that = this;
console.log("车牌号")
console.log("车牌号");
if (that.data.addCar) { if (that.data.addCar) {
// 绑车牌 // 绑车牌
if (app.globalData.carLogin) { if (app.globalData.carLogin) {
that.bindCar(that.data.addCar)
that.bindCar(that.data.addCar);
} else { } else {
that.bindCar(that.data.addCar)
that.bindCar(that.data.addCar);
} }
that.setData({ that.setData({
addCar: null addCar: null
})
});
} }
}, },
//我的停车券的显示与消失 //我的停车券的显示与消失
showquan: function () {
showquan: function() {
let that = this; let that = this;
if (that.data.tcq == 1) { if (that.data.tcq == 1) {
that.setData({ that.setData({
tcq: 2 tcq: 2
})
}
else if (that.data.tcq == 2) {
});
} else if (that.data.tcq == 2) {
that.setData({ that.setData({
tcq: 1 tcq: 1
})
});
} }
}, },
jumpToAdd: function () {
jumpToAdd: function() {
wx.navigateTo({ wx.navigateTo({
url: '/pages/addPark/addPark',
url: "/pages/addPark/addPark"
}); });
}, },
passc: function () {
passc: function() {
wx.showToast({ wx.showToast({
title: '宝宝最可爱~',
})
title: "宝宝最可爱~"
});
}, },
// orderPay: function () { // orderPay: function () {
// wx.redirectTo({ // wx.redirectTo({
@@ -79,10 +78,10 @@ Page({
// } // }
// }, // },
//券绑定车牌 //券绑定车牌
bindCoupon: function (e) {
bindCoupon: function(e) {
var that = this; var that = this;
if (that.data.couponList.length>0){
console.log('00000000000000')
if (that.data.couponList.length > 0) {
console.log("00000000000000");
console.log(e.currentTarget.dataset.checkbind); console.log(e.currentTarget.dataset.checkbind);
/** /**
* 如果1 已经绑定 * 如果1 已经绑定
@@ -90,54 +89,54 @@ Page({
*/ */
for (let car of that.data.carList) { for (let car of that.data.carList) {
if (car.stopFee.parkingFee) { if (car.stopFee.parkingFee) {
that.data.payList.push(car)
that.data.payList.push(car);
} }
} }
var etcpData = { var etcpData = {
etcpToken: app.globalData.etcpToken, etcpToken: app.globalData.etcpToken,
carNumber: that.data.payList[0].carNumber ? that.data.payList[0].carNumber : '',
couponOrderId: that.data.couponList[0].id,
}
console.log(etcpData)
carNumber: that.data.payList[0].carNumber
? that.data.payList[0].carNumber
: "",
couponOrderId: that.data.couponList[0].id
};
console.log(etcpData);
// 停简单 // 停简单
var tjdData = { var tjdData = {
carNumber: that.data.payList[0].carNumber,
}
var postCouponData = (app.globalData.parkVendor == 1) ? etcpData : tjdData;
carNumber: that.data.payList[0].carNumber
};
var postCouponData = app.globalData.parkVendor == 1 ? etcpData : tjdData;


Http.post({ Http.post({
url: config.api.getCarCoupon, url: config.api.getCarCoupon,
data: postCouponData,
data: postCouponData
}) })
.then(res => { .then(res => {
that.setData({ that.setData({
flag: '1'
flag: "1"
}); });
// that.initUsrCarList() // that.initUsrCarList()
wx.showModal({ wx.showModal({
title: '提示',
title: "提示",
showCancel: false, showCancel: false,
content: "车牌绑定优免券成功!", content: "车牌绑定优免券成功!",
success: function (res) {
}
})
success: function(res) {}
});
}) })
.catch(error => { .catch(error => {
console.log(error); console.log(error);
if (error.code == 2056) { if (error.code == 2056) {
that.setData({ that.setData({
flags: 'alreadybind'
})
flags: "alreadybind"
});
} }
})
}else{
console.log('1111111111111111111')
});
} else {
console.log("1111111111111111111");
that.setData({ that.setData({
flags: 'alreadybind'
})
console.log(that.data.flags)
flags: "alreadybind"
});
console.log(that.data.flags);
} }

}, },


//获取名下停车券列表 //获取名下停车券列表
@@ -154,107 +153,110 @@ Page({
that.init(); that.init();
that.setData({ that.setData({
couponList: res.data.list couponList: res.data.list
})
setTimeout(function () {
});
setTimeout(function() {
wx.hideLoading(); wx.hideLoading();
}, 1200); }, 1200);
}); });

}, },


bindCar: function (carNum) {
var that = this
// ETCP
bindCar: function(carNum) {
var that = this;
// ETCP
var etcpData = { var etcpData = {
etcpToken: app.globalData.etcpToken, etcpToken: app.globalData.etcpToken,
carNumber: carNum,
}
carNumber: carNum
};
var tjdData = { var tjdData = {
carNumber: carNum,
}
var postData = (app.globalData.parkVendor == 1) ? etcpData : tjdData
carNumber: carNum
};
var postData = app.globalData.parkVendor == 1 ? etcpData : tjdData;
Http.post({ Http.post({
url: config.api.bindCar, url: config.api.bindCar,
data: postData,
data: postData
}) })
.then(res => { .then(res => {
console.log(res)
console.log(res);
that.setData({ that.setData({
addCar: null addCar: null
})
that.initUsrCarList()
});
that.initUsrCarList();
wx.showModal({ wx.showModal({
title: '提示',
title: "提示",
showCancel: false, showCancel: false,
content: "绑车牌成功!", content: "绑车牌成功!",
success: function () { }
})
success: function() {}
});
}) })
.catch(error => { .catch(error => {
console.log(error)
console.log(error);
wx.showModal({ wx.showModal({
title: '提示',
title: "提示",
showCancel: false, showCancel: false,
content: error.data.message, content: error.data.message,
success: function () { }
})
})
success: function() {}
});
});
}, },
unbindCar: function (carNum) {
var that = this
unbindCar: function(carNum) {
var that = this;
var postData = var postData =
(app.globalData.parkVendor == 1) ? {
etcpToken: app.globalData.etcpToken,
carNumber: carNum,
} : {
carNumber: carNum,
}
app.globalData.parkVendor == 1
? {
etcpToken: app.globalData.etcpToken,
carNumber: carNum
}
: {
carNumber: carNum
};
Http.post({ Http.post({
url: config.api.unbindCar, url: config.api.unbindCar,
data: postData,
data: postData
}) })
.then(res => { .then(res => {
console.log(res)
that.initUsrCarList()
console.log(res);
that.initUsrCarList();
wx.showModal({ wx.showModal({
title: '提示',
title: "提示",
showCancel: false, showCancel: false,
content: "解绑车牌成功!", content: "解绑车牌成功!",
success: function () { }
})
success: function() {}
});
}) })
.catch(error => { .catch(error => {
wx.showModal({ wx.showModal({
title: '提示',
title: "提示",
showCancel: false, showCancel: false,
content: "解绑车牌失败!", content: "解绑车牌失败!",
success: function () { }
})
})
success: function() {}
});
});
}, },
unbindCarBtn: function (e) {
console.log(e)
var that = this
var carNum = e.currentTarget.dataset.car
that.unbindCar(carNum)
unbindCarBtn: function(e) {
console.log(e);
var that = this;
var carNum = e.currentTarget.dataset.car;
that.unbindCar(carNum);
}, },
getStopFeeItem: function (carItem, i) {
getStopFeeItem: function(carItem, i) {
var that = this; var that = this;
var postData = var postData =
(app.globalData.parkVendor == 1) ? {
etcpToken: app.globalData.etcpToken,
carNumber: carItem.carNumber,
} : {
carNumber: carItem.carNumber,
outCarId: carItem.outCarId,
}
var stopFee = 'carList[' + i + '].stopFee'
var extraData = 'carList[' + i + '].extraData';
app.globalData.parkVendor == 1
? {
etcpToken: app.globalData.etcpToken,
carNumber: carItem.carNumber
}
: {
carNumber: carItem.carNumber,
outCarId: carItem.outCarId
};
var stopFee = "carList[" + i + "].stopFee";
var extraData = "carList[" + i + "].extraData";
console.log(extraData); console.log(extraData);
var extraDataStr = { params: { CarNumber: carItem.carNumber } }; var extraDataStr = { params: { CarNumber: carItem.carNumber } };
that.setData({ that.setData({
extraData: extraDataStr extraData: extraDataStr
})
});
Http.post({ Http.post({
url: config.api.getCarStopFee, url: config.api.getCarStopFee,
data: postData data: postData
@@ -267,39 +269,36 @@ Page({
[stopFee]: res.data, [stopFee]: res.data,
[extraData]: extraDataStr, [extraData]: extraDataStr,
buttonBox: res.data.parkingFee buttonBox: res.data.parkingFee

}), }),
console.log('res>>>' + JSON.stringify(that.data.buttonBox))

console.log("res>>>" + JSON.stringify(that.data.buttonBox));
}) })
.catch(error => { .catch(error => {
console.log(error)
})
console.log(error);
});
}, },
getStopFee: function () {
var that = this
getStopFee: function() {
var that = this;
// carLogin // carLogin
for (var i = 0; i < that.data.carList.length; i++) { for (var i = 0; i < that.data.carList.length; i++) {
that.getStopFeeItem(that.data.carList[i], i)
that.getStopFeeItem(that.data.carList[i], i);
} }
// console.log(JSON.stringify(getStopFeeItem)) // console.log(JSON.stringify(getStopFeeItem))
}, },


initPark: function () {
var that = this
initPark: function() {
var that = this;
// 车场信息获取 // 车场信息获取
Http.get({ Http.get({
url: config.api.getParkInfo, url: config.api.getParkInfo,
data: {} data: {}
})
.then(res => {
that.setData({
park: res.data,
})
})
}).then(res => {
that.setData({
park: res.data
});
});
}, },
initUsrCarList: function () {
var that = this
initUsrCarList: function() {
var that = this;
// 绑定车获取 // 绑定车获取
Http.get({ Http.get({
url: config.api.getUserCarList, url: config.api.getUserCarList,
@@ -307,18 +306,16 @@ Page({
}).then(res => { }).then(res => {
that.setData({ that.setData({
carList: res.data carList: res.data
})
console.log('aaaa' + JSON.stringify(that.data.carList) );


})
});
console.log("aaaa" + JSON.stringify(that.data.carList));
});
}, },
init: function () {
var that = this
init: function() {
var that = this;


app.parkInitCallback = token => { app.parkInitCallback = token => {
that.initPark()
that.initUsrCarList()
that.initPark();
that.initUsrCarList();
if (!app.globalData.carLogin) { if (!app.globalData.carLogin) {
// 共同登录 // 共同登录
Http.post({ Http.post({
@@ -327,19 +324,19 @@ Page({
phone: app.globalData.phone phone: app.globalData.phone
} }
}).then(res => { }).then(res => {
app.globalData.carLogin = true
app.globalData.parkVendor = res.data.vendor
app.globalData.carLogin = true;
app.globalData.parkVendor = res.data.vendor;
if (res.data.token != "undefined") { if (res.data.token != "undefined") {
app.globalData.etcpToken = res.data.token
console.log("etcpToken", app.globalData.etcpToken)
app.globalData.etcpToken = res.data.token;
console.log("etcpToken", app.globalData.etcpToken);
} }
// 获取 停车费 // 获取 停车费
that.getStopFee()
})
that.getStopFee();
});
} }
}
};
if (app.globalData.token && app.globalData.token != null) { if (app.globalData.token && app.globalData.token != null) {
app.parkInitCallback(app.globalData.token)
app.parkInitCallback(app.globalData.token);
} }
} }
})
});

Carregando…
Cancelar
Guardar