银花优选微信小程序修改后的最新版本代码
This commit is contained in:
274
pages/business/index.js
Normal file
274
pages/business/index.js
Normal file
@@ -0,0 +1,274 @@
|
||||
var WxParse = null;
|
||||
var app = getApp()
|
||||
var that=null
|
||||
var that0=null
|
||||
Page( {
|
||||
data: {
|
||||
loadingHidden:false,
|
||||
nodataHidden:true,
|
||||
indicatorDots: true,
|
||||
indicatorDots0: true,
|
||||
vertical: false,
|
||||
vertical0: false,
|
||||
autoplay: true,
|
||||
interval: 6000,
|
||||
interval0: 8000,
|
||||
duration: 1000,
|
||||
duration0: 1000,
|
||||
business:[],
|
||||
navData:[],
|
||||
nav:0,
|
||||
Start: 0,
|
||||
qkeyword:"请输入关键字",
|
||||
keyword:"",
|
||||
},onShow: function () {
|
||||
if (typeof this.getTabBar === 'function' && this.getTabBar()) {
|
||||
that0=this;
|
||||
var userId = wx.getStorageSync("userId")
|
||||
var userInfodata = wx.getStorageSync("userInfo")
|
||||
var sel=2;
|
||||
var ifsel=0;
|
||||
if(userId&&userInfodata){
|
||||
var userInfo = JSON.parse(userInfodata)
|
||||
|
||||
ifsel=userInfo.bdshEnable;
|
||||
}
|
||||
|
||||
if(ifsel==1){
|
||||
that0.getTabBar().setData({
|
||||
"list": [
|
||||
{
|
||||
"pagePath": "/pages/index/index",
|
||||
"text": "首页",
|
||||
"iconPath": "/images/footer-icon-01.png",
|
||||
"selectedIconPath": "/images/footer-icon-01-active.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "/pages/news/index",
|
||||
"iconPath": "/images/footer-icon-05.png",
|
||||
"selectedIconPath": "/images/footer-icon-05-active.png",
|
||||
"text": "资讯"
|
||||
},
|
||||
|
||||
{
|
||||
"pagePath": "/pages/my/index",
|
||||
"text": "我的",
|
||||
"iconPath": "/images/footer-icon-04.png",
|
||||
"selectedIconPath": "/images/footer-icon-04-active.png"
|
||||
}
|
||||
]
|
||||
})
|
||||
}else{
|
||||
that0.getTabBar().setData({
|
||||
"list": [
|
||||
{
|
||||
"pagePath": "/pages/index/index",
|
||||
"text": "首页",
|
||||
"iconPath": "/images/footer-icon-01.png",
|
||||
"selectedIconPath": "/images/footer-icon-01-active.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "/pages/news/index",
|
||||
"iconPath": "/images/footer-icon-05.png",
|
||||
"selectedIconPath": "/images/footer-icon-05-active.png",
|
||||
"text": "资讯"
|
||||
},
|
||||
{
|
||||
"pagePath": "/pages/business/index",
|
||||
"iconPath": "/images/footer-icon-02.png",
|
||||
"selectedIconPath": "/images/footer-icon-02-active.png",
|
||||
"text": "门店"
|
||||
},
|
||||
|
||||
{
|
||||
"pagePath": "/pages/my/index",
|
||||
"text": "我的",
|
||||
"iconPath": "/images/footer-icon-04.png",
|
||||
"selectedIconPath": "/images/footer-icon-04-active.png"
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
that0.getTabBar().setData({
|
||||
selected: sel
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
onLoad: function(options) {
|
||||
that = this
|
||||
wx.setBackgroundColor({
|
||||
backgroundColor: "#00B050",
|
||||
})
|
||||
that.clearCache();//清本页缓存
|
||||
that.getlist(0);//第一次加载数据
|
||||
var sopenFrame0=setInterval(function (){
|
||||
clearInterval(sopenFrame0);
|
||||
wx.getLocation({
|
||||
type: 'gcj02', // 比较精确
|
||||
success: (res) => {
|
||||
wx.setStorageSync("latitude", res.latitude)
|
||||
wx.setStorageSync("longitude", res.longitude)
|
||||
that.clearCache();//清本页缓存
|
||||
that.getlist(0);
|
||||
},fail: (err) => {
|
||||
/*wx.showToast({
|
||||
title: JSON.stringify(err),
|
||||
icon: "none",
|
||||
duration: 20000
|
||||
})*/
|
||||
}
|
||||
|
||||
})
|
||||
},1000);
|
||||
},
|
||||
|
||||
// 下拉刷新
|
||||
onPullDownRefresh: function () {
|
||||
//在当前页面显示导航条加载动画
|
||||
wx.showNavigationBarLoading();
|
||||
//显示 loading 提示框。需主动调用 wx.hideLoading 才能关闭提示框
|
||||
wx.showLoading({
|
||||
title: '刷新中...',
|
||||
})
|
||||
|
||||
that.clearCache();
|
||||
that.getlist(1);//第一次加载数据
|
||||
},
|
||||
|
||||
// 页面上拉触底事件(上拉加载更多)
|
||||
onReachBottom: function () {
|
||||
that.getlist(2);//后台获取新数据并追加渲染
|
||||
},
|
||||
|
||||
// 清缓存
|
||||
clearCache:function(){
|
||||
that.setData({
|
||||
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:"getBusinessdata",
|
||||
userId:(!userId?"":userId),
|
||||
LoginId:(!LoginId?"":LoginId),
|
||||
keyword:that.data.keyword,
|
||||
t:(that.data.nav>0?that.data.nav:""),
|
||||
Start:that.data.Start,
|
||||
latitude:(!latitude?"":latitude),
|
||||
longitude:(!longitude?"":longitude),
|
||||
},
|
||||
method:"GET",
|
||||
dataType:"json",
|
||||
header: {
|
||||
"content-type": "application/json" // 默认值
|
||||
},
|
||||
success (res) {
|
||||
if(res.data.status==1){
|
||||
var tmpArr = null;
|
||||
if(gp==0||gp==1){
|
||||
tmpArr = res.data.Businesslist
|
||||
}else{
|
||||
tmpArr = that.data.business;
|
||||
tmpArr.push.apply(tmpArr,res.data.Businesslist);
|
||||
}
|
||||
that.setData({
|
||||
business: tmpArr,
|
||||
Start: that.data.Start+res.data.Businesslist.length,
|
||||
loadingHidden:true
|
||||
})
|
||||
if(gp==0||gp==1){
|
||||
that.setData({
|
||||
navData:res.data.lbs
|
||||
})
|
||||
if(res.data.Businesslist.length==0){
|
||||
that.setData({
|
||||
nodataHidden:false
|
||||
})
|
||||
}else{
|
||||
that.setData({
|
||||
nodataHidden:true
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(res.data.msg=="您未登录"){
|
||||
wx.removeStorageSync('userId')
|
||||
wx.removeStorageSync('LoginId')
|
||||
}
|
||||
}
|
||||
if(gp==0||gp==1){
|
||||
//隐藏loading 提示框
|
||||
wx.hideLoading();
|
||||
//隐藏导航条加载动画
|
||||
wx.hideNavigationBarLoading();
|
||||
//停止下拉刷新
|
||||
wx.stopPullDownRefresh();
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
},onsearch:function() {
|
||||
var keyword=that.data.keyword.replace(/\s+/g, "");
|
||||
if(keyword!=""){
|
||||
that.setData({
|
||||
keyword:keyword
|
||||
})
|
||||
that.clearCache();//清本页缓存
|
||||
that.getlist(0);//第一次加载数据
|
||||
}else{
|
||||
wx.showToast({
|
||||
title: "关键字不能为空",
|
||||
icon: "none",
|
||||
duration: 3000
|
||||
})
|
||||
}
|
||||
},swiperchange0:function(e) {
|
||||
|
||||
},closeserver:function(e) {
|
||||
that.setData({
|
||||
bodyHidden:true
|
||||
})
|
||||
},inserver :function(e) {
|
||||
|
||||
},onnav:function(e) {
|
||||
var index = e.currentTarget.dataset.id
|
||||
that.setData({
|
||||
nav:index
|
||||
})
|
||||
|
||||
that.clearCache();
|
||||
that.getlist(0);
|
||||
},onamap:function(e) {
|
||||
var address = e.currentTarget.dataset.id
|
||||
var lat = e.currentTarget.dataset.lat
|
||||
var lon = e.currentTarget.dataset.lon
|
||||
wx.navigateTo({
|
||||
url: "../map/index?lat=" + lon + "&lon=" + lat + "&address=" + address
|
||||
})
|
||||
},oncopy0:function(e) {
|
||||
var address = e.currentTarget.dataset.id
|
||||
wx.setClipboardData({
|
||||
data: address,
|
||||
success: function (res) {
|
||||
wx.showToast({
|
||||
title: "复制成功"
|
||||
})
|
||||
}
|
||||
})
|
||||
},onview:function(e) {
|
||||
var id = e.currentTarget.dataset.id
|
||||
wx.navigateTo({
|
||||
url: "../businessview/index?id=" + id
|
||||
})
|
||||
}
|
||||
})
|
||||
3
pages/business/index.json
Normal file
3
pages/business/index.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"navigationBarTitleText": "门店"
|
||||
}
|
||||
72
pages/business/index.wxml
Normal file
72
pages/business/index.wxml
Normal file
@@ -0,0 +1,72 @@
|
||||
<view class="container">
|
||||
<view class="container-header">
|
||||
<view class="header">
|
||||
<!--<view class="searchbox2">
|
||||
<view class="logobox"><image src="../../images/logo2.png" /></view>
|
||||
</view>-->
|
||||
<view class="searchbox">
|
||||
<view class="icobox" bindtap="onsearch"><image src="../../images/searchto1.png" /></view>
|
||||
<view class="inpubox">
|
||||
<input type="text" placeholder="{{qkeyword}}" confirm-type="search" focus="{{getfocus}}" bindinput="getkeyword" bindconfirm="onsearch" placeholder-style="color:#bbb;" />
|
||||
</view>
|
||||
<view class="searchicobox" bindtap="onsearch">搜索</view>
|
||||
|
||||
|
||||
</view>
|
||||
|
||||
|
||||
</view>
|
||||
|
||||
</view>
|
||||
|
||||
<view class="menudata_box">
|
||||
<view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
<view class="business_box">
|
||||
<view class="business_item" wx:for="{{business}}" bindtap="onview" data-id="{{item._id}}">
|
||||
<view class="business_item_top">
|
||||
<view class="ub item_image">
|
||||
<image wx:if="{{item.showpic==0}}" src="{{item.image}}" />
|
||||
</view>
|
||||
<view class="ub-f1 item_info">
|
||||
<view class="item_title">{{item.name}}</view>
|
||||
<view class="item_distance">
|
||||
<view class="item_distance_box">
|
||||
<view class="ub-f1">距您直线距离{{item.distance}}</view>
|
||||
<view class="addressico" catchtap="inserver">
|
||||
<image src="../../images/Pin-Assistor.png" bindtap="onamap" data-id='{{item.name+"-"+item.address}}' data-lat="{{item.lat}}" data-lon="{{item.lon}}" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item_address">
|
||||
<view class="ub-f1">地址:{{item.address}}</view>
|
||||
<view class="ub ico" catchtap="inserver">
|
||||
<view class="ico_box" bindtap="oncopy0" data-id="{{item.address}}">
|
||||
<image src="../../images/copy.png" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="ub business_item_bottom">
|
||||
<view class="item_product" wx:for="{{item.products}}" wx:for-item="cell" wx:for-index="index0" catchtap="inserver">
|
||||
<view bindtap="ondetail" data-id="{{cell._id}}">
|
||||
<view class="product_image">
|
||||
<image src="{{cell.image}}" />
|
||||
</view>
|
||||
<view class="products_title">{{cell.name}}</view>
|
||||
<view class="products_price">
|
||||
<text>¥{{cell.hyje}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="nodata" hidden="{{nodataHidden}}">
|
||||
<image src="../../images/order-null.png"/>
|
||||
<view>暂无数据</view>
|
||||
</view>
|
||||
</view>
|
||||
235
pages/business/index.wxss
Normal file
235
pages/business/index.wxss
Normal file
@@ -0,0 +1,235 @@
|
||||
page{
|
||||
background: #ccc;
|
||||
}
|
||||
.container {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
font-size: 14px;
|
||||
color: #000;
|
||||
padding: 0;
|
||||
background: #ccc;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.container-header{ background-color: #00B050;}
|
||||
.header{margin:0;width:100%; padding:0; padding-top: 0em; box-sizing: border-box;}
|
||||
.searchbox2{ display: flex; z-index: 100; flex-direction: row; margin:0; margin-top:0.3em; width:70%; height:2.8em; padding:0; box-sizing: border-box;}
|
||||
.searchbox2 .logobox{margin-left:0.7em;margin-right:0.35em;margin-top:0; width: 6em;height:1.6em; box-sizing:border-box;}
|
||||
.searchbox2 .logobox image{width: 100%; height:100%;}
|
||||
.searchbox2 .inpubox{flex-grow: 1;padding-left: 0.8em; height:2.2em; box-sizing:border-box;border-radius:0.5em;}
|
||||
.searchbox2 .inpubox input{ margin:0; padding-left: 0.2em; width: 100%; font-size:1em; height:2.2em; outline: none; text-indent:0;box-sizing:border-box;color:#000; border:1px solid #f1f1f1;border-radius:0.5em; background-color:#f5f5f5;}
|
||||
.searchbox2 .icobox{margin-left:-0.3em; width:2.2em;height:2.2em; font-size:1em; box-sizing:border-box;}
|
||||
.searchbox2 .icobox image{width: 1.5em; height:1.5em; margin-top: 0.4em; margin-left: 0.6em;}
|
||||
.searchbox2 .icobox0{width:2.2em;height:2.2em; font-size:1em; box-sizing:border-box;margin-left: 0.6em;}
|
||||
.searchbox2 .icobox0 image{width: 1.8em; height:1.8em; margin-top: 0.2em; margin-left: 0.4em;}
|
||||
.searchbox{ display: flex; z-index: 100; flex-direction: row; margin:0;width:100%; padding:0.8em; padding-top: 0; box-sizing: border-box; }
|
||||
|
||||
.searchbox .inpubox{flex-grow: 1;margin:0; height:2.2em; box-sizing:border-box;}
|
||||
.searchbox .inpubox input{ margin:0; padding-left:2.3em; width: 100%; font-size:1em; height:2.2em; outline: none; text-indent:0;box-sizing:border-box;color:#fff;border:1px solid #1A6D3F;border-radius:0.5em 0 0 0.5em; background-color:#1D7946;}
|
||||
.searchbox .icobox{margin-right:-2.3em; width:2.2em;height:2.2em;box-sizing:border-box;z-index: 101;}
|
||||
|
||||
.searchbox .icobox image{width: 1.5em; height:1.5em; margin-top: 0.4em; margin-left: 0.6em;}
|
||||
.searchbox .icobox0{margin:0; margin-left:0.5em; margin-top:0.2em; width:1.8em;height:1.8em; box-sizing:border-box;z-index: 101;border-radius:50%;}
|
||||
.searchbox .icobox0 image{width: 1.5em; height:1.5em; margin-top: 0.1em; margin-left: 0.1em;}
|
||||
.searchbox .searchicobox{margin:0; margin-left:0em; width:3em;height:2.2em; line-height: 2.2em; box-sizing:border-box;z-index: 102;background:linear-gradient(to right,#1D7946,#1D7946); border:1px solid #1A6D3F; border-left:0; color:#fff; text-align: center; border-radius:0 0.5em 0.5em 0;}
|
||||
|
||||
.swiper{
|
||||
width:100%;
|
||||
background-color: #fff;
|
||||
border-radius:0.5em;
|
||||
padding: 0.8em;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.swiper_box {
|
||||
width: 100%;
|
||||
min-height: 14em;
|
||||
}
|
||||
|
||||
swiper-item image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: inline-block;
|
||||
}
|
||||
.menudata_box{
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
padding:0.8em;
|
||||
box-sizing: border-box;
|
||||
z-index: 10;
|
||||
}
|
||||
.menudata_box view{
|
||||
display:block;
|
||||
float:left;
|
||||
width: 100%;
|
||||
padding: 0.4em 0;
|
||||
padding-bottom: 0.4em;
|
||||
border-radius:0.5em;
|
||||
background-color:#fff;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.menudata_box view .swiper_box0 {
|
||||
display:block;
|
||||
float:left;
|
||||
width: 100%;
|
||||
height:11em;
|
||||
}
|
||||
.menudata_box .swiper_box0 .wx-swiper-dots{bottom: 0em;}
|
||||
.menudata_box view view{
|
||||
float: left;
|
||||
display: flex;
|
||||
width: 25%;
|
||||
height: 6em;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-sizing: border-box;
|
||||
font-size:0.8em;
|
||||
}
|
||||
|
||||
.menudata_box view view image{
|
||||
width: 3em;
|
||||
height: 3em;
|
||||
padding:0;
|
||||
background-color: #f5f5f5;
|
||||
border-radius:0.4em;
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.menudata_box view view text{
|
||||
margin-top: 0.4em;
|
||||
|
||||
}
|
||||
.business_box {
|
||||
width: 100%;
|
||||
padding: 0 0.8em;
|
||||
margin-bottom: 6em;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.business_item {
|
||||
width: 100%;
|
||||
background-color: #fff;
|
||||
border-radius: 0.7em;
|
||||
margin-bottom: 0.8em;
|
||||
padding: 0.6em;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.business_item .business_item_top {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.business_item .business_item_top .item_image {
|
||||
width: 5em;
|
||||
height: 5em;
|
||||
margin-right: 0.6em;
|
||||
border: 1px solid #f1f1f1;
|
||||
}
|
||||
|
||||
.business_item .business_item_top .item_image image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
}
|
||||
.business_item .business_item_top .item_info {
|
||||
width: 12em;
|
||||
}
|
||||
.business_item .business_item_top .item_info .item_title {
|
||||
font-size: 1em;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.business_item .business_item_top .item_info .item_distance {
|
||||
margin-top: 0.5em;
|
||||
font-size: 1em;
|
||||
color: #939393;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.item_distance_box {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.item_distance_box .addressico {
|
||||
margin-left: 0.5em;
|
||||
width: 1.2em;
|
||||
height: 1.2em;
|
||||
}
|
||||
|
||||
.item_distance_box .addressico image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.business_item .business_item_top .item_info{
|
||||
flex-grow: 1;
|
||||
}
|
||||
.business_item .business_item_top .item_info view.item_address {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
margin-top: 0.5em;
|
||||
font-size: 1em;
|
||||
color: #939393;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.business_item .business_item_top .item_info view.item_address .ico {
|
||||
width: 1.4em;
|
||||
height: 1.4em;
|
||||
}
|
||||
|
||||
.business_item .business_item_top .item_info view.item_address .ico .ico_box {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.business_item .business_item_top .item_info view.item_address .ico image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.business_item .business_item_bottom {
|
||||
margin-top: 0.6em;
|
||||
padding-top: 0.6em;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
border-top: 1px solid #f1f1f1;
|
||||
}
|
||||
|
||||
.business_item .item_product .product_image {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.business_item .item_product .product_image image {
|
||||
width: 5em;
|
||||
height: 5em;
|
||||
}
|
||||
|
||||
.business_item .item_product .products_title {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.business_item .item_product .products_price {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.business_item .item_product .products_price text {
|
||||
color: #ff4d00;
|
||||
}
|
||||
|
||||
.business_item .item_product .products_price del {
|
||||
color: #939393;
|
||||
}
|
||||
|
||||
.nodata{padding-top:1em; text-align: center; line-height: 1.5em; color:#939393;}
|
||||
.nodata image {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
}
|
||||
Reference in New Issue
Block a user