From f5f49b624e5de3c43d1f1c9cd57b2e8032b057a5 Mon Sep 17 00:00:00 2001 From: meo <18801474720@163.com> Date: Fri, 24 May 2019 16:43:24 +0800 Subject: [PATCH] =?UTF-8?q?[=E9=97=A8=E5=BA=97=E8=AF=A6=E6=83=85][?= =?UTF-8?q?=E4=BF=AE=E6=94=B9]:[=E9=97=A8=E5=BA=97=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E7=9A=84=E4=BF=AE=E6=94=B9]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 3 + components/coupons/index.js | 6 - pages/edit/edit.js | 37 ++- pages/getuserinfo/index.js | 18 ++ pages/index/index.js | 29 +- pages/index/searchbar/detail/index.js | 334 ++++++++++++------------ pages/index/searchbar/detail/index.wxml | 4 +- pages/passCar/passCar.js | 249 ++++++++---------- project.config.json | 2 +- 9 files changed, 346 insertions(+), 336 deletions(-) diff --git a/app.js b/app.js index 8712f83..f73715c 100644 --- a/app.js +++ b/app.js @@ -64,6 +64,9 @@ App({ data: usrdata }) .then(res => { + console.log(res.data.token) + console.log("-------------------------------------------token---------------------------------------") + if (res.data && res.data.score) { if (res.data.score != 0) { that.globalData.score = res.data.score; diff --git a/components/coupons/index.js b/components/coupons/index.js index cd326e6..ff6bcc1 100644 --- a/components/coupons/index.js +++ b/components/coupons/index.js @@ -18,16 +18,10 @@ Component({ data: {}, methods: { gotoDetail(e) { - console.log(e.currentTarget.dataset.couponid); - console.log(e.currentTarget.dataset.title); - console.log(e.currentTarget.dataset.id); let couponId = e.currentTarget.dataset.couponid; let title = e.currentTarget.dataset.title; let id = e.currentTarget.dataset.id; let targetAd = e.currentTarget.dataset.targetad; - if (targetAd) { - - } if (id && targetAd != 7) { wx.navigateTo({ url: `/pages/coupon/detail/index?couponChannelId=${id}&couponId=${couponId}&title=${title}`, diff --git a/pages/edit/edit.js b/pages/edit/edit.js index 964632f..6b19a74 100644 --- a/pages/edit/edit.js +++ b/pages/edit/edit.js @@ -96,10 +96,9 @@ Page({ var birthdate = null; } if (username == null || address == null || sex == 0 || birthdate == null) { - wx.showModal({ - title: '提示', - content: '请输入完整的用户信息', - showCancel: false + wx.showToast({ + title: '请输入完整的用户信息', + icon:"none" }) } else { Http.post({ @@ -112,15 +111,11 @@ Page({ } }) .then(res => { - wx.showModal({ - title: '提示', - content: '修改成功', - showCancel: false, - success: function (res) { - wx.switchTab({ - url: '/pages/user/index', - }) - } + wx.showToast({ + title: "修改成功", + icon: 'none', + duration: 2000, + mask: false }) }) .catch(err => { @@ -129,7 +124,7 @@ Page({ icon: 'none', duration: 2000, mask: false - }); + }) }) } }, @@ -156,7 +151,7 @@ Page({ }) } var reg = RegExp(/address/); - if (res.data.address.match(reg)) { + if (res&&res.data&&res.data.address&&res.data.address.match(reg)) { that.setData({ address: JSON.parse(res.data.address).address + JSON.parse(res.data.address).name, addressStr: JSON.parse(res.data.address).address + JSON.parse(res.data.address).name @@ -198,12 +193,12 @@ Page({ } }) .catch(error=>{ - console.log(error) - wx.showModal({ - title: '提示', - content: error.errMsg, - showCancel:false - }) + wx.showToast({ + title: error.errMsg, + icon: 'none', + duration: 2000, + mask: false + }); }) } }) \ No newline at end of file diff --git a/pages/getuserinfo/index.js b/pages/getuserinfo/index.js index bd672dd..5d05597 100755 --- a/pages/getuserinfo/index.js +++ b/pages/getuserinfo/index.js @@ -28,6 +28,12 @@ Page({ orderId:options.orderId }) } + if (options && options.frommd && options.id){ + that.setData({ + id: options.id, + frommd: options.frommd + }) + } that.setData({ optionData: wx.getStorageSync('options') ? JSON.parse(wx.getStorageSync('options')):null }) @@ -120,6 +126,18 @@ Page({ wx.redirectTo({ url: `/pages/topicDetail/index?id=${that.data.optionData.id}` }); + } + // 门店详情 + else if (that.data.optionData.id && app.globalData.type == 'md') { + wx.redirectTo({ + url: `/pages/index/searchbar/detail/index?id=${that.data.optionData.id}` + }); + } + // 通过分享进入的门店详情页面 + else if (that.data.id && that.data.frommd == 'md') { + wx.redirectTo({ + url: `/pages/index/searchbar/detail/index?id=${that.data.id}` + }); } else if (that.data.optionData.bt && that.data.optionData.id && app.globalData.type == 'bd') { // 宣传页详情 if (that.data.optionData.bt == '2') { diff --git a/pages/index/index.js b/pages/index/index.js index 8e5a6c7..261cd22 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -13,6 +13,7 @@ Page({ */ onLoad: function(options) { let that = this; + console.log(options) wx.showToast({ title: '加载中', icon: "loading", @@ -35,6 +36,7 @@ Page({ that.setData({ newArr: this.data.scene.split(':') }) + //// 大屏-二维码-start if (this.data.newArr[0] == 'JC') { // 跳转券详情 @@ -59,14 +61,16 @@ Page({ } else if (options.type == 'td') { // 专题活动页 options.id = this.data.newArr[2]; + } else if (options.type == 'md') { + // 门店详情 + options.id = this.data.newArr[2]; } } } wx.setStorageSync('options', JSON.stringify(options)) - wx.setStorageSync('imgurl', imgurl) + wx.setStorageSync('imgurl', imgurl); - // app.getLocation(); if (app.globalData.token) { if (options.couponChannelId || options.orderId || options.id) { that.userStatus(options); @@ -171,6 +175,12 @@ Page({ wx.redirectTo({ url: `/pages/topicDetail/index?id=${options.id}` }); + } + // 门店详情 + else if (options && options.id && app.globalData.type == 'md') { + wx.redirectTo({ + url: `/pages/index/searchbar/detail/index?id=${options.id}` + }); } // 参与砍价 else if (options && options.orderId) { @@ -275,11 +285,16 @@ Page({ } // 门店 else if (app.globalData.type == 'ml') { - // 门店 wx.switchTab({ url: '/pages/index/searchbar/index' }) - } else { + } + // 通过分享进入的门店详情 + else if (options && options.id && options.frommd == 'md') { + wx.redirectTo({ + url: `/pages/index/searchbar/detail/index?id=${options.id}` + }); + }else { // 主页 wx.switchTab({ url: '/pages/main/index' @@ -319,6 +334,12 @@ Page({ wx.redirectTo({ url: `/pages/getuserinfo/index?orderId=${options.orderId}&from='${"discount"}` }) + } + // 通过分享进入的门店详情 + else if (options && options.id && options.frommd == 'md') { + wx.redirectTo({ + url: `/pages/getuserinfo/index?id=${options.id}&frommd=md` + }); } else { wx.redirectTo({ url: `/pages/getuserinfo/index` diff --git a/pages/index/searchbar/detail/index.js b/pages/index/searchbar/detail/index.js index 46c98e6..bdbdca7 100644 --- a/pages/index/searchbar/detail/index.js +++ b/pages/index/searchbar/detail/index.js @@ -22,7 +22,7 @@ Page({ imglist: null, shopVoList: [], couponList: [], //活动劵列表 - qrCodeL:'',//小程序码 + qrCodeL: '', //小程序码 currentTab: 0, isshare: false, showpost: false, @@ -33,9 +33,6 @@ Page({ totalHeight: 0, canvasScale: 1.0, // 画布放大的倍数,因为如果保存的是一倍的分享图片的话,分享图会有点虚。所以保存的时候,canvasScale设置为2.0,wxss 里面的left: 500%;打开注释。就可保存两倍的分享图 }, - /** - * 分享海报的生成 - */ //关闭海报 closePoste: function() { this.setData({ @@ -64,9 +61,8 @@ Page({ * 绘制分享海报 */ begainDrawShareImage() { - - wx.showLoading({ - title: '生成中...', + wx.showLoading({ + title: '生成中...', }) var that = this @@ -88,10 +84,10 @@ Page({ let bgimg1 = this.data.poterbg + `?imageView/2/w/${wW}/h/${wH}` let bgimg2 = bgimg1.replace(imgOrgUrl1, imgNewUrl) ctx.drawImage(bgimg2, 0, 0, wW, wH); - //绘制头像 - let avatar1 = this.data.avatarUrl + `?imageView/2/w/${wW}/h/${wH}` - let avatar2 = avatar1.replace(imgOrgUrl, imgNewUrl) - ctx.drawImage(avatar2, 15, 10, 30*scale,30*scale); + //绘制头像 + let avatar1 = this.data.avatarUrl + `?imageView/2/w/${wW}/h/${wH}` + let avatar2 = avatar1.replace(imgOrgUrl, imgNewUrl) + ctx.drawImage(avatar2, 15, 10, 30 * scale, 30 * scale); // 首先要绘制顶部的背景图片,因为它在最底层,然后才能绘制其他内容 let topImageWidth = parseInt(315 * scale) // 因为小数有时候会请求不到图片,所以转成int let topImageHeight = parseInt(200 * scale) @@ -102,22 +98,22 @@ Page({ success: function(res) { // 绘制白色背景 ctx.setFillStyle('#fff') - ctx.fillRect(25,45, topImageWidth+10, topImageHeight+10) + ctx.fillRect(25, 45, topImageWidth + 10, topImageHeight + 10) ctx.draw() - ctx.drawImage(res.path, 30,50, topImageWidth, topImageHeight) + ctx.drawImage(res.path, 30, 50, topImageWidth, topImageHeight) that.drawOtherContent(ctx, scale) that.drawOtherImage(ctx, scale) } }) }, //获取头像和昵称 - getUserInfo: function () { + getUserInfo: function() { let that = this; // 获取用户信息 Http.get({ - url: config.api.getScore, - data: {} - }) + url: config.api.getScore, + data: {} + }) .then(res => { console.log(res) that.setData({ @@ -129,45 +125,45 @@ Page({ // 绘制除了图片之外的剩余内容 drawOtherContent(ctx, scale) { //昵称 - this.drawNormalText(ctx, this.data.nickName+" 向您推荐", 50 * scale, 25 * scale, 16 * scale, '#fff', 'left', 'middle', scale); + this.drawNormalText(ctx, this.data.nickName + " 向您推荐", 50 * scale, 25 * scale, 16 * scale, '#fff', 'left', 'middle', scale); //店铺名 this.drawNormalText(ctx, this.data.data.merchantName, 180 * scale, 280 * scale, 30 * scale, '#fff', 'center', 'middle', scale); //店铺电话 // this.drawNormalText(ctx, "商铺电话:"+this.data.data.merchantLinkPhone, 100 * scale, 405 * scale, 16 * scale, '#000', 'left', 'middle', scale); - if (this.data.couponList.length>0) { + if (this.data.couponList.length > 0) { for (let i = 0; i < this.data.couponList.length; i++) { // 第一个商品信息 - this.drawNormalText(ctx, this.substrTile(this.data.couponList[1].title), 40 * scale, 396 * scale, 14 * scale, '#000', 'left', 'middle', scale); - this.drawNormalText(ctx, "价格:"+this.data.couponList[1].salePrice, 40 * scale, 416 * scale, 14 * scale, '#FF3232', 'left', 'middle', scale); - //第二个商品信息 - this.drawNormalText(ctx, this.substrTile(this.data.couponList[2].title), 155 * scale, 396 * scale, 14 * scale, '#000', 'left', 'middle', scale); - this.drawNormalText(ctx, "价格:"+this.data.couponList[2].salePrice, 155 * scale, 416 * scale, 14 * scale, '#FF3232', 'left', 'middle', scale); - //第三个商品信息 - this.drawNormalText(ctx, this.substrTile(this.data.couponList[3].title), 270 * scale, 396 * scale, 14 * scale, '#000', 'left', 'middle', scale); - this.drawNormalText(ctx, "价格:"+this.data.couponList[3].salePrice, 270 * scale, 416 * scale, 14 * scale, '#FF3232', 'left', 'middle', scale); + this.drawNormalText(ctx, this.substrTile(this.data.couponList[1].title), 40 * scale, 396 * scale, 14 * scale, '#000', 'left', 'middle', scale); + this.drawNormalText(ctx, "价格:" + this.data.couponList[1].salePrice, 40 * scale, 416 * scale, 14 * scale, '#FF3232', 'left', 'middle', scale); + //第二个商品信息 + this.drawNormalText(ctx, this.substrTile(this.data.couponList[2].title), 155 * scale, 396 * scale, 14 * scale, '#000', 'left', 'middle', scale); + this.drawNormalText(ctx, "价格:" + this.data.couponList[2].salePrice, 155 * scale, 416 * scale, 14 * scale, '#FF3232', 'left', 'middle', scale); + //第三个商品信息 + this.drawNormalText(ctx, this.substrTile(this.data.couponList[3].title), 270 * scale, 396 * scale, 14 * scale, '#000', 'left', 'middle', scale); + this.drawNormalText(ctx, "价格:" + this.data.couponList[3].salePrice, 270 * scale, 416 * scale, 14 * scale, '#FF3232', 'left', 'middle', scale); } - + } this.drawNormalText(ctx, "长按二维码识别小程序进店逛逛", 85 * scale, 570 * scale, 16 * scale, '#000', 'left', 'middle', scale); ctx.draw(true) }, - //截取商品名 - substrTile(str){ - return str.substr(0,5)+'...' - }, + //截取商品名 + substrTile(str) { + return str.substr(0, 5) + '...' + }, // 绘制活动图片 drawOtherImage(ctx, scale) { var that = this // 如果该商户有活动商品 - if (that.data.couponList.length>0) { + if (that.data.couponList.length > 0) { let cotentImageWidth = parseInt(80 * scale) let cotentImageHeight = parseInt(80 * scale) for (let i = 0; i < that.data.couponList.length; i++) { let imageItem = that.data.couponList[i].coverImg let src1 = imageItem + `?imageView/2/w/${cotentImageWidth}/h/${cotentImageHeight}` - - let src2 = src1.replace(imgOrgUrl, imgNewUrl) + + let src2 = src1.replace(imgOrgUrl, imgNewUrl) wx.getImageInfo({ src: src2, success: function(res) { @@ -178,23 +174,23 @@ Page({ } }) } - + + } + if (this.data.qrCode) { + let coImageWidth = parseInt(120 * scale) + let coImageHeight = parseInt(120 * scale) + let src1 = this.data.qrCode + `?imageView/2/w/${coImageWidth}/h/${coImageHeight}` + let src2 = src1.replace(imgOrgUrl, imgNewUrl) + wx.getImageInfo({ + src: src2, + success: function(res) { + ctx.drawImage(res.path, 115 * scale, 425 * scale, coImageWidth, coImageHeight) + ctx.draw(true) + } + }) } - if (this.data.qrCode) { - let coImageWidth = parseInt(120 * scale) - let coImageHeight = parseInt(120 * scale) - let src1 = this.data.qrCode + `?imageView/2/w/${coImageWidth}/h/${coImageHeight}` - let src2 = src1.replace(imgOrgUrl, imgNewUrl) - wx.getImageInfo({ - src: src2, - success: function(res) { - ctx.drawImage(res.path, 115 * scale, 425 * scale, coImageWidth, coImageHeight) - ctx.draw(true) - } - }) - } - wx.hideLoading() + wx.hideLoading() }, // 绘制只有一行的文字 drawNormalText(ctx, str, x, y, font, style, align, baseLine) { @@ -244,103 +240,103 @@ Page({ } }, /** - * 图片预览方法 - * 此处注意的一点就是,调用 "wx.previewImage"时,第二个参数要求为数组形式哦 - * 当然,做过图片上传功能的应该会注意到,如果涉及到多张图片预览,图片链接数组集合即为参数 urls! - */ - previewImage: function() { - wx.canvasToTempFilePath({ - x: 0, - y: 0, - width: this.data.windowWidth * this.data.canvasScale, - height: this.data.totalHeight * this.data.canvasScale, - canvasId: 'myCanvas', - success: function (res) { - var current = res.tempFilePath; - wx.previewImage({ - current: current, - urls: [current] - }) - }, - fail: function (res) { - wx.showToast({ - title: '图片生成失败', - icon: 'none', - duration: 2000 - }) - } - }) - -}, - // 保存图片 - saveImage(){ - let that = this - wx.canvasToTempFilePath({ - x: 0, - y: 0, - width: this.data.windowWidth * this.data.canvasScale, - height: this.data.totalHeight * this.data.canvasScale, - canvasId: 'myCanvas', - success: function (res) { - that.saveImageToPhotos(res.tempFilePath); - }, - fail: function (res) { - wx.showToast({ - title: '图片生成失败', - icon: 'none', - duration: 2000 - }) - } - }) -}, -saveImageToPhotos: function (tempFilePath) { - wx.saveImageToPhotosAlbum({ - filePath: tempFilePath, - success(result) { - wx.showToast({ - title: '保存成功,从相册中分享到朋友圈吧', - icon: 'none', - duration: 4000 - }) - }, - fail: function (err) { - if (err.errMsg === "saveImageToPhotosAlbum:fail:auth denied" || err.errMsg === "saveImageToPhotosAlbum:fail auth deny") { - // 这边微信做过调整,必须要在按钮中触发,因此需要在弹框回调中进行调用 - wx.showModal({ - title: '提示', - content: '需要您授权保存相册', - showCancel: false, - success:modalSuccess=>{ - wx.openSetting({ - success(settingdata) { - console.log("settingdata", settingdata) - if (settingdata.authSetting['scope.writePhotosAlbum']) { - wx.showModal({ - title: '提示', - content: '获取权限成功,再次点击图片即可保存', - showCancel: false, - }) - } else { - wx.showModal({ - title: '提示', - content: '获取权限失败,将无法保存到相册哦~', - showCancel: false, - }) - } - }, - fail(failData) { - console.log("failData",failData) - }, - complete(finishData) { - console.log("finishData", finishData) - } - }) - } + * 图片预览方法 + * 此处注意的一点就是,调用 "wx.previewImage"时,第二个参数要求为数组形式哦 + * 当然,做过图片上传功能的应该会注意到,如果涉及到多张图片预览,图片链接数组集合即为参数 urls! + */ + previewImage: function() { + wx.canvasToTempFilePath({ + x: 0, + y: 0, + width: this.data.windowWidth * this.data.canvasScale, + height: this.data.totalHeight * this.data.canvasScale, + canvasId: 'myCanvas', + success: function(res) { + var current = res.tempFilePath; + wx.previewImage({ + current: current, + urls: [current] + }) + }, + fail: function(res) { + wx.showToast({ + title: '图片生成失败', + icon: 'none', + duration: 2000 }) } - }, - }) -}, + }) + + }, + // 保存图片 + saveImage() { + let that = this + wx.canvasToTempFilePath({ + x: 0, + y: 0, + width: this.data.windowWidth * this.data.canvasScale, + height: this.data.totalHeight * this.data.canvasScale, + canvasId: 'myCanvas', + success: function(res) { + that.saveImageToPhotos(res.tempFilePath); + }, + fail: function(res) { + wx.showToast({ + title: '图片生成失败', + icon: 'none', + duration: 2000 + }) + } + }) + }, + saveImageToPhotos: function(tempFilePath) { + wx.saveImageToPhotosAlbum({ + filePath: tempFilePath, + success(result) { + wx.showToast({ + title: '保存成功,从相册中分享到朋友圈吧', + icon: 'none', + duration: 4000 + }) + }, + fail: function(err) { + if (err.errMsg === "saveImageToPhotosAlbum:fail:auth denied" || err.errMsg === "saveImageToPhotosAlbum:fail auth deny") { + // 这边微信做过调整,必须要在按钮中触发,因此需要在弹框回调中进行调用 + wx.showModal({ + title: '提示', + content: '需要您授权保存相册', + showCancel: false, + success: modalSuccess => { + wx.openSetting({ + success(settingdata) { + console.log("settingdata", settingdata) + if (settingdata.authSetting['scope.writePhotosAlbum']) { + wx.showModal({ + title: '提示', + content: '获取权限成功,再次点击图片即可保存', + showCancel: false, + }) + } else { + wx.showModal({ + title: '提示', + content: '获取权限失败,将无法保存到相册哦~', + showCancel: false, + }) + } + }, + fail(failData) { + console.log("failData", failData) + }, + complete(finishData) { + console.log("finishData", finishData) + } + }) + } + }) + } + }, + }) + }, /** * 拨打电话 */ @@ -414,12 +410,14 @@ saveImageToPhotos: function (tempFilePath) { url: config.api.merchantList, data: data }).then(res => { + console.log(res) + console.log("-----------------------------onShow---------------------------------------") let imgList = []; imgList.push(res.data.list[0].merchantImgUrl) that.setData({ data: res.data.list[0], shopVoList: res.data.list[0].shopVoList, - imglist: res.data.list[0].coverPicture == '[]' ? imgList:JSON.parse(res.data.list[0].coverPicture), + imglist: res.data.list[0].coverPicture == '[]' ? imgList : JSON.parse(res.data.list[0].coverPicture), }) }) .catch(err => { @@ -450,7 +448,7 @@ saveImageToPhotos: function (tempFilePath) { }).then(res => { that.setData({ couponList: res.data.page.list, - qrCode:res.data.qrCode, + qrCode: res.data.qrCode, }) }) .catch(err => { @@ -470,24 +468,26 @@ saveImageToPhotos: function (tempFilePath) { url: `/pages/index/merchantList/index?id=${e.currentTarget.dataset.id}` }) }, - // onShareAppMessage: function(res) { - // var that = this; - // var shareObj = { - // title: that.data.data.title, - // path: `/pages/index/index?couponChannelId=${that.data.couponChannelId}`, - // success: function(res) { - // if (res.errMsg == 'shareAppMessage:ok') {} - // }, - // fail: function(error) { - // if (res.errMsg == 'shareAppMessage:fail cancel') {} else if (res.errMsg == 'shareAppMessage:fail') {} - // } - // }; - // // 来自页面内的按钮的转发 - // if (res.from === 'button') { - // var eData = res.target.dataset.id; - // shareObj.path = `/pages/index/index?couponChannelId=${eData}`; - // } - // // 返回shareObj - // return shareObj; - // }, + onShareAppMessage: function(res) { + let that = this; + let shareObj = { + title: that.data.data.merchantName, + path: `/pages/index/index?id=${that.data.id}&frommd=md`, + success: function(res) { + if (res.errMsg == 'shareAppMessage:ok') {} + }, + fail: function(error) { + if (res.errMsg == 'shareAppMessage:fail cancel') {} else if (res.errMsg == 'shareAppMessage:fail') {} + } + }; + // 来自页面内的按钮的转发 + if (res.from === 'button') { + console.log(res) + var eData = res.target.dataset.id; + console.log(eData) + shareObj.path = `/pages/index/index?id=${eData}&frommd=md`; + } + // 返回shareObj + return shareObj; + } }) \ No newline at end of file diff --git a/pages/index/searchbar/detail/index.wxml b/pages/index/searchbar/detail/index.wxml index b6baac6..1455a36 100644 --- a/pages/index/searchbar/detail/index.wxml +++ b/pages/index/searchbar/detail/index.wxml @@ -21,7 +21,7 @@ {{data.merchantName}} {{data.title}} - + @@ -105,7 +105,7 @@ - + 微信好友 diff --git a/pages/passCar/passCar.js b/pages/passCar/passCar.js index 8fd9d13..2dbdd9d 100644 --- a/pages/passCar/passCar.js +++ b/pages/passCar/passCar.js @@ -30,13 +30,13 @@ Page({ current: 0, stopFees: {}, scroll: true, - ifHaveCarModular:"", + ifHaveCarModular: "", canIUse: wx.canIUse("navigator") }, /** * 车牌轮播滑动 */ - onSlideChangeEnd: function (e) { + onSlideChangeEnd: function(e) { var that = this; /** * 获得当前的车牌号码 @@ -52,25 +52,25 @@ Page({ that.getStopFee(listCardNum); } }, - + //停车费用为0 - paySuccess:function(){ + paySuccess: function() { wx.showModal({ title: '支付成功', content: '请尽快离场', - showCancel:false + showCancel: false }) }, - gotomange: function () { + gotomange: function() { wx.navigateTo({ url: '/pages/managelicenseplate/managelicenseplate', }) }, - bindfail: function (res) { + bindfail: function(res) { console.log(res) }, - gotoetcp: function () { + gotoetcp: function() { wx.navigateToMiniProgram({ appId: that.data.etcpAppId, extraData: this.data.extraData, @@ -78,19 +78,19 @@ Page({ path: "pages/main/main", }) }, - showquan: function () { + showquan: function() { wx.navigateTo({ url: '/pages/passCar/couponList/couponList', }) }, - gotodetail: function (e) { + gotodetail: function(e) { wx.showModal({ title: '缴费规则', content: e.target.dataset.rule, showCancel: false, }) }, - onShow: function (options) { + onShow: function(options) { var that = this; that.setData({ etcpAppId: extConfig.attr.etcpAppId, @@ -132,7 +132,7 @@ Page({ }); } }, - onLoad: function (options) { + onLoad: function(options) { var that = this; /** * 获得分享小程序的 @@ -140,35 +140,35 @@ Page({ * desc */ Http.get({ - url: config.api.getWeapNote, - data: { - appId: config.weapp.AppId, - } - }) - .then(res => { - let weapNote = JSON.parse(res.data.weapNote); - that.setData({ - desc: weapNote.carpage.desc, - title: weapNote.carpage.title + url: config.api.getWeapNote, + data: { + appId: config.weapp.AppId, + } + }) + .then(res => { + let weapNote = JSON.parse(res.data.weapNote); + that.setData({ + desc: weapNote.carpage.desc, + title: weapNote.carpage.title + }) + }) + .catch(err => { + console.log(err); }) - }) - .catch(err => { - console.log(err); - }) // 登录 var scene = decodeURIComponent(options.scene); that.setData({ scene: scene }); - if (app.globalData.token) { } else { + if (app.globalData.token) {} else { // app.getLocation(); that.userLogin() } }, /** - * 用户登录 - */ - userLogin: function () { + * 用户登录 + */ + userLogin: function() { var that = this; // 登录 wx.login({ @@ -176,7 +176,7 @@ Page({ code }) => { wx.getSystemInfo({ - success: function (res) { + success: function(res) { that.setData({ systemInfo: JSON.stringify(res) }) @@ -201,14 +201,13 @@ Page({ }; } Http.post({ - url: config.api.login, - data: usrdata - }) + url: config.api.login, + data: usrdata + }) .then(res => { app.globalData.token = res.data.token; Http.setToken(res.data.token); that.checkUserCarStatus(); - // that.getUserInfo(); that.getList(); that.init(); that.initUsrCarList(); @@ -217,8 +216,7 @@ Page({ data: {} }); }) - .then(res => { - }) + .then(res => {}) .catch(err => { if (err.code == 11004) { // 用户昵称未授权 @@ -237,49 +235,30 @@ Page({ }); }, /** - * 检查用户是否有车 - */ - checkUserCarStatus: function () { + * 检查用户是否有车 + */ + checkUserCarStatus: function() { var that = this; Http.get({ - url: config.api.userCarCount, - data: {} - }).then(res => { - if (res.data > 0) { - // 用户名下有车 - app.globalData.phone = res.data.phone; - app.globalData.supportCar = true; - // 共同登录 - that.userCarLogin(); - } - }) - .catch(err => { + url: config.api.userCarCount, + data: {} + }).then(res => { + if (res.data > 0) { + // 用户名下有车 + app.globalData.phone = res.data.phone; + app.globalData.supportCar = true; + // 共同登录 + that.userCarLogin(); + } }) + .catch(err => {}) }, - /** - * 获取用户信息 - */ - // getUserInfo: function () { - // // 获取用户信息 - // wx.getSetting({ - // success: res => { - // if (res.authSetting["scope.userInfo"]) { - // // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框 - // wx.getUserInfo({ - // success: res => { - // // 可以将 res 发送给后台解码出 unionId - // } - // }); - // } - // } - // }) - // }, - jumpToAdd: function () { + jumpToAdd: function() { wx.navigateTo({ url: `/pages/addPark/addPark?flags=managepalte` }); }, - passc: function () { + passc: function() { wx.navigateTo({ url: '/pages/ques/ques', }) @@ -289,7 +268,7 @@ Page({ /** * 券绑定车牌 */ - bindCoupon: function (quanid) { + bindCoupon: function(quanid) { var that = this; /** * etcp @@ -307,9 +286,9 @@ Page({ }; var postCouponData = app.globalData.parkVendor == 1 ? etcpData : tjdData; Http.post({ - url: config.api.getCarCoupon, - data: postCouponData - }) + url: config.api.getCarCoupon, + data: postCouponData + }) .then(res => { that.initUsrCarList(); }) @@ -326,7 +305,7 @@ Page({ /** * 选择优惠券 */ - gotoquan: function () { + gotoquan: function() { let that = this; if (that.data.quanid) { wx.navigateTo({ @@ -344,17 +323,17 @@ Page({ getList() { var that = this; Http.get({ - url: config.api.couponOrderCarList + "?type=5&couponOrderStatus=0", - data: { - pageNum: 1, - pageSize: 8, - couponOrderStatus: 0 - } - }).then(res => { - that.setData({ - couponList: res.data.list - }); - }) + url: config.api.couponOrderCarList + "?type=5&couponOrderStatus=0", + data: { + pageNum: 1, + pageSize: 8, + couponOrderStatus: 0 + } + }).then(res => { + that.setData({ + couponList: res.data.list + }); + }) .catch(err => { console.log(err) }) @@ -364,7 +343,7 @@ Page({ /** * 共同登录 */ - init: function (carNumber) { + init: function(carNumber) { var that = this; app.parkInitCallback = token => { that.initPark(); @@ -374,9 +353,9 @@ Page({ * 判断是否授权手机号 */ Http.get({ - url: config.api.checkPhoneStatus, - data: {} - }) + url: config.api.checkPhoneStatus, + data: {} + }) .then(res => { Http.post({ url: config.api.carInit, @@ -426,7 +405,7 @@ Page({ } }, - bindCar: function (carNum) { + bindCar: function(carNum) { var that = this; // ETCP var etcpData = { @@ -438,9 +417,9 @@ Page({ }; var postData = app.globalData.parkVendor == 1 ? etcpData : tjdData; Http.post({ - url: config.api.bindCar, - data: postData - }) + url: config.api.bindCar, + data: postData + }) .then(res => { that.setData({ addCar: null @@ -450,7 +429,7 @@ Page({ title: "提示", showCancel: false, content: "绑车牌成功!", - success: function () { } + success: function() {} }); }) .catch(error => { @@ -458,19 +437,19 @@ Page({ title: "提示", showCancel: false, content: error.data.message, - success: function () { } + success: function() {} }); }); }, /** * 车场信息获取 */ - initPark: function () { + initPark: function() { var that = this; Http.get({ - url: config.api.getParkInfo, - data: {} - }) + url: config.api.getParkInfo, + data: {} + }) .then(res => { that.setData({ park: res.data @@ -490,11 +469,11 @@ Page({ /** * 车场状态获取 */ - getParkStatus: function () { + getParkStatus: function() { var that = this; Http.get({ - url: config.api.getParkStatus, - }) + url: config.api.getParkStatus, + }) .then(res => { console.log(res) }) @@ -511,30 +490,30 @@ Page({ /** * 绑定车获取 */ - initUsrCarList: function (flag) { + initUsrCarList: function(flag) { var that = this; Http.get({ - url: config.api.getUserCarList, - data: {} - }).then(res => { - that.setData({ - carList: res.data - }); - /** - * flag ==flags - * 表示从首页onShow进来的 - */ - if (flag == "flags" && res.data.length > 0) { - var listCardNum = res.data[0].carNumber; + url: config.api.getUserCarList, + data: {} + }).then(res => { that.setData({ - listCardNum: listCardNum - }) + carList: res.data + }); /** - * 获得停车费用 + * flag ==flags + * 表示从首页onShow进来的 */ - that.getStopFee(listCardNum); - } - }) + if (flag == "flags" && res.data.length > 0) { + var listCardNum = res.data[0].carNumber; + that.setData({ + listCardNum: listCardNum + }) + /** + * 获得停车费用 + */ + that.getStopFee(listCardNum); + } + }) .catch(err => { wx.showToast({ title: err.message, @@ -548,20 +527,20 @@ Page({ /** * 获得停车费用修改 */ - getStopFee: function (carNumber) { + getStopFee: function(carNumber) { let that = this; let postData = app.globalData.parkVendor == 1 ? { etcpToken: app.globalData.etcpToken, carNumber: carNumber } : { - carNumber: carNumber, - outCarId: outCarId - }; + carNumber: carNumber, + outCarId: outCarId + }; Http.post({ - url: config.api.getCarStopFee, - data: postData - }) + url: config.api.getCarStopFee, + data: postData + }) .then(res => { console.log(res) var extraDataStr = { @@ -595,22 +574,22 @@ Page({ /** * 下拉刷新 */ - onPullDownRefresh: function (e) { + onPullDownRefresh: function(e) { let that = this; that.initUsrCarList("flags"); wx.stopPullDownRefresh(); }, // 用户点击右上角分享 - onShareAppMessage: function () { + onShareAppMessage: function() { return { title: this.data.title, desc: this.data.desc, - success: function (res) { + success: function(res) { wx.showToast({ title: "分享成功", duration: 1000, icon: "success" - }); + }) } } } diff --git a/project.config.json b/project.config.json index 6edba2f..ff1f058 100644 --- a/project.config.json +++ b/project.config.json @@ -13,7 +13,7 @@ "checkInvalidKey": true }, "compileType": "miniprogram", - "libVersion": "2.2.0", + "libVersion": "2.5.0", "appid": "wxb11603577a84a86d", "projectname": "C%E7%AB%AF%E5%B0%8F%E7%A8%8B%E5%BA%8F", "isGameTourist": false,