654 lines
30 KiB
JavaScript
654 lines
30 KiB
JavaScript
var e = require("../../../@babel/runtime/helpers/interopRequireDefault")(require("../../../@babel/runtime/helpers/typeof")), t = getApp(), a = t.requirejs("core"), d = t.requirejs("foxui"), i = t.requirejs("biz/diyform"), c = t.requirejs("jquery"), r = t.requirejs("biz/selectdate");
|
||
|
||
Page({
|
||
data: {
|
||
icons: t.requirejs("icons"),
|
||
list: {},
|
||
goodslist: {},
|
||
data: {
|
||
dispatchtype: 0,
|
||
remark: ""
|
||
},
|
||
areaDetail: {
|
||
detail: {
|
||
realname: "",
|
||
mobile: "",
|
||
areas: "",
|
||
street: "",
|
||
address: ""
|
||
}
|
||
},
|
||
merchid: 0,
|
||
showPicker: !1,
|
||
pvalOld: [ 0, 0, 0 ],
|
||
pval: [ 0, 0, 0 ],
|
||
areas: [],
|
||
street: [],
|
||
streetIndex: 0,
|
||
noArea: !1,
|
||
showaddressview: !1,
|
||
city_express_state: !1,
|
||
onFocus: !1,
|
||
isShowText: !0,
|
||
remark: "50字以内(选填)",
|
||
trade: "",
|
||
currentDate: "",
|
||
dayList: "",
|
||
currentDayList: "",
|
||
currentObj: "",
|
||
currentDay: "",
|
||
cycelbuy_showdate: "",
|
||
receipttime: "",
|
||
scope: "",
|
||
bargainid: "",
|
||
selectcard: "",
|
||
olddeductcredit: "",
|
||
olddeductcredit2: "",
|
||
oldrealprice: "",
|
||
isLoad: !1
|
||
},
|
||
onShowTextarea: function() {
|
||
"50字以内(选填)" == this.data.remark && this.setData({
|
||
remark: ""
|
||
}), this.setData({
|
||
isShowText: !1,
|
||
onFacus: !0
|
||
});
|
||
},
|
||
onShowText: function(e) {
|
||
var t = e.detail.value;
|
||
"" == t && (t = "50字以内(选填)"), this.setData({
|
||
isShowText: !0,
|
||
onFacus: !1,
|
||
remark: t
|
||
});
|
||
},
|
||
onLoad: function(e) {
|
||
var a = this;
|
||
if (e.goods) {
|
||
var d = JSON.parse(e.goods);
|
||
e.goods = d, this.setData({
|
||
ispackage: !0
|
||
});
|
||
}
|
||
a.setData({
|
||
options: e
|
||
}), a.setData({
|
||
bargainid: e.bargainid
|
||
}), t.url(e), this.getQuickAddressDetail(), t.setCache("coupon", ""), setTimeout(function() {
|
||
a.setData({
|
||
areas: t.getCache("cacheset").areas
|
||
});
|
||
}, 3e3);
|
||
},
|
||
show_cycelbuydate: function() {
|
||
var e = r.getCurrentDayString(this, this.data.cycelbuy_showdate);
|
||
this.setData({
|
||
currentObj: e,
|
||
currentDate: e.getFullYear() + "." + (e.getMonth() + 1) + "." + e.getDate() + " " + [ "周日", "周一", "周二", "周三", "周四", "周五", "周六" ][e.getDay()],
|
||
currentYear: e.getFullYear(),
|
||
currentMonth: e.getMonth() + 1,
|
||
currentDay: e.getDate(),
|
||
initDate: Date.parse(e.getFullYear() + "/" + (e.getMonth() + 1) + "/" + e.getDate()),
|
||
checkedDate: Date.parse(e.getFullYear() + "/" + (e.getMonth() + 1) + "/" + e.getDate()),
|
||
maxday: this.data.scope
|
||
});
|
||
},
|
||
onShow: function() {
|
||
var d = t.getCache("orderAddress"), i = t.getCache("orderShop"), r = t.getCache("isIpx"), s = this, o = [];
|
||
a.get("order/create", s.data.options, function(e) {
|
||
if (0 == e.error) {
|
||
o = s.getGoodsList(e.goods);
|
||
var d = (s.data.originalprice - e.goodsprice).toFixed(2), i = {
|
||
list: e,
|
||
goods: e,
|
||
show: !0,
|
||
address: !0,
|
||
card_info: e.card_info || {},
|
||
cardid: e.card_info.cardid || "",
|
||
cardname: e.card_info.cardname || "",
|
||
carddiscountprice: e.card_info.carddiscountprice,
|
||
goodslist: o,
|
||
merchid: e.merchid,
|
||
comboprice: d,
|
||
diyform: {
|
||
f_data: e.f_data,
|
||
fields: e.fields
|
||
},
|
||
city_express_state: e.city_express_state,
|
||
cycelbuy_showdate: e.selectDate,
|
||
receipttime: e.receipttime,
|
||
iscycel: e.iscycel,
|
||
scope: e.scope,
|
||
fromquick: e.fromquick,
|
||
hasinvoice: e.hasinvoice,
|
||
credittext: e.sysset.texts.credit,
|
||
trade: e.trade,
|
||
olddeductcredit: e.deductmoney,
|
||
olddeductcredit2: e.deductcredit2,
|
||
oldrealprice: e.realprice
|
||
};
|
||
s.data.isLoad ? delete i.list : (i.isLoad = !0, e.trade && e.trade.trade_first && "0" != e.trade.trade_first && (s.setData({
|
||
"data.dispatchtype": e.trade.trade_first
|
||
}), i.oldrealprice = e.realprice - e.dispatch_price, e.realprice = e.realprice - e.dispatch_price)),
|
||
s.setData(i), t.setCache("goodsInfo", {
|
||
goodslist: o,
|
||
merchs: e.merchs
|
||
}, 1800);
|
||
} else a.toast(e.message, "loading"), setTimeout(function() {
|
||
wx.navigateBack();
|
||
}, 1e3);
|
||
if ("" != e.fullbackgoods) {
|
||
if (null == e.fullbackgoods) return;
|
||
var c = e.fullbackgoods.fullbackratio, r = e.fullbackgoods.maxallfullbackallratio;
|
||
c = Math.round(c), r = Math.round(r);
|
||
s.setData({
|
||
fullbackratio: c,
|
||
maxallfullbackallratio: r
|
||
});
|
||
}
|
||
1 == e.iscycelbuy && s.show_cycelbuydate();
|
||
}), r ? s.setData({
|
||
isIpx: !0,
|
||
iphonexnavbar: "fui-iphonex-navbar",
|
||
paddingb: "padding-b"
|
||
}) : s.setData({
|
||
isIpx: !1,
|
||
iphonexnavbar: "",
|
||
paddingb: ""
|
||
}), d && (this.setData({
|
||
"list.address": d
|
||
}), s.caculate(s.data.list)), i && this.setData({
|
||
"list.carrierInfo": i,
|
||
"list.storeInfo": i
|
||
});
|
||
var n = t.getCache("coupon");
|
||
"object" == (0, e.default)(n) && 0 != n.id && n ? (this.setData({
|
||
"data.couponid": n.id,
|
||
"data.couponname": n.name
|
||
}), a.post("order/create/getcouponprice", {
|
||
couponid: n.id,
|
||
goods: this.data.goodslist,
|
||
goodsprice: this.data.list.goodsprice,
|
||
discountprice: this.data.list.discountprice,
|
||
isdiscountprice: this.data.list.isdiscountprice
|
||
}, function(e) {
|
||
0 == e.error ? (delete e.$goodsarr, s.setData({
|
||
coupon: e
|
||
}), s.caculate(s.data.list)) : a.alert(e.message);
|
||
}, !0)) : (this.setData({
|
||
"data.couponid": 0,
|
||
"data.couponname": null,
|
||
coupon: null
|
||
}), c.isEmptyObject(s.data.list) || s.caculate(s.data.list));
|
||
},
|
||
getGoodsList: function(e) {
|
||
var t = [];
|
||
c.each(e, function(e, a) {
|
||
c.each(a.goods, function(e, a) {
|
||
t.push(a);
|
||
});
|
||
});
|
||
for (var a = 0, d = 0; d < t.length; d++) a += t[d].price;
|
||
return this.setData({
|
||
originalprice: a
|
||
}), t;
|
||
},
|
||
toggle: function(e) {
|
||
var t = a.pdata(e), d = t.id, i = t.type, c = {};
|
||
c[i] = 0 == d || void 0 === d ? 1 : 0, this.setData(c);
|
||
},
|
||
phone: function(e) {
|
||
a.phone(e);
|
||
},
|
||
dispatchtype: function(e) {
|
||
var t = a.data(e).type;
|
||
this.setData({
|
||
"data.dispatchtype": t
|
||
}), this.caculate(this.data.list);
|
||
},
|
||
number: function(e) {
|
||
var t = a.pdata(e), i = d.number(this, e), r = t.id, s = this.data.list, o = 0, n = 0;
|
||
c.each(s.goods, function(e, t) {
|
||
c.each(t.goods, function(t, a) {
|
||
a.id == r && (s.goods[e].goods[t].total = i), o += parseInt(s.goods[e].goods[t].total),
|
||
n += parseFloat(o * s.goods[e].goods[t].price);
|
||
});
|
||
}), s.total = o, s.goodsprice = c.toFixed(n, 2), this.setData({
|
||
list: s,
|
||
goodslist: this.getGoodsList(s.goods)
|
||
}), this.caculate(s);
|
||
},
|
||
caculate: function(e) {
|
||
var t = this, d = 0;
|
||
t.data.data && 0 != t.data.data.couponid && (d = t.data.data.couponid), a.post("order/create/caculate", {
|
||
goods: this.data.goodslist,
|
||
dflag: this.data.data.dispatchtype,
|
||
addressid: this.data.list.address ? this.data.list.address.id : 0,
|
||
packageid: this.data.list.packageid,
|
||
bargain_id: this.data.bargainid,
|
||
discountprice: this.data.list.discountprice,
|
||
cardid: this.data.cardid,
|
||
couponid: d
|
||
}, function(a) {
|
||
console.log(a, "aaaa", t.data.data.dispatchtype), e.couponcount = a.couponcount,
|
||
e.dispatch_price = a.price, e.enoughdeduct = a.deductenough_money, e.enoughmoney = a.deductenough_enough,
|
||
e.taskdiscountprice = a.taskdiscountprice, e.discountprice = a.discountprice, e.isdiscountprice = a.isdiscountprice,
|
||
e.seckill_price = a.seckill_price, e.deductcredit2 = a.deductcredit2, e.deductmoney = a.deductmoney,
|
||
e.deductcredit = a.deductcredit, e.gifts = a.gifts, t.data.oldrealprice = a.realprice - a.coupon_deductprice,
|
||
t.data.olddeductcredit = a.deductmoney, t.data.olddeductcredit2 = a.deductcredit2,
|
||
1 == t.data.data.dispatchtype && (a.realprice -= a.price), t.data.coupon && void 0 !== t.data.coupon.deductprice ? (t.setData({
|
||
"coupon.deductprice": a.coupon_deductprice
|
||
}), a.realprice -= a.coupon_deductprice, 1 == a.include_dispatch ? t.data.data.deduct && !t.data.data.deduct2 ? (e.deductcredit2 = e.deductcredit2 > a.realprice - a.price - a.deductmoney ? c.toFixed(a.realprice - a.price - a.deductmoney, 2) : parseFloat(e.deductcredit2),
|
||
e.deductcredit2 <= 0 && (a.realprice = a.price, e.deductcredit2 = 0, t.data.data.deduct2 = !1),
|
||
a.realprice = t.data.oldrealprice - e.deductmoney) : t.data.data.deduct && t.data.data.deduct2 ? (e.deductcredit2 = e.deductcredit2 > a.realprice - a.price - a.deductmoney ? c.toFixed(a.realprice - a.price - a.deductmoney, 2) : parseFloat(e.deductcredit2),
|
||
e.deductcredit2 <= 0 && (e.deductcredit2 = 0, a.realprice = a.price, t.data.data.deduct2 = !1),
|
||
a.realprice = t.data.oldrealprice - e.deductmoney - e.deductcredit2) : !t.data.data.deduct && t.data.data.deduct2 && (a.realprice = t.data.oldrealprice - e.deductcredit2) : 0 == a.include_dispatch && (!t.data.data.deduct && t.data.data.deduct2 ? a.realprice = t.data.oldrealprice - e.deductcredit2 : t.data.data.deduct && !t.data.data.deduct2 ? (e.deductcredit2 = e.deductcredit2 > a.realprice - a.deductmoney ? c.toFixed(a.realprice - a.deductmoney, 2) : parseFloat(e.deductcredit2),
|
||
a.realprice = t.data.oldrealprice - e.deductmoney, e.deductcredit2 <= 0 && (e.deductcredit2 = 0,
|
||
t.data.data.deduct2 = !1)) : t.data.data.deduct && t.data.data.deduct2 && (console.log("全不选中啊啊"),
|
||
e.deductcredit2 = e.deductcredit2 > a.realprice - a.deductmoney ? parseFloat(a.realprice - a.deductmoney) : parseFloat(e.deductcredit2),
|
||
e.deductcredit2 <= 0 && (e.deductcredit2 = 0, t.data.data.deduct2 = !1), a.realprice = t.data.oldrealprice - e.deductmoney - e.deductcredit2))) : 1 == a.include_dispatch ? (console.log("不抵扣,不用优惠券", t.data.oldrealprice),
|
||
t.data.data.deduct && !t.data.data.deduct2 && (e.deductcredit2 = e.deductcredit2 > a.realprice - a.deductmoney - a.price ? c.toFixed(a.realprice - a.deductmoney - a.price, 2) : parseFloat(e.deductcredit2),
|
||
a.realprice = t.data.oldrealprice - e.deductmoney), t.data.data.deduct2 && !t.data.data.deduct && (e.deductcredit2 = e.deductcredit2 > a.realprice - a.deductmoney - a.price ? c.toFixed(a.realprice - a.deductmoney - a.price, 2) : parseFloat(e.deductcredit2),
|
||
a.realprice = t.data.oldrealprice - e.deductcredit2), t.data.data.deduct2 && t.data.data.deduct && (e.deductcredit2 = e.deductcredit2 > a.realprice - a.deductmoney - a.price ? c.toFixed(a.realprice - a.deductmoney - a.price, 2) : parseFloat(e.deductcredit2),
|
||
a.realprice = t.data.oldrealprice - e.deductcredit2 - e.deductmoney)) : 0 == a.include_dispatch && (t.data.data.deduct && !t.data.data.deduct2 && (e.deductcredit2 = e.deductcredit2 > a.realprice - a.deductmoney ? c.toFixed(a.realprice - a.deductmoney, 2) : parseFloat(e.deductcredit2),
|
||
a.realprice = t.data.oldrealprice - e.deductmoney), t.data.data.deduct2 && !t.data.data.deduct && (e.deductcredit2 = e.deductcredit2 > a.realprice - a.deductcredit ? c.toFixed(a.realprice - a.deductmoney, 2) : parseFloat(e.deductcredit2),
|
||
a.realprice = t.data.oldrealprice - e.deductcredit2), t.data.data.deduct2 && t.data.data.deduct && (e.deductcredit2 = e.deductcredit2 > a.realprice - a.deductcredit ? c.toFixed(a.realprice - a.deductmoney, 2) : parseFloat(e.deductcredit2),
|
||
a.realprice = t.data.oldrealprice - e.deductcredit2 - e.deductmoney)), a.card_info && (e.card_free_dispatch = a.card_free_dispatch),
|
||
0 == t.data.goods.giftid && t.setData({
|
||
"goods.gifts": a.gifts
|
||
}), e.realprice <= 0 && (e.realprice = 1e-6), e.realprice = c.toFixed(a.realprice, 2),
|
||
("-0.00" == e.realprice || e.realprice < 0) && (e.realprice = 0), t.setData({
|
||
list: e,
|
||
cardid: a.card_info.cardid,
|
||
cardname: a.card_info.cardname,
|
||
goodsprice: a.card_info.goodsprice ? a.card_info.goodsprice : 0,
|
||
carddiscountprice: a.card_info.carddiscountprice,
|
||
city_express_state: a.city_express_state
|
||
});
|
||
}, !0);
|
||
},
|
||
submit: function() {
|
||
var e = this.data, t = this, d = this.data.diyform, r = e.goods.giftid || e.giftid;
|
||
if ((0 == this.data.goods.giftid && 1 == this.data.goods.gifts.length && (r = this.data.goods.gifts[0].id),
|
||
!e.submit) && i.verify(this, d)) {
|
||
e.list.carrierInfo = e.list.carrierInfo || {};
|
||
var s = {
|
||
id: e.options.id ? e.options.id : 0,
|
||
goods: e.goodslist,
|
||
gdid: e.options.gdid,
|
||
dispatchtype: e.data.dispatchtype,
|
||
fromcart: e.list.fromcart,
|
||
carrierid: 1 == e.data.dispatchtype && e.list.carrierInfo ? e.list.carrierInfo.id : 0,
|
||
addressid: e.list.address ? e.list.address.id : 0,
|
||
carriers: 1 == e.data.dispatchtype || e.list.isvirtual || e.list.isverify ? {
|
||
carrier_realname: e.list.member.realname,
|
||
carrier_mobile: e.list.member.mobile,
|
||
realname: e.list.carrierInfo.realname,
|
||
mobile: e.list.carrierInfo.mobile,
|
||
storename: e.list.carrierInfo.storename,
|
||
address: e.list.carrierInfo.address
|
||
} : "",
|
||
remark: e.data.remark,
|
||
deduct: e.data.deduct,
|
||
deduct2: e.data.deduct2,
|
||
couponid: e.data.couponid,
|
||
cardid: e.cardid,
|
||
invoicename: e.list.invoicename,
|
||
submit: !0,
|
||
packageid: e.list.packageid,
|
||
giftid: r,
|
||
diydata: e.diyform.f_data,
|
||
receipttime: e.receipttime,
|
||
bargain_id: t.data.options.bargainid,
|
||
fromquick: e.fromquick
|
||
};
|
||
if (e.list.storeInfo && (s.carrierid = e.list.storeInfo.id), 1 == e.data.dispatchtype || e.list.isvirtual || e.list.isverify) {
|
||
if ("" == c.trim(e.list.member.realname) && "0" == e.list.set_realname) return void a.alert("请填写联系人!");
|
||
if ("" == c.trim(e.list.member.mobile) && "0" == e.list.set_mobile) return void a.alert("请填写联系方式!");
|
||
if ("0" == e.list.set_mobile && !/^[1][3-9]\d{9}$|^([6|9])\d{7}$|^[0][9]\d{8}$|^[6]([8|6])\d{5}$/.test(c.trim(e.list.member.mobile))) return void a.alert("请填写正确联系电话!");
|
||
if (e.list.isforceverifystore && !e.list.storeInfo) return void a.alert("请选择门店!");
|
||
s.addressid = 0;
|
||
} else if (!s.addressid && !e.list.isonlyverifygoods) return void a.alert("地址没有选择!");
|
||
t.setData({
|
||
submit: !0
|
||
}), console.log(s), a.post("order/create/submit", s, function(e) {
|
||
t.setData({
|
||
submit: !1
|
||
}), 0 == e.error ? 1 == e.is_merch && e.has_sub_account && e.order_count > 1 ? wx.navigateTo({
|
||
url: "/pages/order/waitpay/index?orderid=" + e.orderid
|
||
}) : wx.navigateTo({
|
||
url: "/pages/order/pay/index?id=" + e.orderid
|
||
}) : a.alert(e.message);
|
||
}, !0);
|
||
}
|
||
},
|
||
dataChange: function(e) {
|
||
var t = this.data.data, a = this.data.list, d = e.target.id, i = this.data.olddeductcredit, r = this.data.olddeductcredit2, s = this.data.oldrealprice;
|
||
switch (console.log(s, "--==-=-=-=-"), console.log(this.data.olddeductcredit2),
|
||
console.log(this.data.olddeductcredit), d) {
|
||
case "remark":
|
||
t.remark = e.detail.value;
|
||
break;
|
||
|
||
case "deduct":
|
||
t.deduct = e.detail.value;
|
||
var o = parseFloat(a.realprice);
|
||
0 == a.include_dispatch ? (t.deduct && !t.deduct2 ? (o += t.deduct ? -parseFloat(a.deductmoney) : parseFloat(a.deductmoney),
|
||
a.deductcredit2 = a.deductcredit2 > o ? parseFloat(o) : parseFloat(a.deductcredit2)) : t.deduct || t.deduct2 ? !t.deduct && t.deduct2 ? (a.deductcredit2 = r,
|
||
o = s - r) : t.deduct && t.deduct2 && (o = s - i, a.deductcredit2 = a.deductcredit2 > o ? parseFloat(o) : parseFloat(a.deductcredit2),
|
||
o -= parseFloat(a.deductcredit2)) : (a.deductcredit2 = r, o += t.deduct ? -parseFloat(a.deductmoney) : parseFloat(a.deductmoney)),
|
||
a.realprice = o) : 1 == a.include_dispatch && (t.deduct && !t.deduct2 ? (o += t.deduct ? -parseFloat(a.deductmoney) : parseFloat(a.deductmoney),
|
||
a.deductcredit2 = a.deductcredit2 > o - parseFloat(a.dispatch_price) ? o - parseFloat(a.dispatch_price) : a.deductcredit2,
|
||
console.log(o, ">>>>>>>>>>>")) : t.deduct || t.deduct2 ? !t.deduct && t.deduct2 ? (a.deductcredit2 = r,
|
||
o = s - r) : t.deduct && t.deduct2 && (o = s - i, a.deductcredit2 = a.deductcredit2 > o - parseFloat(a.dispatch_price) ? o - parseFloat(a.dispatch_price) : a.deductcredit2,
|
||
a.deductcredit2 <= 0 && (t.deduct2 = !1), o -= parseFloat(a.deductcredit2)) : (a.deductcredit2 = r,
|
||
a.deductmoney = i, o = s, console.log(o, "?????")), a.realprice = o);
|
||
break;
|
||
|
||
case "deduct2":
|
||
t.deduct2 = e.detail.value;
|
||
o = parseFloat(a.realprice);
|
||
0 == a.include_dispatch ? (!t.deduct && t.deduct2 ? (console.log("只选余额"), o += t.deduct2 ? -parseFloat(a.deductcredit2) : parseFloat(a.deductcredit2)) : t.deduct || t.deduct2 ? t.deduct && !t.deduct2 ? (console.log("取消掉余额,只留积分"),
|
||
o = s - parseFloat(a.deductmoney)) : t.deduct && t.deduct2 && (console.log("全选中"),
|
||
o = s - parseFloat(a.deductcredit) - parseFloat(a.deductcredit2)) : (a.deductcredit2 = r,
|
||
o += t.deduct2 ? -parseFloat(a.deductcredit2) : parseFloat(a.deductcredit2)), a.realprice = o) : 1 == a.include_dispatch && (!t.deduct && t.deduct2 ? o += t.deduct2 ? -parseFloat(a.deductcredit2) : parseFloat(a.deductcredit2) : t.deduct || t.deduct2 ? t.deduct && !t.deduct2 ? o = s - parseFloat(a.deductmoney) : t.deduct && t.deduct2 && (o = s - parseFloat(a.deductmoney) - parseFloat(a.deductcredit2)) : (a.deductcredit2 = r,
|
||
a.deductmoney = i, o = s), a.realprice = o);
|
||
}
|
||
a.realprice <= 0 && (a.realprice = 1e-6), a.realprice = c.toFixed(a.realprice, 2),
|
||
this.setData({
|
||
data: t,
|
||
list: a
|
||
});
|
||
},
|
||
listChange: function(e) {
|
||
var t = this.data.list;
|
||
switch (e.target.id) {
|
||
case "invoicename":
|
||
t.invoicename = e.detail.value;
|
||
break;
|
||
|
||
case "realname":
|
||
t.member.realname = e.detail.value;
|
||
break;
|
||
|
||
case "mobile":
|
||
t.member.mobile = e.detail.value;
|
||
}
|
||
this.setData({
|
||
list: t
|
||
});
|
||
},
|
||
url: function(e) {
|
||
var t = a.pdata(e).url;
|
||
wx.redirectTo({
|
||
url: t
|
||
});
|
||
},
|
||
onChange: function(e) {
|
||
return i.onChange(this, e);
|
||
},
|
||
DiyFormHandler: function(e) {
|
||
return i.DiyFormHandler(this, e);
|
||
},
|
||
selectArea: function(e) {
|
||
return i.selectArea(this, e);
|
||
},
|
||
bindChange: function(e) {
|
||
return i.bindChange(this, e);
|
||
},
|
||
onCancel: function(e) {
|
||
return i.onCancel(this, e);
|
||
},
|
||
onConfirm: function(e) {
|
||
i.onConfirm(this, e);
|
||
var t = this.data.pval, a = this.data.areas, d = this.data.areaDetail.detail;
|
||
d.province = a[t[0]].name, d.city = a[t[0]].city[t[1]].name, d.datavalue = a[t[0]].code + " " + a[t[0]].city[t[1]].code,
|
||
a[t[0]].city[t[1]].area && a[t[0]].city[t[1]].area.length > 0 ? (d.area = a[t[0]].city[t[1]].area[t[2]].name,
|
||
d.datavalue += " " + a[t[0]].city[t[1]].area[t[2]].code, this.getStreet(a, t)) : d.area = "",
|
||
d.street = "", this.setData({
|
||
"areaDetail.detail": d,
|
||
streetIndex: 0,
|
||
showPicker: !1
|
||
});
|
||
},
|
||
getIndex: function(e, t) {
|
||
return i.getIndex(e, t);
|
||
},
|
||
showaddressview: function(e) {
|
||
var t = "";
|
||
t = "open" == e.target.dataset.type, this.setData({
|
||
showaddressview: t
|
||
});
|
||
},
|
||
onChange2: function(e) {
|
||
var t = this.data.areaDetail.detail, a = e.currentTarget.dataset.type, d = c.trim(e.detail.value);
|
||
"street" == a && (t.streetdatavalue = this.data.street[d].code, d = this.data.street[d].name),
|
||
t[a] = d, this.setData({
|
||
"areaDetail.detail": t
|
||
});
|
||
},
|
||
getStreet: function(e, t) {
|
||
if (e && t) {
|
||
var d = this;
|
||
if (d.data.areaDetail.detail.province && d.data.areaDetail.detail.city && this.data.openstreet) {
|
||
var i = e[t[0]].city[t[1]].code, c = e[t[0]].city[t[1]].area[t[2]].code;
|
||
a.get("getstreet", {
|
||
city: i,
|
||
area: c
|
||
}, function(e) {
|
||
var t = e.street, a = {
|
||
street: t
|
||
};
|
||
if (t && d.data.areaDetail.detail.streetdatavalue) for (var i in t) if (t[i].code == d.data.areaDetail.detail.streetdatavalue) {
|
||
a.streetIndex = i, d.setData({
|
||
"areaDetail.detail.street": t[i].name
|
||
});
|
||
break;
|
||
}
|
||
d.setData(a);
|
||
});
|
||
}
|
||
}
|
||
},
|
||
getQuickAddressDetail: function() {
|
||
var e = this, t = e.data.id;
|
||
a.get("member/address/get_detail", {
|
||
id: t
|
||
}, function(t) {
|
||
var a = {
|
||
openstreet: t.openstreet,
|
||
show: !0
|
||
};
|
||
if (!c.isEmptyObject(t.detail)) {
|
||
var d = t.detail.province + " " + t.detail.city + " " + t.detail.area, i = e.getIndex(d, e.data.areas);
|
||
a.pval = i, a.pvalOld = i, a.areaDetail.detail = t.detail;
|
||
}
|
||
e.setData(a), t.openstreet && i && e.getStreet(e.data.areas, i);
|
||
});
|
||
},
|
||
submitaddress: function() {
|
||
var e = this, t = e.data.areaDetail.detail;
|
||
e.data.posting || ("" != t.realname && t.realname ? "" != t.mobile && t.mobile ? "" != t.city && t.city ? !(e.data.street.length > 0) || "" != t.street && t.street ? "" != t.address && t.address ? t.datavalue ? (t.id = 0,
|
||
e.setData({
|
||
posting: !0
|
||
}), a.post("member/address/submit", t, function(i) {
|
||
if (0 != i.error) return e.setData({
|
||
posting: !1
|
||
}), void d.toast(e, i.message);
|
||
t.id = i.addressid, e.setData({
|
||
showaddressview: !1,
|
||
"list.address": t
|
||
}), a.toast("保存成功");
|
||
})) : d.toast(e, "地址数据出错,请重新选择") : d.toast(e, "请填写详细地址") : d.toast(e, "请选择所在街道") : d.toast(e, "请选择所在地区") : d.toast(e, "请填写联系电话") : d.toast(e, "请填写收件人"));
|
||
},
|
||
giftPicker: function() {
|
||
this.setData({
|
||
active: "active",
|
||
gift: !0
|
||
});
|
||
},
|
||
emptyActive: function() {
|
||
this.setData({
|
||
active: "",
|
||
slider: "out",
|
||
tempname: "",
|
||
showcoupon: !1,
|
||
gift: !1
|
||
});
|
||
},
|
||
radioChange: function(e) {
|
||
this.setData({
|
||
giftid: e.currentTarget.dataset.giftgoodsid,
|
||
gift_title: e.currentTarget.dataset.title
|
||
});
|
||
},
|
||
sendclick: function() {
|
||
wx.navigateTo({
|
||
url: "/pages/map/index"
|
||
});
|
||
},
|
||
clearform: function() {
|
||
var e = this.data.diyform, t = {};
|
||
c.each(e, function(a, d) {
|
||
c.each(d, function(a, d) {
|
||
5 == d.data_type && (e.f_data[d.diy_type].count = 0, e.f_data[d.diy_type].images = [],
|
||
t[d.diy_type] = e.f_data[d.diy_type]);
|
||
});
|
||
}), e.f_data = t, this.setData({
|
||
diyform: e
|
||
});
|
||
},
|
||
syclecancle: function() {
|
||
this.setData({
|
||
cycledate: !1
|
||
});
|
||
},
|
||
sycleconfirm: function() {
|
||
this.setData({
|
||
cycledate: !1
|
||
});
|
||
},
|
||
editdate: function(e) {
|
||
r.setSchedule(this), this.setData({
|
||
cycledate: !0,
|
||
create: !0
|
||
});
|
||
},
|
||
doDay: function(e) {
|
||
r.doDay(e, this);
|
||
},
|
||
selectDay: function(e) {
|
||
r.selectDay(e, this), r.setSchedule(this);
|
||
},
|
||
showinvoicepicker: function() {
|
||
var e = this.data.list;
|
||
0 == e.invoice_type && (e.invoice_info.entity = !0), 1 == e.invoice_type && (e.invoice_info.entity = !1),
|
||
this.setData({
|
||
invoicepicker: !0,
|
||
list: e
|
||
});
|
||
},
|
||
noinvoicepicker: function() {
|
||
this.setData({
|
||
invoicepicker: !1
|
||
});
|
||
},
|
||
clearinvoice: function() {
|
||
var e = this.data.list;
|
||
e.invoicename = "", this.setData({
|
||
invoicepicker: !1,
|
||
list: e
|
||
});
|
||
},
|
||
chaninvoice: function(e) {
|
||
var t = this.data.list;
|
||
"0" == e.currentTarget.dataset.type ? t.invoice_info.entity = !1 : t.invoice_info.entity = !0,
|
||
this.setData({
|
||
list: t
|
||
});
|
||
},
|
||
changeType: function(e) {
|
||
var t = this.data.list;
|
||
"0" == e.currentTarget.dataset.type ? t.invoice_info.company = !1 : t.invoice_info.company = !0,
|
||
this.setData({
|
||
list: t
|
||
});
|
||
},
|
||
invoicetitle: function(e) {
|
||
var t = this.data.list;
|
||
t.invoice_info.title = e.detail.value.replace(/\s+/g, ""), this.setData({
|
||
list: t
|
||
});
|
||
},
|
||
invoicenumber: function(e) {
|
||
var t = this.data.list;
|
||
t.invoice_info.number = e.detail.value.replace(/\s+/g, ""), this.setData({
|
||
list: t
|
||
});
|
||
},
|
||
confirminvoice: function() {
|
||
var e = this.data.list;
|
||
e.invoice_info.company || this.setData({
|
||
invoicenumber: ""
|
||
});
|
||
var t = e.invoice_info.entity ? "[纸质] " : "[电子] ", a = e.invoice_info.title + " ", i = e.invoice_info.company ? "(单位: " + e.invoice_info.number + ")" : "(个人)";
|
||
e.invoicename = t + a + i, e.invoice_info.title ? e.invoice_info.company && !e.invoice_info.number ? d.toast(this, "请填写税号") : this.setData({
|
||
list: e,
|
||
invoicepicker: !1
|
||
}) : d.toast(this, "请填写发票抬头");
|
||
},
|
||
selectCard: function() {
|
||
this.setData({
|
||
selectcard: "in"
|
||
});
|
||
},
|
||
cancalCard: function() {
|
||
this.setData({
|
||
cardid: ""
|
||
});
|
||
},
|
||
changecard: function(e) {
|
||
var t = this;
|
||
t.data.card_info;
|
||
t.setData({
|
||
selectcard: "",
|
||
cardid: e.currentTarget.dataset.id
|
||
});
|
||
var d = e.currentTarget.dataset.id, i = {
|
||
cardid: d,
|
||
goodsprice: this.data.list.goodsprice,
|
||
dispatch_price: this.data.list.dispatch_price,
|
||
discountprice: this.data.list.discountprice,
|
||
goodslist: this.data.list.goods
|
||
};
|
||
a.post("order/create/getcardprice", i, function(e) {
|
||
if ("" != d) if (0 == e.error) {
|
||
var i = {
|
||
carddiscount_rate: e.carddiscount_rate,
|
||
carddiscountprice: e.carddiscountprice,
|
||
cardid: e.cardid,
|
||
cardname: e.name,
|
||
dispatch_price: e.dispatch_price,
|
||
totalprice: e.totalprice,
|
||
comboprice: 0
|
||
};
|
||
t.setData(i), t.caculate(t.data.list);
|
||
} else a.alert(e.message); else {
|
||
var r = {
|
||
cardid: "",
|
||
selectcard: "",
|
||
cardname: "",
|
||
carddiscountprice: 0,
|
||
ispackage: !1
|
||
}, s = (t.data.originalprice - t.data.list.goodsprice).toFixed(2);
|
||
t.data.options.goods && (r.ispackage = !0, r.comboprice = s), t.setData(r), c.isEmptyObject(t.data.list) || t.caculate(t.data.list);
|
||
}
|
||
}, !0);
|
||
},
|
||
closeCardModal: function() {
|
||
this.setData({
|
||
selectcard: ""
|
||
});
|
||
}
|
||
}); |