diff --git a/app.json b/app.json index 2fdf307..5f383e0 100644 --- a/app.json +++ b/app.json @@ -1,6 +1,7 @@ { "pages": [ "pages/index/index", + "pages/passCar/choiceCar/choiceCar", "pages/bannerdetail/index", "pages/getuserinfo/index", "pages/getphoneInfo/index", @@ -20,7 +21,8 @@ "pages/park/park", "pages/passCar/passCar", "pages/addPark/addPark", - "pages/youhuiquanma/index" + "pages/youhuiquanma/index", + "pages/passCar/couponList/couponList" ], "tabBar": { "color": "#9F9F9F", @@ -57,4 +59,4 @@ "downloadFile": 10000 }, "debug": false -} +} \ No newline at end of file diff --git a/assets/img/parkCoupon.png b/assets/img/parkCoupon.png new file mode 100644 index 0000000..8f4449d Binary files /dev/null and b/assets/img/parkCoupon.png differ diff --git a/pages/coupon/detail/index.js b/pages/coupon/detail/index.js index 29fd101..01005c3 100644 --- a/pages/coupon/detail/index.js +++ b/pages/coupon/detail/index.js @@ -5,6 +5,7 @@ const util = require("../../../utils/util"); Page({ data: { data: {}, + carList: [], couponChannelId: null, couponId: null, orderId: "", @@ -16,6 +17,7 @@ Page({ let that = this; console.log(options.couponChannelId); console.log(options.couponId); + that.init(); /** * 首页banner detail couponlist传过来的值 * iambannercoupon @@ -31,6 +33,7 @@ Page({ }); if (options.flag) { + console.log('111111111111111'+JSON.stringify(options)) this.orderFunc(); } else { @@ -111,6 +114,73 @@ Page({ console.log("payOrderUpdate catch", err); }); }, + /** + * 拉取车牌列表 + */ + init: function () { + var that = this + + app.parkInitCallback = token => { + that.initPark() + that.initUsrCarList() + if (!app.globalData.carLogin) { + // 共同登录 + Http.post({ + url: config.api.carInit, + data: { + phone: app.globalData.phone + } + }).then(res => { + app.globalData.carLogin = true + app.globalData.parkVendor = res.data.vendor + if (res.data.token != "undefined") { + app.globalData.etcpToken = res.data.token + console.log("etcpToken", app.globalData.etcpToken) + } + // 获取 停车费 + that.getStopFee() + }) + } + } + if (app.globalData.token && app.globalData.token != null) { + app.parkInitCallback(app.globalData.token) + } + }, + getStopFee: function () { + var that = this + // carLogin + for (var i = 0; i < that.data.carList.length; i++) { + that.getStopFeeItem(that.data.carList[i], i) + } + // console.log(JSON.stringify(getStopFeeItem)) + }, + initPark: function () { + var that = this + // 车场信息获取 + Http.get({ + url: config.api.getParkInfo, + data: {} + }) + .then(res => { + console.log(res) + that.setData({ + park: res.data, + }) + }) + }, + initUsrCarList: function () { + var that = this + // 绑定车获取 + Http.get({ + url: config.api.getUserCarList, + data: {} + }).then(res => { + console.log('>>>>>>>>>>>>>>>>>1' + JSON.stringify(res)); + that.setData({ + carList: res.data + }) + }) + }, /** * 发起支付 */ @@ -119,9 +189,11 @@ Page({ wx.showLoading({ title: "加载中..." }); - if (that.data.type == 5) { + if (that.data.data.type == 5) { + this.initUsrCarList() // 领取 5.停车券 // TODO 选取用户下的车牌 + console.log(11111111111111111111111111111111) } else { Http.post({ url: config.api.checkPhoneStatus, diff --git a/pages/passCar/choiceCar/choiceCar.js b/pages/passCar/choiceCar/choiceCar.js new file mode 100644 index 0000000..925e5fa --- /dev/null +++ b/pages/passCar/choiceCar/choiceCar.js @@ -0,0 +1,273 @@ +// pages/passCar/passCar.js +let config = require('../../../config/config.js') +let Http = require('../../../utils/HttpBasics') +const app = getApp(); +Page({ + data: { + park: null, + carList: [], + addCar: null, + tcq: 2 + }, + // ready() { + // app.couponChannelListCallback = token => { + // Http.setToken(token); + // Http.get({ + // url: config.api.couponChannelList, + // data: { + // pageNum: 1, + // pageSize: 2, + // targetAd: 2 + // } + // }).then(res => { + // console.log(res); + // this.setData({ + // list: res.data.list + // }); + // }); + // }; + // }, + /*车牌动态样式 */ + 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({ + dataHeight: height, + dataLineHeight: lineHeight, + dataFontWeight: fontWeight + }); + }, + onLoad: function (options) { + var that = this + that.init(); + }, + onShow: function (options) { + var that = this + if (options) + console.log(options) + if (that.data.addCar) { + console.log(JSON.stringify(that.data.addCar)) + // 绑车牌 + if (app.globalData.carLogin) { + that.bindCar(that.data.addCar) + } else { + that.bindCar(that.data.addCar) + } + that.setData({ + addCar: null + }) + } + }, + //我的停车券的显示与消失 + showquan: function () { + let that = this; + if (that.data.tcq == 1) { + that.setData({ + tcq: 2 + }) + } + else if (that.data.tcq == 2) { + that.setData({ + tcq: 1 + }) + } + }, + jumpToAdd: function () { + wx.navigateTo({ + url: '/pages/addPark/addPark', + }); + }, + jumpToPay: function () { + console.log("停车支付去") + //wx.redirectTo({ + // url: '/pages/pay/pay', + //}) + }, + passb: function () { + wx.showToast({ + title: '货物在路上~', + }) + }, + passc: function () { + wx.showToast({ + title: '宝宝最可爱~', + }) + }, + orderPay: function () { + wx.redirectTo({ + url: '/pages/pay/pay' + }); + }, + bindCar: function (carNum) { + var that = this + // ETCP + var etcpData = { + etcpToken: app.globalData.etcpToken, + carNumber: carNum, + } + // 停简单 + var tjdData = { + carNumber: carNum, + } + var postData = (app.globalData.parkVendor == 1) ? etcpData : tjdData + Http.post({ + url: config.api.bindCar, + data: postData, + }) + .then(res => { + console.log(res) + that.setData({ + addCar: null + }) + that.initUsrCarList() + wx.showModal({ + title: '提示', + showCancel: false, + content: "绑车牌成功!", + success: function () { } + }) + }) + .catch(error => { + console.log(error) + wx.showModal({ + title: '提示', + showCancel: false, + content: error.data.message, + success: function () { } + }) + }) + }, + unbindCar: function (carNum) { + var that = this + var postData = + (app.globalData.parkVendor == 1) ? { + etcpToken: app.globalData.etcpToken, + carNumber: carNum, + } : { + carNumber: carNum, + } + Http.post({ + url: config.api.unbindCar, + data: postData, + }) + .then(res => { + console.log(res) + that.initUsrCarList() + wx.showModal({ + title: '提示', + showCancel: false, + content: "解绑车牌成功!", + success: function () { } + }) + }) + .catch(error => { + wx.showModal({ + title: '提示', + showCancel: false, + content: "解绑车牌失败!", + success: function () { } + }) + }) + }, + unbindCarBtn: function (e) { + console.log(e) + var that = this + var carNum = e.currentTarget.dataset.car + that.unbindCar(carNum) + }, + getStopFeeItem: function (carItem, i) { + var that = this + 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' + var extraDataStr = { params: { CarNumber: carItem.carNumber } } + console.log(postData) + Http.post({ + url: config.api.getCarStopFee, + data: postData + }) + .then(res => { + console.log(res) + console.log(stopFee) + that.setData({ + [stopFee]: res.data, + [extraData]: extraDataStr + }) + }) + .catch(error => { + console.log(error) + }) + }, + getStopFee: function () { + var that = this + // carLogin + for (var i = 0; i < that.data.carList.length; i++) { + that.getStopFeeItem(that.data.carList[i], i) + } + // console.log(JSON.stringify(getStopFeeItem)) + }, + initPark: function () { + var that = this + // 车场信息获取 + Http.get({ + url: config.api.getParkInfo, + data: {} + }) + .then(res => { + console.log(res) + that.setData({ + park: res.data, + }) + }) + }, + initUsrCarList: function () { + var that = this + // 绑定车获取 + Http.get({ + url: config.api.getUserCarList, + data: {} + }).then(res => { + console.log(res); + that.setData({ + carList: res.data + }) + }) + }, + init: function () { + var that = this + + app.parkInitCallback = token => { + that.initPark() + that.initUsrCarList() + if (!app.globalData.carLogin) { + // 共同登录 + Http.post({ + url: config.api.carInit, + data: { + phone: app.globalData.phone + } + }).then(res => { + app.globalData.carLogin = true + app.globalData.parkVendor = res.data.vendor + if (res.data.token != "undefined") { + app.globalData.etcpToken = res.data.token + console.log("etcpToken", app.globalData.etcpToken) + } + // 获取 停车费 + that.getStopFee() + }) + } + } + if (app.globalData.token && app.globalData.token != null) { + app.parkInitCallback(app.globalData.token) + } + } +}) \ No newline at end of file diff --git a/pages/passCar/choiceCar/choiceCar.json b/pages/passCar/choiceCar/choiceCar.json new file mode 100644 index 0000000..be67e26 --- /dev/null +++ b/pages/passCar/choiceCar/choiceCar.json @@ -0,0 +1,3 @@ +{ + "navigationBarTitleText": "券绑车牌" +} \ No newline at end of file diff --git a/pages/passCar/choiceCar/choiceCar.wxml b/pages/passCar/choiceCar/choiceCar.wxml new file mode 100644 index 0000000..390c226 --- /dev/null +++ b/pages/passCar/choiceCar/choiceCar.wxml @@ -0,0 +1,29 @@ + + + 我的爱车 + + + + + + {{item.carNumber}} + + + + + + {{'待支付金额:¥'+item.remainingFee}} + + + + + + + + + + + +添加爱车 + + + \ No newline at end of file diff --git a/pages/passCar/choiceCar/choiceCar.wxss b/pages/passCar/choiceCar/choiceCar.wxss new file mode 100644 index 0000000..bfb628f --- /dev/null +++ b/pages/passCar/choiceCar/choiceCar.wxss @@ -0,0 +1,291 @@ +/**passCar.wxss**/ +page{ + background-color: #f8f8f8; +} +.headBox{ + margin-top: 13rpx; + width: 750rpx; + height: 210rpx; + box-sizing: border-box; + padding: 30rpx 40rpx; + display: flex; + background-color: white +} +.headBox image{ + width: 150rpx; + height: 150rpx; + margin:10rpx 30rpx 0 0; + border-radius:16rpx; +} +.numberBox{ + width: 400rpx; + height: 150rpx +} +.titleName{ + line-height: 60rpx; + height:60rpx; + color: #666; + font-size: 32rpx; + width: 400rpx; + word-break:break-all; + text-align: justify; + margin-bottom: 10rpx; +} +::-webkit-scrollbar{ +width: 0; +height: 0; +color: transparent; +} +.carLocation,.locationNumber{ + width: 400rpx; + height: 40rpx; + color: #666; + font-size: 24rpx; + line-height: 30rpx; +} +.price{ + font-size: 28rpx; +} +.borderBox{ + width: 750rpx; + margin-top: 26rpx; + +} +.borderUp{ + padding: 50rpx; + width: 650rpx; + height: 50rpx; + line-height: 50rpx; + font-size: 36rpx; + color: #333; + border-bottom: 1rpx #f8f8f8 solid; + background-color: white; + +} +.carNumber{ + padding: 50rpx; + height: 50rpx; + line-height: 50rpx; + font-size: 28rpx; + color: #cbcbcb; + background-color: white; +} +.addBox{ + width: 750rpx; + height: 220rpx; + position: relative; + background-color: white; +} +.add{ + position: absolute; + left: 50%; + top: 50%; + transform: translate(-50%,-50%); + font-size: 34rpx; + color: #666; + border:2px dashed #eee; + padding: 30rpx 50rpx; + border-radius:16rpx; +} +.add text{ + font-size: 40rpx; +} +.bottonBox{ + width: 750rpx; + margin-top: 75rpx; +} +.textStyle{ + background-color: white; + height: 90rpx; + line-height: 90rpx; + padding-left: 130rpx; + color: #333; + font-size: 28rpx; + letter-spacing: 1rpx; + border-bottom: 1rpx #f8f8f8 solid; + position: relative; +} +.textStyle image{ + width: 50rpx; + height: 50rpx; + top: 20rpx; + left: 50rpx; + position: absolute; + +} +.passNumberBox{ + width: 750rpx; + position: relative; + background-color: white; + border-bottom: 1rpx #f8f8f8 solid ; +} +.passNumber{ + width: 400rpx; + height: 150rpx; + + font-size: 32rpx; + font-weight: 600; + line-height: 150rpx; + left: 55rpx; + position: absolute; +} +.nopay{ + height: 80rpx; + line-height: 80rpx; + font-weight: 400; +} +.number{ + font-size: 32rpx; +} +.parkPrice{ + font-size: 30rpx; + font-weight: 500; +} +.deleteButton{ + font-size: 28rpx; + line-height: 50rpx; + height: 50rpx; + top: 50%; + right: 30rpx; + position: absolute; + transform: translate(0,-50%); +} +.detail{ + width: 32rpx; + height: 32rpx; + right: 50rpx; + top: 32rpx; + position: absolute; +} +.detail image{ + width: 32rpx; + height: 32rpx; + position: absolute; + left: 0; + top: 0; +} +.voucher{ + width: 90%; + padding: 0 5%; + background-color: rgb(255, 178, 50); + /* background-color: #cbcbcb; */ + height: 80rpx; + position: relative; + margin: 24rpx 0; + border-bottom: 2rpx #fff solid; + display: flex; + justify-content: space-between; + +} +.textV1,.textV2{ + height: 58rpx; + width: 225rpx; + padding-top: 22rpx; + text-align: center; + line-height: 80rxp; + font-size: 28rpx; + color: #fff; +} +.textV2{ + margin-top: -1rpx; + padding: 0; + /* background-color: rgb(0, 192, 255); */ + border-radius: 10rpx; + width: 221rpx; + height: 80rpx; + line-height: 80rpx; + font-size: 36rpx; + border: 4rpx #fff solid; + margin-bottom: 22rpx; +} +/* .textV1{ + position: absolute; + left: 10rpx; + top: 22rpx; +} */ +/* .textV2{ + position: absolute; + top: 22rpx; + right: 80rpx; +} */ +.choice{ + width: 80rpx; + height: 80rpx; + position: relative; +} +.choice image{ + position: absolute; + left: 50%; + top: 50%; + transform: translate(-50%,-50%); + width: 30rpx; + height: 30rpx; +} +.buy-view { + background: #fff; + position: relative; + padding-top: 10rpx; + height:98rpx; + bottom: 0rpx; + margin-top: 50rpx; + /* left: 0; + right: 0; */ +} +.buy { + background: #00c0ff; + height: 88rpx; + width: 98%; + margin: 30rpx auto; + color: #fff; + font-size: 36rpx; + line-height: 88rpx; + border-radius: 6rpx; +} +.borderBox{ + width: 750rpx; + margin-top: 26rpx; + +} +.orderBox { + width: 100%; + height: 100rpx; + border-top: 1rpx #f8f8f8 solid; + position: relative; + display: flex; +} + +.passUp { + width: 100%; + height: 150rpx; + position: relative; +} +.priceBox{ + width: 500rpx; +} +.priceBox text{ + margin-top: 35rpx; + color: #333; + font-size: 24rpx; + margin-left: 50rpx; + display: block; +} +.payBox{ + width: 250rpxpx; +} +.payBox button{ + width: 230rpx; + border:0; + font-size: 32rpx; + margin-top: 13rpx; + margin-right: 20rpx; + background-color: lightgreen; + color: white; +} +input{ + outline:none; + border:none; + list-style: none; +} +button::after{ +border:none; +} diff --git a/pages/passCar/couponList/couponList.js b/pages/passCar/couponList/couponList.js new file mode 100644 index 0000000..f08075e --- /dev/null +++ b/pages/passCar/couponList/couponList.js @@ -0,0 +1,129 @@ +const format = require("../../../utils/util.js"); +const config = require("../../../config/config.js"); +const app = getApp(); +const Http = require("../../../utils/HttpBasics"); +Page({ + data: { + tabs: [ + { + key: 0, + name: "未使用" + }, + { + key: 1, + name: "已使用" + }, + { + key: 2, + name: "已过期" + }, + { + key: 3, + name: "已退款" + } + ], + list: [], + current: "0", + current_scroll: "0", + page: 1, + allow_load: true + }, + onLoad() { + this.getList(0, 0); + }, + + //点击跳转到券详情页面 + gotouse: function (e) { + console.log(e.currentTarget.dataset.quancode); + console.log("点击跳转到券详情"); + wx.navigateTo({ + url: `/pages/couponorder/detail/index?quancode=${ + e.currentTarget.dataset.quancode + }`, + success: function (res) { + // success + console.log("点击跳转到券详情页面"); + }, + fail: function () { + // fail + }, + complete: function () { + // complete + } + }); + }, + getList(key, pageNum) { + var that = this; + console.log(key); + console.log(pageNum); + if (that.data.allow_load) { + wx.showLoading({ + title: "加载中" + }); + Http.get({ + url: config.api.couponOrderList + "?type=5", + data: { + pageNum: pageNum, + pageSize: 8, + couponOrderStatus: key + } + }).then(res => { + console.log(res); + res.data.list.map(file => { + file.expiredTime = format.formatTime( + file.expiredTime, + "yyyy-MM-dddd hh:mm:ss" + ); + }); + console.log("姐姐的订单列表"); + setTimeout(function () { + wx.hideLoading(); + }, 1200); + if (pageNum >= res.data.pages) { + that.setData({ + allow_load: false + }); + } + /** + * 先赋值后渲染页面 + * concat 不会改变原数组值 + * push 会改变原数组值,但不会一条一条插入,而是整个数组插入 + */ + that.data.list = that.data.list.concat(res.data.list); + that.setData({ + list: that.data.list + }); + }); + } else { + console.log("加载完成allow_load设置成false"); + } + }, + handleChange({ detail }) { + console.log(detail); + this.setData({ + current: detail.key + }); + }, + handleChangeScroll({ detail }) { + this.setData({ + list: [], + allow_load: true, + current_scroll: detail.key + }); + this.getList(detail.key, 1); + this.setData({ + current_scroll: detail.key + }); + }, + onReachBottom: function () { + var that = this; + console.log(that.data.page); + that.data.page++; + console.log(that.data.page); + that.setData({ + page: that.data.page + }); + console.info("after++ " + that.data.page); + that.getList(that.data.current_scroll, that.data.page); + } +}); diff --git a/pages/passCar/couponList/couponList.json b/pages/passCar/couponList/couponList.json new file mode 100644 index 0000000..276ffad --- /dev/null +++ b/pages/passCar/couponList/couponList.json @@ -0,0 +1,7 @@ +{ + "usingComponents": { + "i-tab": "../../../dist/tab/index", + "i-tabs": "../../../dist/tabs/index" + }, + "navigationBarTitleText": "我的优惠劵" +} \ No newline at end of file diff --git a/pages/passCar/couponList/couponList.wxml b/pages/passCar/couponList/couponList.wxml new file mode 100644 index 0000000..9990206 --- /dev/null +++ b/pages/passCar/couponList/couponList.wxml @@ -0,0 +1,43 @@ + + + + + + + + + 暂无优惠券可用 + + + + + + + + + + + {{item.title}} + + + 有效期至: + {{item.expiredTime}} + + 立即使用 + 查看 + + + + + + 2小时免费停车券 + 京A88888 + 2018-08-30 + + 2018-09-30 + 朝阳大悦城 + + + \ No newline at end of file diff --git a/pages/passCar/couponList/couponList.wxss b/pages/passCar/couponList/couponList.wxss new file mode 100644 index 0000000..6ff18eb --- /dev/null +++ b/pages/passCar/couponList/couponList.wxss @@ -0,0 +1,165 @@ +.market { + width: 100%; + height: 100%; +} + +.tabs { + width: 100% !important; + height: 88rpx; + text-align: center; +} + +.i-tab { + width: 25% !important; + display: inline-block; +} + +.section { + margin-top: 2%; +} +.section:nth-of-type(1) { + margin-top: 30rpx; +} + +.detail_msg { + width: 92%; + height: 202rpx !important; + background: #fff; + display: flex; + padding: 0 4%; + margin-top: 2%; + border-bottom: 1px solid #ededed; +} + +.logo { + width: 348rpx; + height: 184rpx; +} + +.logo image { + width: 100%; + height: 100%; + border-radius: 15rpx; +} + +.info view:nth-child(1) { + display: flex; + justify-content: space-between; + padding: 0 4%; +} + +.info { + width: 100%; +} + +.info view:nth-child(1) text { + font-size: 30rpx; + margin-top: 10rpx; + color: #666; +} + +.info view:nth-child(2) { + color: #ff3434; + font-size: 24rpx; + padding-left: 4%; + margin-top: 1%; +} + +.info view:nth-child(3) { + margin-left: 20rpx; +} + +.btns { + width: 200rpx; + height: 60rpx; + line-height: 60rpx; + text-align: center; + background: #00c0ff; + color: #fff; + float: right; + border-radius: 15rpx; + font-size: 28rpx; + margin-top: 20rpx; +} + +.txt1 { + font-size: 22rpx; + color: #999; +} + +.txt2 { + font-size: 22rpx; + color: #f96563; +} + +.nocoupon image{ + width: 203rpx; + display: block; + margin: 200rpx auto 0; +} +.nocoupon text{ + display: block; + text-align: center; + font-size:30rpx; + color: #00C0FF; +} +.nocoupon button{ + background: #00C0FF; + color: #fff; + font-style: 30rpx; + width: 70%; + margin: 30rpx auto 0; +} +.imageBox,imageBox image{ + width: 100%; + height: 250rpx; + margin-top: 30rpx; + position: relative; +} +image{ + width: 100%; + height: 100%; +} +.text1{ + color: white; + font-size: 28rpx; + position: absolute; + top: 32rpx; + left: 50rpx; +} +.text2{ + color: white; + font-size: 40rpx; + position: absolute; + top: 90rpx; + left: 50rpx; +} +.text3{ + color: white; + font-size: 32rpx; + position: absolute; + top: 60rpx; + right: 50rpx; +} +.text4{ + color: white; + font-size: 32rpx; + position: absolute; + top: 150rpx; + right: 50rpx; +} +.text5{ + color: white; + font-size: 28rpx; + position: absolute; + bottom: 32rpx; + left: 50rpx; +} +.text6{ + color: white; + font-size: 24rpx; + position: absolute; + top: 110rpx; + right: 120rpx; + font-weight: 600; +} \ No newline at end of file diff --git a/pages/passCar/passCar.js b/pages/passCar/passCar.js index 1b87fd0..ceee941 100644 --- a/pages/passCar/passCar.js +++ b/pages/passCar/passCar.js @@ -47,6 +47,7 @@ Page({ if (options) console.log(options) if (that.data.addCar) { + console.log(JSON.stringify(that.data.addCar)) // 绑车牌 if (app.globalData.carLogin) { that.bindCar(that.data.addCar) diff --git a/pages/passCar/passCar.wxml b/pages/passCar/passCar.wxml index 6bca2a0..a039011 100644 --- a/pages/passCar/passCar.wxml +++ b/pages/passCar/passCar.wxml @@ -9,7 +9,6 @@ 总车位: - @@ -60,6 +59,7 @@ + 我的停车券 @@ -68,6 +68,7 @@ +