更换版本
This commit is contained in:
81
pages/home/searchShop/searchShop.js
Normal file
81
pages/home/searchShop/searchShop.js
Normal file
@@ -0,0 +1,81 @@
|
||||
var a;
|
||||
(a = getApp()),
|
||||
Page({
|
||||
data: {
|
||||
focus: !1,
|
||||
inputValue: "",
|
||||
heatShop: [],
|
||||
shop: [],
|
||||
res: [],
|
||||
heatShops: [],
|
||||
keywordArr: [],
|
||||
inputVal: "",
|
||||
},
|
||||
onLoad: function () {
|
||||
var e = this;
|
||||
a.siteInfo.uniacid,
|
||||
this.setData({ keywordArr: wx.getStorageSync("keywordArr") }),
|
||||
a.util.request({
|
||||
url: "entry/wxapp/Api",
|
||||
data: { m: "monai_market", r: "home.index.search_detail" },
|
||||
cachetime: "0",
|
||||
success: function (a) {
|
||||
console.log(a), e.setData({ shop: a.data.data });
|
||||
},
|
||||
});
|
||||
},
|
||||
bindKeyInput: function (e) {
|
||||
a.siteInfo.uniacid;
|
||||
for (
|
||||
var t = [], n = e.detail.value, r = this.data.shop, i = 0;
|
||||
i < r.length;
|
||||
i++
|
||||
)
|
||||
r[i].unickname.match(n) && t.push(r[i]);
|
||||
this.setData({ res: t, inputVal: n });
|
||||
},
|
||||
range: function () {
|
||||
var a,
|
||||
e,
|
||||
t = this.data.heatShops,
|
||||
n = t.length;
|
||||
if (n)
|
||||
for (; --n; )
|
||||
(a = t[(e = Math.floor(Math.random() * (n + 1)))]),
|
||||
(t[e] = t[n]),
|
||||
(t[n] = a);
|
||||
this.setData({ heatShop: t.slice(0, 7) });
|
||||
},
|
||||
searchPage: function (e) {
|
||||
var t = a.getAttr(e, "name");
|
||||
wx.navigateTo({ url: "/pages/home/index/index?name=" + t });
|
||||
},
|
||||
del: function () {
|
||||
wx.setStorageSync("keywordArr", []), this.setData({ keywordArr: [] });
|
||||
},
|
||||
formSubmit: function (a) {
|
||||
var e = wx.getStorageSync("keywordArr") || [],
|
||||
t = a.detail.value.name;
|
||||
if (e.length > 0)
|
||||
for (var n = 0; n < e.length; n++)
|
||||
if (e[n] == t.trim()) {
|
||||
e.splice(n, 1);
|
||||
break;
|
||||
}
|
||||
e.unshift(t),
|
||||
e.length >= 10 && e.pop(),
|
||||
wx.setStorageSync("keywordArr", e),
|
||||
this.setData({ keywordArr: e }),
|
||||
wx.navigateTo({ url: "/pages/home/index/index?name=" + t });
|
||||
},
|
||||
shop_id: function (a) {
|
||||
var e = a.detail.value.shopid;
|
||||
wx.navigateTo({ url: "/pages/home/carMessage/carMessage?id=" + e });
|
||||
},
|
||||
cant: function () {
|
||||
this.setData({ res: [], inputVal: "" });
|
||||
},
|
||||
click_val: function (a) {
|
||||
wx.navigateBack({});
|
||||
},
|
||||
});
|
1
pages/home/searchShop/searchShop.json
Normal file
1
pages/home/searchShop/searchShop.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "navigationBarTitleText": "搜索", "usingComponents": {} }
|
30
pages/home/searchShop/searchShop.wxml
Normal file
30
pages/home/searchShop/searchShop.wxml
Normal file
@@ -0,0 +1,30 @@
|
||||
<form bindsubmit="formSubmit">
|
||||
<view class="serch_view">
|
||||
<view class="serch_border">
|
||||
<image class="serch_border_img" src="../../image/sousuo_btn.png"></image>
|
||||
<input bindinput="bindKeyInput" class="serch_border_text" focus="{{true}}" name="name" placeholder="请输入关键字进行搜索" placeholderStyle="font-size: 24rpx;color: #B2B2B2;" type="text" value="{{inputVal}}"></input>
|
||||
</view>
|
||||
<button class="serch_border_btn btn_active" formType="submit" wx:if="{{inputVal}}">搜索</button>
|
||||
<button bindtap="click_val" class="serch_border_btn" wx:else>取消</button>
|
||||
<image bindtap="cant" class="close_img" src="../image/gb_btn.png" wx:if="{{inputVal}}"></image>
|
||||
</view>
|
||||
</form>
|
||||
<view class="mohu_border_view" wx:if="{{res.length>0}}">
|
||||
<view class="mohu_border">
|
||||
<view class="mohu_border_modle mohu_border_modle_first">搜索{{inputVal}}店铺</view>
|
||||
<form bindsubmit="shop_id" reportSubmit="true" wx:for="{{res}}">
|
||||
<input hidden="true" name="shopid" value="{{item.id}}"></input>
|
||||
<button class="mohu_border_modle" formType="submit">{{item.unickname}}</button>
|
||||
</form>
|
||||
</view>
|
||||
</view>
|
||||
<view class="serch_nav"></view>
|
||||
<view class="biaoqian_border_all" wx:if="{{keywordArr.length>0}}">
|
||||
<view class="biaoqian_modle">
|
||||
<view class="biaoqian_title">历史搜索 <view bindtap="del" class="biaoqian_title_right">删除</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="biaoqian_border">
|
||||
<view bindtap="searchPage" class="biaoqian" data-name="{{item}}" wx:for="{{keywordArr}}"> {{item}} </view>
|
||||
</view>
|
||||
</view>
|
141
pages/home/searchShop/searchShop.wxss
Normal file
141
pages/home/searchShop/searchShop.wxss
Normal file
@@ -0,0 +1,141 @@
|
||||
page {
|
||||
background: #f0f0f0;
|
||||
height: 100%;
|
||||
}
|
||||
.serch_view {
|
||||
background: #fff;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
height: 68rpx;
|
||||
padding: 1rpx 3% 20rpx;
|
||||
position: fixed;
|
||||
width: 94%;
|
||||
}
|
||||
.serch_nav {
|
||||
height: 83rpx;
|
||||
width: 100%;
|
||||
}
|
||||
.serch_border {
|
||||
background: #f5f5f5;
|
||||
border-radius: 100px;
|
||||
float: left;
|
||||
height: 60rpx;
|
||||
margin-top: 5rpx;
|
||||
width: 82%;
|
||||
}
|
||||
.serch_border_img {
|
||||
border-right: 1rpx solid rgba(0, 0, 0, 0.1);
|
||||
float: left;
|
||||
height: 38rpx;
|
||||
margin-left: 20rpx;
|
||||
margin-top: 13rpx;
|
||||
padding-right: 10rpx;
|
||||
width: 38rpx;
|
||||
}
|
||||
.serch_border_text {
|
||||
color: #b2b2b2;
|
||||
float: left;
|
||||
font-size: 24rpx;
|
||||
height: 60rpx;
|
||||
line-height: 60rpx;
|
||||
padding-left: 15rpx;
|
||||
width: 76%;
|
||||
}
|
||||
.serch_border_btn {
|
||||
background: #f5f5f5;
|
||||
border: 1rpx solid rgba(0, 0, 0, 0.1);
|
||||
border-radius: 10rpx;
|
||||
color: #555;
|
||||
float: right;
|
||||
font-size: 24rpx;
|
||||
height: 60rpx;
|
||||
line-height: 58rpx;
|
||||
margin: 5rpx 0rpx 0rpx;
|
||||
padding: 0rpx;
|
||||
text-align: center;
|
||||
width: 100rpx;
|
||||
}
|
||||
button::after {
|
||||
border: none;
|
||||
}
|
||||
.biaoqian_border_all {
|
||||
background: #fff;
|
||||
width: 100%;
|
||||
}
|
||||
.biaoqian_modle {
|
||||
margin-left: 3%;
|
||||
margin-top: 10rpx;
|
||||
width: 94%;
|
||||
}
|
||||
.biaoqian_title {
|
||||
color: #555;
|
||||
font-size: 24rpx;
|
||||
height: 60rpx;
|
||||
line-height: 60rpx;
|
||||
width: 100%;
|
||||
}
|
||||
.biaoqian_title_right {
|
||||
color: #f75f5f;
|
||||
float: right;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
.biaoqian_border {
|
||||
padding-bottom: 20rpx;
|
||||
width: 100%;
|
||||
}
|
||||
.biaoqian {
|
||||
background: #f5f5f5;
|
||||
border-radius: 10rpx;
|
||||
color: #555;
|
||||
display: inline-block;
|
||||
font-size: 24rpx;
|
||||
margin-left: 20rpx;
|
||||
margin-top: 20rpx;
|
||||
padding: 5rpx 13rpx;
|
||||
}
|
||||
.biaoqian_nav {
|
||||
background: #f0f0f0;
|
||||
height: 7rpx;
|
||||
width: 100%;
|
||||
}
|
||||
.mohu_border_view {
|
||||
background: #fff;
|
||||
height: 87%;
|
||||
overflow-y: scroll;
|
||||
position: fixed;
|
||||
top: 92rpx;
|
||||
width: 100%;
|
||||
}
|
||||
.mohu_border {
|
||||
background: #fff;
|
||||
margin-left: 5%;
|
||||
width: 90%;
|
||||
}
|
||||
.mohu_border_modle {
|
||||
background: #fff;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
color: #555;
|
||||
font-size: 28rpx;
|
||||
height: 88rpx;
|
||||
line-height: 88rpx;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
text-align: left;
|
||||
width: 100%;
|
||||
}
|
||||
.mohu_border_modle_first {
|
||||
color: #555;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
.btn_active {
|
||||
background: #3d61f0;
|
||||
border-color: #3d61f0;
|
||||
color: #fff;
|
||||
}
|
||||
.close_img {
|
||||
display: block;
|
||||
height: 36rpx;
|
||||
position: fixed;
|
||||
right: 180rpx;
|
||||
top: 18rpx;
|
||||
width: 36rpx;
|
||||
}
|
Reference in New Issue
Block a user