| }, | }, | ||||
| success(res) { | success(res) { | ||||
| res = res.data; | res = res.data; | ||||
| console.log(res) | |||||
| if (res.code == 200) { | if (res.code == 200) { | ||||
| that.globalData.baseInfo = res.data; | that.globalData.baseInfo = res.data; | ||||
| wx.setStorageSync('laomenkuangBaseInfo', res.data) | wx.setStorageSync('laomenkuangBaseInfo', res.data) | ||||
| } | } | ||||
| }) | }) | ||||
| }, | }, | ||||
| setUserInfo(userInfo){ | |||||
| userInfo.nickname = userInfo.nickName | |||||
| userInfo.headimgurl = userInfo.avatarUrl | |||||
| return userInfo | |||||
| }, | |||||
| getInfo: function() { | getInfo: function() { | ||||
| this.requestGet('getinfo', "", res => { | this.requestGet('getinfo', "", res => { | ||||
| if (res.code == 200) { | if (res.code == 200) { | ||||
| this.globalData.userState = 1; | this.globalData.userState = 1; | ||||
| this.globalData.storeData=res.data; | this.globalData.storeData=res.data; | ||||
| if (res.data.user_info){ | |||||
| res.data.user_info.nickName = res.data.user_info.nickname | |||||
| res.data.user_info.avatarUrl = res.data.user_info.headimgurl | |||||
| } | |||||
| this.globalData.userInfo = res.data.user_info; | |||||
| } else { | } else { | ||||
| this.globalData.userState = 0; | this.globalData.userState = 0; | ||||
| } | } |
| state: state | state: state | ||||
| }) | }) | ||||
| }) | }) | ||||
| }, | }, | ||||
| /** | /** | ||||
| * 添加优惠券 | * 添加优惠券 |
| * 页面的初始数据 | * 页面的初始数据 | ||||
| */ | */ | ||||
| data: { | data: { | ||||
| phone:'',//手机号 | |||||
| isQuerying: false, | isQuerying: false, | ||||
| storeName: '', //店名 | storeName: '', //店名 | ||||
| }, | }, | ||||
| * 生命周期函数--监听页面显示 | * 生命周期函数--监听页面显示 | ||||
| */ | */ | ||||
| onShow: function() { | onShow: function() { | ||||
| this.setData({ | |||||
| phone:'' | |||||
| }) | |||||
| }, | }, | ||||
| /** | /** |
| <view class="fromBox"> | <view class="fromBox"> | ||||
| <image class="arrow" src="../../static/home/arrow.png"></image> | <image class="arrow" src="../../static/home/arrow.png"></image> | ||||
| <form bindsubmit="check"> | <form bindsubmit="check"> | ||||
| <!-- <input name="code" maxlength="6" placeholder="请输入券码" placeholder-class="inputPlaceholder" style="margin-top:138rpx;" disabled="true" /> --> | |||||
| <input name="phone" maxlength="11" placeholder="手机号核销" placeholder-class="inputPlaceholder" style="margin-top:132rpx;" type="number" /> | |||||
| <input name="phone" maxlength="11" value="{{phone}}" placeholder="手机号核销" placeholder-class="inputPlaceholder" style="margin-top:132rpx;" type="number" /> | |||||
| <button class="btn query {{isQuerying?'select':''}}" form-type="submit">查询</button> | <button class="btn query {{isQuerying?'select':''}}" form-type="submit">查询</button> | ||||
| <button class="btn scanning" bindtap="scanCode">点击扫描核销</button> | <button class="btn scanning" bindtap="scanCode">点击扫描核销</button> | ||||
| </form> | </form> |
| * 页面的初始数据 | * 页面的初始数据 | ||||
| */ | */ | ||||
| data: { | data: { | ||||
| showLogin:false, | |||||
| isLoginIng: false, | isLoginIng: false, | ||||
| canIUse: wx.canIUse('button.open-type.getUserInfo'), | canIUse: wx.canIUse('button.open-type.getUserInfo'), | ||||
| hasUserInfo: false, | hasUserInfo: false, | ||||
| * 生命周期函数--监听页面加载 | * 生命周期函数--监听页面加载 | ||||
| */ | */ | ||||
| onLoad: function(options) { | onLoad: function(options) { | ||||
| var that=this; | |||||
| wx.hideShareMenu(); | wx.hideShareMenu(); | ||||
| if (app.globalData.userInfo) { | if (app.globalData.userInfo) { | ||||
| this.setData({ | this.setData({ | ||||
| wx.switchTab({ | wx.switchTab({ | ||||
| url: '../home/home' | url: '../home/home' | ||||
| }) | }) | ||||
| }else{ | |||||
| that.setData({ | |||||
| showLogin:true | |||||
| }) | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| hasUserInfo: true | hasUserInfo: true | ||||
| }) | }) | ||||
| if (e.detail.userInfo){ | if (e.detail.userInfo){ | ||||
| app.requestPost('submit', e.detail.userInfo,res=>{ | |||||
| var userInfo = app.setUserInfo(e.detail.userInfo) | |||||
| app.requestPost('submit', userInfo,res=>{ | |||||
| console.log(res) | console.log(res) | ||||
| }) | }) | ||||
| } | } |
| <!--pages/login/login.wxml--> | <!--pages/login/login.wxml--> | ||||
| <view class="container"> | |||||
| <view class="container" wx:if="{{showLogin}}"> | |||||
| <image class="bg" src="../../static/login/bg.jpg" mode="aspectFill"></image> | <image class="bg" src="../../static/login/bg.jpg" mode="aspectFill"></image> | ||||
| <image class="logo" src="../../static/login/logo.png"></image> | <image class="logo" src="../../static/login/logo.png"></image> | ||||
| <view class="fromBox"> | <view class="fromBox"> |
| userInfo: null, | userInfo: null, | ||||
| canIUse: wx.canIUse('button.open-type.getUserInfo'), | canIUse: wx.canIUse('button.open-type.getUserInfo'), | ||||
| hasUserInfo: false, | hasUserInfo: false, | ||||
| userNo: '000001', //员工编号 | |||||
| userNo: '', //员工编号 | |||||
| showIndex: 1, | showIndex: 1, | ||||
| data: [], | data: [], | ||||
| }, | }, | ||||
| } | } | ||||
| }) | }) | ||||
| } | } | ||||
| // console.log(app.globalData.userInfo) | |||||
| this.setData({ | |||||
| userNo: app.globalData.storeData.account_id | |||||
| }) | |||||
| }, | }, | ||||
| /** | /** | ||||
| * 获取头像昵称 | * 获取头像昵称 | ||||
| userInfo: e.detail.userInfo, | userInfo: e.detail.userInfo, | ||||
| hasUserInfo: true | hasUserInfo: true | ||||
| }) | }) | ||||
| app.requestPost('submit', e.detail.userInfo, res => { | |||||
| var userInfo = app.setUserInfo(e.detail.userInfo) | |||||
| app.requestPost('submit', userInfo, res => { | |||||
| console.log(res) | console.log(res) | ||||
| }) | }) | ||||
| } | } |
| this.setData({ | this.setData({ | ||||
| key: "" | key: "" | ||||
| }) | }) | ||||
| this.search() | |||||
| }, | }, | ||||
| /** | /** | ||||
| * 输入内容改变 | * 输入内容改变 | ||||
| openLocation(e){ | openLocation(e){ | ||||
| var latitude = parseFloat(e.currentTarget.dataset.latitude); | var latitude = parseFloat(e.currentTarget.dataset.latitude); | ||||
| var longitude = parseFloat(e.currentTarget.dataset.longitude); | var longitude = parseFloat(e.currentTarget.dataset.longitude); | ||||
| var shopName = e.currentTarget.dataset.name; | |||||
| wx.openLocation({ | wx.openLocation({ | ||||
| latitude: latitude, | latitude: latitude, | ||||
| longitude: longitude, | longitude: longitude, | ||||
| scale: 18, | scale: 18, | ||||
| name: shopName | |||||
| }) | }) | ||||
| }, | }, | ||||
| /** | /** |
| </view> | </view> | ||||
| </view> | </view> | ||||
| <view class="name">{{item.shop_name}}</view> | <view class="name">{{item.shop_name}}</view> | ||||
| <view class="infoBox" data-latitude="{{item.shop_latitude}}" data-longitude="{{item.shop_longtitude}}" bindtap="openLocation"> | |||||
| <view class="infoBox" data-name="{{item.shop_name}}" data-latitude="{{item.shop_latitude}}" data-longitude="{{item.shop_longtitude}}" bindtap="openLocation"> | |||||
| <image class="icon" src="../../static/store/location.png"></image> | <image class="icon" src="../../static/store/location.png"></image> | ||||
| <text>{{item.shop_addr}}</text> | <text>{{item.shop_addr}}</text> | ||||
| </view> | </view> |
| "ignore": [] | "ignore": [] | ||||
| }, | }, | ||||
| "setting": { | "setting": { | ||||
| "urlCheck": false, | |||||
| "urlCheck": true, | |||||
| "es6": true, | "es6": true, | ||||
| "postcss": true, | "postcss": true, | ||||
| "minified": true, | "minified": true, |