| @@ -1,12 +1,41 @@ | |||
| //app.js | |||
| App({ | |||
| onLaunch: function () { | |||
| // 登录 | |||
| wx.login({ | |||
| success: res => { | |||
| // 发送 res.code 到后台换取 openId, sessionKey, unionId | |||
| } | |||
| }) | |||
| onLaunch: function() { | |||
| var baseInfo = wx.getStorageSync('laomenkuangBaseInfo'); | |||
| if (!baseInfo) { | |||
| // 登录 | |||
| wx.login({ | |||
| success: res => { | |||
| // 发送 res.code 到后台换取 openId, sessionKey, unionId | |||
| var that = this; | |||
| wx.request({ | |||
| url: that.globalData.apiUrl + 'openid', | |||
| header: { | |||
| 'code': res.code, | |||
| 'content-type': 'application/json' // 默认值 | |||
| }, | |||
| success(res) { | |||
| res = res.data; | |||
| console.log(res) | |||
| if (res.code == 200) { | |||
| that.globalData.baseInfo = res.data; | |||
| wx.setStorageSync('laomenkuangBaseInfo', res.data) | |||
| that.getInfo() | |||
| } else { | |||
| wx.showToast({ | |||
| title: res.message, | |||
| icon: 'none', | |||
| duration: 2000 | |||
| }) | |||
| } | |||
| } | |||
| }) | |||
| } | |||
| }) | |||
| } else { | |||
| this.globalData.baseInfo = baseInfo | |||
| this.getInfo() | |||
| } | |||
| // 获取用户信息 | |||
| wx.getSetting({ | |||
| success: res => { | |||
| @@ -15,6 +44,7 @@ App({ | |||
| wx.getUserInfo({ | |||
| success: res => { | |||
| // 可以将 res 发送给后台解码出 unionId | |||
| // console.log(res.userInfo) | |||
| this.globalData.userInfo = res.userInfo | |||
| // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 | |||
| @@ -28,7 +58,53 @@ App({ | |||
| } | |||
| }) | |||
| }, | |||
| getInfo: function() { | |||
| this.requestGet('getinfo', "", res => { | |||
| if (res.code == 200) { | |||
| this.globalData.userState = 1; | |||
| } else { | |||
| this.globalData.userState = 0; | |||
| } | |||
| if (this.userStateReadyCallback) { | |||
| this.userStateReadyCallback(this.globalData.userState) | |||
| } | |||
| }) | |||
| }, | |||
| requestGet: function(url, data, callBack) { | |||
| wx.request({ | |||
| url: this.globalData.apiUrl + url, //仅为示例,并非真实的接口地址 | |||
| data: data, | |||
| header: { | |||
| 'openid': this.globalData.baseInfo.openid, | |||
| 'token': this.globalData.couponToken, | |||
| 'content-type': 'application/json' // 默认值 | |||
| }, | |||
| success(res) { | |||
| callBack(res.data) | |||
| } | |||
| }) | |||
| }, | |||
| requestPost: function(url, data, callBack) { | |||
| wx.request({ | |||
| url: this.globalData.apiUrl + url, //仅为示例,并非真实的接口地址 | |||
| data: data, | |||
| header: { | |||
| 'openid': this.globalData.baseInfo.openid, | |||
| 'token': this.globalData.couponToken, | |||
| 'content-type': 'application/x-www-form-urlencoded' // 默认值 | |||
| }, | |||
| method: "POST", | |||
| success(res) { | |||
| callBack(res.data) | |||
| } | |||
| }) | |||
| }, | |||
| globalData: { | |||
| userInfo: null | |||
| userInfo: null, | |||
| userState: -1, //-1未获取 -0未注册 1已注册 | |||
| apiUrl: 'https://laomenkuang.jiyou-tech.com/apiWxAdmin/', | |||
| baseInfo: null, | |||
| couponData:null,//优惠券信息 | |||
| couponToken:null,//优惠券Token | |||
| } | |||
| }) | |||
| @@ -1,10 +1,10 @@ | |||
| { | |||
| "pages": [ | |||
| "pages/login/login", | |||
| "pages/store/store", | |||
| "pages/coupon/coupon", | |||
| "pages/record/record", | |||
| "pages/home/home", | |||
| "pages/login/login" | |||
| "pages/home/home" | |||
| ], | |||
| "window": { | |||
| "backgroundTextStyle": "light", | |||
| @@ -1,38 +1,88 @@ | |||
| // pages/coupon/coupon.js | |||
| const app = getApp() | |||
| Page({ | |||
| /** | |||
| * 页面的初始数据 | |||
| */ | |||
| data: { | |||
| type:2,//1券码核销 2手机号核销 | |||
| state:0,//核销未完成 1核销中 2核销已完成 | |||
| totalNums:50,//总数量 | |||
| nums:1,//核销数量 | |||
| type: 2, //1券码核销 2手机号核销 | |||
| user_phone: '', //手机号 | |||
| state: 0, //0核销未完成 1核销中 2核销已完成 | |||
| totalNums: 50, //总数量 | |||
| nums: 1, //核销数量 | |||
| coupon_name: '', //优惠券名称 | |||
| couponTime: '', //优惠券购买时间 | |||
| code_num: '', //核销短信验证码 | |||
| }, | |||
| /** | |||
| * 核销 | |||
| * 验证码修改 | |||
| */ | |||
| writeOff:function(){ | |||
| console.log('核销') | |||
| wx.switchTab({ | |||
| url: '../record/record' | |||
| changeCode(event) { | |||
| this.setData({ | |||
| code_num: event.detail.value | |||
| }) | |||
| }, | |||
| /** | |||
| * 核销 | |||
| */ | |||
| writeOff: function() { | |||
| if (this.data.state == 1) { | |||
| return | |||
| } | |||
| if (this.data.code_num.length != 6) { | |||
| wx.showToast({ | |||
| title: '验证码错误', | |||
| icon: 'none', | |||
| duration: 2000 | |||
| }) | |||
| } else { | |||
| this.setData({ | |||
| state: 1 | |||
| }) | |||
| var data = { | |||
| check_type: 2, | |||
| user_phone: this.data.user_phone, | |||
| code_num: this.data.code_num, | |||
| coupon_sell_id: app.globalData.couponData.coupon_sell_id, | |||
| coupon_code: '', | |||
| check_num: this.data.nums | |||
| } | |||
| app.requestPost('couponbuy/check', data, res => { | |||
| var state; | |||
| if (res.code == 200) { | |||
| state = 2; | |||
| wx.switchTab({ | |||
| url: '../record/record' | |||
| }) | |||
| } else { | |||
| state = 0; | |||
| wx.showToast({ | |||
| title: res.message, | |||
| icon: 'none', | |||
| duration: 2000 | |||
| }) | |||
| } | |||
| this.setData({ | |||
| state: state | |||
| }) | |||
| }) | |||
| } | |||
| }, | |||
| /** | |||
| * 添加优惠券 | |||
| */ | |||
| addCoupon(){ | |||
| if (this.data.nums+1<=this.data.totalNums){ | |||
| addCoupon() { | |||
| if (this.data.nums + 1 <= this.data.totalNums) { | |||
| this.setData({ | |||
| nums:this.data.nums+1 | |||
| nums: this.data.nums + 1 | |||
| }) | |||
| } | |||
| }, | |||
| /** | |||
| * 减少优惠券 | |||
| */ | |||
| reduceCoupon(){ | |||
| reduceCoupon() { | |||
| if (this.data.nums - 1 > 0) { | |||
| this.setData({ | |||
| nums: this.data.nums - 1 | |||
| @@ -43,63 +93,85 @@ Page({ | |||
| /** | |||
| * 生命周期函数--监听页面加载 | |||
| */ | |||
| onLoad: function (options) { | |||
| onLoad: function(options) { | |||
| wx.hideShareMenu(); | |||
| var code = options.code; | |||
| var pohone = options.phone; | |||
| if (code){//券码查询 | |||
| console.log('券码查询') | |||
| if (code) { //券码查询 | |||
| this.setData({ | |||
| type: 1 | |||
| }) | |||
| } | |||
| if (pohone){//手机号查询 | |||
| console.log('手机号查询') | |||
| if (pohone) { //手机号查询 | |||
| console.log(app.globalData.couponData) | |||
| var couponData = app.globalData.couponData; | |||
| this.setData({ | |||
| type: 2, | |||
| user_phone: pohone, | |||
| totalNums: couponData.num, | |||
| coupon_name: couponData.coupon_name, | |||
| couponTime: couponData.cdate | |||
| }) | |||
| /** | |||
| * 发送验证码 | |||
| */ | |||
| app.requestGet('couponbuy/check/smscode', { user_phone: pohone},res=>{ | |||
| if(res.code==200){ | |||
| }else{ | |||
| wx.showToast({ | |||
| title: res.message, | |||
| icon: 'none', | |||
| duration: 2000 | |||
| }) | |||
| } | |||
| }) | |||
| } | |||
| }, | |||
| /** | |||
| * 生命周期函数--监听页面初次渲染完成 | |||
| */ | |||
| onReady: function () { | |||
| onReady: function() { | |||
| }, | |||
| /** | |||
| * 生命周期函数--监听页面显示 | |||
| */ | |||
| onShow: function () { | |||
| }, | |||
| onShow: function() {}, | |||
| /** | |||
| * 生命周期函数--监听页面隐藏 | |||
| */ | |||
| onHide: function () { | |||
| onHide: function() { | |||
| }, | |||
| /** | |||
| * 生命周期函数--监听页面卸载 | |||
| */ | |||
| onUnload: function () { | |||
| onUnload: function() { | |||
| }, | |||
| /** | |||
| * 页面相关事件处理函数--监听用户下拉动作 | |||
| */ | |||
| onPullDownRefresh: function () { | |||
| onPullDownRefresh: function() { | |||
| }, | |||
| /** | |||
| * 页面上拉触底事件的处理函数 | |||
| */ | |||
| onReachBottom: function () { | |||
| onReachBottom: function() { | |||
| }, | |||
| /** | |||
| * 用户点击右上角分享 | |||
| */ | |||
| onShareAppMessage: function () { | |||
| onShareAppMessage: function() { | |||
| } | |||
| }) | |||
| @@ -5,8 +5,8 @@ | |||
| <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> | |||
| <text class="txt1">{{coupon_name}}</text> | |||
| <text class="txt2">购买时间:{{couponTime}}</text> | |||
| </view> | |||
| <view class="detailsRight" wx:if="{{type==2}}">{{totalNums}}<text class="company">张</text> | |||
| </view> | |||
| @@ -38,7 +38,7 @@ | |||
| <view class="state">核销成功</view> | |||
| </view> | |||
| <view id="vCodeBox" wx:if="{{type==2}}"> | |||
| <input placeholder="输入短信验证码" placeholder-style="color:#FFFFFF;font-size:30rpx;"></input> | |||
| <input placeholder="输入短信验证码" placeholder-style="color:#FFFFFF;font-size:30rpx;" value="{{code_num}}" bindinput="changeCode"></input> | |||
| <view class="countBox"> | |||
| <text>核销</text> | |||
| <view class="countContent">{{nums}} | |||
| @@ -48,5 +48,5 @@ | |||
| </view> | |||
| </view> | |||
| </view> | |||
| <button class="btn shadow" bindtap="writeOff">核销</button> | |||
| <button class="btn shadow {{state==1?'select':''}}" bindtap="writeOff">核销</button> | |||
| </view> | |||
| @@ -180,6 +180,9 @@ | |||
| font-size: 36rpx; | |||
| background: linear-gradient(-72deg, rgba(235, 97, 0, 1), rgba(255, 137, 42, 1)); | |||
| } | |||
| .btn.select{ | |||
| background: #cccccc; | |||
| } | |||
| #vCodeBox>input { | |||
| width: 600rpx; | |||
| @@ -1,17 +1,18 @@ | |||
| // pages/home/home.js | |||
| const app = getApp() | |||
| Page({ | |||
| /** | |||
| * 页面的初始数据 | |||
| */ | |||
| data: { | |||
| isQuerying:false, | |||
| isQuerying: false, | |||
| }, | |||
| /** | |||
| * 核销查询 | |||
| */ | |||
| check: function(e) { | |||
| if (this.data.isQuerying){ | |||
| if (this.data.isQuerying) { | |||
| return | |||
| } | |||
| var data = e.detail.value; | |||
| @@ -29,9 +30,9 @@ Page({ | |||
| }) | |||
| } else { | |||
| var type; | |||
| if(data.code!=''){//券码查询 | |||
| type=1; | |||
| if(data.code.length!=6){ | |||
| if (data.code != '') { //券码查询 | |||
| type = 1; | |||
| if (data.code.length != 6) { | |||
| wx.showToast({ | |||
| title: '券码格式错误', | |||
| icon: 'none', | |||
| @@ -40,7 +41,7 @@ Page({ | |||
| return | |||
| } | |||
| } | |||
| if(data.phone!=''){//手机号查询 | |||
| if (data.phone != '') { //手机号查询 | |||
| type = 2; | |||
| if (data.phone.length != 11) { | |||
| wx.showToast({ | |||
| @@ -52,22 +53,39 @@ Page({ | |||
| } | |||
| } | |||
| this.setData({ | |||
| isQuerying:true | |||
| isQuerying: true | |||
| }) | |||
| this.query(data,type); | |||
| this.query(data, type); | |||
| } | |||
| }, | |||
| query(data, type){ | |||
| var key,value; | |||
| if (type == 1) {//券码查询 | |||
| key='code'; | |||
| value=data.code; | |||
| } else {//手机号查询 | |||
| 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 | |||
| app.requestGet('couponbuy/searchbyphone', { | |||
| user_phone: data.phone | |||
| }, res => { | |||
| this.setData({ | |||
| isQuerying: false | |||
| }) | |||
| if (res.code == 200) { | |||
| app.globalData.couponData = res.data[0]; | |||
| app.globalData.couponToken = res.token; | |||
| wx.navigateTo({ | |||
| url: '../coupon/coupon?' + key + '=' + value | |||
| }) | |||
| } else { | |||
| wx.showToast({ | |||
| title: res.message, | |||
| icon: 'none', | |||
| duration: 2000 | |||
| }) | |||
| } | |||
| }) | |||
| }, | |||
| @@ -75,7 +93,7 @@ Page({ | |||
| * 生命周期函数--监听页面加载 | |||
| */ | |||
| onLoad: function(options) { | |||
| wx.hideShareMenu(); | |||
| }, | |||
| /** | |||
| @@ -4,7 +4,7 @@ | |||
| <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="code" maxlength="6" placeholder="请输入券码" placeholder-class="inputPlaceholder" style="margin-top:138rpx;" disabled="true"/> | |||
| <input name="phone" maxlength="11" placeholder="手机号核销" placeholder-class="inputPlaceholder" type="number" /> | |||
| <button class="query {{isQuerying?'select':''}}" form-type="submit">查询</button> | |||
| </form> | |||
| @@ -1,55 +0,0 @@ | |||
| //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 | |||
| }) | |||
| } | |||
| }) | |||
| @@ -1,3 +0,0 @@ | |||
| { | |||
| "usingComponents": {} | |||
| } | |||
| @@ -1,13 +0,0 @@ | |||
| <!--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> | |||
| @@ -1,21 +0,0 @@ | |||
| /**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; | |||
| } | |||
| @@ -1,11 +1,14 @@ | |||
| // pages/login/login.js | |||
| const app = getApp() | |||
| Page({ | |||
| /** | |||
| * 页面的初始数据 | |||
| */ | |||
| data: { | |||
| isLoginIng: false | |||
| isLoginIng: false, | |||
| canIUse: wx.canIUse('button.open-type.getUserInfo'), | |||
| hasUserInfo: false, | |||
| }, | |||
| /** | |||
| * 登录 | |||
| @@ -35,18 +38,83 @@ Page({ | |||
| } | |||
| }, | |||
| login(data) { | |||
| setTimeout(function() { | |||
| wx.switchTab({ | |||
| url: '../home/home' | |||
| var data={ | |||
| account_id: data.userName, | |||
| account_password: data.password | |||
| } | |||
| app.requestPost('register', data,res=>{ | |||
| this.setData({ | |||
| isLoginIng: false | |||
| }) | |||
| }, 500) | |||
| if(res.code==200){ | |||
| wx.switchTab({ | |||
| url: '../home/home' | |||
| }) | |||
| }else{ | |||
| wx.showToast({ | |||
| title: res.message, | |||
| icon: 'none', | |||
| duration: 2000 | |||
| }) | |||
| } | |||
| }) | |||
| }, | |||
| /** | |||
| * 生命周期函数--监听页面加载 | |||
| */ | |||
| onLoad: function(options) { | |||
| wx.hideShareMenu(); | |||
| if (app.globalData.userInfo) { | |||
| this.setData({ | |||
| hasUserInfo: true | |||
| }) | |||
| } else if (this.data.canIUse) { | |||
| // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 | |||
| // 所以此处加入 callback 以防止这种情况 | |||
| app.userInfoReadyCallback = res => { | |||
| this.setData({ | |||
| hasUserInfo: true | |||
| }) | |||
| } | |||
| } else { | |||
| // 在没有 open-type=getUserInfo 版本的兼容处理 | |||
| wx.getUserInfo({ | |||
| success: res => { | |||
| app.globalData.userInfo = res.userInfo | |||
| this.setData({ | |||
| hasUserInfo: true | |||
| }) | |||
| } | |||
| }) | |||
| } | |||
| if (app.globalData.userState==1){//已注册 | |||
| wx.switchTab({ | |||
| url: '../home/home' | |||
| }) | |||
| } else if (app.globalData.userState == -1){ | |||
| app.userStateReadyCallback = res => { | |||
| if(res){ | |||
| wx.switchTab({ | |||
| url: '../home/home' | |||
| }) | |||
| } | |||
| } | |||
| } | |||
| }, | |||
| /** | |||
| * 获取头像昵称 | |||
| */ | |||
| getUserInfo: function (e) { | |||
| app.globalData.userInfo = e.detail.userInfo | |||
| this.setData({ | |||
| hasUserInfo: true | |||
| }) | |||
| if (e.detail.userInfo){ | |||
| app.requestPost('submit', e.detail.userInfo,res=>{ | |||
| console.log(res) | |||
| }) | |||
| } | |||
| }, | |||
| /** | |||
| @@ -12,7 +12,8 @@ | |||
| 密码 | |||
| <input name="password" password></input> | |||
| </view> | |||
| <button class="btn {{isLoginIng?'select':''}}" form-type="submit">登录</button> | |||
| <button wx:if="{{!hasUserInfo && canIUse}}" class="btn" open-type="getUserInfo" bindgetuserinfo="getUserInfo" >登录</button> | |||
| <button wx:else class="btn {{isLoginIng?'select':''}}" form-type="submit">登录</button> | |||
| </form> | |||
| </view> | |||
| </view> | |||
| @@ -6,64 +6,12 @@ Page({ | |||
| * 页面的初始数据 | |||
| */ | |||
| data: { | |||
| userInfo: {}, | |||
| userInfo: null, | |||
| canIUse: wx.canIUse('button.open-type.getUserInfo'), | |||
| userName: '老门框内部操作', | |||
| hasUserInfo: false, | |||
| 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元券' | |||
| }], | |||
| data: [], | |||
| }, | |||
| panel: function(e) { | |||
| if (e.currentTarget.dataset.index != this.data.showIndex) { | |||
| @@ -81,6 +29,7 @@ Page({ | |||
| * 生命周期函数--监听页面加载 | |||
| */ | |||
| onLoad: function(options) { | |||
| wx.hideShareMenu(); | |||
| if (app.globalData.userInfo) { | |||
| this.setData({ | |||
| userInfo: app.globalData.userInfo, | |||
| @@ -107,17 +56,22 @@ Page({ | |||
| } | |||
| }) | |||
| } | |||
| console.log(app.globalData.userInfo) | |||
| // console.log(app.globalData.userInfo) | |||
| }, | |||
| /** | |||
| * 获取头像昵称 | |||
| */ | |||
| getUserInfo: function (e) { | |||
| app.globalData.userInfo = e.detail.userInfo | |||
| this.setData({ | |||
| userInfo: e.detail.userInfo, | |||
| hasUserInfo: true | |||
| }) | |||
| if (e.detail.userInfo) { | |||
| this.setData({ | |||
| userInfo: e.detail.userInfo, | |||
| hasUserInfo: true | |||
| }) | |||
| app.requestPost('submit', e.detail.userInfo, res => { | |||
| console.log(res) | |||
| }) | |||
| } | |||
| }, | |||
| /** | |||
| @@ -131,7 +85,26 @@ Page({ | |||
| * 生命周期函数--监听页面显示 | |||
| */ | |||
| onShow: function() { | |||
| this.setData({ | |||
| data:[] | |||
| }) | |||
| var data={ | |||
| cur_page: 1, | |||
| show_num: 99 | |||
| } | |||
| app.requestGet('couponbuy/checklog', data,res=>{ | |||
| if(res.code==200){ | |||
| this.setData({ | |||
| data: res.data | |||
| }) | |||
| }else{ | |||
| wx.showToast({ | |||
| title: res.message, | |||
| icon: 'none', | |||
| duration: 2000 | |||
| }) | |||
| } | |||
| }) | |||
| }, | |||
| /** | |||
| @@ -20,11 +20,12 @@ | |||
| <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 wx:if="{{showIndex == 1&&data.length==0}}" style="text-align: center;font-size: 30rpx;">暂无数据</view> | |||
| <view class="details" wx:if="{{showIndex == 1}}" wx:for="{{data}}" wx:key="id"> | |||
| <text class="time">{{item.cdate}}</text> | |||
| <view class="infoBox"> | |||
| <text>券码:{{item.no}}</text> | |||
| <text>{{item.txt}}</text> | |||
| <text>券码:{{item.coupon_code}}</text> | |||
| <text>{{item.coupon_type}}</text> | |||
| </view> | |||
| </view> | |||
| </view> | |||
| @@ -1,118 +1,202 @@ | |||
| // pages/store/store.js | |||
| const app = getApp() | |||
| Page({ | |||
| /** | |||
| * 页面的初始数据 | |||
| */ | |||
| data: { | |||
| searchContent:'测试呢容',//搜索内容 | |||
| multiArray: [['浙江省', '广东省'], ['宁波市', '杭州市', '温州市', '绍兴市', '台州市']], | |||
| multiIndex: [0, 0], | |||
| list:[ | |||
| { | |||
| url:'../../static/store/01.png', | |||
| name:'北京东城区金宝店', | |||
| address:'北京市东城区金宝大雅宝59号(鄂尔多斯酒店对面)', | |||
| mobile:'010-8388-6698' | |||
| }, | |||
| { | |||
| url: '../../static/store/01.png', | |||
| name: '北京东城区金宝店', | |||
| address: '北京市东城区金宝大雅宝59号(鄂尔多斯酒店对面)', | |||
| mobile: '010-8388-6698' | |||
| }, | |||
| { | |||
| url: '../../static/store/01.png', | |||
| name: '北京东城区金宝店', | |||
| address: '北京市东城区金宝大雅宝59号(鄂尔多斯酒店对面)', | |||
| mobile: '010-8388-6698' | |||
| } | |||
| ] | |||
| key: '', //检索关键字 | |||
| multiArray: [ | |||
| [], | |||
| [] | |||
| ], //省份列表 | |||
| showMultArray: [ | |||
| [], | |||
| [] | |||
| ], //省份显示列表 | |||
| multiIndex: [0, 0], //省份下标 | |||
| multiData: null, //省份数据 | |||
| cur_page: 1, //当前页数 | |||
| show_num: 99, //每页显示项目数 | |||
| storeList: [], //门店列表 | |||
| }, | |||
| /** | |||
| * 清除搜索内容 | |||
| */ | |||
| clearSearchContent(){ | |||
| clearSearchContent() { | |||
| this.setData({ | |||
| searchContent:"" | |||
| key: "" | |||
| }) | |||
| }, | |||
| /** | |||
| * 输入内容改变 | |||
| */ | |||
| changeSearch(event){ | |||
| changeSearch(event) { | |||
| this.setData({ | |||
| searchContent: event.detail.value | |||
| key: event.detail.value | |||
| }) | |||
| }, | |||
| /** | |||
| *搜索 | |||
| */ | |||
| search(){ | |||
| console.log(this.data.searchContent) | |||
| search() { | |||
| this.setData({ | |||
| cur_page: 1 | |||
| }) | |||
| this.getStoreList(); | |||
| }, | |||
| /** | |||
| * 拨打电话 | |||
| */ | |||
| callMobile(e){ | |||
| console.log(e); | |||
| callMobile(e) { | |||
| wx.makePhoneCall({ | |||
| phoneNumber: e.currentTarget.dataset.mobile //仅为示例,并非真实的电话号码 | |||
| phoneNumber: e.currentTarget.dataset.mobile | |||
| }) | |||
| }, | |||
| /** | |||
| * 打开定位地图 | |||
| */ | |||
| openLocation(e){ | |||
| var latitude = parseFloat(e.currentTarget.dataset.latitude); | |||
| var longitude = parseFloat(e.currentTarget.dataset.longitude); | |||
| wx.openLocation({ | |||
| latitude: latitude, | |||
| longitude: longitude, | |||
| scale: 18, | |||
| }) | |||
| }, | |||
| /** | |||
| * 生命周期函数--监听页面加载 | |||
| */ | |||
| onLoad: function (options) { | |||
| onLoad: function(options) { | |||
| wx.hideShareMenu(); | |||
| //获取省份信息 | |||
| app.requestGet('shop/shop_province', '', res => { | |||
| if (res.code == 200) { | |||
| this.setData({ | |||
| multiData: res.data, | |||
| }) | |||
| this.changeCityList(this.data.multiIndex, true); | |||
| this.getStoreList(); | |||
| } | |||
| }) | |||
| }, | |||
| /** | |||
| * 选择省市 | |||
| */ | |||
| changeCityList(showList, boolem) { | |||
| var data = this.data.multiData; | |||
| var list = [], | |||
| list2; | |||
| for (var i = 0; i < data.length; i++) { | |||
| list.push(data[i].shop_province) | |||
| if (i == showList[0]) { | |||
| list2 = data[i].shop_city.split(',') | |||
| } | |||
| } | |||
| if (boolem) { | |||
| this.setData({ | |||
| multiArray: [list, list2], | |||
| showMultArray: [list, list2], | |||
| multiIndex: showList | |||
| }) | |||
| } else { | |||
| this.setData({ | |||
| multiArray: [list, list2] | |||
| }) | |||
| } | |||
| }, | |||
| bindMultiPickerColumnChange(e) { | |||
| if (e.detail.column == 0) { //省份改变 | |||
| this.changeCityList([e.detail.value, 0], false) | |||
| } | |||
| }, | |||
| bindMultiPickerChange(e) { | |||
| this.changeCityList(e.detail.value, true); | |||
| this.setData({ | |||
| cur_page:1 | |||
| }) | |||
| this.getStoreList(); | |||
| }, | |||
| bindMultiPickerCancelChange(e) { | |||
| this.changeCityList(this.data.multiIndex, true); | |||
| }, | |||
| /** | |||
| * 获取门店列表数据 | |||
| */ | |||
| getStoreList() { | |||
| this.setData({ | |||
| storeList: [] | |||
| }) | |||
| var data = { | |||
| 'shop_province': this.data.showMultArray[0][this.data.multiIndex[0]], | |||
| 'shop_city': this.data.showMultArray[1][this.data.multiIndex[1]], | |||
| 'key': this.data.key, | |||
| 'cur_page': this.data.cur_page, | |||
| 'show_num': this.data.show_num | |||
| } | |||
| app.requestGet('shop/search', data, res => { | |||
| if (res.code === 200) { | |||
| this.setData({ | |||
| storeList: res.data | |||
| }) | |||
| } else { | |||
| wx.showToast({ | |||
| title: res.message, | |||
| icon: 'none', | |||
| duration: 2000 | |||
| }) | |||
| } | |||
| }) | |||
| }, | |||
| /** | |||
| * 生命周期函数--监听页面初次渲染完成 | |||
| */ | |||
| onReady: function () { | |||
| onReady: function() { | |||
| }, | |||
| /** | |||
| * 生命周期函数--监听页面显示 | |||
| */ | |||
| onShow: function () { | |||
| onShow: function() { | |||
| }, | |||
| /** | |||
| * 生命周期函数--监听页面隐藏 | |||
| */ | |||
| onHide: function () { | |||
| onHide: function() { | |||
| }, | |||
| /** | |||
| * 生命周期函数--监听页面卸载 | |||
| */ | |||
| onUnload: function () { | |||
| onUnload: function() { | |||
| }, | |||
| /** | |||
| * 页面相关事件处理函数--监听用户下拉动作 | |||
| */ | |||
| onPullDownRefresh: function () { | |||
| onPullDownRefresh: function() { | |||
| }, | |||
| /** | |||
| * 页面上拉触底事件的处理函数 | |||
| */ | |||
| onReachBottom: function () { | |||
| onReachBottom: function() { | |||
| }, | |||
| /** | |||
| * 用户点击右上角分享 | |||
| */ | |||
| onShareAppMessage: function () { | |||
| onShareAppMessage: function() { | |||
| } | |||
| }) | |||
| @@ -2,34 +2,34 @@ | |||
| <view class="container"> | |||
| <view class="headSearch"> | |||
| <view class="pickerBox"> | |||
| <picker mode="multiSelector" bindchange="bindMultiPickerChange" bindcolumnchange="bindMultiPickerColumnChange" value="{{multiIndex}}" range="{{multiArray}}"> | |||
| {{multiArray[1][multiIndex[1]]}} | |||
| <picker mode="multiSelector" bindcancel="bindMultiPickerCancelChange" bindchange="bindMultiPickerChange" bindcolumnchange="bindMultiPickerColumnChange" value="{{multiIndex}}" range="{{multiArray}}"> | |||
| {{showMultArray[1][multiIndex[1]]}} | |||
| <image class="down" src="../../static/record/down.png"></image> | |||
| </picker> | |||
| <image class="down" src="../../static/record/down.png"></image> | |||
| </view> | |||
| <view class="searchBox"> | |||
| <icon class="iconSearch" type="search" size="30rpx" /> | |||
| <input class="search" confirm-type="search" placeholder="输入搜索内容" placeholder-style="color:#B2B2B2;font-size: 24rpx;" value="{{searchContent}}" bindinput="changeSearch" bindconfirm="search"></input> | |||
| <icon class="iconClose" type="clear" size="30rpx" wx:if="{{searchContent!=''}}" bindtap="clearSearchContent" /> | |||
| <input class="search" confirm-type="search" placeholder="输入搜索内容" placeholder-style="color:#B2B2B2;font-size: 24rpx;" value="{{key}}" bindinput="changeSearch" bindconfirm="search"></input> | |||
| <icon class="iconClose" type="clear" size="30rpx" wx:if="{{key!=''}}" bindtap="clearSearchContent" /> | |||
| </view> | |||
| <view class="btnSearch" bindtap="search">搜索</view> | |||
| </view> | |||
| <scroll-view class="content" scroll-y="true"> | |||
| <view class="Item clearfix" wx:for="{{list}}"> | |||
| <view class="Item clearfix" wx:for="{{storeList}}" wx:key="id"> | |||
| <view class="photoBox"> | |||
| <image class="photo" src="{{item.url}}" mode="aspectFill"></image> | |||
| <view class="phoneBox"> | |||
| <image class="photo" src="{{item.shop_img}}" mode="aspectFill"></image> | |||
| <view class="phoneBox" data-mobile="{{item.shop_phone}}" bindtap="callMobile"> | |||
| <image class="phone" src="../../static/store/phone.png"></image> | |||
| </view> | |||
| </view> | |||
| <view class="name">{{item.name}}</view> | |||
| <view class="infoBox"> | |||
| <view class="name">{{item.shop_name}}</view> | |||
| <view class="infoBox" data-latitude="{{item.shop_latitude}}" data-longitude="{{item.shop_longtitude}}" bindtap="openLocation"> | |||
| <image class="icon" src="../../static/store/location.png"></image> | |||
| <text>{{item.address}}</text> | |||
| <text>{{item.shop_addr}}</text> | |||
| </view> | |||
| <view class="infoBox" data-mobile="{{item.mobile}}" bindtap="callMobile"> | |||
| <view class="infoBox" data-mobile="{{item.shop_phone}}" bindtap="callMobile"> | |||
| <image class="icon" src="../../static/store/mobile.png"></image> | |||
| <text>{{item.mobile}}</text> | |||
| <text>{{item.shop_phone}}</text> | |||
| </view> | |||
| </view> | |||
| </scroll-view> | |||
| @@ -22,10 +22,10 @@ | |||
| justify-content: center; | |||
| align-items: center; | |||
| } | |||
| .headSearch>.pickerBox>.down{ | |||
| .headSearch>.pickerBox .down{ | |||
| display: inline-block; | |||
| width: 19rpx; | |||
| height: 10rpx; | |||
| margin-left: 10rpx; | |||
| } | |||
| .headSearch>.searchBox { | |||
| @@ -4,15 +4,23 @@ | |||
| "ignore": [] | |||
| }, | |||
| "setting": { | |||
| "urlCheck": true, | |||
| "urlCheck": false, | |||
| "es6": true, | |||
| "postcss": true, | |||
| "minified": true, | |||
| "newFeature": true, | |||
| "autoAudits": false, | |||
| "coverView": true, | |||
| "autoAudits": false, | |||
| "showShadowRootInWxmlPanel": true, | |||
| "scopeDataCheck": false | |||
| "scopeDataCheck": false, | |||
| "checkInvalidKey": true, | |||
| "checkSiteMap": true, | |||
| "uploadWithSourceMap": true, | |||
| "babelSetting": { | |||
| "ignore": [], | |||
| "disablePlugins": [], | |||
| "outputPath": "" | |||
| } | |||
| }, | |||
| "compileType": "miniprogram", | |||
| "libVersion": "2.10.2", | |||