diff --git a/src/api/chooseCommunity.js b/src/api/chooseCommunity.js index 00c91b7..99c9626 100644 --- a/src/api/chooseCommunity.js +++ b/src/api/chooseCommunity.js @@ -12,5 +12,8 @@ export default { method: 'GET', url: '/mall/web/estate/query/estateList', }, - + getGoodsTemlate: { + method: 'GET', + url: '/mall/web/goods/template', + }, } \ No newline at end of file diff --git a/src/common/util.js b/src/common/util.js index af8a178..666753d 100644 --- a/src/common/util.js +++ b/src/common/util.js @@ -1,69 +1,131 @@ /** * Created by jerry on 2017/4/14. */ +import homeApi from "../models/home-model.js"; var SIGN_REGEXP = /([yMdhsm])(\1*)/g 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 { - 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) { 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; } diff --git a/src/components/nav-bottom.vue b/src/components/nav-bottom.vue index 0bf467a..48e81b0 100644 --- a/src/components/nav-bottom.vue +++ b/src/components/nav-bottom.vue @@ -5,11 +5,11 @@ 首页 - + 服务 - + 我的 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/models/wxLocation.js b/src/models/wxLocation.js index 9976dda..492ff2c 100644 --- a/src/models/wxLocation.js +++ b/src/models/wxLocation.js @@ -2,67 +2,74 @@ import Vue from "vue"; import wx from "weixin-js-sdk"; import axios from "axios"; import wxShareModel from "../models/wxShare-model.js"; +let instance = axios.create(); //引入BMap import BMap from "BMap"; - 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); }); }); - }); - - } - \ No newline at end of file + }) + +} + diff --git a/src/models/wxShare.js b/src/models/wxShare.js index 8743ccb..e32aaf4 100644 --- a/src/models/wxShare.js +++ b/src/models/wxShare.js @@ -112,7 +112,7 @@ wxShareModel.getWXCheck().then(response =>{ localStorage.setItem("longitude", res.longitude); }, cancel: function () { - alter("拒绝定位"); + alert("拒绝定位"); } }); } else { @@ -120,7 +120,8 @@ wxShareModel.getWXCheck().then(response =>{ } // alert("lat:" + localStorage.getItem("latitude") + ";lng:" + localStorage.getItem("longitude")); wx.error(function (res) { - alter("wx-js初始化: " + res); + console.log("--------wx") + alert("wx-js初始化: " + res); }); }); }); diff --git a/src/view/choose-community.vue b/src/view/choose-community.vue index 4e79329..3bcb0a3 100644 --- a/src/view/choose-community.vue +++ b/src/view/choose-community.vue @@ -1,55 +1,57 @@ - - - 选择小区 - - - - - - {{defaultCity}} - - - + + + + 选择小区 - - - - - - - - 当前小区 - - - - {{nowEstate}} - {{nowAddress}} + + + + + {{defaultCity}} + + - + + + - - - 附近小区 + + + + 当前小区 + + + + {{nowEstate}} + {{nowAddress}} + + + - - - {{item.housingEstateName}} - {{item.prefixAddress}} + + + 附近小区 + + + + {{item.housingEstateName}} + {{item.prefixAddress}} + + 距离{{item.distance}}m - 距离{{item.distance}}m + + + + 没有更多了 - - - 没有更多了 - + + + - - - - + diff --git a/src/view/order-check.vue b/src/view/order-check.vue index 33aecc3..961f5eb 100644 --- a/src/view/order-check.vue +++ b/src/view/order-check.vue @@ -14,10 +14,17 @@ - {{info.goodsName}} + + {{info.goodsName}} + ¥{{info.totalPrice?info.totalPrice/100:''}} + {{info.shortDesc}} - ¥{{info.totalPrice?info.totalPrice/100:''}} + + + + + {{item.labelText}} @@ -93,6 +100,7 @@