소스 검색

添加查询页面

liguorui 6 년 전
부모
커밋
0bebef3842

+ 3 - 1
app.json

@@ -1,7 +1,9 @@
 {
   "pages":[
     "pages/index/index",
-    "pages/logs/logs"
+    "pages/logs/logs",
+    "pages/search/search",
+    "pages/searchresult/searchresult"
   ],
   "window":{
     "backgroundTextStyle":"light",

+ 15 - 0
data/car.js

@@ -0,0 +1,15 @@
+export const retCartData = function(list){
+  list.forEach(function(item){
+    if (item.license_time){
+      var date = new Date(item.license_time.replace(/-/g,"/"));
+      item.licensetime = `${date.getFullYear()}年${date.getMonth()+1}月`
+    }
+    if (item.sale_price){
+      item.saleprice = (item.sale_price / 10000).toFixed(2)
+    }
+    if (item.guide_price){
+      item.guideprice = (item.guide_price / 10000).toFixed(2)
+    }
+  })
+  return list;
+}

BIN
img/search.png


+ 8 - 0
module/search/search.wxml

@@ -0,0 +1,8 @@
+
+  <view class="search">
+    <navigator 
+      style='background-image:url(../../img/search.png)'
+      class="search_input" 
+      url="../../pages/search/search"
+    >搜索</navigator>
+  </view>

+ 20 - 0
module/search/search.wxss

@@ -0,0 +1,20 @@
+/***********search************/
+.search{
+  display: block;
+  height: 78rpx;
+  background: #fede18;
+}
+.search_input{
+  height: 52rpx;
+  width:674rpx;
+  margin: 0px auto;
+  background: white;
+  border-radius: 10rpx;
+  text-align: center;
+  line-height: 52rpx;
+  color: rgba(183, 183, 183, 1);
+  font-size: 24rpx;
+  background-position: 270rpx 14rpx;
+  background-size:30rpx;
+  background-repeat:no-repeat;
+}

+ 2 - 2
pages/index/cardetail.wxml

@@ -4,10 +4,10 @@
     <view class="car_info">
       <view class="car_t">{{car.title}}</view>
       <view class="car_time">
-        {{car.license_time}}年上牌|{{car.mileage}}万公里
+        {{car.licensetime}}年上牌|{{car.mileage}}万公里
       </view>
       <view class="car_p">
-        售价:{{car.sale_price}}
+        售价:{{car.saleprice}}
       </view>
       <view class="car_characteristic">
         <view class="car_characteristic_i">11111</view>

+ 5 - 2
pages/index/index.js

@@ -2,6 +2,7 @@
 //获取应用实例
 import {get} from "../../common/request.js"
 import pathmap from "../../common/pathmap"
+import { retCartData} from "../../data/car"
 const app = getApp()
 
 Page({
@@ -51,8 +52,9 @@ Page({
       offset: 0,
       limit: 9
     }, function (json) {
+      var list = retCartData(json.data.list)
       _self.setData({
-        recommended: json.data.list
+        recommended: list
       })
     })
   },
@@ -62,8 +64,9 @@ Page({
       offset: 0,
       limit: 10
     }, function (json) {
+      var list = retCartData(json.data.list)
       _self.setData({
-        like: json.data.list
+        like: list
       })
     })
   },

+ 1 - 0
pages/index/index.wxml

@@ -4,6 +4,7 @@
 <import src="cardetail.wxml"/>
 <import src="likecardetail.wxml"/>
 <view class="conent">
+  <include src="../../module/search/search.wxml"/>
   <template is="banner" data="{{banner:banner}}"/>
   <view class="nav_list">
     <view class="nav_item">

+ 20 - 1
pages/index/index.wxss

@@ -1,4 +1,23 @@
-
+/***********search************/
+.search{
+  display: block;
+  height: 78rpx;
+  background: #fede18;
+}
+.search_input{
+  height: 52rpx;
+  width:674rpx;
+  margin: 0px auto;
+  background: white;
+  border-radius: 10rpx;
+  text-align: center;
+  line-height: 52rpx;
+  color: rgba(183, 183, 183, 1);
+  font-size: 24rpx;
+  background-position: 270rpx 14rpx;
+  background-size:30rpx;
+  background-repeat:no-repeat;
+}
 /*******topbanner*********/
 
 .conent{

+ 3 - 3
pages/index/likecardetail.wxml

@@ -4,14 +4,14 @@
     <view class="car_info">
       <view class="car_t">{{car.title}}</view>
       <view class="car_time">
-        {{car.license_time}}年上牌|{{car.mileage}}万公里
+        {{car.licensetime}}年上牌|{{car.mileage}}万公里
         <view class="car_store">{{car.store_name}}</view>
       </view>
       <view class="car_p">
-        {{car.sale_price}}
+        {{car.saleprice}}
       </view>
       <view class="car_guide_p">
-        新手指导价:<view class="car_guidep">{{car.guide_price}}</view>
+        新手指导价:<view class="car_guidep">{{car.guideprice}}</view>
       </view>
     </view>
   </view>

+ 70 - 0
pages/search/search.js

@@ -0,0 +1,70 @@
+// pages/search/search.js
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+  
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+  
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+  
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+  
+  },
+  linkToSearch:function(e){
+    var word = e.target.dataset.val;
+    wx.navigateTo({url:`../searchresult/searchresult?value=${word}`});
+  }
+})

+ 1 - 0
pages/search/search.json

@@ -0,0 +1 @@
+{}

+ 46 - 0
pages/search/search.wxml

@@ -0,0 +1,46 @@
+<!--pages/search/search.wxml-->
+<view class="content">
+  <view class="search">
+    <view 
+      class="search_input_b"
+      style='background-image:url(../../img/search.png)'  
+    >
+      <input 
+        class="search_input"  
+        placeholder-class="search_input_holder"
+        placeholder="搜索"
+      />
+    </view>
+    <navigator
+      class='cancle_search'
+      open-type='navigateBack'
+    >
+      取消
+    </navigator>
+  </view>
+  <view class="hot_search">
+    <view class="hot_search_t">
+      热门搜索
+    </view>
+    <view class="hot_search_w" bindtap="linkToSearch">
+      <view  class="hot_search_i" data-val = "玛莎拉蒂">
+        玛莎拉蒂
+      </view>
+      <view  class="hot_search_i" data-val = "劳斯莱斯">
+        劳斯莱斯
+      </view>
+      <view  class="hot_search_i" data-val = "宾利">
+        宾利
+      </view>
+      <view  class="hot_search_i" data-val = "法拉利">
+        法拉利
+      </view>
+      <view  class="hot_search_i" data-val = "兰博基尼">
+        兰博基尼
+      </view>
+      <view  class="hot_search_i" data-val = "布加迪">
+        布加迪
+      </view>
+    </view>
+  </view>
+</view>

+ 70 - 0
pages/search/search.wxss

@@ -0,0 +1,70 @@
+/* pages/search/search.wxss */
+.content{
+
+}
+.search{
+  display: block;
+  height: 78rpx;
+  background: #fede18;
+}
+.search_input_b{
+  display: inline-block;
+  height: 52rpx;
+  width:600rpx;
+  margin-left:38rpx;
+  background: white;
+  border-radius: 10rpx;
+  line-height: 52rpx;
+  font-size: 24rpx;
+  background-position: 20rpx 14rpx;
+  background-size:30rpx;
+  background-repeat:no-repeat;
+}
+.search_input{
+  margin-left:70rpx;
+}
+.search_input_holder{
+  color: rgba(183, 183, 183, 1);
+}
+.cancle_search{
+  float:right;
+  margin-right: 26rpx;
+  height: 52rpx;
+  line-height: 52rpx;
+  color: rgba(56, 55, 53, 1);
+  font-size: 26rpx;
+  font-family: NotoSansHans-DemiLight;
+}
+
+/*************hotsearch**************/
+.hot_search{
+  margin-top: 30px;
+}
+.hot_search_t{
+  text-indent: 38rpx;
+  height: 33rpx;
+  line-height: 33rpx;
+  color: rgba(56, 55, 53, 1);
+  font-size: 22rpx;
+}
+.hot_search_w{
+  width:702rpx;
+  margin-left:18rpx;
+  display: flex;
+  flex-wrap:wrap;
+}
+.hot_search_i{
+  display: block;
+  width:142rpx;
+  height: 52rpx;
+  margin-top:30rpx;
+  margin-left:28rpx;
+  border-radius: 6rpx;
+  border: 1px solid rgba(235, 235, 235, 1);
+  line-height: 52rpx;
+  color: rgba(56, 55, 53, 1);
+  font-size: 24rpx;
+  text-align: center;
+  font-family: NotoSansHans-Regular;
+
+}

+ 66 - 0
pages/searchresult/searchresult.js

@@ -0,0 +1,66 @@
+// pages/searchresult/searchresult.js
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+  
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+  
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+  
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+  
+  }
+})

+ 1 - 0
pages/searchresult/searchresult.json

@@ -0,0 +1 @@
+{}

+ 2 - 0
pages/searchresult/searchresult.wxml

@@ -0,0 +1,2 @@
+<!--pages/searchresult/searchresult.wxml-->
+<text>pages/searchresult/searchresult.wxml</text>

+ 1 - 0
pages/searchresult/searchresult.wxss

@@ -0,0 +1 @@
+/* pages/searchresult/searchresult.wxss */