Browse Source

Merge branch 'feature/3.1.0-小区合伙人' of ssh://gogs.1hhd.com:10022/1hjz-3N/1hjz-h5 into release/3.1.0-小区合伙人

develop
nesxy 6 years ago
parent
commit
b5567a33a3
9 changed files with 652 additions and 343 deletions
  1. 5
      src/api/chooseCommunity.js
  2. 168
      src/common/util.js
  3. 4
      src/components/nav-bottom.vue
  4. 6
      src/models/choose-community.js
  5. 119
      src/models/wxLocation.js
  6. 5
      src/models/wxShare.js
  7. 229
      src/view/choose-community.vue
  8. 395
      src/view/home.vue
  9. 64
      src/view/order-check.vue

5
src/api/chooseCommunity.js

@ -12,5 +12,8 @@ export default {
method: 'GET', method: 'GET',
url: '/mall/web/estate/query/estateList', url: '/mall/web/estate/query/estateList',
}, },
getGoodsTemlate: {
method: 'GET',
url: '/mall/web/goods/template',
},
} }

168
src/common/util.js

@ -1,69 +1,131 @@
/** /**
* Created by jerry on 2017/4/14. * Created by jerry on 2017/4/14.
*/ */
import homeApi from "../models/home-model.js";
var SIGN_REGEXP = /([yMdhsm])(\1*)/g var SIGN_REGEXP = /([yMdhsm])(\1*)/g
var DEFAULT_PATTERN = 'yyyy-MM-dd' var DEFAULT_PATTERN = 'yyyy-MM-dd'
function padding (s, len) {
let l = len - (s + '').length
for (var i = 0; i < l; i++) { s = '0' + s }
return s
function padding(s, len) {
let l = len - (s + '').length
for (var i = 0; i < l; i++) { s = '0' + s }
return s
}; };
export default { export default {
getQueryStringByName: function (name) {
var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i')
var r = window.location.search.substr(1).match(reg)
var context = ''
if (r != null) { context = r[2] }
reg = null
r = null
return context === null || context === '' || context === 'undefined' ? '' : context
},
formatDate: {
format: function (date, pattern) {
pattern = pattern || DEFAULT_PATTERN
return pattern.replace(SIGN_REGEXP, function ($0) {
switch ($0.charAt(0)) {
case 'y': return padding(date.getFullYear(), $0.length)
case 'M': return padding(date.getMonth() + 1, $0.length)
case 'd': return padding(date.getDate(), $0.length)
case 'w': return date.getDay() + 1
case 'h': return padding(date.getHours(), $0.length)
case 'm': return padding(date.getMinutes(), $0.length)
case 's': return padding(date.getSeconds(), $0.length)
}
})
getQueryStringByName: function (name) {
var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i')
var r = window.location.search.substr(1).match(reg)
var context = ''
if (r != null) { context = r[2] }
reg = null
r = null
return context === null || context === '' || context === 'undefined' ? '' : context
}, },
parse: function (dateString, pattern) {
var matchs1 = pattern.match(SIGN_REGEXP)
var matchs2 = dateString.match(/(\d)+/g)
if (matchs1.length === matchs2.length) {
var _date = new Date(1970, 0, 1)
for (var i = 0; i < matchs1.length; i++) {
var _int = parseInt(matchs2[i])
var sign = matchs1[i]
switch (sign.charAt(0)) {
case 'y': _date.setFullYear(_int); break
case 'M': _date.setMonth(_int - 1); break
case 'd': _date.setDate(_int); break
case 'h': _date.setHours(_int); break
case 'm': _date.setMinutes(_int); break
case 's': _date.setSeconds(_int); break
}
formatDate: {
format: function (date, pattern) {
pattern = pattern || DEFAULT_PATTERN
return pattern.replace(SIGN_REGEXP, function ($0) {
switch ($0.charAt(0)) {
case 'y': return padding(date.getFullYear(), $0.length)
case 'M': return padding(date.getMonth() + 1, $0.length)
case 'd': return padding(date.getDate(), $0.length)
case 'w': return date.getDay() + 1
case 'h': return padding(date.getHours(), $0.length)
case 'm': return padding(date.getMinutes(), $0.length)
case 's': return padding(date.getSeconds(), $0.length)
}
})
},
parse: function (dateString, pattern) {
var matchs1 = pattern.match(SIGN_REGEXP)
var matchs2 = dateString.match(/(\d)+/g)
if (matchs1.length === matchs2.length) {
var _date = new Date(1970, 0, 1)
for (var i = 0; i < matchs1.length; i++) {
var _int = parseInt(matchs2[i])
var sign = matchs1[i]
switch (sign.charAt(0)) {
case 'y': _date.setFullYear(_int); break
case 'M': _date.setMonth(_int - 1); break
case 'd': _date.setDate(_int); break
case 'h': _date.setHours(_int); break
case 'm': _date.setMinutes(_int); break
case 's': _date.setSeconds(_int); break
}
}
return _date
}
return null
} }
return _date
}
return null
}
},
},
}; };
export function isEmpty(val) { export function isEmpty(val) {
return ( return (
val === undefined ||
val === null ||
val === "undefined" ||
val === "")
val === undefined ||
val === null ||
val === "undefined" ||
val === "")
}
export function countPartner() {
var estateId = "";
let estateStr = localStorage.getItem("estate") || "";
if (!estateStr) {
} else {
let estateArr = estateStr.split("&");
estateId = estateArr[0];
}
if(estateId !== ""){
let keyStr = "1hjz_open_housing_log_" + estateId
let open_housing = localStorage.getItem(keyStr) || "";
if (!open_housing) {
return new Promise((resolve, reject) => {
var params = {
buryingPointType: 0,
housingEstateId: estateId,
timeStr: getTime(Date.now())
};
homeApi.countPartner(params).then(res => {
localStorage.setItem(keyStr, getTime(Date.now()))
resolve();
});
});
}else{
if(open_housing !== getTime(Date.now())){
return new Promise((resolve, reject) => {
var params = {
buryingPointType: 0,
housingEstateId: estateId,
timeStr: getTime(Date.now())
};
homeApi.countPartner(params).then(res => {
localStorage.setItem(keyStr, getTime(Date.now()))
resolve();
});
});
}
}
}
}
export function getTime(time) {
let date = new Date(time);
let year = date.getFullYear();
let month = checkTime(date.getMonth() + 1);
let day = checkTime(date.getDate());
let str = year + "-" + month + "-" + day;
return str;
}
export function checkTime(i) {
if (i < 10) {
i = "0" + i;
}
return i;
} }

4
src/components/nav-bottom.vue

@ -5,11 +5,11 @@
<img v-else src="../assets/images/icon/home-s.png"> <img v-else src="../assets/images/icon/home-s.png">
<span>首页</span> <span>首页</span>
</router-link> </router-link>
<a class="service" href="http://192.168.31.52:8080/mall/web/appoint_index">
<a class="service" href="http://test.yihaojiazheng.cn/mall/web/appoint_index">
<img src="../assets/images/icon/server.png" /> <img src="../assets/images/icon/server.png" />
<span>服务</span> <span>服务</span>
</a> </a>
<a class="user-center" href="http://192.168.31.52:8080/mall/web/owner">
<a class="user-center" href="http://test.yihaojiazheng.cn/mall/web/owner">
<img src="../assets/images/icon/my.png" /> <img src="../assets/images/icon/my.png" />
<span>我的</span> <span>我的</span>
</a> </a>

6
src/models/choose-community.js

@ -18,6 +18,12 @@ export default {
getEstateList : (params) => getEstateList : (params) =>
utilsModel utilsModel
.config(chooseCommunity.getEstateList) .config(chooseCommunity.getEstateList)
.request({
params : params,
}),
getGoodsTemlate : (params) =>
utilsModel
.config(chooseCommunity.getGoodsTemlate)
.request({ .request({
params : params, params : params,
}) })

119
src/models/wxLocation.js

@ -2,67 +2,74 @@ import Vue from "vue";
import wx from "weixin-js-sdk"; import wx from "weixin-js-sdk";
import axios from "axios"; import axios from "axios";
import wxShareModel from "../models/wxShare-model.js"; import wxShareModel from "../models/wxShare-model.js";
let instance = axios.create();
//引入BMap //引入BMap
import BMap from "BMap"; import BMap from "BMap";
Vue.prototype.wxLocation = function () { Vue.prototype.wxLocation = function () {
wxShareModel.getWXCheck().then(response =>{
if (response.code != 0) {
return;
}
var jsApiSignConfig = response.response.jsApiSignConfig;
wx.config({
debug: false, // 开启调试模式,开发时可以开启
appId: jsApiSignConfig.appId, // 必填,公众号的唯一标识 由接口返回
timestamp: jsApiSignConfig.timestamp, // 必填,生成签名的时间戳 由接口返回
nonceStr: jsApiSignConfig.nonceStr, // 必填,生成签名的随机串 由接口返回
signature: jsApiSignConfig.signature, // 必填,签名 由接口返回
jsApiList: [
'checkJsApi', 'openLocation', 'getLocation'
],
});
wx.checkJsApi({
jsApiList: ['getLocation'],
success: function (res) {
if (res.checkResult.getLocation == false) {
alert('你的微信版本太低,不支持微信JS接口,请升级到最新的微信版本!');
return;
}
return new Promise((resolve, reject) => {
wxShareModel.getWXCheck().then(response => {
if (response.code != 0) {
return;
} }
});
wx.ready(() => {
// 首次进入页面进会弹窗确认地理位置
if (localStorage.getItem("latitude") == null) {
wx.getLocation({
type: "gcj02", // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
success: function (res) {
console.log('res:'+res);
localStorage.setItem("latitude", res.latitude);
localStorage.setItem("longitude", res.longitude);
$.ajax({
url: 'http://api.map.baidu.com/geocoder/v2/?ak=a79bFu054xIbE23jlynkSXX20F9yGD4G&callback=renderReverse&location=' + res.latitude + ',' + res.longitude + '&output=json&pois=1',
type: "get",
dataType: "jsonp",
jsonp: "callback",
success: function (data) {
console.log('data:'+data);
alert('data:'+data);
}
});
},
cancel: function () {
alert("拒绝定位");
var jsApiSignConfig = response.response.jsApiSignConfig;
wx.config({
debug: false, // 开启调试模式,开发时可以开启
appId: jsApiSignConfig.appId, // 必填,公众号的唯一标识 由接口返回
timestamp: jsApiSignConfig.timestamp, // 必填,生成签名的时间戳 由接口返回
nonceStr: jsApiSignConfig.nonceStr, // 必填,生成签名的随机串 由接口返回
signature: jsApiSignConfig.signature, // 必填,签名 由接口返回
jsApiList: [
'checkJsApi', 'openLocation', 'getLocation'
],
});
wx.checkJsApi({
jsApiList: ['getLocation'],
success: function (res) {
if (res.checkResult.getLocation == false) {
alert('你的微信版本太低,不支持微信JS接口,请升级到最新的微信版本!');
return "";
} }
}
});
wx.ready(() => {
// 首次进入页面进会弹窗确认地理位置
if (localStorage.getItem("latitude") == null) {
wx.getLocation({
type: "gcj02", // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
success: function (res) {
console.log('res:' + res);
// alert('res.latitude:' + res.latitude + '------res.longitude:' + res.longitude);
// localStorage.setItem("latitude", res.latitude);
// localStorage.setItem("longitude", res.longitude);
$.ajax({
url: 'http://api.map.baidu.com/geocoder/v2/?ak=a79bFu054xIbE23jlynkSXX20F9yGD4G&callback=renderReverse&location=' + res.latitude + ',' + res.longitude + '&output=json&pois=1',
type: "get",
dataType: "jsonp",
jsonp: "callback",
success: function (data) {
// alert('data.result.location.lng:' + data.result.location.lng + '-----data.result.location.lat:' + data.result.location.lat);
localStorage.setItem("latitude", data.result.location.lat);
localStorage.setItem("longitude", data.result.location.lng);
resolve("定位成功")
}
});
},
cancel: function () {
alert("拒绝定位");
resolve("定位失败")
}
});
} else {
resolve("已经有定位")
}
// alert("lat:" + localStorage.getItem("latitude") + ";lng:" + localStorage.getItem("longitude"));
wx.error(function (res) {
alert("wx-js初始化: " + res);
resolve("定位失败")
}); });
} else {
}
alert("lat:" + localStorage.getItem("latitude") + ";lng:" + localStorage.getItem("longitude"));
wx.error(function (res) {
alert("wx-js初始化: " + res);
}); });
}); });
});
}
})
}

5
src/models/wxShare.js

@ -112,7 +112,7 @@ wxShareModel.getWXCheck().then(response =>{
localStorage.setItem("longitude", res.longitude); localStorage.setItem("longitude", res.longitude);
}, },
cancel: function () { cancel: function () {
alter("拒绝定位");
alert("拒绝定位");
} }
}); });
} else { } else {
@ -120,7 +120,8 @@ wxShareModel.getWXCheck().then(response =>{
} }
// alert("lat:" + localStorage.getItem("latitude") + ";lng:" + localStorage.getItem("longitude")); // alert("lat:" + localStorage.getItem("latitude") + ";lng:" + localStorage.getItem("longitude"));
wx.error(function (res) { wx.error(function (res) {
alter("wx-js初始化: " + res);
console.log("--------wx")
alert("wx-js初始化: " + res);
}); });
}); });
}); });

229
src/view/choose-community.vue

@ -1,55 +1,57 @@
<template> <template>
<div class="container" style="background:#fff">
<div class="top f-bb-gray">
<img src="../assets/images/icon/arrow-left.png" v-on:click="goBack" />选择小区
</div>
<!--搜索和筛选-->
<div class="f-flex f-flex-justify f-mr16 f-ml15 " style="background: #EDEDED;margin-top:5px;height: 35px;">
<div class="f-flex f-mr16 f-ml15 f-ws-nowrap" @click="show = true">
<div :class="show?'f-font-13 text-blue f-mr3':'f-font-13 f-text-666 f-mr3'">
{{defaultCity}}
</div>
<div :class="show?'triangle_border_top':'triangle_border_down'">
</div>
<form action="javascript:return true">
<div class="container" style="background:#fff">
<div class="top f-bb-gray">
<img src="../assets/images/icon/arrow-left.png" v-on:click="goBack" />选择小区
</div> </div>
<el-input style="border-left: 1px solid #c1c1c1;" placeholder="请输入小区名称" v-model="communityName" @keyup.enter.native="searchByName" @clear="clear" clearable>
<i slot="prefix" class="el-input__icon el-icon-search"></i>
</el-input>
</div>
<div class="content" style="margin-bottom: 50px;">
<div v-if="nowEstate.length > 0" style="border-bottom: 10px solid #f3f3f3;">
<div class="title">
<span class="f-ml15 f-font-14 f-text-666">当前小区</span>
</div>
<div class="f-flex f-flex-justify f-h60 f-ml15 f-mr15" style="border-bottom: 1px solid #f3f3f3;">
<div>
<div class="f-text-333 f-font-16">{{nowEstate}}</div>
<div class="f-text-666 f-font-12">{{nowAddress}}</div>
<!--搜索和筛选-->
<div class="f-flex f-flex-justify f-mr16 f-ml15 " style="background: #EDEDED;margin-top:5px;height: 35px;">
<div class="f-flex f-mr16 f-ml15 f-ws-nowrap" @click="show = true">
<div :class="show?'f-font-13 text-blue f-mr3':'f-font-13 f-text-666 f-mr3'">
{{defaultCity}}
</div>
<div :class="show?'triangle_border_top':'triangle_border_down'">
</div> </div>
<div class="f-text-666 f-font-12 "></div>
</div> </div>
<el-input type="search" style="border-left: 1px solid #c1c1c1;" placeholder="请输入小区名称" v-model="communityName" @keyup.enter.native="searchByName" @clear="clear" clearable>
<i slot="prefix" class="el-input__icon el-icon-search"></i>
</el-input>
</div> </div>
<div>
<div class="title">
<span class="f-ml15 f-font-14 f-text-666">附近小区</span>
<div class="content" style="margin-bottom: 50px;">
<div v-if="nowEstate.length > 0" style="border-bottom: 10px solid #f3f3f3;">
<div class="title">
<span class="f-ml15 f-font-14 f-text-666">当前小区</span>
</div>
<div class="f-flex f-flex-justify f-h60 f-ml15 f-mr15" style="border-bottom: 1px solid #f3f3f3;">
<div>
<div class="f-text-333 f-font-16">{{nowEstate}}</div>
<div class="f-text-666 f-font-12">{{nowAddress}}</div>
</div>
<div class="f-text-666 f-font-12 "></div>
</div>
</div> </div>
<div v-for="item in communityList" :key="item.housingEstateId" v-if="item.housingEstateId != estateId" class="f-flex f-flex-justify f-h60 f-ml15 f-mr15" style="border-bottom: 1px solid #f3f3f3;" @click="chooseCommunity(item)">
<div>
<div class="f-text-333 f-font-16">{{item.housingEstateName}}</div>
<div class="f-text-666 f-font-12">{{item.prefixAddress}}</div>
<div>
<div class="title">
<span class="f-ml15 f-font-14 f-text-666">附近小区</span>
</div>
<div v-for="item in communityList" :key="item.housingEstateId" v-if="item.housingEstateId !== estateId" class="f-flex f-flex-justify f-h60 f-ml15 f-mr15" style="border-bottom: 1px solid #f3f3f3;" @click="chooseCommunity(item)">
<div>
<div class="f-text-333 f-font-16">{{item.housingEstateName}}</div>
<div class="f-text-666 f-font-12">{{item.prefixAddress}}</div>
</div>
<div class="f-text-666 f-font-12 ">距离{{item.distance}}m</div>
</div> </div>
<div class="f-text-666 f-font-12 ">距离{{item.distance}}m</div>
</div>
<!-- 无限加载 -->
<div :class="loadMoreHide ? 'load-more-hide' : 'load-more-normal'" v-infinite-scroll="fetchCommunityList" infinite-scroll-disabled="busy" infinite-scroll-distance="10">
<span class="load-more-tips f-flex f-flex-center" v-show="!noRecords && loadMoreTips" style="padding-top:4px">没有更多了</span>
</div> </div>
</div> </div>
<!-- 无限加载 -->
<div :class="loadMoreHide ? 'load-more-hide' : 'load-more-normal'" v-infinite-scroll="fetchCommunityList" infinite-scroll-disabled="busy" infinite-scroll-distance="10">
<span class="load-more-tips f-flex f-flex-center" v-show="!noRecords && loadMoreTips" style="padding-top:4px">没有更多了</span>
</div>
<popup-picker :show="show" @cancel="cancel" @confirm="confirm" :data-list="addressData" :value="addressValue"></popup-picker>
<!-- Loading -->
<loading :show="showLoading" text="loading"></loading>
</div> </div>
<popup-picker :show="show" @cancel="cancel" @confirm="confirm" :data-list="addressData" :value="addressValue"></popup-picker>
<!-- Loading -->
<loading :show="showLoading" text="loading"></loading>
</div>
</form>
</template> </template>
<script> <script>
import myScroll from "@/utils/scroll"; import myScroll from "@/utils/scroll";
@ -58,6 +60,8 @@ import homeApi from "../models/home-model.js";
import { Alert, Toast, Loading } from "vux"; import { Alert, Toast, Loading } from "vux";
import popupPicker from "../components/popup-picker.vue"; import popupPicker from "../components/popup-picker.vue";
import chooseCommunity from "../api/chooseCommunity"; import chooseCommunity from "../api/chooseCommunity";
import { countPartner } from "@/common/util";
import { isEmpty } from "@/common/util";
export default { export default {
components: { components: {
Toast, Toast,
@ -68,6 +72,7 @@ export default {
data() { data() {
return { return {
show: false, show: false,
templateNo: this.$route.query.templateNo || "",
defaultCity: "天河区", defaultCity: "天河区",
districtId: "440106000", //id districtId: "440106000", //id
provinceId: "", provinceId: "",
@ -119,8 +124,8 @@ export default {
if (data.addressComponents) { if (data.addressComponents) {
const result = data.addressComponents; const result = data.addressComponents;
const location = { const location = {
creditLongitude: r.point.lat, //
creditLatitude: r.point.lng, //
creditLongitude: r.point.lng, //
creditLatitude: r.point.lat, //
creditProvince: result.province || "", // creditProvince: result.province || "", //
creditCity: result.city || "", // creditCity: result.city || "", //
creditArea: result.district || "", // creditArea: result.district || "", //
@ -158,20 +163,26 @@ export default {
this.$vux.toast.text("请选择一个小区", "middle"); this.$vux.toast.text("请选择一个小区", "middle");
return; return;
} }
this.$router.push({
name: "首页"
});
if (isEmpty(this.templateNo)) {
this.$router.push({
name: "首页"
});
} else {
history.go(-1);
}
}, },
// //
confirm(list) { confirm(list) {
console.log("list:" + list); console.log("list:" + list);
// let addressArr = list.split(",");
let arr = list[2].split("&") || ""; let arr = list[2].split("&") || "";
this.districtId = arr[0]; this.districtId = arr[0];
this.defaultCity = arr[1]; this.defaultCity = arr[1];
this.addressValue = list.slice(); this.addressValue = list.slice();
console.log("arr:" + this.defaultCity);
// localStorage.setItem("cityName", list); // localStorage.setItem("cityName", list);
this.show = false; this.show = false;
this.pageNum = 1;
this.pageNum = 0;
this.busy = false; this.busy = false;
this.loadMoreHide = false; this.loadMoreHide = false;
this.loadMoreTips = false; this.loadMoreTips = false;
@ -179,30 +190,10 @@ export default {
this.fetchCommunityList(); this.fetchCommunityList();
}, },
cancel() { cancel() {
let str = localStorage.getItem("cityName") || "";
//
if (!str) {
this.defaultCity = "天河区";
//
this.merchantNo = 2;
//id
this.districtId = "440106000";
this.addressValue = [
"440000000&广东省",
"440100000&广州市",
"440106000&天河区&2"
];
this.pageNum = 0;
this.busy = false;
this.loadMoreHide = false;
this.loadMoreTips = false;
this.communityList = [];
this.fetchCommunityList();
}
this.show = false; this.show = false;
}, },
clear() { clear() {
console.log("communityName11:"+this.communityName)
console.log("communityName11:" + this.communityName);
// //
this.showFlag = false; this.showFlag = false;
this.communityName = ""; this.communityName = "";
@ -211,7 +202,7 @@ export default {
this.loadMoreHide = false; this.loadMoreHide = false;
this.loadMoreTips = false; this.loadMoreTips = false;
this.communityList = []; this.communityList = [];
this.fetchCommunityList(); this.fetchCommunityList();
}, },
searchByName(event) { searchByName(event) {
@ -233,7 +224,7 @@ export default {
this.isRequesting = true; this.isRequesting = true;
//this.busy = true; //this.busy = true;
var _this = this; var _this = this;
console.log("communityName:" + this.communityName);
console.log("communityName:" + this.defaultCity);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
var params = { var params = {
pageNo: this.pageNum, pageNo: this.pageNum,
@ -270,21 +261,80 @@ export default {
}); });
}, },
chooseCommunity(item) { chooseCommunity(item) {
var addressValue = [
this.addressValue = [
item.provinceId + "&" + item.provinceName, item.provinceId + "&" + item.provinceName,
item.cityId + "&" + item.cityName, item.cityId + "&" + item.cityName,
item.districtId + "&" + item.districtName + "&" + item.merchantNo item.districtId + "&" + item.districtName + "&" + item.merchantNo
]; ];
localStorage.setItem("cityName", addressValue.slice());
localStorage.setItem(
"estate",
item.housingEstateId + "&" + item.housingEstateName
);
this.estateId = item.housingEstateId;
this.countPartner();
this.$router.push({
name: "首页"
this.$vux.confirm.show({
title: "确定选择",
content: item.cityName+item.districtName +"【" + item.housingEstateName + "】",
confirmText: "确定",
cancelText: "取消",
onCancel: () => {},
onConfirm: () => {
this.estateId = item.housingEstateId;
if (isEmpty(this.templateNo)) {
localStorage.setItem("cityName", this.addressValue.slice());
localStorage.setItem(
"estate",
item.housingEstateId + "&" + item.housingEstateName
);
this.estateId = item.housingEstateId;
countPartner();
this.$router.push({
name: "首页"
});
} else {
chooseCommunityApi
.getGoodsTemlate({
templateNo: this.templateNo,
housingEstateId: this.estateId ? this.estateId : ""
})
.then(res => {
this.showLoading = false;
if (res.code === 0) {
localStorage.setItem("cityName", this.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",
this.addressValue.slice()
);
localStorage.setItem(
"estate",
item.housingEstateId + "&" + item.housingEstateName
);
this.$router.push({
name: "首页"
});
}
});
}
})
.catch(error => {
this.showLoading = false;
});
}
}
}); });
// this.$router.push({
// name: ""
// });
}, },
ShareWenXin() { ShareWenXin() {
var merchantNo = this.merchantNo; var merchantNo = this.merchantNo;
@ -307,18 +357,7 @@ export default {
}); });
}); });
}, },
countPartner() {
return new Promise((resolve, reject) => {
var params = {
buryingPointType: 0,
housingEstateId: this.estateId,
timeStr: this.getTime(Date.now())
};
homeApi.countPartner(params).then(res => {
resolve();
});
});
},
getTime(time) { getTime(time) {
let date = new Date(time); let date = new Date(time);
let year = date.getFullYear(); let year = date.getFullYear();
@ -407,8 +446,12 @@ export default {
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.container { .container {
background-color: #fff; background-color: #fff;
-webkit-search-cancel-button{
-webkit-appearance: none!important;//×
};
.top { .top {
position: relative; position: relative;
width: 100%; width: 100%;

395
src/view/home.vue

@ -149,9 +149,10 @@ import chooseCommunityApi from "../models/choose-community";
import homeApi from "../models/home-model.js"; import homeApi from "../models/home-model.js";
import configs from "../configs"; import configs from "../configs";
import { Alert, Toast, Loading } from "vux"; import { Alert, Toast, Loading } from "vux";
import {isEmpty} from "@/common/util";
import { isEmpty } from "@/common/util";
import routerFooter from "../components/nav-bottom"; import routerFooter from "../components/nav-bottom";
import popupPicker from "../components/popup-picker.vue"; import popupPicker from "../components/popup-picker.vue";
import { countPartner } from "@/common/util";
import Qs from "qs"; import Qs from "qs";
//BMap //BMap
import BMap from "BMap"; import BMap from "BMap";
@ -170,7 +171,8 @@ export default {
show: false, show: false,
location: {}, location: {},
uniqueId: "", uniqueId: "",
defaultCity: "天河区", //
defaultDistrict: "天河区",
defaultCity: "广州市", //
defaultCommunity: "请选择小区", defaultCommunity: "请选择小区",
merchantNo: 2, // merchantNo: 2, //
districtId: "440106000", //id districtId: "440106000", //id
@ -318,11 +320,12 @@ export default {
lng: this.lng lng: this.lng
}) })
.then(res => { .then(res => {
console.log("----------getAddressInfo");
if (res.response.allAddress && res.response.userAddress) { if (res.response.allAddress && res.response.userAddress) {
this.addressData = res.response.allAddress; this.addressData = res.response.allAddress;
this.flag = true; this.flag = true;
let data = res.response; let data = res.response;
//type:1-0-1-2-
//type:-10-1-2-3-
if (data.userAddress.type == 1) { if (data.userAddress.type == 1) {
this.address = this.address =
data.userAddress.cityName + data.userAddress.cityName +
@ -331,57 +334,27 @@ export default {
: ""); : "");
this.alertShow = true; this.alertShow = true;
} else if (data.userAddress.type == 2) { } else if (data.userAddress.type == 2) {
return new Promise((resolve, reject) => {
chooseCommunityApi
.getEstateList({
draw: 0,
lat: this.lat,
lng: this.lng,
num: 1
})
.then(res => {
//
if (res.dataList.length > 0) {
var addreRes = res.dataList[0];
this.$vux.confirm.show({
title: "自动定位小区:",
content:addreRes.housingEstateName,
cancelText: "切换地址",
onCancel: () => {
this.chooseCommunity();
},
onConfirm: () => {
this.defaultLocalEstate(addreRes);
this.getGoodsList();
}
});
}else{
this.$vux.confirm.show({
title: "自动定位地址:",
content:
data.userAddress.cityName +
(data.userAddress.districtName
? data.userAddress.districtName
: ""),
confirmText: "选择小区",
cancelText: "切换地址",
onCancel: () => {
this.chooseCommunity();
},
onConfirm: () => {
this.defaultLocalEstate(data.estateInfo);
this.chooseCommunity();
}
});
}
this.showLoading = false;
})
.catch(error => {
this.showLoading = false;
});
this.showLoading = false;
this.$vux.confirm.show({
title: "自动定位小区",
content:
data.estateInfo.cityName +
data.estateInfo.districtName +
"【" +
data.estateInfo.housingEstateName +
"】",
cancelText: "切换",
onCancel: () => {
this.chooseCommunity();
},
onConfirm: () => {
this.defaultLocalEstate(data.estateInfo);
this.getGoodsList();
}
}); });
} else if (data.userAddress.type == 0) { } else if (data.userAddress.type == 0) {
this.getGoodsList(); this.getGoodsList();
countPartner();
} else if (data.userAddress.type == -1) { } else if (data.userAddress.type == -1) {
// this.state = -1; // this.state = -1;
this.$vux.alert.show({ this.$vux.alert.show({
@ -391,6 +364,20 @@ export default {
this.chooseCommunity(); this.chooseCommunity();
} }
}); });
} else if (data.userAddress.type == 3) {
localStorage.removeItem("estate");
this.$vux.alert.show({
title:
this.defaultCity +
this.defaultDistrict +
"【" +
this.defaultCommunity +
"】",
content: "暂无开通服务",
onHide: () => {
this.chooseCommunity();
}
});
} }
resolve(); resolve();
} }
@ -411,9 +398,10 @@ export default {
this.addressValue = arr; this.addressValue = arr;
this.provinceId = arr[0].split("&")[0]; this.provinceId = arr[0].split("&")[0];
this.cityId = arr[1].split("&")[0]; this.cityId = arr[1].split("&")[0];
let cityNameArr = arr[2].split("&");
this.districtId = cityNameArr[0];
this.defaultCity = cityNameArr[1];
this.defaultCity = arr[1].split("&")[1];
let districtArr = arr[2].split("&");
this.districtId = districtArr[0];
this.defaultDistrict = districtArr[1];
// this.merchantNo = cityNameArr[2]; // this.merchantNo = cityNameArr[2];
this.merchantNo = 2; this.merchantNo = 2;
} }
@ -426,6 +414,7 @@ export default {
}, },
getData() { getData() {
let get = async () => { let get = async () => {
this.getId();
await this.getAddressInfo(); await this.getAddressInfo();
// await this.getGoodsList(); // await this.getGoodsList();
}; };
@ -439,61 +428,112 @@ export default {
// //
var ua = window.navigator.userAgent.toLowerCase(); var ua = window.navigator.userAgent.toLowerCase();
//uaMicroMessenger //uaMicroMessenger
let _this = this;
if (ua.match(/MicroMessenger/i) == "micromessenger") { if (ua.match(/MicroMessenger/i) == "micromessenger") {
// //
this.wxLocation({});
this.wxLocation().then(result => {
console.log("wxLocationresult:" + result);
this.getId();
this.getAddressInfo();
});
} else { } else {
// TODO api // TODO api
this.getCity(); this.getCity();
} }
}, },
getCity() { getCity() {
let _this = this; let _this = this;
var geolocation = new BMap.Geolocation(); var geolocation = new BMap.Geolocation();
geolocation.getCurrentPosition(function(r) { geolocation.getCurrentPosition(function(r) {
if (this.getStatus() == BMAP_STATUS_SUCCESS) { if (this.getStatus() == BMAP_STATUS_SUCCESS) {
// if(r.accuracy==null){
var lat = r.point.lat;
var lng = r.point.lng;
const pointBak = new BMap.Point(lng, lat);
const convertor = new BMap.Convertor();
convertor.translate([pointBak], 1, 5, function(resPoint) {
if (resPoint && resPoint.points && resPoint.points.length > 0) {
console.log("resPoint:"+resPoint.points[0]);
lng = resPoint.points[0].lng;
lat = resPoint.points[0].lat;
}
const point = new BMap.Point(lng, lat);
const geo = new BMap.Geocoder();
geo.getLocation(point, res => {
if (res.addressComponents) {
const result = res.addressComponents;
const location = {
creditLongitude: point.lng, //
creditLatitude: point.lat, //
creditProvince: result.province || "", //
creditCity: result.city || "", //
creditArea: result.district || "", //
creditStreet:
(result.street || "") + (result.streetNumber || "") //
};
_this.location = location;
localStorage.setItem("latitude", location.creditLatitude);
localStorage.setItem("longitude", location.creditLongitude);
_this.lat = location.creditLatitude;
_this.lng = location.creditLongitude;
alert(
"省-" +
location.creditProvince +
";市-" +
location.creditCity +
";区-" +
location.creditArea +
";街道-" +
location.creditStreet +
";lat-" +
location.creditLatitude +
";lng-" +
location.creditLongitude
);
_this.getId();
_this.getAddressInfo();
}
});
});
// alert(''); // alert('');
// // // //
// return; // return;
// }else{ // }else{
const myGeo = new BMap.Geocoder();
myGeo.getLocation(new BMap.Point(r.point.lng, r.point.lat), data => {
if (data.addressComponents) {
const result = data.addressComponents;
const location = {
creditLongitude: r.point.lat, //
creditLatitude: r.point.lng, //
creditProvince: result.province || "", //
creditCity: result.city || "", //
creditArea: result.district || "", //
creditStreet:
(result.street || "") + (result.streetNumber || "") //
};
_this.location = location;
localStorage.setItem("latitude", location.creditLatitude);
localStorage.setItem("longitude", location.creditLongitude);
_this.lat = location.creditLatitude;
_this.lng = location.creditLongitude;
// alert(
// "-" +
// location.creditProvince +
// ";-" +
// location.creditCity +
// ";-" +
// location.creditArea +
// ";-" +
// location.creditStreet +
// ";lat-" +
// location.creditLatitude +
// ";lng-" +
// location.creditLongitude
// );
}
});
// const myGeo = new BMap.Geocoder();
// myGeo.getLocation(new BMap.Point(r.point.lng, r.point.lat), data => {
// if (data.addressComponents) {
// const result = data.addressComponents;
// const location = {
// creditLongitude: r.point.lng, //
// creditLatitude: r.point.lat, //
// creditProvince: result.province || "", //
// creditCity: result.city || "", //
// creditArea: result.district || "", //
// creditStreet:
// (result.street || "") + (result.streetNumber || "") //
// };
// _this.location = location;
// localStorage.setItem("latitude", location.creditLatitude);
// localStorage.setItem("longitude", location.creditLongitude);
// _this.lat = location.creditLatitude;
// _this.lng = location.creditLongitude;
// alert(
// "-" +
// location.creditProvince +
// ";-" +
// location.creditCity +
// ";-" +
// location.creditArea +
// ";-" +
// location.creditStreet +
// ";lat-" +
// location.creditLatitude +
// ";lng-" +
// location.creditLongitude
// );
// _this.getId();
// _this.getAddressInfo();
// }
// });
// } // }
} }
}); });
@ -503,12 +543,15 @@ export default {
? estateRes.provinceId ? estateRes.provinceId
: this.provinceId; : this.provinceId;
this.cityId = estateRes.cityId ? estateRes.cityId : this.cityId; this.cityId = estateRes.cityId ? estateRes.cityId : this.cityId;
this.cityName = estateRes.cityName
? estateRes.cityName
: this.defaultCity;
this.districtId = estateRes.districtId this.districtId = estateRes.districtId
? estateRes.districtId ? estateRes.districtId
: this.districtId; : this.districtId;
this.defaultCity = estateRes.districtName
this.defaultDistrict = estateRes.districtName
? estateRes.districtName ? estateRes.districtName
: this.defaultCity;
: this.defaultDistrict;
this.merchantNo = estateRes.merchantNo; this.merchantNo = estateRes.merchantNo;
this.addressValue = [ this.addressValue = [
this.provinceId + "&" + estateRes.provinceName, this.provinceId + "&" + estateRes.provinceName,
@ -526,22 +569,33 @@ export default {
this.defaultCommunity = estateRes.housingEstateName this.defaultCommunity = estateRes.housingEstateName
? estateRes.housingEstateName ? estateRes.housingEstateName
: this.defaultCommunity; : this.defaultCommunity;
if(!isEmpty(this.estateId)){
localStorage.setItem("estate",this.estateId + "&" + this.defaultCommunity);
}
if (!isEmpty(this.estateId)) {
localStorage.setItem(
"estate",
this.estateId + "&" + this.defaultCommunity
);
countPartner();
}
} }
}, },
mounted() {
mounted() {
// //
// this.getdefaultAddress(); // this.getdefaultAddress();
// this.getAddress(); // this.getAddress();
// this.getLocation(); // this.getLocation();
// this.$vux.confirm.show({
// content: "",
// confirmText: "",
// onConfirm: () => {}
// });
this.getId(); this.getId();
let eId = this.$route.query.estateId; let eId = this.$route.query.estateId;
if (!isEmpty(eId) ) {
console.log("eId----" + eId + "estateId---" + this.estateId);
if (!isEmpty(eId)) {
if (!isEmpty(this.estateId)) { if (!isEmpty(this.estateId)) {
//
this.showLoading = true; this.showLoading = true;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
chooseCommunityApi chooseCommunityApi
@ -551,10 +605,76 @@ mounted() {
.then(res => { .then(res => {
if (isEmpty(res.response)) { if (isEmpty(res.response)) {
// //
this.estateId = eId;
this.getData();
localStorage.removeItem("estate");
if (eId !== this.estateId) {
//
chooseCommunityApi
.getEstateInfo({
estateId: eId ? eId : ""
})
.then(res => {
this.showLoading = false;
if (isEmpty(res.response)) {
//
this.$vux.alert.show({
title:
this.defaultCity +
this.defaultDistrict +
"【" +
this.defaultCommunity +
"】",
content: "暂无开通服务",
onHide: () => {
this.chooseCommunity();
}
});
} else {
//
var linkEstate = res.response;
this.$vux.confirm.show({
title: "当前小区",
content:
linkEstate.cityName +
linkEstate.districtName +
"【" +
linkEstate.housingEstateName +
"】",
confirmText: "切换",
cancelText: "确定",
onCancel: () => {
this.defaultLocalEstate(linkEstate);
},
onConfirm: () => {
this.chooseCommunity();
}
});
}
})
.catch(error => {
this.showLoading = false;
});
} else {
this.$vux.alert.show({
title:
this.defaultCity +
this.defaultDistrict +
"【" +
this.defaultCommunity +
"】",
content: "暂无开通服务",
onHide: () => {
this.chooseCommunity();
}
});
}
} else { } else {
var loclEstate = res.response; var loclEstate = res.response;
if (eId === this.estateId) {
this.showLoading = false;
this.getGoodsList();
countPartner();
return;
}
//, //,
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
chooseCommunityApi chooseCommunityApi
@ -565,20 +685,33 @@ mounted() {
this.showLoading = false; this.showLoading = false;
if (isEmpty(res.response)) { if (isEmpty(res.response)) {
// //
this.defaultLocalEstate(loclEstate);
this.getGoodsList();
countPartner();
} else { } else {
// //
var linkEstate = res.response; var linkEstate = res.response;
this.$vux.confirm.show({ this.$vux.confirm.show({
title: "切换小区",
content: linkEstate.housingEstateName,
content:
"当前小区为:" +
this.defaultCity +
this.defaultDistrict +
"【" +
this.defaultCommunity +
"】,是否切换为:" +
linkEstate.cityName +
linkEstate.districtName +
"【" +
linkEstate.housingEstateName +
"】",
confirmText: "不切换", confirmText: "不切换",
cancelText: "切换",
cancelText: "确定",
onCancel: () => { onCancel: () => {
this.chooseCommunity();
this.defaultLocalEstate(linkEstate);
this.getGoodsList();
countPartner();
}, },
onConfirm: () => { onConfirm: () => {
this.defaultLocalEstate(linkEstate);
this.getGoodsList();
} }
}); });
} }
@ -595,12 +728,49 @@ mounted() {
}); });
}); });
} else { } else {
this.estateId = eId;
this.getData();
// this.estateId = eId;
// this.getData();
//
chooseCommunityApi
.getEstateInfo({
estateId: eId ? eId : ""
})
.then(res => {
this.showLoading = false;
if (isEmpty(res.response)) {
//
this.chooseCommunity();
} else {
//
var linkEstate = res.response;
this.$vux.confirm.show({
title: "当前小区",
content:
linkEstate.cityName +
linkEstate.districtName +
"【" +
linkEstate.housingEstateName +
"】",
confirmText: "切换",
cancelText: "确定",
onCancel: () => {
this.defaultLocalEstate(linkEstate);
this.getGoodsList();
countPartner();
},
onConfirm: () => {
this.chooseCommunity();
}
});
}
})
.catch(error => {
this.showLoading = false;
});
} }
} else { } else {
//this.getData();
this.getLocation(); this.getLocation();
this.getData();
} }
var uuniqueId = this.$route.query.uniqueId; var uuniqueId = this.$route.query.uniqueId;
@ -653,6 +823,7 @@ mounted() {
background-color: rgba(255, 255, 255, 1); background-color: rgba(255, 255, 255, 1);
} }
.weui-dialog__hd { .weui-dialog__hd {
margin-top: 10px;
padding: 0; padding: 0;
} }
</style> </style>

64
src/view/order-check.vue

@ -14,10 +14,17 @@
<div class="goods-container"> <div class="goods-container">
<img :src="imghost+info.goodsImgUrl"> <img :src="imghost+info.goodsImgUrl">
<div class="goods-main-container"> <div class="goods-main-container">
<div class="name">{{info.goodsName}}</div>
<div class="title-box">
<div class="name">{{info.goodsName}}</div>
<div class="name">¥{{info.totalPrice?info.totalPrice/100:''}}</div>
</div>
<div class="box"> <div class="box">
<div class="box-text">{{info.shortDesc}}</div> <div class="box-text">{{info.shortDesc}}</div>
<div class="box-price">¥{{info.totalPrice?info.totalPrice/100:''}}</div>
<div class="box-num">
<el-input-number v-model="num" :min="1" :max="99"></el-input-number>
</div>
<!-- <div class="box-price">¥{{info.totalPrice?info.totalPrice/100:''}}</div> -->
</div> </div>
<div class="tag-box"> <div class="tag-box">
<i class="tag" v-for="item in labelList" v-if="item.labelText">{{item.labelText}}</i> <i class="tag" v-for="item in labelList" v-if="item.labelText">{{item.labelText}}</i>
@ -93,6 +100,7 @@
<script> <script>
import backHeader from "../components/back-header.vue"; import backHeader from "../components/back-header.vue";
import orderApi from "../models/order-model.js"; import orderApi from "../models/order-model.js";
import { InlineXNumber } from "vux";
var qs = require("qs"); var qs = require("qs");
import Qs from "qs"; import Qs from "qs";
export default { export default {
@ -102,17 +110,19 @@ export default {
text: "" text: ""
}, },
agree: false, agree: false,
goodsNo: ""
goodsNo: "",
num: 1
}; };
}, },
components: { components: {
"back-header": backHeader
"back-header": backHeader,
InlineXNumber
}, },
computed: { computed: {
price() { price() {
let price = this.info.payPrice; let price = this.info.payPrice;
let discount = this.info.primeCoupon ? this.info.primeCoupon.amount : 0; let discount = this.info.primeCoupon ? this.info.primeCoupon.amount : 0;
return price / 100 - discount / 100;
return price*this.num / 100 - discount / 100;
}, },
labelList() { labelList() {
let str = this.info.smallLabel; let str = this.info.smallLabel;
@ -240,6 +250,7 @@ export default {
goodsNo: goodsNo, goodsNo: goodsNo,
couponNo: couponNo, couponNo: couponNo,
goodsVersion: goodsVersion, goodsVersion: goodsVersion,
goodsNum:this.num,
salesmanUniqueIdentity: this.$cookies.get("1hjz_mall_unique_id"), salesmanUniqueIdentity: this.$cookies.get("1hjz_mall_unique_id"),
housingEstateId: estateId, housingEstateId: estateId,
remark: this.info.text remark: this.info.text
@ -295,6 +306,9 @@ export default {
.top { .top {
margin-bottom: 0.18rem; margin-bottom: 0.18rem;
} }
.el-input-number {
width: 120px;
}
.item-top { .item-top {
height: 0.65rem; height: 0.65rem;
width: 100%; width: 100%;
@ -340,11 +354,10 @@ export default {
.goods-container { .goods-container {
width: 100%; width: 100%;
color: #333; color: #333;
height: 1.6rem;
background-color: white; background-color: white;
display: flex; display: flex;
box-sizing: border-box; box-sizing: border-box;
padding: 0.16rem 0.37rem 0rem 0.22rem;
padding: 0.16rem 0.37rem 0.22rem 0.22rem;
img { img {
width: 1.28rem; width: 1.28rem;
height: 1.28rem; height: 1.28rem;
@ -355,20 +368,26 @@ export default {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
padding-top: 0.06rem; padding-top: 0.06rem;
.name {
line-height: 1.2;
font-size: 0.3rem;
text-overflow: ellipsis;
overflow: hidden;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;
word-wrap: break-word;
// margin-top: 0.1rem;
white-space: normal;
word-break: break-all;
margin-bottom: 0.15rem;
.title-box {
display: flex;
justify-content: space-between;
align-items: flex-end;
.name {
line-height: 1.2;
font-size: 0.3rem;
text-overflow: ellipsis;
overflow: hidden;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;
word-wrap: break-word;
// margin-top: 0.1rem;
white-space: normal;
word-break: break-all;
margin-bottom: 0.15rem;
}
} }
.box { .box {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
@ -376,20 +395,17 @@ export default {
margin-bottom: 0.15rem; margin-bottom: 0.15rem;
.box-text { .box-text {
font-size: 0.24rem; font-size: 0.24rem;
line-height: 1.1;
text-overflow: ellipsis; text-overflow: ellipsis;
overflow: hidden; overflow: hidden;
display: -webkit-box; display: -webkit-box;
-webkit-box-orient: vertical; -webkit-box-orient: vertical;
-webkit-line-clamp: 1;
word-wrap: break-word; word-wrap: break-word;
white-space: normal; white-space: normal;
word-break: break-all; word-break: break-all;
color: #999; color: #999;
height: 0.24rem;
margin-right: 0.2rem; margin-right: 0.2rem;
} }
.box-price {
.box-num {
line-height: 1; line-height: 1;
font-weight: 400; font-weight: 400;
font-size: 0.38rem; font-size: 0.38rem;

Loading…
Cancel
Save