银花优选微信小程序修改后的最新版本代码
This commit is contained in:
143
pages/businessview/index.js
Normal file
143
pages/businessview/index.js
Normal file
@@ -0,0 +1,143 @@
|
||||
var WxParse = null;
|
||||
var app = getApp()
|
||||
var that=null
|
||||
Page( {
|
||||
data: {
|
||||
loadingHidden:false,
|
||||
nodataHidden:true,
|
||||
indicatorDots: false,
|
||||
indicatorDots0: true,
|
||||
vertical: false,
|
||||
vertical0: false,
|
||||
autoplay: true,
|
||||
interval: 6000,
|
||||
interval0: 8000,
|
||||
duration: 1000,
|
||||
duration0: 1000,
|
||||
viewid:0,
|
||||
showpic:0,
|
||||
title:"",
|
||||
products:[],
|
||||
images:[],
|
||||
Start:0,
|
||||
latitude:"",
|
||||
longitude:"",
|
||||
distance:"",
|
||||
address:"",
|
||||
fwbody:""
|
||||
},
|
||||
|
||||
onLoad: function(options) {
|
||||
that = this
|
||||
if(options.id){
|
||||
that.setData({
|
||||
viewid: options.id
|
||||
});
|
||||
}
|
||||
that.clearCache();//清本页缓存
|
||||
that.getlist(0);//第一次加载数据
|
||||
},
|
||||
|
||||
// 下拉刷新
|
||||
onPullDownRefresh: function () {
|
||||
that.clearCache();
|
||||
that.getlist(0);//第一次加载数据
|
||||
},
|
||||
|
||||
// 页面上拉触底事件(上拉加载更多)
|
||||
onReachBottom: function () {
|
||||
that.getlist(1);//后台获取新数据并追加渲染
|
||||
},
|
||||
|
||||
// 清缓存
|
||||
clearCache:function(){
|
||||
that.setData({
|
||||
products: [],
|
||||
Start: 0,
|
||||
loadingHidden:false
|
||||
});
|
||||
}, getlist: function (gp) {
|
||||
|
||||
var userId = wx.getStorageSync("userId")
|
||||
var LoginId = wx.getStorageSync("LoginId")
|
||||
var latitude = wx.getStorageSync("latitude")
|
||||
var longitude = wx.getStorageSync("longitude")
|
||||
wx.request({
|
||||
url: app.globalData.apiurl + "/xapiajax.ashx",
|
||||
data: {
|
||||
action:"getbusinessview",
|
||||
userId:(!userId?"":userId),
|
||||
LoginId:(!LoginId?"":LoginId),
|
||||
latitude:(!latitude?"":latitude),
|
||||
longitude:(!LoginId?"":longitude),
|
||||
viewId:that.data.viewid,
|
||||
Start:that.data.Start
|
||||
},
|
||||
method:"GET",
|
||||
dataType:"json",
|
||||
header: {
|
||||
"content-type": "application/json" // 默认值
|
||||
},
|
||||
success (res) {
|
||||
|
||||
var tmpArr = null;
|
||||
tmpArr = that.data.products;
|
||||
if(res.data.productlist.length>0){
|
||||
tmpArr.push.apply(tmpArr,res.data.productlist);
|
||||
}
|
||||
that.setData({
|
||||
products: tmpArr,
|
||||
Start: that.data.Start+res.data.productlist.length,
|
||||
showpic:res.data.showpic,
|
||||
loadingHidden:true
|
||||
})
|
||||
|
||||
if(gp==0||gp==1){
|
||||
that.setData({
|
||||
images:res.data.pic,
|
||||
title:res.data.name,
|
||||
address:res.data.address,
|
||||
distance:res.data.distance,
|
||||
longitude:res.data.lon,
|
||||
latitude:res.data.lat,
|
||||
fwbody:res.data.fwbody,
|
||||
})
|
||||
if(res.data.productlist.length==0){
|
||||
that.setData({
|
||||
nodataHidden:false
|
||||
})
|
||||
}else{
|
||||
that.setData({
|
||||
nodataHidden:true
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
},swiperchange:function(e) {
|
||||
|
||||
},closeserver:function(e) {
|
||||
that.setData({
|
||||
bodyHidden:true
|
||||
})
|
||||
},inserver :function(e) {
|
||||
|
||||
},onamap:function(e) {
|
||||
var address = that.data.address
|
||||
var lat = that.data.latitude
|
||||
var lon = that.data.longitude
|
||||
wx.navigateTo({
|
||||
url: "../map/index?lat=" + lon + "&lon=" + lat + "&address=" + address
|
||||
})
|
||||
},oncopy0:function(e) {
|
||||
var address = that.data.address
|
||||
wx.setClipboardData({
|
||||
data: address,
|
||||
success: function (res) {
|
||||
wx.showToast({
|
||||
title: "复制成功"
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user