From 4ebde40ed73130c4b3d08ed7f208517e3201f2a6 Mon Sep 17 00:00:00 2001 From: lfs3 Date: Fri, 30 Aug 2019 20:50:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E4=BA=AB=E5=95=86=E5=93=81=E5=AF=B9?= =?UTF-8?q?=E5=BA=94=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/models/choose-community.js | 6 +++ src/view/choose-community.vue | 92 +++++++++++++++++++++++++++------- src/view/home.vue | 1 + 3 files changed, 80 insertions(+), 19 deletions(-) diff --git a/src/models/choose-community.js b/src/models/choose-community.js index 86de4b9..f1b3bae 100644 --- a/src/models/choose-community.js +++ b/src/models/choose-community.js @@ -18,6 +18,12 @@ export default { getEstateList : (params) => utilsModel .config(chooseCommunity.getEstateList) + .request({ + params : params, + }), + getGoodsTemlate : (params) => + utilsModel + .config(chooseCommunity.getGoodsTemlate) .request({ params : params, }) diff --git a/src/view/choose-community.vue b/src/view/choose-community.vue index 5acdb63..6e2c86f 100644 --- a/src/view/choose-community.vue +++ b/src/view/choose-community.vue @@ -12,7 +12,7 @@
- + @@ -59,6 +59,8 @@ import { Alert, Toast, Loading } from "vux"; import popupPicker from "../components/popup-picker.vue"; import chooseCommunity from "../api/chooseCommunity"; import { countPartner } from "@/common/util"; +import { isEmpty } from "@/common/util"; +import { exists } from "fs"; export default { components: { Toast, @@ -69,6 +71,7 @@ export default { data() { return { show: false, + templateNo: this.$route.query.templateNo || "", defaultCity: "天河区", districtId: "440106000", //区id 默认值 不需要去掉 provinceId: "", @@ -159,10 +162,10 @@ export default { this.$vux.toast.text("请选择一个小区", "middle"); return; } - history.go(-1) - // this.$router.push({ - // name: "首页" - // }); + history.go(-1); + // this.$router.push({ + // name: "首页" + // }); }, //确定时保存记录 confirm(list) { @@ -204,7 +207,7 @@ export default { this.show = false; }, clear() { - console.log("communityName11:"+this.communityName) + console.log("communityName11:" + this.communityName); // 清除搜索条件 this.showFlag = false; this.communityName = ""; @@ -213,7 +216,7 @@ export default { this.loadMoreHide = false; this.loadMoreTips = false; this.communityList = []; - + this.fetchCommunityList(); }, searchByName(event) { @@ -277,17 +280,68 @@ export default { item.cityId + "&" + item.cityName, item.districtId + "&" + item.districtName + "&" + item.merchantNo ]; - localStorage.setItem("cityName", addressValue.slice()); - localStorage.setItem( - "estate", - item.housingEstateId + "&" + item.housingEstateName - ); - this.estateId = item.housingEstateId; - countPartner(); - history.go(-1) - // this.$router.push({ - // name: "首页" - // }); + if (isEmpty(this.templateNo)) { + localStorage.setItem("cityName", addressValue.slice()); + localStorage.setItem( + "estate", + item.housingEstateId + "&" + item.housingEstateName + ); + this.estateId = item.housingEstateId; + countPartner(); + history.go(-1); + } else { + this.$vux.confirm.show({ + title: "选择小区", + content: "确定选择" + item.housingEstateName, + confirmText: "确定", + cancelText: "取消", + onCancel: () => {}, + onConfirm: () => { + this.estateId = item.housingEstateId; + chooseCommunityApi + .getGoodsTemlate({ + templateNo: this.templateNo, + housingEstateId: this.estateId ? this.estateId : "" + }) + .then(res => { + this.showLoading = false; + if (res.code === 0) { + localStorage.setItem("cityName", addressValue.slice()); + localStorage.setItem( + "estate", + item.housingEstateId + "&" + item.housingEstateName + ); + countPartner(); + //存在商品 + window.location.href = + "/mall/web/vgoods/detail/" + res.response.goodsNo; + } else { + this.$vux.confirm.show({ + title: "无服务", + content: item.housingEstateName + "暂无提供此商品服务", + confirmText: "确定", + onConfirm: () => { + localStorage.setItem("cityName", addressValue.slice()); + localStorage.setItem( + "estate", + item.housingEstateId + "&" + item.housingEstateName + ); + this.$router.push({ + name: "首页" + }); + } + }); + } + }) + .catch(error => { + this.showLoading = false; + }); + } + }); + } + // this.$router.push({ + // name: "首页" + // }); }, ShareWenXin() { var merchantNo = this.merchantNo; @@ -310,7 +364,7 @@ export default { }); }); }, - + getTime(time) { let date = new Date(time); let year = date.getFullYear(); diff --git a/src/view/home.vue b/src/view/home.vue index 81f0a0b..f8073c4 100644 --- a/src/view/home.vue +++ b/src/view/home.vue @@ -553,6 +553,7 @@ mounted() { .then(res => { if (isEmpty(res.response)) { //本地小区无效 + localStorage.removeItem("estate") this.estateId = eId; this.getData(); } else {