chache/pages/index/index.js
2024-01-22 18:48:00 +08:00

502 lines
14 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var a, t;
(a = require("../../utils/data.js")),
(t = getApp()),
Page({
data: {
ioszf: 1,
ioskg: 1,
phone: t.globalData.myDevice.platform,
isShow: !1,
parent_uid: 0,
is_ok: !1,
banner: [],
indicatorDots: !0,
autoplay: !0,
interval: 5e3,
duration: 1e3,
textJson: [],
textIndex: 0,
show_new: !0,
brand_show: !1,
sort_show: !1,
keyword: "汽车用品",
appscene: 0,
currentData: 0,
active_index: 0,
page: 1,
index: 0,
fenlei_id: 0,
pinpai_id: 0,
nianxian_id: 0,
km_id: 0,
sort_id: 0,
car_year: "",
car_brand: "",
car_km: "",
car_class: "",
search_arr: [],
market: [],
brand: [],
check_name: "",
carList: [],
sort_show: !1,
leftid: 1,
show_new: !0,
brand_show: !1,
recom: 0,
home_arr: [],
brandname: "",
selectbrand: "",
brand_status: 0,
plate_type: 1,
scanReachBottom: !1,
unitid: 123,
latitude: 0,
longitude: 0,
region: ["", "", ""],
showPrivacy: t.globalData.showPrivacy,
banner: a.banner,
dhlist: a.index,
},
dcbg: function (a) {
wx.navigateTo({ url: "/packageA/pages/dcbg/incxjl" });
},
gscx: function (a) {
wx.navigateTo({ url: "/packageA/pages/gscx/incxjl" });
},
gslxcx: function (a) {
wx.navigateTo({ url: "/packageA/pages/gslxcx/incxjl" });
},
wncx: function (a) {
wx.navigateTo({ url: "/packageA/pages/wannen/incxjl?id=1307" });
},
syxcx: function (a) {
wx.navigateTo({ url: "/packageA/pages/carsyx/incxjl" });
},
onLoad: function (a) {
console.log("自动uid", wx.getStorageSync("uid")),
wx.getStorageSync("uid") ||
getApp()
.wxlogin()
.then((a) => {
console.log("回调数据:", a), this.setData({ showPrivacy: a });
}),
this.look();
var e = this;
a &&
a.scene &&
(e.setData({ parent_uid: a.scene }),
t.util.getUserInfo(function (a) {
wx.setStorageSync("uid", a.memberInfo.uid),
a.memberInfo ? e.firstin(a.memberInfo) : e.setData({ isShow: !0 });
})),
this._list(1),
wx.getPrivacySetting({
success: (a) => {
console.log(a),
a.needAuthorization
? this.setData({ showPrivacy: !0 })
: this.setData({ showPrivacy: !1 });
},
fail: () => {},
complete: () => {},
});
},
handleAgreePrivacyAuthorization() {
this.setData({ showPrivacy: !1 }),
wx.getStorageSync("uid") || getApp().wxlogin(),
this.look(),
wx.showToast({
title: "感谢您的同意,请开始使用~",
icon: "none",
duration: 2e3,
});
},
handleOpenPrivacyContract() {
wx.openPrivacyContract({
success: () => {},
fail: () => {},
complete: () => {},
});
},
info_notice: function () {
wx.navigateTo({ url: "../dting/index" });
},
changeurl: function (a) {
let t = {};
return (
a.replace(/([^?&]+)=([^?&]+)/g, function (a, e, i) {
return (t[e] = decodeURIComponent(i)), i + "=" + e;
}),
t
);
},
bindRegionChange: function (a) {
this.setData({ region: a.detail.value }), this._list(2);
},
hideDialog: function () {
this.setData({ isShow: !this.data.isShow });
},
updateUserInfo: function (a) {
var e = this;
t.util.getUserInfo(function (a) {
e.hideDialog(), e.firstin(a.memberInfo);
}, a.detail);
},
firstin: function (a) {
t.util.request({
url: "entry/wxapp/Api",
data: {
m: "monai_market",
r: "me.binding",
uid: a.uid,
head_image: a.avatar,
nickname: a.nickname,
parent_uid: this.data.parent_uid,
},
success: function (a) {},
});
},
_notice: function () {
var a = this;
t.util.request({
url: "entry/wxapp/Api",
data: { m: "monai_market", r: "home.index.home1" },
cachetime: "0",
success: function (t) {
console.log(t),
t.data.data.info_name.name &&
wx.setNavigationBarTitle({
title: t.data.data.info_name.name + "",
}),
1 == t.data.data.info_name.recom &&
2 == t.data.data.info_name.plate_type &&
a.setData({ plate_type: 2 }),
a.setData({
ioszf: t.data.data.info_name.ioszf,
banner: t.data.data.banner,
market: t.data.data.market,
brand: t.data.data.brand,
textJson: t.data.data.notice,
info_name: t.data.data.info_name.name,
recom: t.data.data.info_name.recom,
info: t.data.data.info_name,
dhlist: t.data.data.dhdata,
});
},
});
},
ok: function () {
this.setData({ is_ok: !1 });
},
banner: function (a) {
var e = t.getAttr(a, "id"),
i = t.getAttr(a, "type");
console.log(i),
4 == i
? wx.navigateTo({ url: "/pages/mine/sale/index" })
: 5 == i
? wx.navigateTo({ url: "/pages/enter/enter" })
: 6 == i ||
(0 != e &&
wx.navigateTo({
url: "/pages/home/carMessage/carMessage?id=" + e,
}));
},
market_class: function (a) {
var e = t.getAttr(a, "active_index"),
i = !1;
this.data.active_index == e && ((e = 0), (i = !0)),
this.setData({
car_type: this.data.market,
brand_show: !1,
sort_show: !1,
active_index: e,
show_new: i,
});
},
market_brand: function (a) {
wx.navigateTo({ url: "../selectscards/index" });
},
navtonew: function (a) {
console.log(a);
var t = a.currentTarget.dataset.url,
e = a.currentTarget.dataset.appid,
i = a.currentTarget.dataset.tzpage,
n = a.currentTarget.dataset.nbpage,
r = a.currentTarget.dataset.id;
"ios" != this.data.phone || 0 != this.data.ioszf
? n
? wx.navigateTo({ url: n + "?id=" + r })
: e
? wx.navigateToMiniProgram({
appId: e,
path: i,
extarData: { open: "happy" },
envVersion: "release",
success(a) {},
})
: t && wx.navigateTo({ url: "/pages/website/website?url=" + t })
: wx.showModal({
title: "温馨提示",
content: "由于相关规范iOS功能暂不可用",
success: function (a) {
a.confirm
? console.log("点击确认回调")
: console.log("点击取消回调");
},
});
},
carList: function (a) {
var e = t.getAttr(a, "name"),
i = t.getAttr(a, "id");
if (1 == this.data.active_index)
(n = {
fenlei_id: i,
car_class: e,
active_index: 1,
mark: (o = "active_index1"),
check_name: e,
}),
(c = this.data.search_arr.filter(function (a) {
return a.mark != o;
})).push(n),
this.setData({
car_class: e,
fenlei_id: i,
check_name: e,
search_arr: c,
leftid: 1,
show_new: !0,
});
else if (2 == this.data.active_index) {
e = t.getAttr(a, "name");
var n = {
pinpai_id: (i = t.getAttr(a, "id")),
car_brand: e,
active_index: 2,
mark: (o = "active_index2"),
check_name: e,
};
(c = this.data.search_arr.filter(function (a) {
return a.mark != o;
})).push(n),
this.setData({
is_ok: !1,
car_brand: e,
pinpai_id: i,
search_arr: c,
leftid: 1,
show_new: !0,
brand_show: !1,
});
} else if (3 == this.data.active_index) {
var r = t.getAttr(a, "year");
(n = {
nianxian_id: (i = t.getAttr(a, "index")),
car_year: r,
active_index: 3,
mark: (o = "active_index3"),
check_name: r,
}),
(c = this.data.search_arr.filter(function (a) {
return a.mark != o;
})).push(n),
this.setData({
is_ok: !1,
car_year: r,
nianxian_id: 1 + parseInt(i),
search_arr: c,
leftid: 1,
show_new: !0,
});
} else if (4 == this.data.active_index) {
var s = t.getAttr(a, "km"),
o = "active_index4",
c =
((n = {
km_id: (i = t.getAttr(a, "index")),
car_km: s,
active_index: 4,
mark: o,
check_name: s,
}),
this.data.search_arr.filter(function (a) {
return a.mark != o;
}));
c.push(n),
this.setData({
is_ok: !1,
car_km: s,
km_id: 1 + parseInt(i),
search_arr: c,
leftid: 1,
show_new: !0,
});
}
this._list(1);
},
_list: function (a) {
var e = this;
1 == a
? this.setData({ carList: [] })
: 2 == a && this.setData({ carList: [], leftid: 1, show_new: !0 }),
this.setData({ active_index: 0 }),
t.util.request({
url: "entry/wxapp/Api",
data: {
m: "monai_market",
r: "home.index.carList",
fenlei_id: this.data.fenlei_id,
pinpai_id: this.data.pinpai_id,
nianxian_id: this.data.nianxian_id,
km_id: parseInt(this.data.km_id),
sort_id: this.data.sort_id,
leftid: this.data.leftid++,
latitude: this.data.latitude,
longitude: this.data.longitude,
province: this.data.region[0],
city: this.data.region[1],
district: this.data.region[2],
},
cachetime: "0",
success: function (a) {
var t;
a.data.data.length > 0
? ((t = e.data.carList).push.apply(
t,
(function (a) {
if (Array.isArray(a)) {
for (var t = 0, e = Array(a.length); t < a.length; t++)
e[t] = a[t];
return e;
}
return Array.from(a);
})(a.data.data)
),
e.setData({ scanReachBottom: !1 }),
e.setData({ is_ok: !1, carList: e.data.carList }))
: (e.setData({ scanReachBottom: !0 }), (e.data.show_new = !1));
},
});
},
previewImage: function (a) {
var e = t.getAttr(a, "src"),
i = t.getAttr(a, "index"),
n = [],
r = !0,
s = !1,
o = void 0;
try {
for (
var c, d = this.data.carList[i].image[Symbol.iterator]();
!(r = (c = d.next()).done);
r = !0
) {
var h = c.value;
n.push(h.img_patch);
}
} catch (a) {
(s = !0), (o = a);
} finally {
try {
!r && d.return && d.return();
} finally {
if (s) throw o;
}
}
wx.previewImage({ current: e, urls: n });
},
detile: function (a) {
var e = t.getAttr(a, "id");
wx.navigateTo({ url: "/pages/home/carMessage/carMessage?id=" + e });
},
onShareAppMessage: function (a) {
return {
title: this.data.info_name + "",
path: "/pages/index/index",
success: function (a) {},
fail: function (a) {},
};
},
onShow: function () {
this.look();
},
look: function () {
var a = this;
if (
(this._notice(),
"" != a.data.brandid &&
"" != a.data.brandname &&
1 == a.data.brand_status)
) {
var t = a.data.brandname,
e = a.data.brandid,
i = "active_index2",
n = {
pinpai_id: e,
car_brand: t,
active_index: 2,
mark: i,
check_name: t,
},
r = this.data.search_arr.filter(function (a) {
return a.mark != i;
});
r.push(n),
this.setData({
is_ok: !1,
car_brand: t,
pinpai_id: e,
search_arr: r,
leftid: 1,
show_new: !0,
brand_show: !1,
brandid: 0,
brandname: "",
}),
this._list(1);
}
},
bindKeyInput: function (a) {
var t = a.detail.value;
this.setData({ keyword: t, page: 1 });
},
checkCurrent: function (a) {
if (
(console.log(a),
console.log(a.currentTarget.dataset.current),
this.data.currentData === a.currentTarget.dataset.current)
)
return !1;
this.setData({
currentData: a.currentTarget.dataset.current,
keyword: a.currentTarget.dataset.title,
page: 1,
});
},
active_nav: function (a) {
var e = t.getAttr(a, "active_index");
this.data.active_index != e
? this.setData({
sort_show: !0,
show_new: !1,
active_index: e,
brand_show: !1,
})
: this.setData({ sort_show: !1, active_index: 0, show_new: !1 });
},
sort_car: function (a) {
console.log(a);
var t = a.currentTarget.dataset.index,
e = this.data.sortArrb[t];
this.setData({
page: 1,
cindex: t,
sort_show: !1,
is_ok: !0,
sort_id: e,
});
},
});