diff --git a/app.json b/app.json index 138671d..8faae3a 100644 --- a/app.json +++ b/app.json @@ -1,6 +1,10 @@ { "pages": [ "pages/index/index", + "index/index", + "index/searchbar", + "index/passCar", + "index/user", "pages/integralmall/integraHistory/index", "pages/integralmall/payIntegcouponStatus/index", "pages/integralmall/payIntegcoupondetail/index", @@ -13,8 +17,6 @@ "pages/complete/index", "pages/topicDetail/index", "pages/acSignIn/index", - "pages/main/index", - "pages/index/searchbar/index", "pages/index/merchantList/index", "pages/index/searchbar/detail/index", "pages/bargain/bargainDatail/bargainDatail", @@ -27,7 +29,6 @@ "pages/bannerdetail/index", "pages/getuserinfo/index", "pages/phoneinput/phoneinput", - "pages/user/index", "pages/user/myactivity/index", "pages/coupon/detail/index", "pages/rushToBuy/index", @@ -38,7 +39,6 @@ "pages/order/detail/index", "pages/order/index/index", "pages/ques/ques", - "pages/passCar/passCar", "pages/getphoneInfo/index", "pages/addPark/addPark", "pages/orderquanma/index", @@ -70,35 +70,35 @@ } }, "tabBar": { - "color": "#abb1be", - "selectedColor": "#FD782D", + "custom": true, "list": [ { - "pagePath": "pages/main/index", + "pagePath": "index/index", "iconPath": "assets/images/home.png", "selectedIconPath": "assets/images/home-a.png", "text": "首页" }, { - "pagePath": "pages/index/searchbar/index", + "pagePath": "index/searchbar", "iconPath": "assets/images/mendian.png", "selectedIconPath": "assets/images/mendian-a.png", "text": "门店" }, { - "pagePath": "pages/passCar/passCar", + "pagePath": "index/passCar", "iconPath": "assets/images/park.png", "selectedIconPath": "assets/images/park-a.png", "text": "停车" }, { - "pagePath": "pages/user/index", + "pagePath": "index/user", "iconPath": "assets/images/user.png", "selectedIconPath": "assets/images/user-a.png", "text": "我的" } ] }, + "usingComponents": {}, "window": { "backgroundTextStyle": "dark", "navigationBarBackgroundColor": "#FFFFFF", diff --git a/components/navbar/navbar.js b/components/navbar/navbar.js index 48f045a..7c3c2b6 100644 --- a/components/navbar/navbar.js +++ b/components/navbar/navbar.js @@ -32,7 +32,7 @@ Component({ methods: { backHome: function () { wx.switchTab({ - url: '/pages/main/index', + url: '/index/index', }) }, back: function () { diff --git a/custom-tab-bar/index.js b/custom-tab-bar/index.js new file mode 100644 index 0000000..6823f96 --- /dev/null +++ b/custom-tab-bar/index.js @@ -0,0 +1,65 @@ +const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {} +let ifStoreApp = extConfig.attr.ifStoreApp; +Component({ + data: { + selected: 0, + "color": "#abb1be", + "selectedColor": "#FD782D", + "list": [ + { + "pagePath": "/index/index", + "iconPath": "../assets/images/home.png", + "selectedIconPath": "../assets/images/home-a.png", + "text": "首页" + }, + { + "pagePath": "/index/searchbar", + "iconPath": "../assets/images/mendian.png", + "selectedIconPath": "../assets/images/mendian-a.png", + "text": "门店" + }, + { + "pagePath": "/index/passCar", + "iconPath": "../assets/images/park.png", + "selectedIconPath": "../assets/images/park-a.png", + "text": "停车" + }, + { + "pagePath": "/index/user", + "iconPath": "../assets/images/user.png", + "selectedIconPath": "../assets/images/user-a.png", + "text": "我的" + } + ] + }, + attached() { + if (ifStoreApp==1){ + this.setData({ + list: [ + { + "pagePath": "/index/index", + "iconPath": "../assets/images/home.png", + "selectedIconPath": "../assets/images/home-a.png", + "text": "首页" + }, + { + "pagePath": "/index/user", + "iconPath": "../assets/images/user.png", + "selectedIconPath": "../assets/images/user-a.png", + "text": "我的" + } + ] + }) + } + }, + methods: { + switchTab(e) { + const data = e.currentTarget.dataset + const url = data.path + wx.switchTab({url}) + this.setData({ + selected: data.index + }) + } + } +}) \ No newline at end of file diff --git a/custom-tab-bar/index.json b/custom-tab-bar/index.json new file mode 100644 index 0000000..32640e0 --- /dev/null +++ b/custom-tab-bar/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} \ No newline at end of file diff --git a/custom-tab-bar/index.wxml b/custom-tab-bar/index.wxml new file mode 100644 index 0000000..29d1b9e --- /dev/null +++ b/custom-tab-bar/index.wxml @@ -0,0 +1,8 @@ + + + + + + {{item.text}} + + diff --git a/custom-tab-bar/index.wxss b/custom-tab-bar/index.wxss new file mode 100644 index 0000000..0cd91e7 --- /dev/null +++ b/custom-tab-bar/index.wxss @@ -0,0 +1,38 @@ +.tab-bar { + position: fixed; + bottom: 0; + left: 0; + right: 0; + height: 48px; + background: white; + display: flex; + padding-bottom: env(safe-area-inset-bottom); +} + +.tab-bar-border { + background-color: rgba(0, 0, 0, 0.33); + position: absolute; + left: 0; + top: 0; + width: 100%; + height: 1px; + transform: scaleY(0.5); +} + +.tab-bar-item { + flex: 1; + text-align: center; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; +} + +.tab-bar-item cover-image { + width: 27px; + height: 27px; +} + +.tab-bar-item cover-view { + font-size: 10px; +} diff --git a/ext.json b/ext.json index 0001af2..c01d81f 100644 --- a/ext.json +++ b/ext.json @@ -21,6 +21,7 @@ "etcpVersion": "release", "etcpCallbackUrl": "https://ciformall.youlane.cn/api/carCallback/etcpPaidCallback", "ifHaveWebSocket": "0", + "ifStoreApp": "1", "ifHaveCarModular": "1" }, "name": "富茂客官开发", @@ -29,34 +30,33 @@ }, "debug": false, "tabBar": { + "custom": true, "list": [ { - "text": "首页", + "pagePath": "index/index", "iconPath": "assets/images/home.png", - "pagePath": "pages/main/index", - "selectedIconPath": "assets/images/home-a.png" + "selectedIconPath": "assets/images/home-a.png", + "text": "首页" }, { - "text": "门店", + "pagePath": "index/searchbar", "iconPath": "assets/images/mendian.png", - "pagePath": "pages/index/searchbar/index", - "selectedIconPath": "assets/images/mendian-a.png" + "selectedIconPath": "assets/images/mendian-a.png", + "text": "门店" }, { - "text": "停车", + "pagePath": "index/passCar", "iconPath": "assets/images/park.png", - "pagePath": "pages/passCar/passCar", - "selectedIconPath": "assets/images/park-a.png" + "selectedIconPath": "assets/images/park-a.png", + "text": "停车" }, { - "text": "我的", + "pagePath": "index/user", "iconPath": "assets/images/user.png", - "pagePath": "pages/user/index", - "selectedIconPath": "assets/images/user-a.png" + "selectedIconPath": "assets/images/user-a.png", + "text": "我的" } - ], - "color": "#abb1be", - "selectedColor": "#FD782D" + ] }, "window": { "backgroundTextStyle": "dark", diff --git a/pages/main/index.js b/index/index.js similarity index 95% rename from pages/main/index.js rename to index/index.js index 47671ee..214dfac 100644 --- a/pages/main/index.js +++ b/index/index.js @@ -1,13 +1,16 @@ +const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {} +let ifStoreApp = extConfig.attr.ifStoreApp; const navigationBarHeight = (getApp().statusBarHeight + 60) + 'px' -const Http = require("../../utils/HttpBasics"); -const imgurl = require("../../utils/imgurl"); -const config = require("../../config/config"); -const QR = require("../../utils/memberqrcode.js"); -const util = require("../../utils/util"); -const bgColor = require("../../utils/bgColor.js") +const Http = require("../utils/HttpBasics"); +const imgurl = require("../utils/imgurl"); +const config = require("../config/config"); +const QR = require("../utils/memberqrcode.js"); +const util = require("../utils/util"); +const bgColor = require("../utils/bgColor.js") let app = getApp(); Page({ data: { + ifStoreApp: ifStoreApp, navigationBarTitle: '首页', navigationBarHeight, chengzhangBox: bgColor.colorFirst.main.chengzhangBox, @@ -106,30 +109,12 @@ Page({ }) } }, - // hideQrcode: function() { - // let that = this; - // that.setData({ - // showQrcode: false - // }) - // }, //跳往限时秒杀 gotoRushBuy: function() { wx.navigateTo({ url: '/pages/rushToBuy/index', }) }, - - //搜索门店 - // searchbar:function(){ - // wx.switchTab({ - // url: '/pages/index/searchbar/index', - // }) - // }, - - // createQrCode: function(url, canvasId, cavW, cavH) { - // //调用插件中的draw方法,绘制二维码图片 - // QR.api.draw(url, canvasId, cavW, cavH); - // }, swiperChange: function(e) { this.setData({ swiperCurrent: e.detail.current @@ -221,6 +206,12 @@ Page({ // util.barcode("barcode", optionss.quancode, 510, 100); }, onShow: function() { + if (typeof this.getTabBar === 'function' && + this.getTabBar()) { + this.getTabBar().setData({ + selected: 0 + }) + } let that = this; that.setData({ havePlayEd: app.globalData.havePlayEd ? app.globalData.havePlayEd : false diff --git a/index/index.json b/index/index.json new file mode 100644 index 0000000..f502a8d --- /dev/null +++ b/index/index.json @@ -0,0 +1,12 @@ +{ + "usingComponents": { + "c-banner": "../components/banner/index", + "discount-card": "../components/discountCard/index", + "c-coupons": "../pages/main/coupons/index", + "g-entry": "../components/gameentry/gentry", + "c-hot": "../components/hot/index", + "navbar": "../components/navbar/navbar" + }, + "enablePullDownRefresh": true, + "navigationBarBackgroundColor": "#F4F5F9" +} diff --git a/pages/main/index.wxml b/index/index.wxml similarity index 78% rename from pages/main/index.wxml rename to index/index.wxml index 62d8b26..e131645 100644 --- a/pages/main/index.wxml +++ b/index/index.wxml @@ -1,7 +1,7 @@ - + @@ -30,7 +30,7 @@ - + 砍价 @@ -43,7 +43,7 @@ 消费卡 - + 游戏频道 @@ -52,8 +52,23 @@ 积分商城 + + + + + 砍价 + + + + 拼团 + + + + 限时抢购 + + - + diff --git a/pages/main/index.wxss b/index/index.wxss similarity index 99% rename from pages/main/index.wxss rename to index/index.wxss index c91f8cc..1658e6c 100644 --- a/pages/main/index.wxss +++ b/index/index.wxss @@ -1,4 +1,4 @@ - @import "../../app.wxss"; + @import "../app.wxss"; page{ background: #F4F5F9; } diff --git a/pages/passCar/passCar.js b/index/passCar.js similarity index 94% rename from pages/passCar/passCar.js rename to index/passCar.js index c5d8184..59d0804 100644 --- a/pages/passCar/passCar.js +++ b/index/passCar.js @@ -1,768 +1,774 @@ -const navigationBarHeight = (getApp().statusBarHeight + 50) + 'px' -const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {} -let app = getApp(); -const format = require("../../utils/util.js"); -let config = require("../../config/config.js"); -let Http = require("../../utils/HttpBasics"); -let Util = require("../../utils/util"); -const imgurl = require("../../utils/imgurl"); -Page({ - data: { - navigationBarHeight, - jianUrl: imgurl.jian.url, - jiaofeiwm: imgurl.jiaofeiwm.url, - parkUrl: imgurl.park.url, - guanliHr: imgurl.guanliHr.url, - qidaiUrl: imgurl.qidai.url, - addUrl: imgurl.add.url, - tingcheHr: imgurl.tingcheHr.url, - cheUrl: imgurl.che.url, - jiaofei: imgurl.jiaofei.url, - wentiHr: imgurl.wentiHr.url, - park: null, - carList: [], - payList: [], - addCar: null, - tcq: 2, - flag: "", - extraData: {}, - desc: '', - title: '', - indicatorDots: true, - autoplay: false, - interval: 5000, - duration: 1000, - current: 0, - stopFees: {}, - scroll: true, - ifHaveCarModular: "", - canIUse: wx.canIUse("navigator"), - showTicketModal: false, - ticketList: [], - noCoupon:imgurl.noCoupon.url, - loadingUrl: imgurl.loading.url, - allow_load: true, - curPageNum: 1, - curPageSize: 15, - curTotalpageNum: 0, - quantitle: '', - quanid: '', - gouHr: imgurl.gouHr.url, - totalTicketNum: 0, - - }, - getMoreList(e) { - let totalNum = this.data.ticketList.length; - if (this.data.curPageNum < this.data.curTotalpageNum) { - this.setData({ - curPageNum: this.data.curPageNum+1 - }) - this.getTicketList(0 ,this.data.curPageNum); - } - - }, - /** - * 选择使用的优惠券 - */ - choicecoupon: function(e) { - /* wx.navigateBack(); - var pages = getCurrentPages(); - var prevPage = pages[pages.length - 2] //上一个页面 */ - var that = this; - var quantitle = e.currentTarget.dataset.title; - var quanid = e.currentTarget.dataset.id; - this.setData({ - quantitle: quantitle, - quanid: quanid, - showTicketModal: false, - }); - - that.bindCoupon(that.data.quanid); - /* wx.setStorage({ - key: 'chosed', - data: 'chosed', - }) */ - }, - /* - */ - getTicketList(key, pageNum) { - var that = this; - if (that.data.allow_load) { - wx.showLoading({ - title: "加载中" - }); - Http.get({ - url: config.api.couponOrderCarList, - data: { - pageNum: pageNum, - pageSize: 15, - couponOrderStatus: key - } - }).then(res => { - that.setData({ - curTotalpageNum: res.data.pages, - curPageNum: res.data.pageNum, - totalTicketNum: res.data.total - }) - res.data.list.map(file => { - file.expiredTime = format.formatTime( - file.expiredTime, - "yyyy-MM-dd hh:mm:ss" - ); - }); - setTimeout(function () { - wx.hideLoading(); - }, 1200); - if (pageNum >= res.data.pages) { - that.setData({ - allow_load: false - }); - } - /** - * 先赋值后渲染页面 - * concat 不会改变原数组值 - * push 会改变原数组值,但不会一条一条插入,而是整个数组插入 - */ - if (pageNum == 1) { - that.setData({ - ticketList: res.data.list, - curPageNum: pageNum - }); - } else { - that.setData({ - ticketList: that.data.ticketList.concat(res.data.list) - }); - } - // that.data.ticketList = that.data.ticketList.concat(res.data.list); - - this.hideLoading(); - }) - .catch(err => { - setTimeout(function () { - wx.hideLoading(); - }, 1200); - wx.showToast({ - title: err.errMsg, - icon: 'none', - duration: 2000, - mask: false - }); - }) - } else { - } - }, - //点击跳转到券详情页面 - gotouse: function (e) { - wx.navigateTo({ - url: `/pages/passCar/couponDetail/couponDetail?quancode=${ - e.currentTarget.dataset.quancode - }`, - success: function (res) { - // success - }, - fail: function () { - // fail - }, - complete: function () { - // complete - } - }); - }, - /** - * 车牌轮播滑动 - */ - onSlideChangeEnd: function (e) { - var that = this; - /** - * 获得当前的车牌号码 - */ - var listCardNum = (that.data.carList)[e.detail.current].carNumber; - that.setData({ - listCardNum: listCardNum - }); - /** - * 获得停车费用 - */ - if (that.data.scroll) { - that.getStopFee(listCardNum); - } - }, - - //停车费用为0 - paySuccess: function () { - wx.showModal({ - title: '支付成功', - content: '请尽快离场', - showCancel: false - }) - }, - - gotomange: function () { - wx.navigateTo({ - url: '/pages/managelicenseplate/managelicenseplate', - }) - }, - bindfail: function (res) { - console.log(res) - }, - gotoetcp: function () { - wx.navigateToMiniProgram({ - appId: that.data.etcpAppId, - extraData: this.data.extraData, - envVersion: 'release', - path: "pages/main/main", - }) - }, - showquan: function () { - wx.navigateTo({ - url: '/pages/passCar/couponList/couponList', - }) - }, - gotodetail: function (e) { - wx.showModal({ - title: '缴费规则', - content: e.target.dataset.rule, - showCancel: false, - }) - }, - onShow: function (options) { - console.log(123) - var that = this; - that.setData({ - etcpAppId: extConfig.attr.etcpAppId, - etcpVersion: extConfig.attr.etcpVersion, - etcpCallbackUrl: extConfig.attr.etcpCallbackUrl, - ifHaveCarModular: extConfig.attr.ifHaveCarModular - }) - if (app.globalData.token) { - that.getList(); - that.init(); - } else { - that.init(); - } - /** - * 只有用户选择了优惠券 - * 才会进行券和车牌的绑定 - */ - /* if (wx.getStorageSync("chosed") && that.data.quanid) { - that.getStopFee(that.data.listCardNum); - that.bindCoupon(that.data.quanid); - wx.setStorage({ - key: 'chosed', - data: '', - }) - }; */ - if (app.globalData.token) { - // that.initUsrCarList(); - that.initUsrCarList("flags"); - that.setData({ - current: 0 - }) - } - - if (that.data.addCar) { - // 绑车牌 - if (app.globalData.carLogin) { - that.bindCar(that.data.addCar); - } else { - that.bindCar(that.data.addCar); - } - that.setData({ - addCar: null - }); - } - - this.getTicketList(0, 1); - - - - }, - cancelMove: function() { - console.log(111) - return false; - }, - onHide: function () { - this.setData({ - allow_load: true, - showTicketModal: false, - curPageNum: 1, - ticketList: [] - }) - }, - onLoad: function (options) { - var that = this; - /** - * 获得分享小程序的 - * title - * 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 - }) - }) - .catch(err => { - console.log(err); - }) - // 登录 - var scene = decodeURIComponent(options.scene); - that.setData({ - scene: scene - }); - if (app.globalData.token) { } else { - // app.getLocation(); - that.userLogin() - } - - }, - /** - * 用户登录 - */ - userLogin: function () { - var that = this; - // 登录 - wx.login({ - success: ({ - code - }) => { - wx.getSystemInfo({ - success: function (res) { - that.setData({ - systemInfo: JSON.stringify(res) - }) - } - }) - var usrdata = { - appId: config.weapp.AppId, - code: code, - sceneAddress: app.globalData.sceneAddress, - scene: that.data.scene, - systemInfo: that.data.systemInfo - }; - if (app.globalData.locationInfo) { - usrdata = { - appId: config.weapp.AppId, - code: code, - sceneAddress: app.globalData.sceneAddress, - latitude: "" + app.globalData.locationInfo.latitude, - longitude: "" + app.globalData.locationInfo.longitude, - scene: that.data.scene, - systemInfo: that.data.systemInfo - }; - } - Http.post({ - url: config.api.login, - data: usrdata - }) - .then(res => { - app.globalData.token = res.data.token; - Http.setToken(res.data.token); - that.checkUserCarStatus(); - that.getList(); - that.init(); - that.initUsrCarList(); - return Http.get({ - url: config.api.checkUserStatus, - data: {} - }); - }) - .then(res => { }) - .catch(err => { - if (err.code == 11004) { - // 用户昵称未授权 - wx.redirectTo({ - url: "/pages/getuserinfo/index" - }); - } else { - wx.showModal({ - title: '提示', - content: err.errMsg, - showCancel: false - }) - } - }); - } - }); - }, - /** - * 检查用户是否有车 - */ - 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 => { }) - }, - jumpToAdd: function () { - wx.navigateTo({ - url: `/pages/addPark/addPark?flags=managepalte` - }); - }, - passc: function () { - wx.navigateTo({ - url: '/pages/ques/ques', - }) - }, - - - /** - * 券绑定车牌 - */ - bindCoupon: function (quanid) { - var that = this; - /** - * etcp - */ - var etcpData = { - etcpToken: app.globalData.etcpToken, - carNumber: that.data.listCardNum, - couponOrderId: quanid - }; - /** - * 停简单 - */ - var tjdData = { - carNumber: that.data.listCardNum - }; - var postCouponData = app.globalData.parkVendor == 1 ? etcpData : tjdData; - Http.post({ - url: config.api.getCarCoupon, - data: postCouponData - }) - .then(res => { - that.getStopFee(that.data.listCardNum); - that.initUsrCarList(); - }) - .catch(err => { - if (err.message!=undefined) { - wx.showToast({ - title: err.message, - icon: 'none', - duration: 2000, - mask: false - }); - } - - }) - }, - /** - * 选择优惠券 - */ - // gotoquan: function () { - // let that = this; - // if (that.data.quanid) { - // wx.navigateTo({ - // url: `/pages/passCar/choicecoupon/choicecoupon?quanid=${that.data.quanid}`, - // }) - // } else { - // wx.navigateTo({ - // url: '/pages/passCar/choicecoupon/choicecoupon', - // }) - // } - - // }, - closeTicketModal: function () { - this.setData({ - showTicketModal: false - }) - }, - /** - * 停车券 弹框 - */ - openTicketModal: function () { - this.setData({ - showTicketModal: true, - allow_load: true, - ticketList: [], - curPageNum: 1, - - }) - this.getTicketList(0, 1); - /* if (!this.data.ticketList.length){ - this.getTicketList(0, 1); - } */ - - }, - - //获取名下停车券列表 - getList() { - var that = this; - Http.get({ - url: config.api.couponOrderCarList + "?type=5&couponOrderStatus=0", - data: { - pageNum: 1, - pageSize: 15, - couponOrderStatus: 0 - } - }).then(res => { - that.setData({ - couponList: res.data.list - }); - }) - .catch(err => { - console.log(err) - }) - }, - - - /** - * 共同登录 - */ - init: function (carNumber) { - var that = this; - app.parkInitCallback = token => { - that.initPark(); - that.getParkStatus(); - if (!app.globalData.carLogin) { - /** - * 判断是否授权手机号 - */ - Http.get({ - url: config.api.checkPhoneStatus, - data: {} - }) - .then(res => { - 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) { - app.globalData.etcpToken = res.data.token; - } - /** - * 获得停车费用 - */ - that.initUsrCarList("flags"); - }); - }) - .catch(err => { - if (err.code == 11005) { - // 用户手机未授权 - /** - * 将值传到用户手机号授权的页面 - * - */ - wx.redirectTo({ - url: "/pages/getphoneInfo/index" - }); - } else if (err.code == 11006) { - // 用户手机已加密 - wx.redirectTo({ - url: "/pages/phoneinput/phoneinput" - }); - } else { - wx.showToast({ - title: err.errMsg, - icon: 'none', - duration: 2000, - mask: false - }); - } - }) - } - }; - if (app.globalData.token && app.globalData.token != null) { - app.parkInitCallback(app.globalData.token); - } - }, - - 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 => { - that.setData({ - addCar: null - }); - that.initUsrCarList(); - wx.showModal({ - title: "提示", - showCancel: false, - content: "绑车牌成功!", - success: function () { } - }); - }) - .catch(error => { - wx.showModal({ - title: "提示", - showCancel: false, - content: error.data.message, - success: function () { } - }); - }); - }, - /** - * 车场信息获取 - */ - initPark: function () { - var that = this; - Http.get({ - url: config.api.getParkInfo, - data: {} - }) - .then(res => { - that.setData({ - park: res.data - }) - }) - .catch(err => { - console.log(err); - // wx.showToast({ - // title: err.message, - // icon: 'none', - // duration: 2000, - // mask: false - // }); - }) - }, - - /** - * 车场状态获取 - */ - getParkStatus: function () { - var that = this; - Http.get({ - url: config.api.getParkStatus, - }) - .then(res => { - console.log(res) - }) - .catch(err => { - console.log(err) - // wx.showToast({ - // title: err.message, - // icon:"none" - // }) - }) - }, - - - /** - * 绑定车获取 - */ - 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; - that.setData({ - listCardNum: listCardNum - }) - /** - * 获得停车费用 - */ - that.getStopFee(listCardNum); - } - }) - .catch(err => { - wx.showToast({ - title: err.message, - icon: 'none', - duration: 2000, - mask: false - }); - }) - }, - - /** - * 获得停车费用修改 - */ - getStopFee: function (carNumber) { - let that = this; - let postData = - app.globalData.parkVendor == 1 ? { - etcpToken: app.globalData.etcpToken, - carNumber: carNumber - } : { - carNumber: carNumber, - outCarId: outCarId - }; - Http.post({ - url: config.api.getCarStopFee, - data: postData - }) - .then(res => { - console.log(res) - var extraDataStr = { - params: { - token: app.globalData.etcpToken, - syncId: res.data.orderId, - payType: 6, // 小程序支付 - CarNumber: carNumber, - returnUrl: that.data.etcpCallbackUrl, - source: "FUMAO-001", - actionId: "1" //操作ID,1:小程序支付 - } - }; - that.setData({ - extraData: extraDataStr, - stopFees: res.data, - timecha: Util.timecha(res.data.exitTime, res.data.entranceTime) - }); - that.setData({ - scroll: true - }) - }) - .catch(error => { - that.setData({ - stopFees: {}, - scroll: true - }) - }); - }, - - /** - * 下拉刷新 - */ - onPullDownRefresh: function (e) { - let that = this; - that.initUsrCarList("flags"); - that.setData({ - current:0 - }) - wx.stopPullDownRefresh(); - } + +const navigationBarHeight = (getApp().statusBarHeight + 50) + 'px' +const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {} +let app = getApp(); +const format = require("../utils/util.js"); +let config = require("../config/config.js"); +let Http = require("../utils/HttpBasics"); +let Util = require("../utils/util"); +const imgurl = require("../utils/imgurl"); +Page({ + data: { + navigationBarHeight, + jianUrl: imgurl.jian.url, + jiaofeiwm: imgurl.jiaofeiwm.url, + parkUrl: imgurl.park.url, + guanliHr: imgurl.guanliHr.url, + qidaiUrl: imgurl.qidai.url, + addUrl: imgurl.add.url, + tingcheHr: imgurl.tingcheHr.url, + cheUrl: imgurl.che.url, + jiaofei: imgurl.jiaofei.url, + wentiHr: imgurl.wentiHr.url, + park: null, + carList: [], + payList: [], + addCar: null, + tcq: 2, + flag: "", + extraData: {}, + desc: '', + title: '', + indicatorDots: true, + autoplay: false, + interval: 5000, + duration: 1000, + current: 0, + stopFees: {}, + scroll: true, + ifHaveCarModular: "", + canIUse: wx.canIUse("navigator"), + showTicketModal: false, + ticketList: [], + noCoupon:imgurl.noCoupon.url, + loadingUrl: imgurl.loading.url, + allow_load: true, + curPageNum: 1, + curPageSize: 15, + curTotalpageNum: 0, + quantitle: '', + quanid: '', + gouHr: imgurl.gouHr.url, + totalTicketNum: 0, + + }, + getMoreList(e) { + let totalNum = this.data.ticketList.length; + if (this.data.curPageNum < this.data.curTotalpageNum) { + this.setData({ + curPageNum: this.data.curPageNum+1 + }) + this.getTicketList(0 ,this.data.curPageNum); + } + + }, + /** + * 选择使用的优惠券 + */ + choicecoupon: function(e) { + /* wx.navigateBack(); + var pages = getCurrentPages(); + var prevPage = pages[pages.length - 2] //上一个页面 */ + var that = this; + var quantitle = e.currentTarget.dataset.title; + var quanid = e.currentTarget.dataset.id; + this.setData({ + quantitle: quantitle, + quanid: quanid, + showTicketModal: false, + }); + + that.bindCoupon(that.data.quanid); + /* wx.setStorage({ + key: 'chosed', + data: 'chosed', + }) */ + }, + /* + */ + getTicketList(key, pageNum) { + var that = this; + if (that.data.allow_load) { + wx.showLoading({ + title: "加载中" + }); + Http.get({ + url: config.api.couponOrderCarList, + data: { + pageNum: pageNum, + pageSize: 15, + couponOrderStatus: key + } + }).then(res => { + that.setData({ + curTotalpageNum: res.data.pages, + curPageNum: res.data.pageNum, + totalTicketNum: res.data.total + }) + res.data.list.map(file => { + file.expiredTime = format.formatTime( + file.expiredTime, + "yyyy-MM-dd hh:mm:ss" + ); + }); + setTimeout(function () { + wx.hideLoading(); + }, 1200); + if (pageNum >= res.data.pages) { + that.setData({ + allow_load: false + }); + } + /** + * 先赋值后渲染页面 + * concat 不会改变原数组值 + * push 会改变原数组值,但不会一条一条插入,而是整个数组插入 + */ + if (pageNum == 1) { + that.setData({ + ticketList: res.data.list, + curPageNum: pageNum + }); + } else { + that.setData({ + ticketList: that.data.ticketList.concat(res.data.list) + }); + } + // that.data.ticketList = that.data.ticketList.concat(res.data.list); + + this.hideLoading(); + }) + .catch(err => { + setTimeout(function () { + wx.hideLoading(); + }, 1200); + wx.showToast({ + title: err.errMsg, + icon: 'none', + duration: 2000, + mask: false + }); + }) + } else { + } + }, + //点击跳转到券详情页面 + gotouse: function (e) { + wx.navigateTo({ + url: `/pages/passCar/couponDetail/couponDetail?quancode=${ + e.currentTarget.dataset.quancode + }`, + success: function (res) { + // success + }, + fail: function () { + // fail + }, + complete: function () { + // complete + } + }); + }, + /** + * 车牌轮播滑动 + */ + onSlideChangeEnd: function (e) { + var that = this; + /** + * 获得当前的车牌号码 + */ + var listCardNum = (that.data.carList)[e.detail.current].carNumber; + that.setData({ + listCardNum: listCardNum + }); + /** + * 获得停车费用 + */ + if (that.data.scroll) { + that.getStopFee(listCardNum); + } + }, + + //停车费用为0 + paySuccess: function () { + wx.showModal({ + title: '支付成功', + content: '请尽快离场', + showCancel: false + }) + }, + + gotomange: function () { + wx.navigateTo({ + url: '/pages/managelicenseplate/managelicenseplate', + }) + }, + bindfail: function (res) { + console.log(res) + }, + gotoetcp: function () { + wx.navigateToMiniProgram({ + appId: that.data.etcpAppId, + extraData: this.data.extraData, + envVersion: 'release', + path: "pages/main/main", + }) + }, + showquan: function () { + wx.navigateTo({ + url: '/pages/passCar/couponList/couponList', + }) + }, + gotodetail: function (e) { + wx.showModal({ + title: '缴费规则', + content: e.target.dataset.rule, + showCancel: false, + }) + }, + onShow: function (options) { + if (typeof this.getTabBar === 'function' && + this.getTabBar()) { + this.getTabBar().setData({ + selected: 2 + }) + } + var that = this; + that.setData({ + etcpAppId: extConfig.attr.etcpAppId, + etcpVersion: extConfig.attr.etcpVersion, + etcpCallbackUrl: extConfig.attr.etcpCallbackUrl, + ifHaveCarModular: extConfig.attr.ifHaveCarModular + }) + if (app.globalData.token) { + that.getList(); + that.init(); + } else { + that.init(); + } + /** + * 只有用户选择了优惠券 + * 才会进行券和车牌的绑定 + */ + /* if (wx.getStorageSync("chosed") && that.data.quanid) { + that.getStopFee(that.data.listCardNum); + that.bindCoupon(that.data.quanid); + wx.setStorage({ + key: 'chosed', + data: '', + }) + }; */ + if (app.globalData.token) { + // that.initUsrCarList(); + that.initUsrCarList("flags"); + that.setData({ + current: 0 + }) + } + + if (that.data.addCar) { + // 绑车牌 + if (app.globalData.carLogin) { + that.bindCar(that.data.addCar); + } else { + that.bindCar(that.data.addCar); + } + that.setData({ + addCar: null + }); + } + + this.getTicketList(0, 1); + + + + }, + cancelMove: function() { + console.log(111) + return false; + }, + onHide: function () { + this.setData({ + allow_load: true, + showTicketModal: false, + curPageNum: 1, + ticketList: [] + }) + }, + onLoad: function (options) { + var that = this; + /** + * 获得分享小程序的 + * title + * 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 + }) + }) + .catch(err => { + console.log(err); + }) + // 登录 + var scene = decodeURIComponent(options.scene); + that.setData({ + scene: scene + }); + if (app.globalData.token) { } else { + // app.getLocation(); + that.userLogin() + } + + }, + /** + * 用户登录 + */ + userLogin: function () { + var that = this; + // 登录 + wx.login({ + success: ({ + code + }) => { + wx.getSystemInfo({ + success: function (res) { + that.setData({ + systemInfo: JSON.stringify(res) + }) + } + }) + var usrdata = { + appId: config.weapp.AppId, + code: code, + sceneAddress: app.globalData.sceneAddress, + scene: that.data.scene, + systemInfo: that.data.systemInfo + }; + if (app.globalData.locationInfo) { + usrdata = { + appId: config.weapp.AppId, + code: code, + sceneAddress: app.globalData.sceneAddress, + latitude: "" + app.globalData.locationInfo.latitude, + longitude: "" + app.globalData.locationInfo.longitude, + scene: that.data.scene, + systemInfo: that.data.systemInfo + }; + } + Http.post({ + url: config.api.login, + data: usrdata + }) + .then(res => { + app.globalData.token = res.data.token; + Http.setToken(res.data.token); + that.checkUserCarStatus(); + that.getList(); + that.init(); + that.initUsrCarList(); + return Http.get({ + url: config.api.checkUserStatus, + data: {} + }); + }) + .then(res => { }) + .catch(err => { + if (err.code == 11004) { + // 用户昵称未授权 + wx.redirectTo({ + url: "/pages/getuserinfo/index" + }); + } else { + wx.showModal({ + title: '提示', + content: err.errMsg, + showCancel: false + }) + } + }); + } + }); + }, + /** + * 检查用户是否有车 + */ + 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 => { }) + }, + jumpToAdd: function () { + wx.navigateTo({ + url: `/pages/addPark/addPark?flags=managepalte` + }); + }, + passc: function () { + wx.navigateTo({ + url: '/pages/ques/ques', + }) + }, + + + /** + * 券绑定车牌 + */ + bindCoupon: function (quanid) { + var that = this; + /** + * etcp + */ + var etcpData = { + etcpToken: app.globalData.etcpToken, + carNumber: that.data.listCardNum, + couponOrderId: quanid + }; + /** + * 停简单 + */ + var tjdData = { + carNumber: that.data.listCardNum + }; + var postCouponData = app.globalData.parkVendor == 1 ? etcpData : tjdData; + Http.post({ + url: config.api.getCarCoupon, + data: postCouponData + }) + .then(res => { + that.getStopFee(that.data.listCardNum); + that.initUsrCarList(); + }) + .catch(err => { + if (err.message!=undefined) { + wx.showToast({ + title: err.message, + icon: 'none', + duration: 2000, + mask: false + }); + } + + }) + }, + /** + * 选择优惠券 + */ + // gotoquan: function () { + // let that = this; + // if (that.data.quanid) { + // wx.navigateTo({ + // url: `/pages/passCar/choicecoupon/choicecoupon?quanid=${that.data.quanid}`, + // }) + // } else { + // wx.navigateTo({ + // url: '/pages/passCar/choicecoupon/choicecoupon', + // }) + // } + + // }, + closeTicketModal: function () { + this.setData({ + showTicketModal: false + }) + }, + /** + * 停车券 弹框 + */ + openTicketModal: function () { + this.setData({ + showTicketModal: true, + allow_load: true, + ticketList: [], + curPageNum: 1, + + }) + this.getTicketList(0, 1); + /* if (!this.data.ticketList.length){ + this.getTicketList(0, 1); + } */ + + }, + + //获取名下停车券列表 + getList() { + var that = this; + Http.get({ + url: config.api.couponOrderCarList + "?type=5&couponOrderStatus=0", + data: { + pageNum: 1, + pageSize: 15, + couponOrderStatus: 0 + } + }).then(res => { + that.setData({ + couponList: res.data.list + }); + }) + .catch(err => { + console.log(err) + }) + }, + + + /** + * 共同登录 + */ + init: function (carNumber) { + var that = this; + app.parkInitCallback = token => { + that.initPark(); + that.getParkStatus(); + if (!app.globalData.carLogin) { + /** + * 判断是否授权手机号 + */ + Http.get({ + url: config.api.checkPhoneStatus, + data: {} + }) + .then(res => { + 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) { + app.globalData.etcpToken = res.data.token; + } + /** + * 获得停车费用 + */ + that.initUsrCarList("flags"); + }); + }) + .catch(err => { + if (err.code == 11005) { + // 用户手机未授权 + /** + * 将值传到用户手机号授权的页面 + * + */ + wx.redirectTo({ + url: "/pages/getphoneInfo/index" + }); + } else if (err.code == 11006) { + // 用户手机已加密 + wx.redirectTo({ + url: "/pages/phoneinput/phoneinput" + }); + } else { + wx.showToast({ + title: err.errMsg, + icon: 'none', + duration: 2000, + mask: false + }); + } + }) + } + }; + if (app.globalData.token && app.globalData.token != null) { + app.parkInitCallback(app.globalData.token); + } + }, + + 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 => { + that.setData({ + addCar: null + }); + that.initUsrCarList(); + wx.showModal({ + title: "提示", + showCancel: false, + content: "绑车牌成功!", + success: function () { } + }); + }) + .catch(error => { + wx.showModal({ + title: "提示", + showCancel: false, + content: error.data.message, + success: function () { } + }); + }); + }, + /** + * 车场信息获取 + */ + initPark: function () { + var that = this; + Http.get({ + url: config.api.getParkInfo, + data: {} + }) + .then(res => { + that.setData({ + park: res.data + }) + }) + .catch(err => { + console.log(err); + // wx.showToast({ + // title: err.message, + // icon: 'none', + // duration: 2000, + // mask: false + // }); + }) + }, + + /** + * 车场状态获取 + */ + getParkStatus: function () { + var that = this; + Http.get({ + url: config.api.getParkStatus, + }) + .then(res => { + console.log(res) + }) + .catch(err => { + console.log(err) + // wx.showToast({ + // title: err.message, + // icon:"none" + // }) + }) + }, + + + /** + * 绑定车获取 + */ + 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; + that.setData({ + listCardNum: listCardNum + }) + /** + * 获得停车费用 + */ + that.getStopFee(listCardNum); + } + }) + .catch(err => { + wx.showToast({ + title: err.message, + icon: 'none', + duration: 2000, + mask: false + }); + }) + }, + + /** + * 获得停车费用修改 + */ + getStopFee: function (carNumber) { + let that = this; + let postData = + app.globalData.parkVendor == 1 ? { + etcpToken: app.globalData.etcpToken, + carNumber: carNumber + } : { + carNumber: carNumber, + outCarId: outCarId + }; + Http.post({ + url: config.api.getCarStopFee, + data: postData + }) + .then(res => { + console.log(res) + var extraDataStr = { + params: { + token: app.globalData.etcpToken, + syncId: res.data.orderId, + payType: 6, // 小程序支付 + CarNumber: carNumber, + returnUrl: that.data.etcpCallbackUrl, + source: "FUMAO-001", + actionId: "1" //操作ID,1:小程序支付 + } + }; + that.setData({ + extraData: extraDataStr, + stopFees: res.data, + timecha: Util.timecha(res.data.exitTime, res.data.entranceTime) + }); + that.setData({ + scroll: true + }) + }) + .catch(error => { + that.setData({ + stopFees: {}, + scroll: true + }) + }); + }, + + /** + * 下拉刷新 + */ + onPullDownRefresh: function (e) { + let that = this; + that.initUsrCarList("flags"); + that.setData({ + current:0 + }) + wx.stopPullDownRefresh(); + } }); \ No newline at end of file diff --git a/pages/passCar/passCar.json b/index/passCar.json similarity index 100% rename from pages/passCar/passCar.json rename to index/passCar.json diff --git a/pages/passCar/passCar.wxml b/index/passCar.wxml similarity index 98% rename from pages/passCar/passCar.wxml rename to index/passCar.wxml index 2a549d1..4eea8a8 100644 --- a/pages/passCar/passCar.wxml +++ b/index/passCar.wxml @@ -115,7 +115,7 @@ 请您敬请期待 我们正在筹备一大波优惠活动 - + diff --git a/pages/passCar/passCar.wxss b/index/passCar.wxss similarity index 99% rename from pages/passCar/passCar.wxss rename to index/passCar.wxss index 24b500b..2946ad2 100644 --- a/pages/passCar/passCar.wxss +++ b/index/passCar.wxss @@ -1,4 +1,4 @@ -@import "../../app.wxss"; +@import "../app.wxss"; page { background-color: #fff; diff --git a/pages/index/searchbar/index.js b/index/searchbar.js similarity index 91% rename from pages/index/searchbar/index.js rename to index/searchbar.js index 108f13e..34a8720 100644 --- a/pages/index/searchbar/index.js +++ b/index/searchbar.js @@ -1,7 +1,7 @@ const navigationBarHeight = (getApp().statusBarHeight + 44) + 'px' -const Http = require("../../../utils/HttpBasics"); -const imgurl = require("../../../utils/imgurl"); -const config = require("../../../config/config"); +const Http = require("../utils/HttpBasics"); +const imgurl = require("../utils/imgurl"); +const config = require("../config/config"); let app = getApp(); Page({ @@ -18,7 +18,7 @@ Page({ page:1, isFirstPage:false, isLastPage:false, - teljpgUrl: imgurl.teljpg.url, + teljpgUrl: imgurl.teljpg.url }, // 左侧点击事件 jumpIndex(e) { @@ -53,10 +53,15 @@ Page({ }) }, onShow(){ + if (typeof this.getTabBar === 'function' && + this.getTabBar()) { + this.getTabBar().setData({ + selected: 1 + }) + } let that = this; wx.getSystemInfo({ success: function (res) { - console.log(res.windowHeight, navigationBarHeight); that.setData({ windowHeight: res.windowHeight + parseInt(navigationBarHeight) }) diff --git a/pages/index/searchbar/index.json b/index/searchbar.json similarity index 100% rename from pages/index/searchbar/index.json rename to index/searchbar.json diff --git a/pages/index/searchbar/index.wxml b/index/searchbar.wxml similarity index 100% rename from pages/index/searchbar/index.wxml rename to index/searchbar.wxml diff --git a/pages/index/searchbar/index.wxss b/index/searchbar.wxss similarity index 100% rename from pages/index/searchbar/index.wxss rename to index/searchbar.wxss diff --git a/pages/user/index.js b/index/user.js similarity index 74% rename from pages/user/index.js rename to index/user.js index 1964622..46ea032 100644 --- a/pages/user/index.js +++ b/index/user.js @@ -1,276 +1,236 @@ -const navigationBarHeight = (getApp().statusBarHeight + 44) + 'px' -const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {} -var config = require("../../config/config.js"); -var app = getApp(); -const Http = require("../../utils/HttpBasics"); -const QR = require("../../utils/memberqrcode.js"); -const imgurl = require("../../utils/imgurl"); -const bgColor = require("../../utils/bgColor.js") -Page({ - /** - * 页面的初始数据 - */ - data: { - navigationBarHeight, - banneColor: bgColor.colorFirst.user.banneColor, - levelBg: bgColor.colorFirst.user.levelBg, - view: bgColor.colorFirst.user.view, - redirectUrl: imgurl.redirect.url, - qrcodeUrl: imgurl.qrcode.url, - editUrl: imgurl.edit.url, - activeUrl: imgurl.active.url, - dingUrl: imgurl.ding.url, - quansUrl: imgurl.quans.url, - wmintegral: imgurl.wmintegral.url, - cardiconUrl: imgurl.cardicon.url, - myactivitygift: imgurl.myactivitygift.url, - myactivity: imgurl.myactivity.url, - cheUrl: imgurl.che.url, - giftUrl: imgurl.gift.url, - wmbarginicon: imgurl.wmbarginicon.url, - wmspellgroup: imgurl.wmspellgroup.url, - canIUse: wx.canIUse('official-account'), - mineFlag:"", - flag: 'hidden', - score: '0', - name: "", - birthdate: "", - sex: "", - showEdit: false, - ismember: false, - showQrcode: false, - canvasHidden: false, - maskHidden: true, - imagePath: '', - appVersion: "", - showmemberqrcode: false, - placeholder: '' - }, - checkUserStatus() { - let that = this; - Http.get({ - url: config.api.checkPhoneStatus, - data: {} - }).then(res => { - }).catch(err => { - wx.navigateTo({ - url: `/pages/getphoneInfo/index?mineFlag=mine`, - }) - }) - }, - /** - * 跳转到成长值的页面 - */ - gotograde: function() { - wx.navigateTo({ - url: '/pages/czdetail/czdetail', - }) - }, - navigateTo() { - wx.navigateTo({ - url: `/pages/main/index` - }); - }, - showVersion: function() { - /** - * 长按显示版本号 - */ - let that = this; - if (that.data.flag == 'hidden') { - that.setData({ - flag: 'show' - }); - } - }, - gotoedit: function() { - wx.navigateTo({ - url: '/pages/edit/edit', - }) - }, - onLoad() { - this.getLocation(); - this.updateScene(); - }, - /** - * 获得经纬度 - */ - getLocation() { - let that = this; - wx.getLocation({ - type: "wgs84", - success: function(res) { - console.log(res) - if (res && res.longitude && res.latitude) { - Http.post({ - url: config.api.updateLBS, - data: { - latitude: res.latitude, - longitude: res.longitude - } - }).then(res => { - console.log(res) - }) - } - }, - fail: error => { - console.log(error); - } - }) - }, - - /** - * 用户更新scene - */ - updateScene(){ - Http.post({ - url: config.api.updateScene, - data: { - scene: app.globalData.scene - } - }).then(res => { - console.log(res) - }) - }, - /** - * 生命周期函数--监听页面显示 - */ - onShow: function() { - let that = this; - that.checkUserStatus(); - that.setData({ - appVersion: extConfig.appVersion, - }) - /** - * couponNum - * couponNum2 - */ - let num = wx.getStorageSync('couponNum'); - let num1 = wx.getStorageSync('couponNum2'); - wx.hideTabBarRedDot({ - index: 3 - }); - wx.hideTabBarRedDot({ - index: 3 - }); - if (num == 'couponNum1') { - wx.setStorage({ - key: 'couponNum', - data: "couponNum1", - }) - that.setData({ - couponNum: "couponNum1" - }) - } else if (num == 'couponNum') { - that.setData({ - couponNum: "couponNum" - }) - }; - if (num1 == 'couponNum3') { - wx.setStorage({ - key: 'couponNum2', - data: "couponNum3", - }) - that.setData({ - couponNum2: "couponNum3" - }) - } else if (num1 == 'couponNum2') { - that.setData({ - couponNum2: "couponNum2" - }); - }; - - Http.get({ - url: config.api.getScore, - data: {} - }).then(res => { - if (res.data.address && res.data.name && res.data.sex && res.data.birthdate) { - that.setData({ - showEdit: true - }) - } - that.setData({ - score: res.data.score, - levelName: res.data.levelName, - }) - if (res.data.nickName) { - that.setData({ - ismember: true, - memberId: res.data.id - }) - var size = this.setCanvasSize(); - var initUrl = JSON.stringify({ - flagid: res.data.id - }); - that.createQrCode(initUrl, "mycanvas1", size.w, size.h); - } - }) - .catch(err => { - wx.showModal({ - title: '提示', - content: err.errMsg, - showCancel: false - }) - }) - //暂时注释 - // that.getrun(); - }, - hideQrcode: function() { - let that = this; - that.setData({ - showQrcode: false - }) - }, - //适配不同屏幕大小的canvas - setCanvasSize: function() { - var size = {}; - try { - var res = wx.getSystemInfoSync(); - var scale = 750 / 500; - //不同屏幕下canvas的适配比例;设计稿是750宽 - var width = res.windowWidth / scale; - var height = width; - //canvas画布为正方形 - size.w = width; - size.h = height; - } catch (e) { - // Do something when catch error - console.log("获取设备信息失败" + e); - } - return size; - }, - createQrCode: function(url, canvasId, cavW, cavH) { - //调用插件中的draw方法,绘制二维码图片 - QR.api.draw(url, canvasId, cavW, cavH); - }, - qrcode: function(e) { - var that = this; - that.setData({ - showQrcode: true - }) - wx.showToast({ - title: '生成中...', - icon: 'loading', - duration: 2000 - }); - var st = setTimeout(function() { - wx.hideToast() - var size = that.setCanvasSize(); - var url = JSON.stringify({ - END: "C", - TYPE: "memberCode", - ID: that.data.memberId, - }) - that.createQrCode(url, "mycanvas1", size.w, size.h); - that.setData({ - maskHidden: true - }); - clearTimeout(st); - }, 1000) - - }, - close: function() { - this.setData({ - showmemberqrcode: false, - }) - } -}); \ No newline at end of file +var app = getApp(); +const navigationBarHeight = (getApp().statusBarHeight + 44) + 'px' +const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {} +let ifStoreApp = extConfig.attr.ifStoreApp; +const Http = require("../utils/HttpBasics"); +const imgurl = require("../utils/imgurl"); +var config = require("../config/config.js"); +const bgColor = require("../utils/bgColor.js") +Page({ + /** + * 页面的初始数据 + */ + data: { + navigationBarHeight, + ifStoreApp:ifStoreApp, + banneColor: bgColor.colorFirst.user.banneColor, + levelBg: bgColor.colorFirst.user.levelBg, + view: bgColor.colorFirst.user.view, + redirectUrl: imgurl.redirect.url, + editUrl: imgurl.edit.url, + activeUrl: imgurl.active.url, + dingUrl: imgurl.ding.url, + quansUrl: imgurl.quans.url, + wmintegral: imgurl.wmintegral.url, + cardiconUrl: imgurl.cardicon.url, + myactivitygift: imgurl.myactivitygift.url, + myactivity: imgurl.myactivity.url, + cheUrl: imgurl.che.url, + giftUrl: imgurl.gift.url, + wmbarginicon: imgurl.wmbarginicon.url, + wmspellgroup: imgurl.wmspellgroup.url, + canIUse: wx.canIUse('official-account'), + mineFlag:"", + flag: 'hidden', + score: '0', + name: "", + birthdate: "", + sex: "", + showEdit: false, + ismember: false, + canvasHidden: false, + maskHidden: true, + imagePath: '', + appVersion: "", + placeholder: '' + }, + checkUserStatus() { + let that = this; + Http.get({ + url: config.api.checkPhoneStatus, + data: {} + }).then(res => { + }).catch(err => { + wx.navigateTo({ + url: `/pages/getphoneInfo/index?mineFlag=mine`, + }) + }) + }, + /** + * 跳转到成长值的页面 + */ + gotograde: function() { + wx.navigateTo({ + url: '/pages/czdetail/czdetail', + }) + }, + showVersion: function() { + /** + * 长按显示版本号 + */ + let that = this; + if (that.data.flag == 'hidden') { + that.setData({ + flag: 'show' + }); + } + }, + gotoedit: function() { + wx.navigateTo({ + url: '/pages/edit/edit', + }) + }, + onLoad() { + this.getLocation(); + this.updateScene(); + }, + /** + * 获得经纬度 + */ + getLocation() { + let that = this; + wx.getLocation({ + type: "wgs84", + success: function(res) { + console.log(res) + if (res && res.longitude && res.latitude) { + Http.post({ + url: config.api.updateLBS, + data: { + latitude: res.latitude, + longitude: res.longitude + } + }).then(res => { + console.log(res) + }) + } + }, + fail: error => { + console.log(error); + } + }) + }, + /** + * 用户更新scene + */ + updateScene(){ + Http.post({ + url: config.api.updateScene, + data: { + scene: app.globalData.scene + } + }).then(res => { + console.log(res) + }) + }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function() { + if (typeof this.getTabBar === 'function' && + this.getTabBar()) { + if (ifStoreApp==1){ + this.getTabBar().setData({ + selected: 1 + }) + }else{ + this.getTabBar().setData({ + selected: 3 + }) + } + + } + let that = this; + that.checkUserStatus(); + that.setData({ + appVersion: extConfig.appVersion, + }) + /** + * couponNum + * couponNum2 + */ + let num = wx.getStorageSync('couponNum'); + let num1 = wx.getStorageSync('couponNum2'); + wx.hideTabBarRedDot({ + index: 3 + }); + if (num == 'couponNum1') { + wx.setStorage({ + key: 'couponNum', + data: "couponNum1", + }) + that.setData({ + couponNum: "couponNum1" + }) + } else if (num == 'couponNum') { + that.setData({ + couponNum: "couponNum" + }) + }; + if (num1 == 'couponNum3') { + wx.setStorage({ + key: 'couponNum2', + data: "couponNum3", + }) + that.setData({ + couponNum2: "couponNum3" + }) + } else if (num1 == 'couponNum2') { + that.setData({ + couponNum2: "couponNum2" + }); + }; + + Http.get({ + url: config.api.getScore, + data: {} + }).then(res => { + if (res.data.address && res.data.name && res.data.sex && res.data.birthdate) { + that.setData({ + showEdit: true + }) + } + that.setData({ + score: res.data.score, + levelName: res.data.levelName, + }) + if (res.data.nickName) { + that.setData({ + ismember: true, + memberId: res.data.id + }) + var size = this.setCanvasSize(); + var initUrl = JSON.stringify({ + flagid: res.data.id + }); + } + }) + .catch(err => { + wx.showModal({ + title: '提示', + content: err.errMsg, + showCancel: false + }) + }) + //暂时注释 + // that.getrun(); + }, + //适配不同屏幕大小的canvas + setCanvasSize: function() { + var size = {}; + try { + var res = wx.getSystemInfoSync(); + var scale = 750 / 500; + //不同屏幕下canvas的适配比例;设计稿是750宽 + var width = res.windowWidth / scale; + var height = width; + //canvas画布为正方形 + size.w = width; + size.h = height; + } catch (e) { + // Do something when catch error + console.log("获取设备信息失败" + e); + } + return size; + } +}); diff --git a/pages/user/index.json b/index/user.json similarity index 60% rename from pages/user/index.json rename to index/user.json index e2f3c9d..fb5f604 100644 --- a/pages/user/index.json +++ b/index/user.json @@ -1,7 +1,7 @@ { "usingComponents": { - "i-button": "../../dist/button/index", - "navbar": "../../components/navbar/navbar" + "i-button": "../dist/button/index", + "navbar": "../components/navbar/navbar" }, "navigationBarBackgroundColor": "#FD832D", "navigationBarTextStyle": "white", diff --git a/pages/user/index.wxml b/index/user.wxml similarity index 67% rename from pages/user/index.wxml rename to index/user.wxml index 75f9d8b..ea62a71 100644 --- a/pages/user/index.wxml +++ b/index/user.wxml @@ -1,104 +1,142 @@ - - - - - - - - - - - - {{levelName}} - - - - 我的 - 成长值{{score}} - | - - 更多成长值 - - - - - - - 我的订单 - - - - - - - 我的券包 - - - - - - - - - 我的卡包 - - - - - - - - - - - - - - - 我的砍价 - - - - - - - 我的拼团 - - - - - - - 积分商城 - - - - - - - 特享礼遇 - - - - - - 我的活动 - - - - - - - 版本号:{{appVersion}} - - - - - - - - - + + + + + + + + + + + + {{levelName}} + + + + 我的 + 成长值{{score}} + | + + 更多成长值 + + + + + + + 我的订单 + + + + + + + 我的券包 + + + + + + + + + 我的卡包 + + + + + + + + + + + + + + + 我的砍价 + + + + + + + 我的拼团 + + + + + + + 积分商城 + + + + + + + 特享礼遇 + + + + + + 我的活动 + + + + + + + + + + + + + + + + + + + 我的订单 + + + + + + + 我的券包 + + + + + + + + + + 我的砍价 + + + + + + + 我的拼团 + + + + + + + + 版本号:{{appVersion}} + + + + + \ No newline at end of file diff --git a/pages/user/index.wxss b/index/user.wxss similarity index 99% rename from pages/user/index.wxss rename to index/user.wxss index 5e9a166..696b822 100644 --- a/pages/user/index.wxss +++ b/index/user.wxss @@ -74,7 +74,9 @@ page{ border-radius: 50%; overflow: hidden; top:-64rpx; - left: 300rpx; + left: 0; + right: 0; + margin: auto; } .chengzhang { diff --git a/pages/acSignIn/index.js b/pages/acSignIn/index.js index 4f2e65d..5642181 100644 --- a/pages/acSignIn/index.js +++ b/pages/acSignIn/index.js @@ -57,7 +57,7 @@ Page({ }, goback: function () { wx.switchTab({ - url: '/pages/main/index', + url: '/index/index', }) } }) \ No newline at end of file diff --git a/pages/addPark/addPark.js b/pages/addPark/addPark.js index 4f2cab4..3df086f 100644 --- a/pages/addPark/addPark.js +++ b/pages/addPark/addPark.js @@ -72,7 +72,7 @@ Page({ jumpTo: function () { // 返回 wx.navigateBack({ - url: '/pages/passCar/passCar' + url: '/index/passCar' }) }, handleTap: function (e) { @@ -358,7 +358,7 @@ Page({ } else{ wx.navigateBack({ - url: '/pages/passCar/passCar?addcar=' + carNumber, + url: '/index/passCar?addcar=' + carNumber, }) } } diff --git a/pages/bannerdetail/index.js b/pages/bannerdetail/index.js index 900f6e6..97d7e18 100644 --- a/pages/bannerdetail/index.js +++ b/pages/bannerdetail/index.js @@ -45,7 +45,7 @@ Page({ }, goback: function () { wx.switchTab({ - url: '/pages/main/index', + url: '/index/index', }) }, }); diff --git a/pages/bargain/bargain.js b/pages/bargain/bargain.js index 7414e58..4faa694 100644 --- a/pages/bargain/bargain.js +++ b/pages/bargain/bargain.js @@ -33,7 +33,7 @@ Page({ }, goback: function () { wx.switchTab({ - url: '/pages/main/index', + url: '/index/index', }) }, onLoad: function (options) { diff --git a/pages/bargain/bargainDatail/bargainDatail.js b/pages/bargain/bargainDatail/bargainDatail.js index 02e4185..ed036d1 100644 --- a/pages/bargain/bargainDatail/bargainDatail.js +++ b/pages/bargain/bargainDatail/bargainDatail.js @@ -78,7 +78,7 @@ Page({ }, goback: function () { wx.switchTab({ - url: '/pages/main/index', + url: '/index/index', }) }, /** diff --git a/pages/cardorder/index/index.js b/pages/cardorder/index/index.js index 7bf63a5..9ba9f3f 100644 --- a/pages/cardorder/index/index.js +++ b/pages/cardorder/index/index.js @@ -37,7 +37,7 @@ Page({ }, goback: function () { wx.switchTab({ - url: '/pages/main/index', + url: '/index/index', }) }, onLoad: function() { diff --git a/pages/cardorder/index/index.wxml b/pages/cardorder/index/index.wxml index 03f5c6f..56be6de 100644 --- a/pages/cardorder/index/index.wxml +++ b/pages/cardorder/index/index.wxml @@ -10,7 +10,7 @@ 请您敬请期待 我们正在筹备一大波优惠活动 - + diff --git a/pages/coupon/detail/index.js b/pages/coupon/detail/index.js index 99dc24f..81b6bc3 100644 --- a/pages/coupon/detail/index.js +++ b/pages/coupon/detail/index.js @@ -204,7 +204,7 @@ Page({ }, goback: function() { wx.switchTab({ - url: '/pages/main/index', + url: '/index/index', }) }, /** diff --git a/pages/couponorder/index/index.js b/pages/couponorder/index/index.js index 610d16a..cfe6ae1 100644 --- a/pages/couponorder/index/index.js +++ b/pages/couponorder/index/index.js @@ -54,7 +54,7 @@ Page({ }, goback: function () { wx.switchTab({ - url: '/pages/main/index', + url: '/index/index', }) }, //点击跳转到券详情页面 diff --git a/pages/couponorder/index/index.wxml b/pages/couponorder/index/index.wxml index 86ddc8a..36ef400 100644 --- a/pages/couponorder/index/index.wxml +++ b/pages/couponorder/index/index.wxml @@ -10,7 +10,7 @@ 请您敬请期待 我们正在筹备一大波优惠活动 - + diff --git a/pages/discountCardList/discountCardList.js b/pages/discountCardList/discountCardList.js index 9865d55..bc966d7 100644 --- a/pages/discountCardList/discountCardList.js +++ b/pages/discountCardList/discountCardList.js @@ -40,7 +40,7 @@ Page({ }, goback: function () { wx.switchTab({ - url: '/pages/main/index', + url: '/index/index', }) }, onLoad(options) { diff --git a/pages/discountCardList/discountCardList.wxml b/pages/discountCardList/discountCardList.wxml index f7eb753..6b6540c 100644 --- a/pages/discountCardList/discountCardList.wxml +++ b/pages/discountCardList/discountCardList.wxml @@ -13,7 +13,7 @@ 请您敬请期待 我们正在筹备一大波优惠活动 - + diff --git a/pages/getphoneInfo/index.js b/pages/getphoneInfo/index.js index 12f0916..1899190 100755 --- a/pages/getphoneInfo/index.js +++ b/pages/getphoneInfo/index.js @@ -116,7 +116,7 @@ Page({ }) } else if (that.data.mineFlag == 'mine'){ wx.switchTab({ - url: '/pages/user/index' + url: '/index/user' }); } else { wx.showToast({ @@ -129,7 +129,7 @@ Page({ }) } else { wx.switchTab({ - url: '/pages/passCar/passCar', + url: '/index/passCar', }) } } diff --git a/pages/getuserinfo/index.js b/pages/getuserinfo/index.js index 083cec2..e1736f2 100755 --- a/pages/getuserinfo/index.js +++ b/pages/getuserinfo/index.js @@ -177,12 +177,12 @@ Page({ } else if (app.globalData.type == 'uc') { // 我的 wx.switchTab({ - url: '/pages/user/index' + url: '/index/user' }); } else if (app.globalData.type == 'in') { // 首页 wx.switchTab({ - url: '/pages/main/index' + url: '/index/index' }); } // 积分 @@ -193,7 +193,7 @@ Page({ }else if (app.globalData.type == 'pc') { // 停车 wx.switchTab({ - url: '/pages/passCar/passCar' + url: '/index/passCar' }); } else if (app.globalData.type == 'mc') { // 我的券包 @@ -254,11 +254,11 @@ Page({ else if (app.globalData.type == 'ml') { // 门店 wx.switchTab({ - url: '/pages/index/searchbar/index' + url: '/index/searchbar' }); } else { wx.switchTab({ - url: "/pages/main/index" + url: "/index/index" }); } } diff --git a/pages/index/index.js b/pages/index/index.js index 43f1174..a22c72f 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -229,7 +229,7 @@ Page({ // 我的 else if (app.globalData.type == 'uc') { wx.switchTab({ - url: '/pages/user/index' + url: '/index/user' }); } // 积分 @@ -241,14 +241,14 @@ Page({ // 首页 else if (app.globalData.type == 'in') { wx.switchTab({ - url: '/pages/main/index' + url: '/index/index' }); } // 停车 else if (app.globalData.type == 'pc') { // 停车 wx.switchTab({ - url: '/pages/passCar/passCar' + url: '/index/passCar' }); } // 我的券包 @@ -324,7 +324,7 @@ Page({ // 门店 else if (app.globalData.type == 'ml') { wx.switchTab({ - url: '/pages/index/searchbar/index' + url: '/index/searchbar' }) } // 通过分享进入的门店详情 @@ -335,7 +335,7 @@ Page({ }else { // 主页 wx.switchTab({ - url: '/pages/main/index' + url: '/index/index' }) } }) diff --git a/pages/index/searchbar/detail/index.js b/pages/index/searchbar/detail/index.js index 2b0f006..8a593c8 100644 --- a/pages/index/searchbar/detail/index.js +++ b/pages/index/searchbar/detail/index.js @@ -41,7 +41,7 @@ Page({ }, goback: function () { wx.switchTab({ - url: '/pages/main/index', + url: '/index/index', }) }, /** diff --git a/pages/integralmall/index.js b/pages/integralmall/index.js index e565800..04283b1 100644 --- a/pages/integralmall/index.js +++ b/pages/integralmall/index.js @@ -43,7 +43,7 @@ Page({ }, goback: function () { wx.switchTab({ - url: '/pages/main/index', + url: '/index/index', }) }, onLoad: function (options) { diff --git a/pages/integralmall/payIntegcouponStatus/index.js b/pages/integralmall/payIntegcouponStatus/index.js index 4d0c716..827ef5e 100644 --- a/pages/integralmall/payIntegcouponStatus/index.js +++ b/pages/integralmall/payIntegcouponStatus/index.js @@ -70,7 +70,7 @@ Page({ */ gotoIndex(){ wx.switchTab({ - url: '/pages/main/index', + url: '/index/index', }) }, /** diff --git a/pages/main/index.json b/pages/main/index.json deleted file mode 100644 index 449949c..0000000 --- a/pages/main/index.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "usingComponents": { - "c-banner": "../../components/banner/index", - "discount-card": "../../components/discountCard/index", - "c-coupons": "./coupons/index", - "g-entry": "../../components/gameentry/gentry", - "c-hot": "../../components/hot/index", - "navbar": "../../components/navbar/navbar" - }, - "enablePullDownRefresh": true, - "navigationBarBackgroundColor": "#F4F5F9" -} diff --git a/pages/order/index/index.js b/pages/order/index/index.js index 37ca9ea..dc1d53b 100644 --- a/pages/order/index/index.js +++ b/pages/order/index/index.js @@ -35,7 +35,7 @@ Page({ }, goback: function () { wx.switchTab({ - url: '/pages/main/index', + url: '/index/index', }) }, onLoad(e) { diff --git a/pages/passCar/couponList/couponList.wxml b/pages/passCar/couponList/couponList.wxml index ec654aa..c4ccd1a 100644 --- a/pages/passCar/couponList/couponList.wxml +++ b/pages/passCar/couponList/couponList.wxml @@ -9,7 +9,7 @@ 请您敬请期待 我们正在筹备一大波优惠活动 - + diff --git a/pages/radetail/index.js b/pages/radetail/index.js index 5c868f1..7bf3fc7 100644 --- a/pages/radetail/index.js +++ b/pages/radetail/index.js @@ -98,7 +98,7 @@ Page({ }, goback: function() { wx.switchTab({ - url: '/pages/main/index', + url: '/index/index', }) }, onShareAppMessage: function (options) { diff --git a/pages/radetail/success/index.js b/pages/radetail/success/index.js index 8bc3ecf..2b7948d 100644 --- a/pages/radetail/success/index.js +++ b/pages/radetail/success/index.js @@ -41,7 +41,7 @@ Page({ }, goback: function () { wx.switchTab({ - url: '/pages/main/index', + url: '/index/index', }) }, /** diff --git a/pages/rushToBuy/index.js b/pages/rushToBuy/index.js index bb64876..18629f3 100644 --- a/pages/rushToBuy/index.js +++ b/pages/rushToBuy/index.js @@ -26,7 +26,7 @@ Page({ }, goback: function () { wx.switchTab({ - url: '/pages/main/index', + url: '/index/index', }) }, //列表 diff --git a/pages/specialcourtesy/specialcourtesy.js b/pages/specialcourtesy/specialcourtesy.js index be670dd..eb88770 100644 --- a/pages/specialcourtesy/specialcourtesy.js +++ b/pages/specialcourtesy/specialcourtesy.js @@ -56,7 +56,7 @@ Page({ goback: function () { wx.switchTab({ - url: '/pages/main/index', + url: '/index/index', }) }, /** diff --git a/pages/spellDetail/index.js b/pages/spellDetail/index.js index ee33a28..ce44347 100644 --- a/pages/spellDetail/index.js +++ b/pages/spellDetail/index.js @@ -54,7 +54,7 @@ Page({ }, gotoIndex(){ wx.switchTab({ - url: '/pages/main/index', + url: '/index/index', }) }, gotoshare() { diff --git a/pages/spellGroup/mySpellGroup/index.js b/pages/spellGroup/mySpellGroup/index.js index 28a2de4..9bb8d47 100644 --- a/pages/spellGroup/mySpellGroup/index.js +++ b/pages/spellGroup/mySpellGroup/index.js @@ -108,7 +108,7 @@ Page({ }, gotoIndex: function() { wx.switchTab({ - url: '/pages/main/index', + url: '/index/index', }) }, /** diff --git a/pages/spellGroup/spellGroup.js b/pages/spellGroup/spellGroup.js index 112f5a4..34343ee 100644 --- a/pages/spellGroup/spellGroup.js +++ b/pages/spellGroup/spellGroup.js @@ -35,7 +35,7 @@ Page({ }, goback: function () { wx.switchTab({ - url: '/pages/main/index', + url: '/index/index', }) }, onLoad: function (options) { diff --git a/pages/topicDetail/index.js b/pages/topicDetail/index.js index 0e701e5..cd778b6 100644 --- a/pages/topicDetail/index.js +++ b/pages/topicDetail/index.js @@ -29,7 +29,7 @@ Page({ }, goback: function () { wx.switchTab({ - url: '/pages/main/index', + url: '/index/index', }) }, topicShow(id){ diff --git a/pages/user/myactivity/index.js b/pages/user/myactivity/index.js index a9ec10e..03d1dd4 100644 --- a/pages/user/myactivity/index.js +++ b/pages/user/myactivity/index.js @@ -37,7 +37,7 @@ Page({ }, goback: function () { wx.switchTab({ - url: '/pages/main/index', + url: '/index/index', }) }, onLoad(options) {