| //app.js | |||||
| App({ | |||||
| onLaunch: function () { | |||||
| // 登录 | |||||
| wx.login({ | |||||
| success: res => { | |||||
| // 发送 res.code 到后台换取 openId, sessionKey, unionId | |||||
| } | |||||
| }) | |||||
| // 获取用户信息 | |||||
| wx.getSetting({ | |||||
| success: res => { | |||||
| if (res.authSetting['scope.userInfo']) { | |||||
| // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框 | |||||
| wx.getUserInfo({ | |||||
| success: res => { | |||||
| // 可以将 res 发送给后台解码出 unionId | |||||
| this.globalData.userInfo = res.userInfo | |||||
| // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 | |||||
| // 所以此处加入 callback 以防止这种情况 | |||||
| if (this.userInfoReadyCallback) { | |||||
| this.userInfoReadyCallback(res) | |||||
| } | |||||
| } | |||||
| }) | |||||
| } | |||||
| } | |||||
| }) | |||||
| }, | |||||
| globalData: { | |||||
| userInfo: null | |||||
| } | |||||
| }) |
| { | |||||
| "pages": [ | |||||
| "pages/record/record", | |||||
| "pages/coupon/coupon", | |||||
| "pages/home/home", | |||||
| "pages/login/login", | |||||
| "pages/store/store" | |||||
| ], | |||||
| "window": { | |||||
| "backgroundTextStyle": "light", | |||||
| "navigationBarBackgroundColor": "#fff", | |||||
| "navigationBarTitleText": "老门框", | |||||
| "navigationBarTextStyle": "black" | |||||
| }, | |||||
| "tabBar": { | |||||
| "color": "#666666", | |||||
| "selectedColor": "#eb6100", | |||||
| "backgroundColor": "#ffffff", | |||||
| "borderStyle": "black", | |||||
| "list": [ | |||||
| { | |||||
| "pagePath": "pages/home/home", | |||||
| "text": "核销大厅", | |||||
| "iconPath": "static/tabBar/home0.png", | |||||
| "selectedIconPath": "static/tabBar/home1.png" | |||||
| }, | |||||
| { | |||||
| "pagePath": "pages/store/store", | |||||
| "text": "门店查询", | |||||
| "iconPath": "static/tabBar/store0.png", | |||||
| "selectedIconPath": "static/tabBar/store1.png" | |||||
| }, | |||||
| { | |||||
| "pagePath": "pages/record/record", | |||||
| "text": "核销记录", | |||||
| "iconPath": "static/tabBar/record0.png", | |||||
| "selectedIconPath": "static/tabBar/record1.png" | |||||
| } | |||||
| ] | |||||
| }, | |||||
| "sitemapLocation": "sitemap.json" | |||||
| } |
| /**app.wxss**/ | |||||
| .container { | |||||
| position: relative; | |||||
| height: 100vh; | |||||
| display: flex; | |||||
| flex-direction: column; | |||||
| align-items: center; | |||||
| box-sizing: border-box; | |||||
| } | |||||
| image{ | |||||
| display: block; | |||||
| } | |||||
| /*防止父元素塌陷*/ | |||||
| .clearfix::before{ | |||||
| content: ''; | |||||
| display: table; | |||||
| } |
| // pages/coupon/coupon.js | |||||
| Page({ | |||||
| /** | |||||
| * 页面的初始数据 | |||||
| */ | |||||
| data: { | |||||
| type:2,//1券码核销 2手机号核销 | |||||
| state:0,//核销未完成 1核销中 2核销已完成 | |||||
| totalNums:50,//总数量 | |||||
| nums:1,//核销数量 | |||||
| }, | |||||
| /** | |||||
| * 核销 | |||||
| */ | |||||
| writeOff:function(){ | |||||
| console.log('核销') | |||||
| wx.switchTab({ | |||||
| url: '../record/record' | |||||
| }) | |||||
| }, | |||||
| /** | |||||
| * 添加优惠券 | |||||
| */ | |||||
| addCoupon(){ | |||||
| if (this.data.nums+1<=this.data.totalNums){ | |||||
| this.setData({ | |||||
| nums:this.data.nums+1 | |||||
| }) | |||||
| } | |||||
| }, | |||||
| /** | |||||
| * 减少优惠券 | |||||
| */ | |||||
| reduceCoupon(){ | |||||
| if (this.data.nums - 1 > 0) { | |||||
| this.setData({ | |||||
| nums: this.data.nums - 1 | |||||
| }) | |||||
| } | |||||
| }, | |||||
| /** | |||||
| * 生命周期函数--监听页面加载 | |||||
| */ | |||||
| onLoad: function (options) { | |||||
| var code = options.code; | |||||
| var pohone = options.phone; | |||||
| if (code){//券码查询 | |||||
| console.log('券码查询') | |||||
| } | |||||
| if (pohone){//手机号查询 | |||||
| console.log('手机号查询') | |||||
| } | |||||
| }, | |||||
| /** | |||||
| * 生命周期函数--监听页面初次渲染完成 | |||||
| */ | |||||
| onReady: function () { | |||||
| }, | |||||
| /** | |||||
| * 生命周期函数--监听页面显示 | |||||
| */ | |||||
| onShow: function () { | |||||
| }, | |||||
| /** | |||||
| * 生命周期函数--监听页面隐藏 | |||||
| */ | |||||
| onHide: function () { | |||||
| }, | |||||
| /** | |||||
| * 生命周期函数--监听页面卸载 | |||||
| */ | |||||
| onUnload: function () { | |||||
| }, | |||||
| /** | |||||
| * 页面相关事件处理函数--监听用户下拉动作 | |||||
| */ | |||||
| onPullDownRefresh: function () { | |||||
| }, | |||||
| /** | |||||
| * 页面上拉触底事件的处理函数 | |||||
| */ | |||||
| onReachBottom: function () { | |||||
| }, | |||||
| /** | |||||
| * 用户点击右上角分享 | |||||
| */ | |||||
| onShareAppMessage: function () { | |||||
| } | |||||
| }) |
| { | |||||
| "usingComponents": {}, | |||||
| "navigationBarTitleText": "优惠券核销", | |||||
| "disableScroll":true | |||||
| } |
| <!--pages/coupon/coupon.wxml--> | |||||
| <view class="container" style="background-color:#f6f6f6;"> | |||||
| <image class="couponImg" src="../../static/coupon/Coupon1.png"></image> | |||||
| <view class="detailsBox shadow"> | |||||
| <image class="bottomBg" src="../../static/coupon/bottomBg1.png"></image> | |||||
| <image class="decorate" src="../../static/coupon/01.png"></image> | |||||
| <view class="detailsInfo"> | |||||
| <text class="txt1">80元抵100元优惠券</text> | |||||
| <text class="txt2">购买时间:2020年02月25日</text> | |||||
| </view> | |||||
| <view class="detailsRight" wx:if="{{type==2}}">{{totalNums}}<text class="company">张</text> | |||||
| </view> | |||||
| <image class="logo" src="../../static/coupon/logo.png" wx:if="{{type==1}}"></image> | |||||
| </view> | |||||
| <view class="middleContent shadow"> | |||||
| <view id="couponCheck" class="relative clearfix" wx:if="{{type==1&&state!=2}}"> | |||||
| <image class="couponIcon" src="../../static/coupon/couponIcon.png"></image> | |||||
| <text class="number">078657</text> | |||||
| <view class="txt">此券有效</view> | |||||
| </view> | |||||
| <view id="couponDetails" class="relative clearfix" wx:if="{{type==1&&state==2}}"> | |||||
| <view class="title">核销详情</view> | |||||
| <view class="detailsItem"> | |||||
| <view class="sign"></view> | |||||
| <text class="itemTitle">券码</text> | |||||
| <text class="itemContent">H0001</text> | |||||
| </view> | |||||
| <view class="detailsItem"> | |||||
| <view class="sign"></view> | |||||
| <text class="itemTitle">类型</text> | |||||
| <text class="itemContent">80元抵100元券</text> | |||||
| </view> | |||||
| <view class="detailsItem"> | |||||
| <view class="sign"></view> | |||||
| <text class="itemTitle">时间</text> | |||||
| <text class="itemContent">2020年02月25日</text> | |||||
| </view> | |||||
| <view class="state">核销成功</view> | |||||
| </view> | |||||
| <view id="vCodeBox" wx:if="{{type==2}}"> | |||||
| <input placeholder="输入短信验证码" placeholder-style="color:#FFFFFF;font-size:30rpx;"></input> | |||||
| <view class="countBox"> | |||||
| <text>核销</text> | |||||
| <view class="countContent">{{nums}} | |||||
| <image class="symbolBox" src="../../static/coupon/symbolLeft.png" style="left:-1rpx;" bindtap="reduceCoupon"></image> | |||||
| <image class="symbolBox" src="../../static/coupon/symbolRight.png" style="right:-1rpx;" bindtap="addCoupon"></image> | |||||
| </view> | |||||
| </view> | |||||
| </view> | |||||
| </view> | |||||
| <button class="btn shadow" bindtap="writeOff">核销</button> | |||||
| </view> |
| /* pages/coupon/coupon.wxss */ | |||||
| .relative { | |||||
| position: relative; | |||||
| width: 100%; | |||||
| height: 100%; | |||||
| } | |||||
| .couponImg { | |||||
| width: 750rpx; | |||||
| height: 300rpx; | |||||
| border-bottom-left-radius: 30rpx; | |||||
| border-bottom-right-radius: 30rpx; | |||||
| } | |||||
| .shadow { | |||||
| box-shadow: 0px 0px 20rpx 20rpx rgba(204, 204, 204, 0.2); | |||||
| } | |||||
| .detailsBox { | |||||
| position: relative; | |||||
| width: 100%; | |||||
| height: 190rpx; | |||||
| border-radius: 30rpx; | |||||
| } | |||||
| .detailsBox>.bottomBg { | |||||
| width: 100%; | |||||
| height: 100%; | |||||
| } | |||||
| .detailsBox>.decorate { | |||||
| position: absolute; | |||||
| top: -5rpx; | |||||
| left: 28rpx; | |||||
| width: 694rpx; | |||||
| height: 10rpx; | |||||
| } | |||||
| .detailsBox>.detailsInfo { | |||||
| position: absolute; | |||||
| top: 0; | |||||
| left: 0; | |||||
| height: 100%; | |||||
| width: 504rpx; | |||||
| display: flex; | |||||
| flex-direction: column; | |||||
| align-items: center; | |||||
| justify-content: center; | |||||
| } | |||||
| .detailsBox>.detailsInfo>.txt1 { | |||||
| color: #333; | |||||
| font-size: 36rpx; | |||||
| font-weight: bold; | |||||
| font-family: SourceHanSansCN; | |||||
| margin-bottom: 10rpx; | |||||
| } | |||||
| .detailsBox>.detailsInfo>.txt2 { | |||||
| color: #999; | |||||
| font-size: 24rpx; | |||||
| font-weight: 500; | |||||
| font-family: SourceHanSansCN; | |||||
| margin-top: 10rpx; | |||||
| } | |||||
| .detailsBox>.detailsRight { | |||||
| position: absolute; | |||||
| top: 0; | |||||
| left: 509rpx; | |||||
| width: 241rpx; | |||||
| height: 100%; | |||||
| line-height: 190rpx; | |||||
| text-align: center; | |||||
| color: #eb6100; | |||||
| font-size: 100rpx; | |||||
| font-weight: bold; | |||||
| } | |||||
| .detailsBox>.detailsRight>.company { | |||||
| color: #333; | |||||
| font-size: 30rpx; | |||||
| margin-left: 10rpx; | |||||
| } | |||||
| .detailsBox>.logo { | |||||
| position: absolute; | |||||
| right: 52rpx; | |||||
| top: 40rpx; | |||||
| width: 155rpx; | |||||
| height: 110rpx; | |||||
| } | |||||
| .middleContent { | |||||
| width: 750rpx; | |||||
| background-color: #fff; | |||||
| border-radius: 30rpx; | |||||
| margin-top: 20rpx; | |||||
| padding: 50rpx 0; | |||||
| } | |||||
| #couponCheck>.couponIcon { | |||||
| width: 513rpx; | |||||
| height: 200rpx; | |||||
| margin: 0 auto; | |||||
| } | |||||
| #couponCheck>.number { | |||||
| position: absolute; | |||||
| top: 144rpx; | |||||
| left: 470rpx; | |||||
| color: #eb6100; | |||||
| font-size: 30rpx; | |||||
| font-weight: 700; | |||||
| } | |||||
| #couponCheck>.txt { | |||||
| width: 100%; | |||||
| text-align: center; | |||||
| color: #eb6100; | |||||
| font-size: 40rpx; | |||||
| font-weight: 550; | |||||
| margin-top: 50rpx; | |||||
| } | |||||
| #couponDetails>.title { | |||||
| color: #333; | |||||
| width: 100%; | |||||
| text-align: center; | |||||
| font-size: 30rpx; | |||||
| font-weight: 550; | |||||
| } | |||||
| #couponDetails>.detailsItem { | |||||
| height: 58rpx; | |||||
| line-height: 58rpx; | |||||
| padding-left: 32rpx; | |||||
| } | |||||
| #couponDetails>.detailsItem>.sign { | |||||
| width: 20rpx; | |||||
| height: 20rpx; | |||||
| border-radius: 50%; | |||||
| background-color: #eb6100; | |||||
| display: inline-block; | |||||
| } | |||||
| #couponDetails>.detailsItem>.itemTitle { | |||||
| color: #333; | |||||
| font-size: 26rpx; | |||||
| font-weight: 500; | |||||
| padding-left: 17rpx; | |||||
| } | |||||
| #couponDetails>.detailsItem>.itemContent { | |||||
| color: #666; | |||||
| font-size: 22rpx; | |||||
| font-weight: 400; | |||||
| padding-left: 41rpx; | |||||
| } | |||||
| #couponDetails>.state { | |||||
| text-align: center; | |||||
| height: 38rpx; | |||||
| line-height: 38rpx; | |||||
| color: #eb6100; | |||||
| font-size: 40rpx; | |||||
| font-weight: 500; | |||||
| margin-top: 49rpx; | |||||
| } | |||||
| .btn { | |||||
| position: absolute; | |||||
| bottom: 0; | |||||
| width: 100%; | |||||
| height: 98rpx; | |||||
| border-radius: 0; | |||||
| color: #fffefe; | |||||
| font-size: 36rpx; | |||||
| background: linear-gradient(-72deg, rgba(235, 97, 0, 1), rgba(255, 137, 42, 1)); | |||||
| } | |||||
| #vCodeBox>input { | |||||
| width: 600rpx; | |||||
| height: 98rpx; | |||||
| background-color: #d8d8d8; | |||||
| margin: 0 auto; | |||||
| border-radius: 49rpx; | |||||
| padding: 0 41rpx; | |||||
| box-sizing: border-box; | |||||
| } | |||||
| #vCodeBox>.countBox { | |||||
| margin-top: 40rpx; | |||||
| height: 44rpx; | |||||
| font-size: 26rpx; | |||||
| display: flex; | |||||
| justify-content: center; | |||||
| align-items: center; | |||||
| } | |||||
| #vCodeBox>.countBox>.countContent { | |||||
| position: relative; | |||||
| text-align: center; | |||||
| height: 100%; | |||||
| line-height: 44rpx; | |||||
| width: 200rpx; | |||||
| padding: 0 44rpx; | |||||
| box-sizing: border-box; | |||||
| background-color: #eee; | |||||
| border: 2px solid rgba(238, 238, 238, 1); | |||||
| border-radius: 6px; | |||||
| display: inline-block; | |||||
| margin-left: 25rpx; | |||||
| } | |||||
| #vCodeBox>.countBox>.countContent>.symbolBox{ | |||||
| position: absolute; | |||||
| text-align: center; | |||||
| width: 44rpx; | |||||
| height: 44rpx; | |||||
| top: -1rpx; | |||||
| } |
| // pages/home/home.js | |||||
| Page({ | |||||
| /** | |||||
| * 页面的初始数据 | |||||
| */ | |||||
| data: { | |||||
| isQuerying:false, | |||||
| }, | |||||
| /** | |||||
| * 核销查询 | |||||
| */ | |||||
| check: function(e) { | |||||
| if (this.data.isQuerying){ | |||||
| return | |||||
| } | |||||
| var data = e.detail.value; | |||||
| if (data.code == '' && data.phone == '') { | |||||
| wx.showToast({ | |||||
| title: '请输入内容后再查询', | |||||
| icon: 'none', | |||||
| duration: 2000 | |||||
| }) | |||||
| } else if (data.code != '' && data.phone != '') { | |||||
| wx.showToast({ | |||||
| title: '仅可选择一项查询', | |||||
| icon: 'none', | |||||
| duration: 2000 | |||||
| }) | |||||
| } else { | |||||
| var type; | |||||
| if(data.code!=''){//券码查询 | |||||
| type=1; | |||||
| if(data.code.length!=6){ | |||||
| wx.showToast({ | |||||
| title: '券码格式错误', | |||||
| icon: 'none', | |||||
| duration: 2000 | |||||
| }) | |||||
| return | |||||
| } | |||||
| } | |||||
| if(data.phone!=''){//手机号查询 | |||||
| type = 2; | |||||
| if (data.phone.length != 11) { | |||||
| wx.showToast({ | |||||
| title: '输入的手机号码有误', | |||||
| icon: 'none', | |||||
| duration: 2000 | |||||
| }) | |||||
| return | |||||
| } | |||||
| } | |||||
| this.setData({ | |||||
| isQuerying:true | |||||
| }) | |||||
| this.query(data,type); | |||||
| } | |||||
| }, | |||||
| query(data, type){ | |||||
| var key,value; | |||||
| if (type == 1) {//券码查询 | |||||
| key='code'; | |||||
| value=data.code; | |||||
| } else {//手机号查询 | |||||
| key = 'phone'; | |||||
| value = data.phone; | |||||
| } | |||||
| wx.navigateTo({ | |||||
| url: '../coupon/coupon?' + key+'='+value | |||||
| }) | |||||
| }, | |||||
| /** | |||||
| * 生命周期函数--监听页面加载 | |||||
| */ | |||||
| onLoad: function(options) { | |||||
| }, | |||||
| /** | |||||
| * 生命周期函数--监听页面初次渲染完成 | |||||
| */ | |||||
| onReady: function() { | |||||
| }, | |||||
| /** | |||||
| * 生命周期函数--监听页面显示 | |||||
| */ | |||||
| onShow: function() { | |||||
| }, | |||||
| /** | |||||
| * 生命周期函数--监听页面隐藏 | |||||
| */ | |||||
| onHide: function() { | |||||
| }, | |||||
| /** | |||||
| * 生命周期函数--监听页面卸载 | |||||
| */ | |||||
| onUnload: function() { | |||||
| }, | |||||
| /** | |||||
| * 页面相关事件处理函数--监听用户下拉动作 | |||||
| */ | |||||
| onPullDownRefresh: function() { | |||||
| }, | |||||
| /** | |||||
| * 页面上拉触底事件的处理函数 | |||||
| */ | |||||
| onReachBottom: function() { | |||||
| }, | |||||
| /** | |||||
| * 用户点击右上角分享 | |||||
| */ | |||||
| onShareAppMessage: function() { | |||||
| } | |||||
| }) |
| { | |||||
| "usingComponents": {}, | |||||
| "navigationBarTitleText":"核销大厅", | |||||
| "disableScroll": true | |||||
| } |
| <!--pages/home/home.wxml--> | |||||
| <view class="container"> | |||||
| <image class="bg" src="../../static/home/bg.jpg" mode="aspectFill"></image> | |||||
| <image class="logo" src="../../static/home/logo.png"></image> | |||||
| <view class="fromBox"> | |||||
| <form bindsubmit="check"> | |||||
| <input name="code" maxlength="6" placeholder="请输入券码" placeholder-class="inputPlaceholder" style="margin-top:138rpx;" /> | |||||
| <input name="phone" maxlength="11" placeholder="手机号核销" placeholder-class="inputPlaceholder" type="number" /> | |||||
| <button class="query {{isQuerying?'select':''}}" form-type="submit">查询</button> | |||||
| </form> | |||||
| </view> | |||||
| </view> |
| /* pages/home/home.wxss */ | |||||
| .bg { | |||||
| position: absolute; | |||||
| width: 100%; | |||||
| height: 100%; | |||||
| z-index: -1; | |||||
| } | |||||
| .logo { | |||||
| width: 314rpx; | |||||
| height: 221rpx; | |||||
| margin-top: 74rpx; | |||||
| } | |||||
| .fromBox { | |||||
| width: 600rpx; | |||||
| height: 676rpx; | |||||
| background-color: rgba(255, 255, 255, 0.9); | |||||
| border-radius: 30rpx; | |||||
| margin-top: 116rpx; | |||||
| } | |||||
| .fromBox input { | |||||
| width: 522rpx; | |||||
| height: 98rpx; | |||||
| background-color: rgba(0, 0, 0, 0.28); | |||||
| margin: 0 auto 40rpx auto; | |||||
| border-radius: 49rpx; | |||||
| padding: 0 34rpx; | |||||
| box-sizing: border-box; | |||||
| } | |||||
| .inputPlaceholder { | |||||
| color: #fff; | |||||
| font-size: 30rpx; | |||||
| } | |||||
| .query { | |||||
| width: 522rpx; | |||||
| height: 98rpx; | |||||
| background: linear-gradient(-72deg, rgba(235, 97, 0, 1), rgba(255, 137, 42, 1)); | |||||
| border-radius: 49rpx; | |||||
| color: #ffffff; | |||||
| text-align: center; | |||||
| line-height: 98rpx; | |||||
| box-sizing: border-box; | |||||
| margin: 26rpx auto 0 auto; | |||||
| } | |||||
| .query.select{ | |||||
| background: #cccccc; | |||||
| } |
| //index.js | |||||
| //获取应用实例 | |||||
| const app = getApp() | |||||
| Page({ | |||||
| data: { | |||||
| motto: 'Hello World', | |||||
| userInfo: {}, | |||||
| hasUserInfo: false, | |||||
| canIUse: wx.canIUse('button.open-type.getUserInfo') | |||||
| }, | |||||
| //事件处理函数 | |||||
| bindViewTap: function() { | |||||
| wx.navigateTo({ | |||||
| url: '../logs/logs' | |||||
| }) | |||||
| }, | |||||
| onLoad: function () { | |||||
| console.log(this.data.canIUse) | |||||
| if (app.globalData.userInfo) { | |||||
| this.setData({ | |||||
| userInfo: app.globalData.userInfo, | |||||
| hasUserInfo: true | |||||
| }) | |||||
| } else if (this.data.canIUse){ | |||||
| // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 | |||||
| // 所以此处加入 callback 以防止这种情况 | |||||
| app.userInfoReadyCallback = res => { | |||||
| this.setData({ | |||||
| userInfo: res.userInfo, | |||||
| hasUserInfo: true | |||||
| }) | |||||
| } | |||||
| } else { | |||||
| // 在没有 open-type=getUserInfo 版本的兼容处理 | |||||
| wx.getUserInfo({ | |||||
| success: res => { | |||||
| app.globalData.userInfo = res.userInfo | |||||
| this.setData({ | |||||
| userInfo: res.userInfo, | |||||
| hasUserInfo: true | |||||
| }) | |||||
| } | |||||
| }) | |||||
| } | |||||
| }, | |||||
| getUserInfo: function(e) { | |||||
| console.log(e) | |||||
| app.globalData.userInfo = e.detail.userInfo | |||||
| this.setData({ | |||||
| userInfo: e.detail.userInfo, | |||||
| hasUserInfo: true | |||||
| }) | |||||
| } | |||||
| }) |
| { | |||||
| "usingComponents": {} | |||||
| } |
| <!--index.wxml--> | |||||
| <view class="container"> | |||||
| <view class="userinfo"> | |||||
| <button wx:if="{{!hasUserInfo && canIUse}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 获取头像昵称 </button> | |||||
| <block wx:else> | |||||
| <image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" mode="cover"></image> | |||||
| <text class="userinfo-nickname">{{userInfo.nickName}}</text> | |||||
| </block> | |||||
| </view> | |||||
| <view class="usermotto"> | |||||
| <text class="user-motto">{{motto}}</text> | |||||
| </view> | |||||
| </view> |
| /**index.wxss**/ | |||||
| .userinfo { | |||||
| display: flex; | |||||
| flex-direction: column; | |||||
| align-items: center; | |||||
| } | |||||
| .userinfo-avatar { | |||||
| width: 128rpx; | |||||
| height: 128rpx; | |||||
| margin: 20rpx; | |||||
| border-radius: 50%; | |||||
| } | |||||
| .userinfo-nickname { | |||||
| color: #aaa; | |||||
| } | |||||
| .usermotto { | |||||
| margin-top: 200px; | |||||
| } |
| // pages/login/login.js | |||||
| Page({ | |||||
| /** | |||||
| * 页面的初始数据 | |||||
| */ | |||||
| data: { | |||||
| isLoginIng: false | |||||
| }, | |||||
| /** | |||||
| * 登录 | |||||
| */ | |||||
| checkLogin(e) { | |||||
| if (this.data.isLoginIng) { | |||||
| return | |||||
| } | |||||
| var data = e.detail.value; | |||||
| if (data.userName == '') { | |||||
| wx.showToast({ | |||||
| title: '请先输入账号', | |||||
| icon: 'none', | |||||
| duration: 2000 | |||||
| }) | |||||
| } else if (data.password == '') { | |||||
| wx.showToast({ | |||||
| title: '请先输入密码', | |||||
| icon: 'none', | |||||
| duration: 2000 | |||||
| }) | |||||
| } else { | |||||
| this.setData({ | |||||
| isLoginIng: true | |||||
| }) | |||||
| this.login(data); | |||||
| } | |||||
| }, | |||||
| login(data) { | |||||
| setTimeout(function() { | |||||
| wx.switchTab({ | |||||
| url: '../home/home' | |||||
| }) | |||||
| }, 500) | |||||
| }, | |||||
| /** | |||||
| * 生命周期函数--监听页面加载 | |||||
| */ | |||||
| onLoad: function(options) { | |||||
| }, | |||||
| /** | |||||
| * 生命周期函数--监听页面初次渲染完成 | |||||
| */ | |||||
| onReady: function() { | |||||
| }, | |||||
| /** | |||||
| * 生命周期函数--监听页面显示 | |||||
| */ | |||||
| onShow: function() { | |||||
| }, | |||||
| /** | |||||
| * 生命周期函数--监听页面隐藏 | |||||
| */ | |||||
| onHide: function() { | |||||
| }, | |||||
| /** | |||||
| * 生命周期函数--监听页面卸载 | |||||
| */ | |||||
| onUnload: function() { | |||||
| }, | |||||
| /** | |||||
| * 页面相关事件处理函数--监听用户下拉动作 | |||||
| */ | |||||
| onPullDownRefresh: function() { | |||||
| }, | |||||
| /** | |||||
| * 页面上拉触底事件的处理函数 | |||||
| */ | |||||
| onReachBottom: function() { | |||||
| }, | |||||
| /** | |||||
| * 用户点击右上角分享 | |||||
| */ | |||||
| onShareAppMessage: function() { | |||||
| } | |||||
| }) |
| { | |||||
| "usingComponents": {}, | |||||
| "navigationBarTitleText": "登录" | |||||
| } |
| <!--pages/login/login.wxml--> | |||||
| <view class="container"> | |||||
| <image class="bg" src="../../static/login/bg.jpg" mode="aspectFill"></image> | |||||
| <image class="logo" src="../../static/login/logo.png"></image> | |||||
| <view class="fromBox"> | |||||
| <form bindsubmit="checkLogin"> | |||||
| <view class="item"> | |||||
| 账号 | |||||
| <input name="userName"></input> | |||||
| </view> | |||||
| <view class="item"> | |||||
| 密码 | |||||
| <input name="password" password></input> | |||||
| </view> | |||||
| <button class="btn {{isLoginIng?'select':''}}" form-type="submit">登录</button> | |||||
| </form> | |||||
| </view> | |||||
| </view> |
| /* pages/login/login.wxss */ | |||||
| .bg { | |||||
| position: absolute; | |||||
| width: 100%; | |||||
| height: 100%; | |||||
| z-index: -1; | |||||
| bottom: 0; | |||||
| } | |||||
| .logo { | |||||
| width: 445rpx; | |||||
| height: 486rpx; | |||||
| } | |||||
| .fromBox { | |||||
| width: 583rpx; | |||||
| margin: 56rpx auto 0 auto; | |||||
| height: 300rpx; | |||||
| } | |||||
| .item { | |||||
| position: relative; | |||||
| height: 95rpx; | |||||
| line-height: 95rpx; | |||||
| margin-bottom: 19rpx; | |||||
| font-size: 28rpx; | |||||
| box-sizing: border-box; | |||||
| color: #fff; | |||||
| border-bottom: 2rpx solid #fff; | |||||
| } | |||||
| .item>input { | |||||
| position: absolute; | |||||
| height: 100%; | |||||
| top: 1rpx; | |||||
| left: 70rpx; | |||||
| right: 0; | |||||
| } | |||||
| .btn { | |||||
| width: 600rpx; | |||||
| height: 98rpx; | |||||
| line-height: 98rpx; | |||||
| border-radius: 49rpx; | |||||
| color: #ffffff; | |||||
| font-size: 36rpx; | |||||
| text-align: center; | |||||
| margin-top: 111rpx; | |||||
| background: linear-gradient(-72deg, rgba(235, 97, 0, 1), rgba(255, 137, 42, 1)); | |||||
| } | |||||
| .btn.select{ | |||||
| background: #cccccc; | |||||
| } |
| // pages/record/record.js | |||||
| Page({ | |||||
| /** | |||||
| * 页面的初始数据 | |||||
| */ | |||||
| data: { | |||||
| userName: '老门框内部操作', | |||||
| userNo: '000001', //员工编号 | |||||
| showIndex: 1, | |||||
| data: [{ | |||||
| time: '2020年02月25日', | |||||
| no: 'H000001', | |||||
| txt: '80抵100元券' | |||||
| }, { | |||||
| time: '2020年02月25日', | |||||
| no: 'H000001', | |||||
| txt: '80抵100元券' | |||||
| }, { | |||||
| time: '2020年02月25日', | |||||
| no: 'H000001', | |||||
| txt: '80抵100元券' | |||||
| }, { | |||||
| time: '2020年02月25日', | |||||
| no: 'H000001', | |||||
| txt: '80抵100元券' | |||||
| }, { | |||||
| time: '2020年02月25日', | |||||
| no: 'H000001', | |||||
| txt: '80抵100元券' | |||||
| }, { | |||||
| time: '2020年02月25日', | |||||
| no: 'H000001', | |||||
| txt: '80抵100元券' | |||||
| }, { | |||||
| time: '2020年02月25日', | |||||
| no: 'H000001', | |||||
| txt: '80抵100元券' | |||||
| }, { | |||||
| time: '2020年02月25日', | |||||
| no: 'H000001', | |||||
| txt: '80抵100元券' | |||||
| }, { | |||||
| time: '2020年02月25日', | |||||
| no: 'H000001', | |||||
| txt: '80抵100元券' | |||||
| }, { | |||||
| time: '2020年02月25日', | |||||
| no: 'H000001', | |||||
| txt: '80抵100元券' | |||||
| }, { | |||||
| time: '2020年02月25日', | |||||
| no: 'H000001', | |||||
| txt: '80抵100元券' | |||||
| }, { | |||||
| time: '2020年02月25日', | |||||
| no: 'H000001', | |||||
| txt: '80抵100元券' | |||||
| }, { | |||||
| time: '2020年02月25日', | |||||
| no: 'H000001', | |||||
| txt: '80抵100元券' | |||||
| }], | |||||
| }, | |||||
| panel: function(e) { | |||||
| if (e.currentTarget.dataset.index != this.data.showIndex) { | |||||
| this.setData({ | |||||
| showIndex: e.currentTarget.dataset.index | |||||
| }) | |||||
| } else { | |||||
| this.setData({ | |||||
| showIndex: 0 | |||||
| }) | |||||
| } | |||||
| }, | |||||
| /** | |||||
| * 生命周期函数--监听页面加载 | |||||
| */ | |||||
| onLoad: function(options) { | |||||
| }, | |||||
| /** | |||||
| * 生命周期函数--监听页面初次渲染完成 | |||||
| */ | |||||
| onReady: function() { | |||||
| }, | |||||
| /** | |||||
| * 生命周期函数--监听页面显示 | |||||
| */ | |||||
| onShow: function() { | |||||
| }, | |||||
| /** | |||||
| * 生命周期函数--监听页面隐藏 | |||||
| */ | |||||
| onHide: function() { | |||||
| }, | |||||
| /** | |||||
| * 生命周期函数--监听页面卸载 | |||||
| */ | |||||
| onUnload: function() { | |||||
| }, | |||||
| /** | |||||
| * 页面相关事件处理函数--监听用户下拉动作 | |||||
| */ | |||||
| onPullDownRefresh: function() { | |||||
| }, | |||||
| /** | |||||
| * 页面上拉触底事件的处理函数 | |||||
| */ | |||||
| onReachBottom: function() { | |||||
| }, | |||||
| /** | |||||
| * 用户点击右上角分享 | |||||
| */ | |||||
| onShareAppMessage: function() { | |||||
| } | |||||
| }) |
| { | |||||
| "usingComponents": {}, | |||||
| "navigationBarTitleText": "核销记录", | |||||
| "disableScroll": true | |||||
| } |
| <!--pages/record/record.wxml--> | |||||
| <view class="container"> | |||||
| <image class="bg" src="../../static/record/bg.jpg"></image> | |||||
| <view class="content"> | |||||
| <view class="headBox"> | |||||
| <image src="../../static/record/head.png" mode="aspectFill"></image> | |||||
| </view> | |||||
| <view class="userName">{{userName}}</view> | |||||
| <view class="userNo">{{userNo}}</view> | |||||
| <scroll-view id="collapseBox" scroll-y="true" class="collapseBox"> | |||||
| <view class="item"> | |||||
| <view class="title" data-index='1' catchtap='panel'> | |||||
| <view class="title_0"> | |||||
| <image style="width:49rpx;height:30rpx;" src="../../static/record/icon1.png"></image> | |||||
| </view> | |||||
| <view class='title_1'>核销记录</view> | |||||
| <view class="title_2"> | |||||
| <image src="../../static/record/{{showIndex == 1 ? 'up':'down'}}.png"></image> | |||||
| </view> | |||||
| </view> | |||||
| <view class="details" wx:if="{{showIndex == 1}}" wx:for="{{data}}"> | |||||
| <text class="time">{{item.time}}</text> | |||||
| <view class="infoBox"> | |||||
| <text>券码:{{item.no}}</text> | |||||
| <text>{{item.txt}}</text> | |||||
| </view> | |||||
| </view> | |||||
| </view> | |||||
| </scroll-view> | |||||
| </view> | |||||
| </view> |
| /* pages/record/record.wxss */ | |||||
| .bg { | |||||
| width: 750rpx; | |||||
| height: 253rpx; | |||||
| } | |||||
| .content { | |||||
| position: absolute; | |||||
| width: 100%; | |||||
| top: 253rpx; | |||||
| bottom: 0; | |||||
| background-color: #fff; | |||||
| } | |||||
| .headBox { | |||||
| position: absolute; | |||||
| top: -152rpx; | |||||
| width: 200rpx; | |||||
| height: 200rpx; | |||||
| left: 50%; | |||||
| transform: translateX(-50%); | |||||
| border-radius: 50%; | |||||
| overflow: hidden; | |||||
| background-color: #fff; | |||||
| } | |||||
| .headBox>image { | |||||
| width: 100%; | |||||
| height: 100%; | |||||
| } | |||||
| .content>.userName { | |||||
| color: #333; | |||||
| font-size: 40rpx; | |||||
| font-weight: bold; | |||||
| text-align: center; | |||||
| margin-top: 78rpx; | |||||
| } | |||||
| .content>.userNo{ | |||||
| text-align: center; | |||||
| color: #666666; | |||||
| font-size: 30rpx; | |||||
| margin-top: 10rpx; | |||||
| } | |||||
| .content>.collapseBox{ | |||||
| width: 630rpx; | |||||
| margin: 49rpx auto 0 auto; | |||||
| padding-top: 30rpx; | |||||
| border-top: 1rpx solid #CCCCCC; | |||||
| height: calc(100vh - 530rpx); | |||||
| } | |||||
| .item{ | |||||
| margin: 10rpx auto; | |||||
| } | |||||
| .item>.title{ | |||||
| font-size: 30rpx; | |||||
| height: 60rpx; | |||||
| line-height: 60rpx; | |||||
| display: flex; | |||||
| } | |||||
| .item>.title>.title_0{ | |||||
| width: 50rpx; | |||||
| text-align: center; | |||||
| display: flex; | |||||
| align-items: center; | |||||
| } | |||||
| .item>.title>.title_1{ | |||||
| width: 520rpx; | |||||
| color: #333333; | |||||
| padding-left: 10rpx; | |||||
| } | |||||
| .item>.title>.title_2 { | |||||
| width: 50rpx; | |||||
| height: 60rpx; | |||||
| text-align: center; | |||||
| } | |||||
| .item>.title>.title_2>image{ | |||||
| width: 34rpx; | |||||
| height: 19rpx; | |||||
| margin: 20.5rpx auto; | |||||
| } | |||||
| .item>.details{ | |||||
| margin: 10rpx auto; | |||||
| } | |||||
| .item>.details>.time{ | |||||
| color: #333333; | |||||
| font-size: 24rpx; | |||||
| } | |||||
| .item>.details>.infoBox{ | |||||
| color: #999999; | |||||
| font-size: 24rpx; | |||||
| display: flex; | |||||
| justify-content: space-between; | |||||
| margin-top: 5rpx; | |||||
| } |
| // pages/store/store.js | |||||
| Page({ | |||||
| /** | |||||
| * 页面的初始数据 | |||||
| */ | |||||
| data: { | |||||
| }, | |||||
| /** | |||||
| * 生命周期函数--监听页面加载 | |||||
| */ | |||||
| onLoad: function (options) { | |||||
| }, | |||||
| /** | |||||
| * 生命周期函数--监听页面初次渲染完成 | |||||
| */ | |||||
| onReady: function () { | |||||
| }, | |||||
| /** | |||||
| * 生命周期函数--监听页面显示 | |||||
| */ | |||||
| onShow: function () { | |||||
| }, | |||||
| /** | |||||
| * 生命周期函数--监听页面隐藏 | |||||
| */ | |||||
| onHide: function () { | |||||
| }, | |||||
| /** | |||||
| * 生命周期函数--监听页面卸载 | |||||
| */ | |||||
| onUnload: function () { | |||||
| }, | |||||
| /** | |||||
| * 页面相关事件处理函数--监听用户下拉动作 | |||||
| */ | |||||
| onPullDownRefresh: function () { | |||||
| }, | |||||
| /** | |||||
| * 页面上拉触底事件的处理函数 | |||||
| */ | |||||
| onReachBottom: function () { | |||||
| }, | |||||
| /** | |||||
| * 用户点击右上角分享 | |||||
| */ | |||||
| onShareAppMessage: function () { | |||||
| } | |||||
| }) |
| { | |||||
| "usingComponents": {}, | |||||
| "navigationBarTitleText": "门店查询", | |||||
| "disableScroll": true | |||||
| } |
| <!--pages/store/store.wxml--> | |||||
| <text>pages/store/store.wxml</text> |
| /* pages/store/store.wxss */ |
| { | |||||
| "description": "项目配置文件", | |||||
| "packOptions": { | |||||
| "ignore": [] | |||||
| }, | |||||
| "setting": { | |||||
| "urlCheck": true, | |||||
| "es6": true, | |||||
| "postcss": true, | |||||
| "minified": true, | |||||
| "newFeature": true, | |||||
| "autoAudits": false, | |||||
| "coverView": true, | |||||
| "showShadowRootInWxmlPanel": true, | |||||
| "scopeDataCheck": false | |||||
| }, | |||||
| "compileType": "miniprogram", | |||||
| "libVersion": "2.10.2", | |||||
| "appid": "wxb83a175962c53ea6", | |||||
| "projectname": "%E8%80%81%E9%97%A8%E6%A1%86", | |||||
| "debugOptions": { | |||||
| "hidedInDevtools": [] | |||||
| }, | |||||
| "isGameTourist": false, | |||||
| "simulatorType": "wechat", | |||||
| "simulatorPluginLibVersion": {}, | |||||
| "condition": { | |||||
| "search": { | |||||
| "current": -1, | |||||
| "list": [] | |||||
| }, | |||||
| "conversation": { | |||||
| "current": -1, | |||||
| "list": [] | |||||
| }, | |||||
| "game": { | |||||
| "currentL": -1, | |||||
| "list": [] | |||||
| }, | |||||
| "miniprogram": { | |||||
| "current": -1, | |||||
| "list": [] | |||||
| } | |||||
| } | |||||
| } |
| { | |||||
| "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html", | |||||
| "rules": [{ | |||||
| "action": "allow", | |||||
| "page": "*" | |||||
| }] | |||||
| } |
| const formatTime = date => { | |||||
| const year = date.getFullYear() | |||||
| const month = date.getMonth() + 1 | |||||
| const day = date.getDate() | |||||
| const hour = date.getHours() | |||||
| const minute = date.getMinutes() | |||||
| const second = date.getSeconds() | |||||
| return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':') | |||||
| } | |||||
| const formatNumber = n => { | |||||
| n = n.toString() | |||||
| return n[1] ? n : '0' + n | |||||
| } | |||||
| module.exports = { | |||||
| formatTime: formatTime | |||||
| } |