218 lines
7.2 KiB
JavaScript
218 lines
7.2 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../../common/vendor.js");
|
|
const components_public_apiMixins = require("../../../components/public/apiMixins.js");
|
|
const JyPopup = () => "../../../components/public/jy-popup/index.js";
|
|
const JyCommonHead = () => "../../../components/public/jy-common-head/index.js";
|
|
const JyAddress = () => "../components/jy-address/index.js";
|
|
const pickRegions = () => "./components/jy-pick-regions/index.js";
|
|
const JyBottomBtn = () => "../../../components/public/jy-bottom-button/index.js";
|
|
const _sfc_main = {
|
|
components: {
|
|
JyCommonHead,
|
|
JyAddress,
|
|
pickRegions,
|
|
JyBottomBtn,
|
|
JyPopup
|
|
},
|
|
mixins: [components_public_apiMixins.apiMixins],
|
|
mounted() {
|
|
this.init();
|
|
},
|
|
methods: {
|
|
openPopup() {
|
|
this.$refs.addressPopup.open();
|
|
},
|
|
init() {
|
|
this.getData({
|
|
api: "address",
|
|
fn: "list"
|
|
}, {});
|
|
console.log("====================================");
|
|
console.log(this.listProperty);
|
|
console.log("====================================");
|
|
},
|
|
onReachBottomHandler() {
|
|
this.listProperty.params.pageNum++;
|
|
this.init();
|
|
},
|
|
onPullDownRefreshHandler() {
|
|
this.listProperty.params.pageNum = 1;
|
|
this.getData({
|
|
api: "address",
|
|
fn: "list"
|
|
}, {}, true);
|
|
}
|
|
},
|
|
setup() {
|
|
const show = common_vendor.ref(false);
|
|
const onhideShow = () => {
|
|
show.value = true;
|
|
};
|
|
const changeClick = (value, value2, value3, value4) => {
|
|
console.log("地址选择器 = " + value + value2 + value3 + value4);
|
|
};
|
|
const onsetCity = (e) => {
|
|
console.log("====================================");
|
|
console.log(e);
|
|
console.log("====================================");
|
|
show.value = false;
|
|
};
|
|
const formData = common_vendor.reactive({
|
|
recipientName: void 0,
|
|
phoneNumber: void 0,
|
|
district: void 0,
|
|
postalCode: void 0,
|
|
city: void 0,
|
|
province: void 0,
|
|
addressDetail: void 0
|
|
});
|
|
const setDefault = () => {
|
|
console.log("setDefault");
|
|
};
|
|
const add = () => {
|
|
common_vendor.index.navigateTo({
|
|
url: "/pages/mine/address-add"
|
|
});
|
|
};
|
|
const validateForm = () => {
|
|
if (!formData.recipientName) {
|
|
common_vendor.index.showToast({ title: "请输入收货人", icon: "none" });
|
|
return false;
|
|
}
|
|
if (!formData.phoneNumber || !/^1[3-9]\d{9}$/.test(formData.phoneNumber)) {
|
|
common_vendor.index.showToast({ title: "请输入正确的手机号", icon: "none" });
|
|
return false;
|
|
}
|
|
return true;
|
|
};
|
|
const saveApi = () => {
|
|
if (validateForm()) {
|
|
console.log("保存地址:", formData);
|
|
}
|
|
};
|
|
const addressData = common_vendor.ref([
|
|
{
|
|
name: "上官婉儿",
|
|
phone: "13800138000",
|
|
address: "北京市海淀区中关村软件园",
|
|
isDefault: false,
|
|
isCompany: true,
|
|
id: Math.random().toString(36).substring(2, 9)
|
|
},
|
|
{
|
|
name: "司空震",
|
|
phone: "13800138000",
|
|
address: "江西省吉安市吉水县东山中央首府11栋",
|
|
isDefault: true,
|
|
isHome: true,
|
|
id: Math.random().toString(36).substring(2, 9)
|
|
},
|
|
{
|
|
name: "苏烈",
|
|
phone: "13800138000",
|
|
address: "广东省深圳市南山区粤海街道109号6楼601",
|
|
isDefault: false,
|
|
id: Math.random().toString(36).substring(2, 9)
|
|
}
|
|
]);
|
|
return {
|
|
addressData,
|
|
formData,
|
|
setDefault,
|
|
add,
|
|
show,
|
|
add,
|
|
changeClick,
|
|
onsetCity,
|
|
onhideShow,
|
|
saveApi
|
|
};
|
|
}
|
|
};
|
|
if (!Array) {
|
|
const _component_JyCommonHead = common_vendor.resolveComponent("JyCommonHead");
|
|
const _component_JyAddress = common_vendor.resolveComponent("JyAddress");
|
|
const _component_JyBottomBtn = common_vendor.resolveComponent("JyBottomBtn");
|
|
const _easycom_uni_forms_item2 = common_vendor.resolveComponent("uni-forms-item");
|
|
const _easycom_uni_easyinput2 = common_vendor.resolveComponent("uni-easyinput");
|
|
const _easycom_uni_forms2 = common_vendor.resolveComponent("uni-forms");
|
|
const _component_pickRegions = common_vendor.resolveComponent("pickRegions");
|
|
const _component_JyPopup = common_vendor.resolveComponent("JyPopup");
|
|
(_component_JyCommonHead + _component_JyAddress + _component_JyBottomBtn + _easycom_uni_forms_item2 + _easycom_uni_easyinput2 + _easycom_uni_forms2 + _component_pickRegions + _component_JyPopup)();
|
|
}
|
|
const _easycom_uni_forms_item = () => "../../../uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.js";
|
|
const _easycom_uni_easyinput = () => "../../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.js";
|
|
const _easycom_uni_forms = () => "../../../uni_modules/uni-forms/components/uni-forms/uni-forms.js";
|
|
if (!Math) {
|
|
(_easycom_uni_forms_item + _easycom_uni_easyinput + _easycom_uni_forms)();
|
|
}
|
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
return {
|
|
a: common_vendor.p({
|
|
title: "收获地址",
|
|
isRight: false
|
|
}),
|
|
b: common_vendor.o$1($setup.setDefault),
|
|
c: common_vendor.p({
|
|
addressData: _ctx.listProperty.list
|
|
}),
|
|
d: common_vendor.o$1($options.openPopup),
|
|
e: $setup.formData.recipientName,
|
|
f: common_vendor.o$1(($event) => $setup.formData.recipientName = $event.detail.value),
|
|
g: common_vendor.p({
|
|
label: "收货人",
|
|
name: "recipientName"
|
|
}),
|
|
h: $setup.formData.phoneNumber,
|
|
i: common_vendor.o$1(($event) => $setup.formData.phoneNumber = $event.detail.value),
|
|
j: common_vendor.p({
|
|
label: "手机号",
|
|
name: "phoneNumber"
|
|
}),
|
|
k: $setup.formData.postalCode,
|
|
l: common_vendor.o$1(($event) => $setup.formData.postalCode = $event.detail.value),
|
|
m: common_vendor.p({
|
|
label: "邮编",
|
|
name: "postalCode"
|
|
}),
|
|
n: common_vendor.o$1((...args) => $setup.onhideShow && $setup.onhideShow(...args)),
|
|
o: $setup.formData.areas,
|
|
p: common_vendor.o$1(($event) => $setup.formData.areas = $event.detail.value),
|
|
q: common_vendor.p({
|
|
label: "地区",
|
|
name: "areas"
|
|
}),
|
|
r: common_vendor.o$1(($event) => $setup.formData.addressDetail = $event),
|
|
s: common_vendor.p({
|
|
type: "textarea",
|
|
autoHeight: true,
|
|
placeholder: "如街道,门牌号,小区,乡镇,村等",
|
|
modelValue: $setup.formData.addressDetail
|
|
}),
|
|
t: common_vendor.p({
|
|
label: "详细地址",
|
|
name: "addressDetail"
|
|
}),
|
|
v: common_vendor.p({
|
|
modelValue: $setup.formData
|
|
}),
|
|
w: common_vendor.o$1($setup.changeClick),
|
|
x: common_vendor.o$1($setup.onsetCity),
|
|
y: common_vendor.o$1($setup.onhideShow),
|
|
z: common_vendor.p({
|
|
province: $setup.add.province,
|
|
city: $setup.add.city,
|
|
area: $setup.add.area,
|
|
show: $setup.show
|
|
}),
|
|
A: common_vendor.o$1((...args) => $setup.saveApi && $setup.saveApi(...args)),
|
|
B: common_vendor.sr("addressPopup", "0f0d4de9-3"),
|
|
C: common_vendor.p({
|
|
title: "添加收货地址",
|
|
type: "center"
|
|
})
|
|
};
|
|
}
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-0f0d4de9"]]);
|
|
wx.createPage(MiniProgramPage);
|