更换版本
This commit is contained in:
177
packageA/pages/caresgznew/selectCar/selectCar.js
Normal file
177
packageA/pages/caresgznew/selectCar/selectCar.js
Normal file
@@ -0,0 +1,177 @@
|
||||
var t;
|
||||
(t = getApp()),
|
||||
Page({
|
||||
data: {
|
||||
showLetter: "",
|
||||
winHeight: 0,
|
||||
tHeight: 0,
|
||||
bHeight: 0,
|
||||
startPageY: 0,
|
||||
carList: [],
|
||||
isShowLetter: !1,
|
||||
scrollTop: 0,
|
||||
three_none: "none",
|
||||
two_none: "none",
|
||||
hasback: "none",
|
||||
car_series: [],
|
||||
car_ser: null,
|
||||
searchLetter: [
|
||||
"*",
|
||||
"A",
|
||||
"B",
|
||||
"C",
|
||||
"D",
|
||||
"E",
|
||||
"F",
|
||||
"G",
|
||||
"H",
|
||||
"J",
|
||||
"K",
|
||||
"L",
|
||||
"M",
|
||||
"N",
|
||||
"P",
|
||||
"Q",
|
||||
"R",
|
||||
"S",
|
||||
"T",
|
||||
"W",
|
||||
"X",
|
||||
"Y",
|
||||
"Z",
|
||||
],
|
||||
car_vend_ser: [],
|
||||
},
|
||||
onLoad: function () {
|
||||
var e = this;
|
||||
wx.showLoading({ title: "请求中" }),
|
||||
t.getdata({ type: 1, pid: 0 }, "carallnew").then((t) => {
|
||||
var a = t.data;
|
||||
console.log("回调数据汽车:", t), e.crCarList(a);
|
||||
});
|
||||
for (
|
||||
var a = e.data.searchLetter,
|
||||
n = wx.getSystemInfoSync().windowHeight,
|
||||
o = n / a.length,
|
||||
r = [],
|
||||
s = 0;
|
||||
s < a.length;
|
||||
s++
|
||||
) {
|
||||
var i = {};
|
||||
(i.name = a[s]),
|
||||
(i.tHeight = s * o),
|
||||
(i.bHeight = (s + 1) * o),
|
||||
r.push(i);
|
||||
}
|
||||
e.setData({ winHeight: n, itemH: o, searchLetter: r });
|
||||
},
|
||||
searchStart: function (t) {
|
||||
var e = t.currentTarget.dataset.letter,
|
||||
a = t.touches[0].pageY;
|
||||
this.setScrollTop(this, e),
|
||||
this.nowLetter(a, this),
|
||||
this.setData({ showLetter: e, startPageY: a, isShowLetter: !0 });
|
||||
},
|
||||
searchMove: function (t) {
|
||||
var e = t.touches[0].pageY,
|
||||
a = this.data.startPageY,
|
||||
n = this.data.tHeight,
|
||||
o = this.data.bHeight;
|
||||
console.log(e),
|
||||
a - e > 0
|
||||
? e < n && this.nowLetter(e, this)
|
||||
: e > o && this.nowLetter(e, this);
|
||||
},
|
||||
searchEnd: function (t) {
|
||||
var e = this;
|
||||
setTimeout(function () {
|
||||
e.setData({ isShowLetter: !1 });
|
||||
}, 1e3);
|
||||
},
|
||||
nowLetter: function (t, e) {
|
||||
for (
|
||||
var a = this.data.searchLetter, n = 0, o = 0, r = "", s = 0;
|
||||
s < a.length;
|
||||
s++
|
||||
)
|
||||
if (a[s].tHeight <= t && t <= a[s].bHeight) {
|
||||
(n = a[s].bHeight), (o = a[s].tHeight), (r = a[s].name);
|
||||
break;
|
||||
}
|
||||
this.setScrollTop(e, r),
|
||||
e.setData({ bHeight: n, tHeight: o, showLetter: r, startPageY: t });
|
||||
},
|
||||
setScrollTop: function (t, e) {
|
||||
for (
|
||||
var a = 0, n = t.data.carList, o = 0, r = 0, s = 0;
|
||||
s < n.length;
|
||||
s++
|
||||
) {
|
||||
if (e == n[s].shou_zm) {
|
||||
a = 30 * r + 41 * o;
|
||||
break;
|
||||
}
|
||||
console.log("数字", s),
|
||||
console.log(n[s]),
|
||||
r++,
|
||||
(o += n[s].carInfo.length);
|
||||
}
|
||||
t.setData({ scrollTop: a });
|
||||
},
|
||||
btn_pinpai: function (e) {
|
||||
var a = this,
|
||||
n = { type: 2, pid: e.currentTarget.dataset.brand };
|
||||
t.getdata(n, "carallnew").then((t) => {
|
||||
var e = t.data;
|
||||
console.log("回调数据汽车:", e),
|
||||
a.setData({
|
||||
three_none: "none",
|
||||
two_none: "block",
|
||||
hasback: "block",
|
||||
car_series: e,
|
||||
});
|
||||
});
|
||||
},
|
||||
btn_name: function (e) {
|
||||
var a = this,
|
||||
n = { type: 3, pid: e.currentTarget.dataset.familyid };
|
||||
t.getdata(n, "carallnew").then((t) => {
|
||||
var e = t.data;
|
||||
console.log("回调数据汽车xiang:", e),
|
||||
a.setData({ three_none: "block", hasback: "block", car_vend_ser: e });
|
||||
});
|
||||
},
|
||||
btn_sel_name: function (t) {
|
||||
var e = t.currentTarget.dataset.item;
|
||||
console.log(e),
|
||||
wx.setStorageSync("carvehicle", e),
|
||||
wx.navigateBack({ delta: 1 });
|
||||
},
|
||||
crCarList: function (t) {
|
||||
for (var e = this.data.searchLetter, a = [], n = 1; n < e.length; n++) {
|
||||
var o = e[n].name,
|
||||
r = [],
|
||||
s = {};
|
||||
s.shou_zm = o;
|
||||
for (var i = 0; i < t.length; i++) o == t[i].sort && r.push(t[i]);
|
||||
(s.carInfo = r), a.push(s);
|
||||
}
|
||||
this.setData({ carList: a }), wx.hideLoading();
|
||||
},
|
||||
crFamilyList: function (t) {
|
||||
var e = {};
|
||||
for (var a in (console.log(t), t)) {
|
||||
var n = t[a].factory;
|
||||
null == e[n] ? (e[n] = [t[a]]) : e[n].push(t[a]);
|
||||
}
|
||||
console.log(e), this.setData({ car_series: e });
|
||||
},
|
||||
goback: function () {
|
||||
"block" == this.data.three_none
|
||||
? this.setData({ three_none: "none" })
|
||||
: "block" == this.data.two_none
|
||||
? this.setData({ two_none: "none", hasback: "none" })
|
||||
: this.setData({ hasback: "none" });
|
||||
},
|
||||
});
|
||||
3
packageA/pages/caresgznew/selectCar/selectCar.json
Normal file
3
packageA/pages/caresgznew/selectCar/selectCar.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
||||
25
packageA/pages/caresgznew/selectCar/selectCar.wxml
Normal file
25
packageA/pages/caresgznew/selectCar/selectCar.wxml
Normal file
@@ -0,0 +1,25 @@
|
||||
<view>
|
||||
<view class="searchLetter touchClass">
|
||||
<view catchtouchend="searchEnd" catchtouchmove="searchMove" catchtouchstart="searchStart" data-letter="{{item.name}}" style="height:{{itemH}}px" wx:for="{{searchLetter}}" wx:key="index"> {{item.name}} </view>
|
||||
</view>
|
||||
<view class="showSlectedLetter" wx:if="{{isShowLetter}}"> {{showLetter}} </view>
|
||||
<scroll-view scrollTop="{{scrollTop}}" scrollY="true" style="height:{{winHeight}}px">
|
||||
<view class="selection" wx:if="{{carList.length>0}}" wx:for="{{carList}}" wx:key="index">
|
||||
<view class="item_letter">{{item.shou_zm}}</view>
|
||||
<view bindtap="btn_pinpai" class="item_city" data-brand="{{ct.brand_id}}" wx:for="{{item.carInfo}}" wx:for-item="ct" wx:key="index"> {{ct.name}} </view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<scroll-view class="scoll_car_service" scrollY="true" style="height:{{car_type_hight}};display:{{two_none}}">
|
||||
<view class="selection" wx:for="{{car_series}}" wx:key="index">
|
||||
<label bindtap="btn_name" class="tab2" data-brandid="{{item.brand_id}}" data-familyid="{{item.series_id}}"> {{item.series_name}} </label>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<scroll-view class="scoll_vender_service" scrollY="true" style="height:{{car_type_hight}};display:{{three_none}}">
|
||||
<view wx:for="{{car_vend_ser}}" wx:key="index">
|
||||
<text bindtap="btn_sel_name" class="tab3" data-item="{{item}}">{{item.fullname}}</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
<view bindtap="goback" class="goback" style="display:{{hasback}}">
|
||||
<text class="arrow"></text>
|
||||
</view>
|
||||
125
packageA/pages/caresgznew/selectCar/selectCar.wxss
Normal file
125
packageA/pages/caresgznew/selectCar/selectCar.wxss
Normal file
@@ -0,0 +1,125 @@
|
||||
.searchLetter {
|
||||
color: #666;
|
||||
display: -webkit-flex;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
justify-content: center;
|
||||
position: fixed;
|
||||
right: 0;
|
||||
text-align: center;
|
||||
width: 40px;
|
||||
z-index: 1;
|
||||
}
|
||||
.tab2 {
|
||||
height: 70rpx;
|
||||
line-height: 70rpx;
|
||||
width: 560rpx;
|
||||
}
|
||||
.tab2,
|
||||
.tab3 {
|
||||
border-bottom: 1px solid #eaeaea;
|
||||
color: #2a2a2a;
|
||||
font-size: 30rpx;
|
||||
padding-left: 30rpx;
|
||||
}
|
||||
.tab3 {
|
||||
word-wrap: break-word;
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
padding-bottom: 20rpx;
|
||||
padding-top: 20rpx;
|
||||
}
|
||||
.scoll_car_service {
|
||||
left: 25%;
|
||||
width: 75%;
|
||||
z-index: 5;
|
||||
}
|
||||
.scoll_car_service,
|
||||
.scoll_vender_service {
|
||||
background-color: #f5f5f5;
|
||||
box-shadow: 0 0 3px 3px #999;
|
||||
display: -webkit-flex;
|
||||
display: flex;
|
||||
height: 100%;
|
||||
position: fixed;
|
||||
top: 1px;
|
||||
}
|
||||
.scoll_vender_service {
|
||||
left: 50%;
|
||||
width: 50%;
|
||||
z-index: 10;
|
||||
}
|
||||
.searchLetter view {
|
||||
height: 70rpx;
|
||||
}
|
||||
.touchClass {
|
||||
color: #a56e0a;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
.showSlectedLetter {
|
||||
align-items: center;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
border-radius: 10px;
|
||||
color: #fff;
|
||||
font-size: 26px;
|
||||
height: 100px;
|
||||
justify-content: center;
|
||||
left: 50%;
|
||||
margin: -50px;
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
width: 100px;
|
||||
z-index: 1;
|
||||
}
|
||||
.selection,
|
||||
.showSlectedLetter {
|
||||
display: -webkit-flex;
|
||||
display: flex;
|
||||
}
|
||||
.selection {
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
}
|
||||
.item_letter {
|
||||
align-items: center;
|
||||
background-color: #f8f8f8;
|
||||
color: #896a0d;
|
||||
display: -webkit-flex;
|
||||
display: flex;
|
||||
font-size: 26rpx;
|
||||
height: 30px;
|
||||
padding-left: 10px;
|
||||
}
|
||||
.item_city {
|
||||
background-color: #f5f5f5;
|
||||
border-bottom: 1px solid #eaeaea;
|
||||
color: #2a2a2a;
|
||||
font-size: 30rpx;
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
padding-left: 10px;
|
||||
}
|
||||
.car_img {
|
||||
height: 80rpx;
|
||||
width: 100rpx;
|
||||
}
|
||||
.goback {
|
||||
border: 2rpx solid #aaa;
|
||||
border-radius: 50%;
|
||||
bottom: 60rpx;
|
||||
height: 80rpx;
|
||||
position: fixed;
|
||||
right: 40rpx;
|
||||
width: 80rpx;
|
||||
z-index: 99;
|
||||
}
|
||||
.arrow {
|
||||
border-bottom: 3px solid #999;
|
||||
border-left: 3px solid #999;
|
||||
display: block;
|
||||
height: 14px;
|
||||
margin: 24rpx 30rpx;
|
||||
transform: rotate(45deg);
|
||||
width: 14px;
|
||||
}
|
||||
Reference in New Issue
Block a user