更换版本
This commit is contained in:
185
packageA/pages/caresgz/selectCar/selectCar.js
Normal file
185
packageA/pages/caresgz/selectCar/selectCar.js
Normal file
@@ -0,0 +1,185 @@
|
||||
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("", "carall").then((t) => {
|
||||
var a = t.data;
|
||||
console.log("回调数据汽车:", a),
|
||||
(a = JSON.parse(a)),
|
||||
e.crCarList(a.retdata);
|
||||
});
|
||||
for (
|
||||
var a = e.data.searchLetter,
|
||||
r = wx.getSystemInfoSync().windowHeight,
|
||||
n = r / a.length,
|
||||
o = [],
|
||||
s = 0;
|
||||
s < a.length;
|
||||
s++
|
||||
) {
|
||||
var i = {};
|
||||
(i.name = a[s]),
|
||||
(i.tHeight = s * n),
|
||||
(i.bHeight = (s + 1) * n),
|
||||
o.push(i);
|
||||
}
|
||||
e.setData({ winHeight: r, itemH: n, searchLetter: o });
|
||||
},
|
||||
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,
|
||||
r = this.data.tHeight,
|
||||
n = this.data.bHeight;
|
||||
console.log(e),
|
||||
a - e > 0
|
||||
? e < r && this.nowLetter(e, this)
|
||||
: e > n && 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, r = 0, n = 0, o = "", s = 0;
|
||||
s < a.length;
|
||||
s++
|
||||
)
|
||||
if (a[s].tHeight <= t && t <= a[s].bHeight) {
|
||||
(r = a[s].bHeight), (n = a[s].tHeight), (o = a[s].name);
|
||||
break;
|
||||
}
|
||||
this.setScrollTop(e, o),
|
||||
e.setData({ bHeight: r, tHeight: n, showLetter: o, startPageY: t });
|
||||
},
|
||||
setScrollTop: function (t, e) {
|
||||
for (
|
||||
var a = 0, r = t.data.carList, n = 0, o = 0, s = 0;
|
||||
s < r.length;
|
||||
s++
|
||||
) {
|
||||
if (e == r[s].shou_zm) {
|
||||
a = 30 * o + 41 * n;
|
||||
break;
|
||||
}
|
||||
console.log("数字", s),
|
||||
console.log(r[s]),
|
||||
o++,
|
||||
(n += r[s].carInfo.length);
|
||||
}
|
||||
t.setData({ scrollTop: a });
|
||||
},
|
||||
btn_pinpai: function (e) {
|
||||
var a = this,
|
||||
r = { brandId: e.currentTarget.dataset.brand };
|
||||
t.getdata(r, "carbrandId").then((t) => {
|
||||
var e = t.data;
|
||||
console.log("回调数据汽车:", e),
|
||||
(e = JSON.parse(e)),
|
||||
a.setData({
|
||||
three_none: "none",
|
||||
two_none: "block",
|
||||
hasback: "block",
|
||||
car_series: e.retdata,
|
||||
});
|
||||
});
|
||||
},
|
||||
btn_name: function (e) {
|
||||
var a = this,
|
||||
r = { familyid: e.currentTarget.dataset.familyid };
|
||||
t.getdata(r, "caridcx").then((t) => {
|
||||
var e = t.data;
|
||||
console.log("回调数据汽车xiang:", e),
|
||||
(e = JSON.parse(e)),
|
||||
a.setData({
|
||||
three_none: "block",
|
||||
hasback: "block",
|
||||
car_vend_ser: e.retdata,
|
||||
});
|
||||
});
|
||||
},
|
||||
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 = [], r = 1; r < e.length; r++) {
|
||||
var n = e[r].name,
|
||||
o = [],
|
||||
s = {};
|
||||
s.shou_zm = n;
|
||||
for (var i = 0; i < t.length; i++) n == t[i].car_char && o.push(t[i]);
|
||||
(s.carInfo = o), a.push(s);
|
||||
}
|
||||
this.setData({ carList: a }), wx.hideLoading();
|
||||
},
|
||||
crFamilyList: function (t) {
|
||||
var e = {};
|
||||
for (var a in (console.log(t), t)) {
|
||||
var r = t[a].factory;
|
||||
null == e[r] ? (e[r] = [t[a]]) : e[r].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/caresgz/selectCar/selectCar.json
Normal file
3
packageA/pages/caresgz/selectCar/selectCar.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
||||
25
packageA/pages/caresgz/selectCar/selectCar.wxml
Normal file
25
packageA/pages/caresgz/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.car_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.serials_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/caresgz/selectCar/selectCar.wxss
Normal file
125
packageA/pages/caresgz/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