return userInfo | return userInfo | ||||
}, | }, | ||||
getInfo: function() { | getInfo: function() { | ||||
this.requestGet('getinfo', "", res => { | |||||
if (res.code == 200) { | |||||
this.globalData.userState = 1; | |||||
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 { | |||||
this.globalData.userState = 0; | |||||
} | |||||
var accountInfo = wx.getStorageSync('laomenkuangAccountInfo'); | |||||
if (accountInfo){//已有账户信息-已登录 | |||||
this.globalData.userState = 1; | |||||
this.globalData.storeData = accountInfo; | |||||
if (this.userStateReadyCallback) { | if (this.userStateReadyCallback) { | ||||
this.userStateReadyCallback(this.globalData.userState) | |||||
this.userStateReadyCallback(1) | |||||
} | } | ||||
}) | |||||
var userInfo = wx.getStorageSync('laomenkuangUserInfo'); | |||||
if (userInfo){ | |||||
this.globalData.userInfo = userInfo; | |||||
} | |||||
}else{ | |||||
this.requestGet('getinfo', "", res => { | |||||
if (res.code == 200) { | |||||
this.globalData.userState = 1; | |||||
wx.setStorageSync('laomenkuangAccountInfo', res.data);//老门框账户信息-id | |||||
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 | |||||
} | |||||
wx.setStorageSync('laomenkuangUserInfo', res.data.user_info);//老门框用户信息-头像昵称 | |||||
this.globalData.userInfo = res.data.user_info; | |||||
} else { | |||||
this.globalData.userState = 0; | |||||
} | |||||
if (this.userStateReadyCallback) { | |||||
this.userStateReadyCallback(this.globalData.userState) | |||||
} | |||||
}) | |||||
} | |||||
}, | }, | ||||
requestGet: function(url, data, callBack) { | requestGet: function(url, data, callBack) { | ||||
wx.request({ | wx.request({ | ||||
}, | }, | ||||
globalData: { | globalData: { | ||||
userInfo: null, | userInfo: null, | ||||
userState: -1, //-1未获取 -0未注册 1已注册 | |||||
userState: -1, //-1未获取 0未注册 1已注册 | |||||
storeData:null,//店铺信息 | storeData:null,//店铺信息 | ||||
apiUrl: 'https://laomenkuang.jiyou-tech.com/apiWxAdmin/', | apiUrl: 'https://laomenkuang.jiyou-tech.com/apiWxAdmin/', | ||||
baseInfo: null, | baseInfo: null, |
"pages/record/record", | "pages/record/record", | ||||
"pages/home/home" | "pages/home/home" | ||||
], | ], | ||||
"permission": { | |||||
"scope.userLocation": { | |||||
"desc": "你的位置信息将用于小程序定位离你最近的门店" | |||||
} | |||||
}, | |||||
"window": { | "window": { | ||||
"backgroundTextStyle": "light", | "backgroundTextStyle": "light", | ||||
"navigationBarBackgroundColor": "#fff", | "navigationBarBackgroundColor": "#fff", |
type: 2, //1券码核销 2手机号核销 | type: 2, //1券码核销 2手机号核销 | ||||
user_phone: '', //手机号 | user_phone: '', //手机号 | ||||
state: 0, //0核销未完成 1核销中 2核销已完成 | state: 0, //0核销未完成 1核销中 2核销已完成 | ||||
headImgUrl:'',//头图 | |||||
totalNums: 1, //总数量 | totalNums: 1, //总数量 | ||||
nums: 1, //核销数量 | nums: 1, //核销数量 | ||||
coupon_name: '', //优惠券名称 | coupon_name: '', //优惠券名称 | ||||
couponTime: '', //优惠券购买时间 | couponTime: '', //优惠券购买时间 | ||||
code_num: '', //核销短信验证码 | code_num: '', //核销短信验证码 | ||||
couponCode: '', //券号 | couponCode: '', //券号 | ||||
couponType: '', //券类型 | |||||
duration: '', //券期间 | duration: '', //券期间 | ||||
type_name:'',//券类型 | |||||
}, | }, | ||||
/** | /** | ||||
* 核销数修改 | * 核销数修改 | ||||
*/ | */ | ||||
changeNums(event) { | changeNums(event) { | ||||
var nums | |||||
if (event.detail.value > this.data.totalNums) { | |||||
nums = this.data.totalNums | |||||
} | |||||
if (event.detail.value < 1) { | |||||
nums = 1 | |||||
} | |||||
this.setData({ | this.setData({ | ||||
nums: nums | |||||
nums: parseInt(event.detail.value) | |||||
}) | }) | ||||
}, | }, | ||||
/** | /** | ||||
if (this.data.state == 1) { | if (this.data.state == 1) { | ||||
return | return | ||||
} | } | ||||
if (this.data.nums>this.data.totalNums){ | |||||
wx.showToast({ | |||||
title: '券剩余数量不足', | |||||
icon: 'none', | |||||
duration: 2000 | |||||
}) | |||||
return | |||||
} | |||||
var data; | var data; | ||||
if (this.data.type == 1) { //券核销 | if (this.data.type == 1) { //券核销 | ||||
data = { | data = { | ||||
if (res.code == 200) { | if (res.code == 200) { | ||||
state = 2; | state = 2; | ||||
if (that.data.type == 2) { //手机号核销 | if (that.data.type == 2) { //手机号核销 | ||||
wx.switchTab({ | |||||
url: '../record/record' | |||||
this.setData({ | |||||
totalNums: this.data.totalNums-this.data.nums | |||||
}) | }) | ||||
} | } | ||||
} else { | } else { | ||||
* 添加优惠券 | * 添加优惠券 | ||||
*/ | */ | ||||
addCoupon() { | addCoupon() { | ||||
if (this.data.nums + 1 <= this.data.totalNums) { | |||||
if (isNaN(this.data.nums)) { | |||||
this.setData({ | |||||
nums: 1 | |||||
}) | |||||
}else if (this.data.nums + 1 <= this.data.totalNums) { | |||||
this.setData({ | this.setData({ | ||||
nums: this.data.nums + 1 | nums: this.data.nums + 1 | ||||
}) | }) | ||||
* 减少优惠券 | * 减少优惠券 | ||||
*/ | */ | ||||
reduceCoupon() { | reduceCoupon() { | ||||
if (this.data.nums - 1 > 0) { | |||||
if (isNaN(this.data.nums)){ | |||||
this.setData({ | |||||
nums: 1 | |||||
}) | |||||
}else if (this.data.nums - 1 > 0) { | |||||
this.setData({ | this.setData({ | ||||
nums: this.data.nums - 1 | nums: this.data.nums - 1 | ||||
}) | }) | ||||
} | } | ||||
}, | }, | ||||
blueNums(){ | |||||
if (isNaN(this.data.nums)) { | |||||
this.setData({ | |||||
nums: 1 | |||||
}) | |||||
} | |||||
}, | |||||
/** | /** | ||||
* 返回核销大厅 | * 返回核销大厅 | ||||
*/ | */ | ||||
type: 1, | type: 1, | ||||
couponCode: code, | couponCode: code, | ||||
coupon_name: couponData.coupon_name, | coupon_name: couponData.coupon_name, | ||||
type_name: couponData.type_name, | |||||
couponTime: couponData.buy_date, | couponTime: couponData.buy_date, | ||||
couponType: couponData.coupon_type, | |||||
duration: couponData.duration | |||||
duration: couponData.duration, | |||||
headImgUrl: couponData.coupon_img_large | |||||
}) | }) | ||||
} | } | ||||
if (pohone) { //手机号查询 | if (pohone) { //手机号查询 | ||||
user_phone: pohone, | user_phone: pohone, | ||||
totalNums: couponData.num, | totalNums: couponData.num, | ||||
coupon_name: couponData.coupon_name, | coupon_name: couponData.coupon_name, | ||||
couponTime: couponData.buy_date | |||||
type_name: couponData.type_name, | |||||
couponTime: couponData.buy_date, | |||||
duration: couponData.duration, | |||||
headImgUrl: couponData.coupon_img_large | |||||
}) | }) | ||||
/** | /** | ||||
* 发送验证码 | * 发送验证码 |
<!--pages/coupon/coupon.wxml--> | <!--pages/coupon/coupon.wxml--> | ||||
<view class="container" style="background-color:#f6f6f6;"> | <view class="container" style="background-color:#f6f6f6;"> | ||||
<image class="couponImg" src="../../static/coupon/Coupon1.png"></image> | |||||
<image class="couponImg" src="{{headImgUrl}}" mode='aspectFill'></image> | |||||
<view class="detailsBox shadow"> | <view class="detailsBox shadow"> | ||||
<image class="bottomBg" src="../../static/coupon/bottomBg1.png"></image> | <image class="bottomBg" src="../../static/coupon/bottomBg1.png"></image> | ||||
<image class="decorate" src="../../static/coupon/01.png"></image> | <image class="decorate" src="../../static/coupon/01.png"></image> | ||||
<view class="detailsInfo"> | <view class="detailsInfo"> | ||||
<text class="txt1">{{coupon_name}}</text> | |||||
<text class="txt1">{{coupon_name+type_name}}</text> | |||||
<text class="txt2">购买时间:{{couponTime}}</text> | <text class="txt2">购买时间:{{couponTime}}</text> | ||||
</view> | </view> | ||||
<view class="detailsRight" wx:if="{{type==2}}"><image class="txt" src="../../static/coupon/txt.png"></image>{{totalNums}}<text class="company">张</text> | <view class="detailsRight" wx:if="{{type==2}}"><image class="txt" src="../../static/coupon/txt.png"></image>{{totalNums}}<text class="company">张</text> | ||||
<text class="number">券码:{{couponCode}}</text> | <text class="number">券码:{{couponCode}}</text> | ||||
<view class="txt">此券有效</view> | <view class="txt">此券有效</view> | ||||
</view> | </view> | ||||
<view id="couponDetails" class="relative clearfix" wx:if="{{type==1&&state==2}}"> | |||||
<view id="couponDetails" class="relative clearfix" wx:if="{{state==2}}"> | |||||
<view class="title">核销详情</view> | <view class="title">核销详情</view> | ||||
<view class="detailsItem"> | <view class="detailsItem"> | ||||
<view class="sign"></view> | <view class="sign"></view> | ||||
<text class="itemTitle">券码</text> | |||||
<text class="itemContent">{{couponCode}}</text> | |||||
<text class="itemTitle" wx:if="{{type==1}}">券码</text> | |||||
<text class="itemTitle" wx:else>数量</text> | |||||
<text class="itemContent" wx:if="{{type==1}}">{{couponCode}}</text> | |||||
<text class="itemContent" wx:else>{{nums}}</text> | |||||
</view> | </view> | ||||
<view class="detailsItem"> | <view class="detailsItem"> | ||||
<view class="sign"></view> | <view class="sign"></view> | ||||
<text class="itemTitle">类型</text> | <text class="itemTitle">类型</text> | ||||
<text class="itemContent">{{couponType}}</text> | |||||
<text class="itemContent">{{coupon_name+type_name}}</text> | |||||
</view> | </view> | ||||
<view class="detailsItem"> | <view class="detailsItem"> | ||||
<view class="sign"></view> | <view class="sign"></view> | ||||
</view> | </view> | ||||
<view class="state">核销成功</view> | <view class="state">核销成功</view> | ||||
</view> | </view> | ||||
<view id="vCodeBox" wx:if="{{type==2}}"> | |||||
<view id="vCodeBox" wx:if="{{type==2&&state!=2}}"> | |||||
<input placeholder="输入短信验证码" placeholder-style="color:#FFFFFF;font-size:30rpx;" value="{{code_num}}" bindinput="changeCode"></input> | <input placeholder="输入短信验证码" placeholder-style="color:#FFFFFF;font-size:30rpx;" value="{{code_num}}" bindinput="changeCode"></input> | ||||
<view class="countBox"> | <view class="countBox"> | ||||
<text>核销</text> | <text>核销</text> | ||||
<view class="countContent"> | <view class="countContent"> | ||||
<input type="number" value="{{nums}}" bindinput="changeNums"></input> | |||||
<input type="number" value="{{nums}}" bindinput="changeNums" bindblur='blueNums'></input> | |||||
<image class="symbolBox" src="../../static/coupon/symbolLeft.png" style="left:-5rpx;" bindtap="reduceCoupon"></image> | <image class="symbolBox" src="../../static/coupon/symbolLeft.png" style="left:-5rpx;" bindtap="reduceCoupon"></image> | ||||
<image class="symbolBox" src="../../static/coupon/symbolRight.png" style="right:-5rpx;" bindtap="addCoupon"></image> | <image class="symbolBox" src="../../static/coupon/symbolRight.png" style="right:-5rpx;" bindtap="addCoupon"></image> | ||||
</view> | </view> |
isLoginIng: false, | isLoginIng: false, | ||||
canIUse: wx.canIUse('button.open-type.getUserInfo'), | canIUse: wx.canIUse('button.open-type.getUserInfo'), | ||||
hasUserInfo: false, | hasUserInfo: false, | ||||
showTip:true, | |||||
}, | |||||
hiddenTip(){ | |||||
this.setData({ | |||||
showTip:false | |||||
}) | |||||
}, | }, | ||||
/** | /** | ||||
* 登录 | * 登录 | ||||
} | } | ||||
}, | }, | ||||
login(data) { | login(data) { | ||||
var that=this | |||||
var data={ | var data={ | ||||
account_id: data.userName, | account_id: data.userName, | ||||
account_password: data.password | account_password: data.password | ||||
isLoginIng: false | isLoginIng: false | ||||
}) | }) | ||||
if(res.code==200){ | if(res.code==200){ | ||||
wx.setStorageSync('laomenkuangAccountInfo', res.data);//老门框账户信息 | |||||
app.globalData.storeData = res.data; | app.globalData.storeData = res.data; | ||||
wx.switchTab({ | |||||
url: '../home/home' | |||||
}) | |||||
app.globalData.userState = 1 | |||||
console.log('回复登录信息') | |||||
if (that.data.hasUserInfo){ | |||||
wx.switchTab({ | |||||
url: '../home/home' | |||||
}) | |||||
} | |||||
}else{ | }else{ | ||||
wx.showToast({ | wx.showToast({ | ||||
title: res.message, | title: res.message, | ||||
wx.switchTab({ | wx.switchTab({ | ||||
url: '../home/home' | url: '../home/home' | ||||
}) | }) | ||||
} else if (app.globalData.userState == -1){ | |||||
} else if (app.globalData.userState == -1){//等待结果 | |||||
app.userStateReadyCallback = res => { | app.userStateReadyCallback = res => { | ||||
if(res){ | if(res){ | ||||
wx.switchTab({ | wx.switchTab({ | ||||
}) | }) | ||||
} | } | ||||
} | } | ||||
} else{//未注册 | |||||
that.setData({ | |||||
showLogin: true | |||||
}) | |||||
} | } | ||||
}, | }, | ||||
/** | /** | ||||
hasUserInfo: true | hasUserInfo: true | ||||
}) | }) | ||||
if (e.detail.userInfo){ | if (e.detail.userInfo){ | ||||
wx.setStorageSync('laomenkuangUserInfo', e.detail.userInfo);//老门框用户信息-头像昵称 | |||||
var userInfo = app.setUserInfo(e.detail.userInfo) | var userInfo = app.setUserInfo(e.detail.userInfo) | ||||
app.requestPost('submit', userInfo,res=>{ | app.requestPost('submit', userInfo,res=>{ | ||||
console.log(res) | console.log(res) | ||||
}) | }) | ||||
} | } | ||||
console.log('回复授权信息') | |||||
if (app.globalData.userState == 1) { | |||||
wx.switchTab({ | |||||
url: '../home/home' | |||||
}) | |||||
} | |||||
}, | }, | ||||
/** | /** |
密码 | 密码 | ||||
<input name="password" password></input> | <input name="password" password></input> | ||||
</view> | </view> | ||||
<button wx:if="{{!hasUserInfo && canIUse}}" class="btn" open-type="getUserInfo" bindgetuserinfo="getUserInfo" >登录</button> | |||||
<button wx:if="{{!hasUserInfo && canIUse}}" class="btn {{isLoginIng?'select':''}}" form-type="submit" open-type="getUserInfo" bindgetuserinfo="getUserInfo">登录</button> | |||||
<button wx:else class="btn {{isLoginIng?'select':''}}" form-type="submit">登录</button> | <button wx:else class="btn {{isLoginIng?'select':''}}" form-type="submit">登录</button> | ||||
<view class="tipBox"> | |||||
<view class="title">温馨提示</view> | |||||
<view class="content">本小程序仅限内部人员使用,各门店工作人员首次使用需使用专属帐号密码登陆。</view> | |||||
</view> | |||||
</form> | </form> | ||||
</view> | </view> | ||||
<view class="mask" wx:if="{{showTip}}"> | |||||
<view class="tipBox"> | |||||
<view class="header">温馨提示</view> | |||||
<view class="contentTxt">本小程序仅限内部人员使用,各门店工作人员首次使用需使用专属帐号密码登陆。</view> | |||||
<button bindtap="hiddenTip">确定</button> | |||||
</view> | |||||
</view> | |||||
</view> | </view> |
height: 98rpx; | height: 98rpx; | ||||
line-height: 98rpx; | line-height: 98rpx; | ||||
border-radius: 49rpx; | border-radius: 49rpx; | ||||
color: #ffffff; | |||||
color: #fff; | |||||
font-size: 36rpx; | font-size: 36rpx; | ||||
text-align: center; | text-align: center; | ||||
margin-top: 111rpx; | margin-top: 111rpx; | ||||
background: linear-gradient(-72deg, rgba(235, 97, 0, 1), rgba(255, 137, 42, 1)); | background: linear-gradient(-72deg, rgba(235, 97, 0, 1), rgba(255, 137, 42, 1)); | ||||
} | } | ||||
.btn.select{ | |||||
background: #cccccc; | |||||
} | |||||
.btn.select { | |||||
background: #ccc; | |||||
} | |||||
.fromBox .tipBox{ | |||||
margin-top: 15rpx; | |||||
} | |||||
.fromBox .tipBox>.title{ | |||||
color: #cccccc; | |||||
text-align: center; | |||||
font-size: 30rpx; | |||||
margin-bottom: 15rpx; | |||||
} | |||||
.fromBox .tipBox>.content{ | |||||
color: #cccccc; | |||||
text-align: center; | |||||
font-size: 25rpx; | |||||
line-height: 45rpx; | |||||
} | |||||
.mask { | |||||
position: absolute; | |||||
left: 0; | |||||
top: 0; | |||||
width: 100%; | |||||
height: 100%; | |||||
background-color: rgba(0, 0, 0, 0.7); | |||||
} | |||||
.mask>.tipBox { | |||||
position: absolute; | |||||
left: 50%; | |||||
top: 50%; | |||||
transform: translate(-50%, -50%); | |||||
width: 600rpx; | |||||
height: 550rpx; | |||||
background-color: #fff; | |||||
border-radius: 15rpx; | |||||
} | |||||
.mask>.tipBox>.header { | |||||
width: 100%; | |||||
height: 80rpx; | |||||
text-align: center; | |||||
line-height: 80rpx; | |||||
border-bottom: 2rpx solid #cccccc; | |||||
} | |||||
.mask>.tipBox>.contentTxt{ | |||||
line-height: 75rpx; | |||||
margin: 30rpx 40rpx 0 40rpx; | |||||
} | |||||
.mask>.tipBox>button{ | |||||
position: absolute; | |||||
width: 100%; | |||||
bottom: 0rpx; | |||||
color: #fffefe; | |||||
font-size: 36rpx; | |||||
background: linear-gradient(-72deg, rgba(235, 97, 0, 1), rgba(255, 137, 42, 1)); | |||||
} |
getUserInfo: function (e) { | getUserInfo: function (e) { | ||||
app.globalData.userInfo = e.detail.userInfo | app.globalData.userInfo = e.detail.userInfo | ||||
if (e.detail.userInfo) { | if (e.detail.userInfo) { | ||||
wx.setStorageSync('laomenkuangUserInfo', e.detail.userInfo);//老门框用户信息-头像昵称 | |||||
this.setData({ | this.setData({ | ||||
userInfo: e.detail.userInfo, | userInfo: e.detail.userInfo, | ||||
hasUserInfo: true | hasUserInfo: true |
} | } | ||||
.item>.details>.infoBox{ | .item>.details>.infoBox{ | ||||
color: #999999; | color: #999999; | ||||
font-size: 23rpx; | |||||
font-size: 21rpx; | |||||
display: flex; | display: flex; | ||||
justify-content: space-between; | justify-content: space-between; | ||||
margin-top: 5rpx; | margin-top: 5rpx; |
// pages/store/store.js | // pages/store/store.js | ||||
const app = getApp() | const app = getApp() | ||||
var amapFile = require('../../libs/amap-wx.js'); | |||||
Page({ | Page({ | ||||
/** | /** | ||||
multiIndex: [0, 0], //省份下标 | multiIndex: [0, 0], //省份下标 | ||||
multiData: null, //省份数据 | multiData: null, //省份数据 | ||||
cur_page: 1, //当前页数 | cur_page: 1, //当前页数 | ||||
show_num: 99, //每页显示项目数 | |||||
show_num: 10, //每页显示项目数 | |||||
storeList: [], //门店列表 | storeList: [], //门店列表 | ||||
state: 0, //0未获取 1获取中 2无更多 | |||||
addressData: null, //地址信息 | |||||
locationData: null, //经纬度信息 | |||||
}, | }, | ||||
/** | /** | ||||
* 清除搜索内容 | * 清除搜索内容 | ||||
*/ | */ | ||||
clearSearchContent() { | clearSearchContent() { | ||||
this.setData({ | this.setData({ | ||||
key: "" | |||||
key: "", | |||||
cur_page: 1 | |||||
}) | }) | ||||
this.search() | 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; | var shopName = e.currentTarget.dataset.name; | ||||
}) | }) | ||||
}, | }, | ||||
/** | /** | ||||
* 获取当前城市 | |||||
*/ | |||||
getCurrentCity() { | |||||
var that = this | |||||
var myAmapFun = new amapFile.AMapWX({ | |||||
key: 'b61cd7baf9244dd531eb27d227218a34' | |||||
}); | |||||
myAmapFun.getRegeo({ | |||||
success: function(res) { | |||||
//成功回调 | |||||
that.setData({ | |||||
addressData: res[0].regeocodeData.addressComponent, | |||||
locationData: { | |||||
latitude: res[0].latitude, | |||||
longitude: res[0].longitude | |||||
} | |||||
}) | |||||
console.log(res) | |||||
that.getProvince(); | |||||
}, | |||||
fail: function(info) { | |||||
//失败回调 | |||||
that.getProvince(); | |||||
} | |||||
}) | |||||
}, | |||||
/** | |||||
* 生命周期函数--监听页面加载 | * 生命周期函数--监听页面加载 | ||||
*/ | */ | ||||
onLoad: function(options) { | onLoad: function(options) { | ||||
wx.hideShareMenu(); | wx.hideShareMenu(); | ||||
//获取省份信息 | |||||
this.getCurrentCity() | |||||
}, | |||||
/** | |||||
* 获取省份信息 | |||||
*/ | |||||
getProvince() { | |||||
app.requestGet('shop/shop_province', '', res => { | app.requestGet('shop/shop_province', '', res => { | ||||
if (res.code == 200) { | if (res.code == 200) { | ||||
var city='全部'; | |||||
for(var i=0;i<res.data.length;i++){ | |||||
var city = '全部'; | |||||
for (var i = 0; i < res.data.length; i++) { | |||||
city += "," + res.data[i].shop_city | city += "," + res.data[i].shop_city | ||||
} | } | ||||
var indexList = [0, 0] | |||||
if (this.data.addressData){ | |||||
var cityList = city.split(',') | |||||
var cityIndex = cityList.indexOf(this.data.addressData.city) | |||||
if (cityIndex > 0) { | |||||
indexList[1] = cityIndex; | |||||
} | |||||
} | |||||
res.data.unshift({ | res.data.unshift({ | ||||
shop_city:city, | |||||
shop_province:'全部' | |||||
shop_city: city, | |||||
shop_province: '全部' | |||||
}) | }) | ||||
this.setData({ | this.setData({ | ||||
multiData: res.data, | multiData: res.data, | ||||
multiIndex: indexList | |||||
}) | }) | ||||
this.changeCityList(this.data.multiIndex, true); | |||||
this.changeCityList(indexList, true); | |||||
this.getStoreList(); | this.getStoreList(); | ||||
} | } | ||||
}) | }) | ||||
bindMultiPickerChange(e) { | bindMultiPickerChange(e) { | ||||
this.changeCityList(e.detail.value, true); | this.changeCityList(e.detail.value, true); | ||||
this.setData({ | this.setData({ | ||||
cur_page:1 | |||||
cur_page: 1 | |||||
}) | }) | ||||
this.getStoreList(); | this.getStoreList(); | ||||
}, | }, | ||||
* 获取门店列表数据 | * 获取门店列表数据 | ||||
*/ | */ | ||||
getStoreList() { | getStoreList() { | ||||
this.setData({ | |||||
storeList: [] | |||||
}) | |||||
if (this.data.cur_page == 1) { | |||||
this.setData({ | |||||
storeList: [] | |||||
}) | |||||
} | |||||
var city = this.data.showMultArray[1][this.data.multiIndex[1]] == '全部' ? '' : this.data.showMultArray[1][this.data.multiIndex[1]]; | var city = this.data.showMultArray[1][this.data.multiIndex[1]] == '全部' ? '' : this.data.showMultArray[1][this.data.multiIndex[1]]; | ||||
var data = { | var data = { | ||||
'shop_city': city, | 'shop_city': city, | ||||
'key': this.data.key, | 'key': this.data.key, | ||||
'cur_page': this.data.cur_page, | 'cur_page': this.data.cur_page, | ||||
'show_num': this.data.show_num | |||||
'show_num': this.data.show_num, | |||||
"location": this.data.locationData ? 2 : 1, | |||||
"lng": this.data.locationData ? this.data.locationData.longitude : null, | |||||
"lat": this.data.locationData ? this.data.locationData.latitude : null, | |||||
} | } | ||||
app.requestGet('shop/search', data, res => { | |||||
app.requestGet('shop/shopsearch', data, res => { | |||||
if (res.code === 200) { | if (res.code === 200) { | ||||
this.setData({ | |||||
storeList: res.data | |||||
}) | |||||
var newList = JSON.parse(JSON.stringify(this.data.storeList)) | |||||
for (var i = 0; i < res.data.length; i++) { | |||||
newList.push(res.data[i]) | |||||
} | |||||
if (res.data.length < this.data.show_num) { | |||||
this.setData({ | |||||
storeList: newList, | |||||
state: 2 | |||||
}) | |||||
} else { | |||||
this.setData({ | |||||
storeList: newList, | |||||
state: 0 | |||||
}) | |||||
} | |||||
} else { | } else { | ||||
wx.showToast({ | wx.showToast({ | ||||
title: res.message, | title: res.message, | ||||
icon: 'none', | icon: 'none', | ||||
duration: 2000 | duration: 2000 | ||||
}) | }) | ||||
this.setData({ | |||||
state: 0 | |||||
}) | |||||
} | } | ||||
}) | }) | ||||
}, | }, | ||||
/** | |||||
* 滚动到底部 | |||||
*/ | |||||
scrollDown() { | |||||
if (this.data.state == 0) { | |||||
this.setData({ | |||||
state: 1, | |||||
cur_page: this.data.cur_page + 1 | |||||
}) | |||||
this.getStoreList() | |||||
} | |||||
}, | |||||
/** | /** | ||||
* 生命周期函数--监听页面初次渲染完成 | * 生命周期函数--监听页面初次渲染完成 |
</view> | </view> | ||||
<view class="btnSearch" bindtap="search">搜索</view> | <view class="btnSearch" bindtap="search">搜索</view> | ||||
</view> | </view> | ||||
<scroll-view class="content" scroll-y="true"> | |||||
<scroll-view class="content" scroll-y="true" bindscrolltolower='scrollDown' lower-threshold='1500'> | |||||
<view class="Item clearfix" wx:for="{{storeList}}" wx:key="id"> | <view class="Item clearfix" wx:for="{{storeList}}" wx:key="id"> | ||||
<view class="photoBox"> | <view class="photoBox"> | ||||
<image class="photo" src="{{item.shop_img}}" mode="aspectFill"></image> | <image class="photo" src="{{item.shop_img}}" mode="aspectFill"></image> | ||||
<view class="name">{{item.shop_name}}</view> | <view class="name">{{item.shop_name}}</view> | ||||
<view class="infoBox" data-name="{{item.shop_name}}" 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 style="overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">{{item.shop_addr}}</text> | |||||
</view> | </view> | ||||
<view class="infoBox" data-mobile="{{item.shop_phone}}" bindtap="callMobile"> | <view class="infoBox" data-mobile="{{item.shop_phone}}" bindtap="callMobile"> | ||||
<image class="icon" src="../../static/store/mobile.png"></image> | <image class="icon" src="../../static/store/mobile.png"></image> | ||||
<text>{{item.shop_phone}}</text> | <text>{{item.shop_phone}}</text> | ||||
</view> | </view> | ||||
</view> | </view> | ||||
<view style="text-align: center;margin: 15rpx;" wx:if="{{state==2&&storeList.length>show_num}}">暂无更多</view> | |||||
<view style="text-align: center;margin: 15rpx;" wx:if="{{state==1}}">获取中....</view> | |||||
</scroll-view> | </scroll-view> | ||||
</view> | </view> |