500 lines
15 KiB
JavaScript
500 lines
15 KiB
JavaScript
var t;
|
|
(t = getApp()).util.url("entry/wxapp/Api", {
|
|
m: "monai_sharing",
|
|
uid: wx.getStorageSync("uid"),
|
|
r: "Upimg",
|
|
}),
|
|
Page({
|
|
data: {
|
|
upcarindex: 0,
|
|
date: 0,
|
|
carsimgs: [{ img: "", intro: "", imgshort: "" }],
|
|
brandid: "",
|
|
brandname: "",
|
|
classid: "",
|
|
classes: [],
|
|
brands: [],
|
|
selectclass: "请选择分类",
|
|
selectbrand: "请选择品牌",
|
|
selecttime: " 请选择上牌日期",
|
|
selecttime1: "",
|
|
vehicletime: "请选择上牌日期",
|
|
vehicletime1: "",
|
|
insurance: "请选择保险到期时间",
|
|
insurance1: "",
|
|
gearboxes: [
|
|
{ name: "手自一体", id: "0" },
|
|
{ name: "手动档", id: "1" },
|
|
{ name: "自动挡", id: "2" },
|
|
],
|
|
gearboxname: "请选择变速箱类型",
|
|
gearboxindex: 0,
|
|
userphone: "",
|
|
mapname: "",
|
|
mapx: "",
|
|
mapy: "",
|
|
carimgs: [],
|
|
buttscan: !1,
|
|
notice: [],
|
|
noticeindex: 0,
|
|
textareatype: !1,
|
|
textareaname: "请输入车辆信息介绍",
|
|
textareainput: "",
|
|
isShow: !1,
|
|
showtextarea: !1,
|
|
status: "",
|
|
choose_index: 1,
|
|
choose_active: 0,
|
|
top: "0",
|
|
},
|
|
intextarea: function () {
|
|
this.setData({ textareatype: !0, textareaname: this.data.textareainput });
|
|
},
|
|
viewTouchMove: function (t) {
|
|
t.touches[0].clientY < 0 ||
|
|
t.touches[0].clientY > 450 ||
|
|
this.setData({ top: t.touches[0].clientY - 30 });
|
|
},
|
|
bindblur: function (t) {
|
|
console.log(t.detail.value);
|
|
var e = t.detail.value,
|
|
a = e;
|
|
e || ((e = "请输入车辆信息介绍"), (a = "")),
|
|
this.setData({ textareatype: !1, textareaname: e, textareainput: a });
|
|
},
|
|
bindconfirm: function () {
|
|
var t = new Date();
|
|
console.log(t.getMilliseconds());
|
|
},
|
|
hideDialog: function () {
|
|
this.setData({ isShow: !this.data.isShow });
|
|
},
|
|
updateUserInfo: function (e) {
|
|
var a = this;
|
|
t.util.getUserInfo(function (t) {
|
|
wx.setStorageSync("uid", t.memberInfo.uid), a.hideDialog();
|
|
}, e.detail);
|
|
},
|
|
showtextarea: function () {
|
|
var t = this;
|
|
console.log(!t.data.showtextarea),
|
|
t.setData({ showtextarea: !t.data.showtextarea });
|
|
},
|
|
textareashow: function (t) {
|
|
this.setData({ mapname: t.detail.value });
|
|
},
|
|
onShow: function () {
|
|
var t = this;
|
|
console.log(wx.getStorageSync("userInfo")),
|
|
"" != t.data.brandid &&
|
|
"" != t.data.brandname &&
|
|
t.setData({ selectbrand: t.data.brandname });
|
|
},
|
|
firstin: function (e) {
|
|
var a = wx.getSystemInfoSync();
|
|
e.setData({ maxwidth: a.windowWidth, maxheight: a.windowHeight }),
|
|
t.util.request({
|
|
url: "entry/wxapp/Api",
|
|
data: {
|
|
|
|
uid: t.getuid(),
|
|
r: "sale.index.saleindex",
|
|
},
|
|
cachetime: "0",
|
|
success: function (t) {
|
|
var a = { classes: t.data.data.class, userphone: "", mapname: "" };
|
|
t.data.data.user &&
|
|
((a.userphone = t.data.data.user.phone),
|
|
(a.mapname = t.data.data.user.address)),
|
|
e.setData(a);
|
|
},
|
|
});
|
|
},
|
|
onLoad: function (e) {
|
|
var a = this;
|
|
t.util.getUserInfo(function (e) {
|
|
e.memberInfo || a.setData({ isShow: !0 }),
|
|
t.util.request({
|
|
url: "entry/wxapp/Api",
|
|
data: {
|
|
|
|
r: "me.info",
|
|
uid: wx.getStorageSync("uid"),
|
|
},
|
|
success: function (t) {
|
|
console.log(t),
|
|
1 == t.data.data.status &&
|
|
wx.showModal({
|
|
title: "提示",
|
|
content: "您的用户已经禁止发布车辆信息,请联系管理员处理",
|
|
showCancel: !1,
|
|
success: function (t) {},
|
|
}),
|
|
a.setData({ status: t.data.data.status });
|
|
},
|
|
});
|
|
}),
|
|
a.firstin(a);
|
|
},
|
|
selectclass: function (t) {
|
|
var e = this.data.classes[t.detail.value];
|
|
e && this.setData({ selectclass: e.name, classid: e.id });
|
|
},
|
|
gearbox: function (t) {
|
|
var e = this.data.gearboxes[t.detail.value];
|
|
e && this.setData({ gearboxname: e.name, gearboxindex: t.detail.value });
|
|
},
|
|
selectbrand: function (t) {
|
|
wx.navigateTo({ url: "/pages/selectscards/index" });
|
|
},
|
|
bindDateChange: function (t) {
|
|
console.log(t.detail.value);
|
|
var e = t.detail.value.split("-");
|
|
this.setData({
|
|
selecttime: e[0] + "年" + e[1] + "月",
|
|
selecttime1: t.detail.value,
|
|
});
|
|
},
|
|
salefast: function (t) {
|
|
wx.navigateTo({ url: "/pages/sale_fast/index" });
|
|
},
|
|
getPhoneNumber: function (e) {
|
|
console.log(e);
|
|
var a = this;
|
|
t.util.request({
|
|
url: "entry/wxapp/Api",
|
|
data: {
|
|
r: "sale.index.userphone",
|
|
|
|
iv: e.detail.iv,
|
|
encryptedData: e.detail.encryptedData,
|
|
},
|
|
cachetime: "0",
|
|
success: function (t) {
|
|
a.setData({ userphone: t.data.data });
|
|
},
|
|
});
|
|
},
|
|
tomap: function () {
|
|
var t = this;
|
|
wx.cLn({
|
|
success: function (e) {
|
|
t.setData({
|
|
mapx: e.latitude,
|
|
mapy: e.longitude,
|
|
mapname: e.address + e.name,
|
|
});
|
|
},
|
|
fail: function () {
|
|
wx.getSetting({
|
|
success: function (t) {
|
|
t.authSetting["scope.userLocation"] ||
|
|
wx.showModal({
|
|
content: "请允许获取地理位置后再次尝试",
|
|
success: function (t) {
|
|
t.confirm
|
|
? wx.openSetting({
|
|
success: function (t) {
|
|
t.authSetting = {
|
|
"scope.userInfo": !0,
|
|
"scope.userLocation": !0,
|
|
};
|
|
},
|
|
fail: function (t) {
|
|
console.log(t);
|
|
},
|
|
})
|
|
: t.cancel && console.log("用户点击取消");
|
|
},
|
|
});
|
|
},
|
|
});
|
|
},
|
|
});
|
|
},
|
|
release: function (e) {
|
|
var a = this,
|
|
i = wx.getStorageSync("uid");
|
|
if (i) {
|
|
a.setData({ buttscan: !0 });
|
|
var s = a.data.classid;
|
|
if ("" == s || "undefined" == s || "请选择车辆类型" == s)
|
|
return (
|
|
t.util.message({ title: "请选择车辆类型", type: "error" }),
|
|
void a.setData({ buttscan: !1 })
|
|
);
|
|
var n = a.data.brandid;
|
|
if ("" == n || "undefined" == n || "请选择车辆品牌" == n)
|
|
return (
|
|
t.util.message({ title: "请选择车辆品牌", type: "error" }),
|
|
void a.setData({ buttscan: !1 })
|
|
);
|
|
var r = a.data.selecttime;
|
|
if (
|
|
"请选择出厂年份" == r ||
|
|
"undefined" == r ||
|
|
"" == a.data.selecttime1
|
|
)
|
|
return (
|
|
t.util.message({ title: "请选择出厂年份", type: "error" }),
|
|
void a.setData({ buttscan: !1 })
|
|
);
|
|
var u = e.detail.value.carname;
|
|
if ("" == u || "undefined" == u)
|
|
return (
|
|
t.util.message({ title: "请填写汽车名称", type: "error" }),
|
|
void a.setData({ buttscan: !1 })
|
|
);
|
|
var d = e.detail.value.kilometre;
|
|
if ("" == d || "undefined" == d)
|
|
return (
|
|
t.util.message({ title: "请填写公里数", type: "error" }),
|
|
void a.setData({ buttscan: !1 })
|
|
);
|
|
var c = e.detail.value.price;
|
|
if ("" == c || "undefined" == c)
|
|
return (
|
|
t.util.message({ title: "请填写价格", type: "error" }),
|
|
void a.setData({ buttscan: !1 })
|
|
);
|
|
var o = e.detail.value.exhaust;
|
|
if ("" == o || "undefined" == o)
|
|
return (
|
|
t.util.message({ title: "请填写排气量", type: "error" }),
|
|
void a.setData({ buttscan: !1 })
|
|
);
|
|
var l = a.data.gearboxindex;
|
|
if ("" == l || "undefined" == l)
|
|
return (
|
|
t.util.message({ title: "请选择变速箱类型", type: "error" }),
|
|
void a.setData({ buttscan: !1 })
|
|
);
|
|
var m = e.detail.value.phone;
|
|
if ("" == m || "undefined" == m)
|
|
return (
|
|
t.util.message({
|
|
title: "请填写联系电话,或点击电话授权",
|
|
type: "error",
|
|
}),
|
|
void a.setData({ buttscan: !1 })
|
|
);
|
|
var g = e.detail.value.address;
|
|
if ("" == g || "undefined" == g)
|
|
return (
|
|
t.util.message({ title: "请填写车辆地址", type: "error" }),
|
|
void a.setData({ buttscan: !1 })
|
|
);
|
|
var p = a.data.carsimgs;
|
|
if (p.length < 3)
|
|
return (
|
|
t.util.message({ title: "请至少添加3个车辆图文", type: "error" }),
|
|
void a.setData({ buttscan: !1 })
|
|
);
|
|
var h = {
|
|
r: "sale.index.insale",
|
|
|
|
fomid: e.detail.formId,
|
|
uid: i,
|
|
classid: s,
|
|
brand: n,
|
|
exhaust: o,
|
|
times: r,
|
|
times1: a.data.selecttime1,
|
|
kilometre: d,
|
|
price: c,
|
|
gearboxindex: l,
|
|
phone: m,
|
|
carname: u,
|
|
address: g,
|
|
carimgs: p,
|
|
mapx: a.data.mapx,
|
|
mapy: a.data.mapy,
|
|
};
|
|
t.util.request({
|
|
url: "entry/wxapp/Api",
|
|
data: h,
|
|
cachetime: "0",
|
|
success: function (t) {
|
|
t && t.data && 405 == t.data.message
|
|
? a.setData({ isShow: !0, buttscan: !1 })
|
|
: t &&
|
|
t.data &&
|
|
t.data.data &&
|
|
wx.showModal({
|
|
content: "提交成功,快去上架吧",
|
|
cancelText: "继续添加",
|
|
confirmText: "去上架",
|
|
success: function (t) {
|
|
t.confirm
|
|
? (a.cleardetail(),
|
|
wx.navigateTo({ url: "/pages/salelist/index" }))
|
|
: t.cancel &&
|
|
(a.setData({ buttscan: !1 }),
|
|
wx.reLaunch({ url: "/pages/sale/index" }));
|
|
},
|
|
});
|
|
},
|
|
fail: function (t) {
|
|
a.setData({ buttscan: !1 });
|
|
},
|
|
});
|
|
} else a.setData({ isShow: !0 });
|
|
},
|
|
cleardetail: function () {
|
|
this.setData({
|
|
selectclass: "请选择分类",
|
|
selectbrand: "请选择品牌",
|
|
selecttime: " 请选择出厂年份",
|
|
selecttime1: "",
|
|
vehicletime: "请选择上牌日期",
|
|
vehicletime1: "",
|
|
insurance: "请选择保险到期时间",
|
|
insurance1: "",
|
|
gearboxname: "请选择变速箱类型",
|
|
gearboxindex: 0,
|
|
mapx: "",
|
|
mapy: "",
|
|
carimgs: [],
|
|
textareaname: "请输入车辆信息介绍",
|
|
textareainput: "",
|
|
carsimgs: [{ img: "", intro: "", imgshort: "" }],
|
|
brandid: "",
|
|
brandname: "",
|
|
classid: "",
|
|
defult_value: "",
|
|
});
|
|
},
|
|
upnotice: function (t) {
|
|
this.data.noticeindex = t.detail.current;
|
|
},
|
|
retonotice: function () {
|
|
var t = this.data.notice[this.data.noticeindex];
|
|
t && t.id && wx.navigateTo({ url: "/pages/index/index?id=" + t.id });
|
|
},
|
|
delcarsimgs: function (e) {
|
|
var a = this,
|
|
i = e.currentTarget.dataset.index,
|
|
s = a.data.carsimgs;
|
|
if (0 == i && s.length > 1 && ("" != s[i].img || "" != s[i].intro))
|
|
return (
|
|
"" != s[i].img &&
|
|
t.util.request({
|
|
url: "entry/wxapp/Api",
|
|
data: {
|
|
m: "monai_sharing",
|
|
uid: t.getuid(),
|
|
imgurl: s[i].img,
|
|
r: "Upimg.delImg",
|
|
},
|
|
}),
|
|
s.splice(i, 1),
|
|
void a.setData({ carsimgs: s })
|
|
);
|
|
0 != i &&
|
|
("" != s[i].img &&
|
|
t.util.request({
|
|
url: "entry/wxapp/Api",
|
|
data: {
|
|
m: "monai_sharing",
|
|
uid: t.getuid(),
|
|
imgurl: s[i].img,
|
|
r: "Upimg.delImg",
|
|
},
|
|
}),
|
|
s.splice(i, 1),
|
|
a.setData({ carsimgs: s }));
|
|
},
|
|
upcarsimgs: function (e) {
|
|
var a = this,
|
|
i = e.currentTarget.dataset.index,
|
|
s = a.data.carsimgs;
|
|
"" != s[i].img &&
|
|
t.util.request({
|
|
url: "entry/wxapp/Api",
|
|
data: {
|
|
m: "monai_sharing",
|
|
uid: t.getuid(),
|
|
imgurl: s[i].img,
|
|
r: "Upimg.delImg",
|
|
},
|
|
}),
|
|
s.length >= 9
|
|
? t.util.message({ title: "您添加的图文已经很多了", type: "error" })
|
|
: ((a.data.upcarindex = i),
|
|
t.upimgs({
|
|
scannums: 1,
|
|
filename: "cars",
|
|
success: function (t) {
|
|
a.addinimgs(t[0]);
|
|
},
|
|
}));
|
|
},
|
|
addinimgs: function (t) {
|
|
var e = this,
|
|
a = e.data.carsimgs,
|
|
i = e.data.upcarindex;
|
|
(a[i].img = t.all), (a[i].imgshort = t.short), e.setData({ carsimgs: a });
|
|
},
|
|
showimgs: function (t) {
|
|
var e = t.currentTarget.dataset.index,
|
|
a = this.data.carsimgs;
|
|
wx.previewImage({ current: a[e].img, urls: [a[e].img] });
|
|
},
|
|
upthiscarsimgs: function (e) {
|
|
var a = e.currentTarget.dataset.index,
|
|
i = this.data.carsimgs;
|
|
t.util.request({
|
|
url: "entry/wxapp/Api",
|
|
data: {
|
|
m: "monai_sharing",
|
|
uid: t.getuid(),
|
|
imgurl: i[a].img,
|
|
r: "Upimg.delImg",
|
|
},
|
|
}),
|
|
(i[a].img = ""),
|
|
this.setData({ carsimgs: i });
|
|
},
|
|
setthisintro: function (t) {
|
|
var e = t.currentTarget.dataset.index;
|
|
this.data.carsimgs[e].intro = t.detail.value;
|
|
},
|
|
addcarsimgs: function () {
|
|
var t = this.data.carsimgs;
|
|
t.push({ img: "", intro: "", imgshort: "" }),
|
|
this.setData({ carsimgs: t });
|
|
},
|
|
upimg: function () {
|
|
var e = this,
|
|
a = e.data.carimgs;
|
|
a.length >= 9
|
|
? t.util.message({ title: "您上传的图片已经很多了", type: "error" })
|
|
: (a.length,
|
|
t.upimgs({
|
|
scannums: 1,
|
|
filename: "cars",
|
|
success: function (t) {
|
|
var i = a.concat(t);
|
|
e.setData({ carimgs: i });
|
|
},
|
|
}));
|
|
},
|
|
delimg: function (e) {
|
|
console.log(e.currentTarget.dataset.index);
|
|
var a = e.currentTarget.dataset.index,
|
|
i = this.data.carimgs,
|
|
s = i[a].all;
|
|
t.util.request({
|
|
url: "entry/wxapp/Api",
|
|
data: {
|
|
m: "monai_sharing",
|
|
uid: t.getuid(),
|
|
imgurl: s,
|
|
r: "Upimg.delImg",
|
|
},
|
|
}),
|
|
i.splice(a, 1),
|
|
this.setData({ carimgs: i });
|
|
},
|
|
});
|