aa
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
|
||||
/* 弹出城市选择页面 */
|
||||
$(document).on("click",".open-about01", function () {
|
||||
$("input").blur()
|
||||
$("#citySearchInp").val("");
|
||||
$("#selectContainer").hide();
|
||||
$.popup(".popup-about01");
|
||||
$("p.close-popup").removeClass("collectionCity");
|
||||
$("p.close-popup").removeClass("active");
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url:BASE_PATH+"/quotations/loadCollectCitys",
|
||||
dataType:'json',
|
||||
success: function(data) {
|
||||
|
||||
var collects = data.collects;
|
||||
|
||||
$("p.close-popup").each(function(){
|
||||
var text = $(this).text();
|
||||
//设置关注城市
|
||||
if(collects){
|
||||
if(collects.indexOf(text)>-1){
|
||||
$(this).addClass("collectionCity");
|
||||
$(this).find("i").addClass("icon-collection03");
|
||||
}
|
||||
}
|
||||
|
||||
//设置当前城市选中
|
||||
if(typeof(curCity)!="undefined"){
|
||||
if(curCity && text == curCity){
|
||||
$(this).addClass("active");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
/* 定位城市 */
|
||||
$("body").on("click", ".letter a", function () {
|
||||
var s = $(this).html();
|
||||
$(".popup-about01 .content").scrollTop(0);
|
||||
$(".popup-about01 .content").scrollTop($("#" + s + "1").offset().top - 106);
|
||||
});
|
||||
$("#tabCity1 .content-block01").scroll(function () {
|
||||
$("#tabCity1 .content-block01 .letter").css("position","absolute");
|
||||
$("#tabCity1 .content-block01 .letter").css("top", 85 - $("#cityContainer").position().top);
|
||||
});
|
||||
|
||||
/* 获取城市 */
|
||||
$(".popup-about01 .cityGPS").on("click", function () {
|
||||
$("#input_city").val($(this).find("p").text());
|
||||
$(".cityChoice a").text($(this).find("p").text());
|
||||
$(".popup-about01 p").removeClass("active");
|
||||
});
|
||||
$(".popup-about01 p").on("click", function () {
|
||||
$("#input_city").val($(this).text());
|
||||
$(".cityChoice a").text($(this).text());
|
||||
$(".popup-about01 p").removeClass("active");
|
||||
$(this).addClass("active");
|
||||
});
|
||||
function req(city){
|
||||
city=city.replace("<i></i>","")
|
||||
$("#input_city").text(city);
|
||||
potenialIndex(city);
|
||||
}
|
||||
//城市选择
|
||||
//$("#cityCopy").html($('.tabs').html())
|
||||
var getAllCitys = function() {
|
||||
var list = new Array();
|
||||
$("#tabCity1 #cityContainer .city p").each(function(i, o) {
|
||||
list.push($(o).text());
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
var search = function(){
|
||||
var city = $("#citySearchInp").val();
|
||||
$("#selectContainer .city-list").empty();
|
||||
$("#selectContainer").show();
|
||||
|
||||
var cityList = getAllCitys();
|
||||
for(var i=0;i<cityList.length;i++) {
|
||||
if(cityList[i].indexOf(city) != -1){
|
||||
$("#selectContainer .city-list").append("<p class='close-popup' onclick=\"req('"+cityList[i]+"')\">"+cityList[i]+"</p>");
|
||||
}
|
||||
}
|
||||
|
||||
if(city == ""){
|
||||
$("#selectContainer").hide();
|
||||
}
|
||||
}
|
||||
|
||||
function req(city){
|
||||
city=city.replace("<i></i>","")
|
||||
$("#input_city").val(city);
|
||||
potenialIndex(city);
|
||||
}
|
||||
|
||||
$("#citySearchInp").bind('input propertychange keyup', function() {
|
||||
search();
|
||||
});
|
||||
|
||||
$("#citySearchInp").bind('keyup', function() {
|
||||
search();
|
||||
});
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,117 @@
|
||||
/*!
|
||||
* jQuery Cookie Plugin v1.4.1
|
||||
* https://github.com/carhartl/jquery-cookie
|
||||
*
|
||||
* Copyright 2013 Klaus Hartl
|
||||
* Released under the MIT license
|
||||
*/
|
||||
(function (factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD
|
||||
define(['jquery'], factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
// CommonJS
|
||||
factory(require('jquery'));
|
||||
} else {
|
||||
// Browser globals
|
||||
factory(jQuery);
|
||||
}
|
||||
}(function ($) {
|
||||
|
||||
var pluses = /\+/g;
|
||||
|
||||
function encode(s) {
|
||||
return config.raw ? s : encodeURIComponent(s);
|
||||
}
|
||||
|
||||
function decode(s) {
|
||||
return config.raw ? s : decodeURIComponent(s);
|
||||
}
|
||||
|
||||
function stringifyCookieValue(value) {
|
||||
return encode(config.json ? JSON.stringify(value) : String(value));
|
||||
}
|
||||
|
||||
function parseCookieValue(s) {
|
||||
if (s.indexOf('"') === 0) {
|
||||
// This is a quoted cookie as according to RFC2068, unescape...
|
||||
s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
|
||||
}
|
||||
|
||||
try {
|
||||
// Replace server-side written pluses with spaces.
|
||||
// If we can't decode the cookie, ignore it, it's unusable.
|
||||
// If we can't parse the cookie, ignore it, it's unusable.
|
||||
s = decodeURIComponent(s.replace(pluses, ' '));
|
||||
return config.json ? JSON.parse(s) : s;
|
||||
} catch(e) {}
|
||||
}
|
||||
|
||||
function read(s, converter) {
|
||||
var value = config.raw ? s : parseCookieValue(s);
|
||||
return $.isFunction(converter) ? converter(value) : value;
|
||||
}
|
||||
|
||||
var config = $.cookie = function (key, value, options) {
|
||||
|
||||
// Write
|
||||
|
||||
if (value !== undefined && !$.isFunction(value)) {
|
||||
options = $.extend({}, config.defaults, options);
|
||||
|
||||
if (typeof options.expires === 'number') {
|
||||
var days = options.expires, t = options.expires = new Date();
|
||||
t.setTime(+t + days * 864e+5);
|
||||
}
|
||||
|
||||
return (document.cookie = [
|
||||
encode(key), '=', stringifyCookieValue(value),
|
||||
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
|
||||
options.path ? '; path=' + options.path : '',
|
||||
options.domain ? '; domain=' + options.domain : '',
|
||||
options.secure ? '; secure' : ''
|
||||
].join(''));
|
||||
}
|
||||
|
||||
// Read
|
||||
|
||||
var result = key ? undefined : {};
|
||||
|
||||
// To prevent the for loop in the first place assign an empty array
|
||||
// in case there are no cookies at all. Also prevents odd result when
|
||||
// calling $.cookie().
|
||||
var cookies = document.cookie ? document.cookie.split('; ') : [];
|
||||
|
||||
for (var i = 0, l = cookies.length; i < l; i++) {
|
||||
var parts = cookies[i].split('=');
|
||||
var name = decode(parts.shift());
|
||||
var cookie = parts.join('=');
|
||||
|
||||
if (key && key === name) {
|
||||
// If second argument (value) is a function it's a converter...
|
||||
result = read(cookie, value);
|
||||
break;
|
||||
}
|
||||
|
||||
// Prevent storing a cookie that we couldn't decode.
|
||||
if (!key && (cookie = read(cookie)) !== undefined) {
|
||||
result[name] = cookie;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
config.defaults = {};
|
||||
|
||||
$.removeCookie = function (key, options) {
|
||||
if ($.cookie(key) === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Must not alter options, thus extending a fresh object...
|
||||
$.cookie(key, '', $.extend({}, options, { expires: -1 }));
|
||||
return !$.cookie(key);
|
||||
};
|
||||
|
||||
}));
|
||||
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* 推送处理业务逻辑
|
||||
* yinjihuan
|
||||
*/
|
||||
document.addEventListener("plusready", function() {
|
||||
message = document.getElementById("message");
|
||||
// 监听点击消息事件
|
||||
plus.push.addEventListener("click", function(msg) {
|
||||
// 判断是从本地创建还是离线推送的消息
|
||||
var payload = msg.payload;
|
||||
var title = msg.title;
|
||||
var content = msg.content;
|
||||
switch(payload) {
|
||||
case "LocalMSG":
|
||||
alert("点击本地创建消息启动:");
|
||||
break;
|
||||
default:
|
||||
if (plus.os.name == "Android"){
|
||||
payload = JSON.parse(payload);
|
||||
if (payload.type == "0") {
|
||||
plus.ui.alert(title+"\n"+content);
|
||||
} else if (payload.type == "1") {
|
||||
plus.ui.alert(title+"\n"+content,function(){
|
||||
window.location.href = payload.url;
|
||||
});
|
||||
} else if (payload.type == "2") {
|
||||
plus.ui.alert(title+"\n"+content,function(){
|
||||
openUrl(basePath+'/message/openView?url='+payload.url);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (payload.type == "0") {
|
||||
plus.ui.alert(content);
|
||||
} else if (payload.type == "1") {
|
||||
plus.ui.alert(content,function(){
|
||||
window.location.href = payload.url;
|
||||
});
|
||||
} else if (payload.type == "2") {
|
||||
plus.ui.alert(content,function(){
|
||||
openUrl(basePath+'/message/openView?url='+payload.url);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}, false);
|
||||
|
||||
// 监听在线消息事件, iOS透传消息在线时会进入这里进行处理
|
||||
plus.push.addEventListener("receive", function(msg) {
|
||||
var title = msg.title;
|
||||
var content = msg.content;
|
||||
var payload = msg.payload;
|
||||
if (payload.type == "0") {
|
||||
plus.ui.alert(title+"\n"+content);
|
||||
} else if (payload.type == "1") {
|
||||
plus.ui.alert(title+"\n"+content,function(){
|
||||
window.location.href = payload.url;
|
||||
});
|
||||
} else if (payload.type == "2") {
|
||||
plus.ui.alert(title+"\n"+content,function(){
|
||||
openUrl(basePath+'/message/openView?url='+payload.url);
|
||||
});
|
||||
}
|
||||
}, false);
|
||||
}, false);
|
||||
@@ -0,0 +1,96 @@
|
||||
var xhr;
|
||||
$("#districtName").bind("input propertychange keyup" , function () {
|
||||
var keyword = $(this).val()
|
||||
if(xhr){
|
||||
xhr.abort()
|
||||
}
|
||||
if(keyword == ""){
|
||||
$('#districtList').empty()
|
||||
return
|
||||
}
|
||||
xhr = $.ajax({
|
||||
url:'../auto/district',
|
||||
data:{keywords : keyword, cityName:$("#input_city").text(),max:20},
|
||||
dataType:'json',
|
||||
success:function (data){
|
||||
$('#searchHistoryDiv').hide();
|
||||
if(data.length == 0){
|
||||
$("#notFound").show()
|
||||
$('#districtList').empty();
|
||||
}else{
|
||||
$("#notFound").hide()
|
||||
var html = $('<ul>')
|
||||
$(data).each(function () {
|
||||
var li = $('<li>').attr("data-region", this.district).attr("data-name", this.name).attr("data-addr", this.address).attr("data-cityAddress", this.city)
|
||||
li.append('<a class="item-link item-content close-popup"><div class="item-inner"><div class="item-title-row"><div class="item-title">' + this.name + '<br><small>' + this.city + this.district + this.address + '</small></div></div></div></a>')
|
||||
html.append(li)
|
||||
})
|
||||
$('#districtList').empty().html(html)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
function saveHistory(district) {
|
||||
var history = recover()
|
||||
var keys = []
|
||||
var newHistory = []
|
||||
newHistory.push(district)
|
||||
keys.push(district.city + "#" + district.region + "#" + district.name)
|
||||
for(var i = 0; i < history.length; i++){
|
||||
var key = history[i].city + "#" +history[i].region + "#" + history[i].name
|
||||
if($.inArray(key, keys) > -1){
|
||||
continue
|
||||
}
|
||||
if(newHistory.length < 5){
|
||||
keys.push(key)
|
||||
newHistory.push(history[i])
|
||||
}else{
|
||||
break
|
||||
}
|
||||
}
|
||||
$.cookie('history',JSON.stringify(newHistory) ,{ expires: 7})
|
||||
}
|
||||
|
||||
function recover() {
|
||||
var history = $.cookie('history')
|
||||
if(history == undefined || history == ''){
|
||||
return new Array()
|
||||
}
|
||||
return JSON.parse(history)
|
||||
}
|
||||
/* 弹出搜索小区页面 */
|
||||
$("body").delegate(".open-about02", "click", function () {
|
||||
$("#districtName").val("");
|
||||
if($("#input_city").text()==""){
|
||||
$.toast("请选择城市")
|
||||
return false;
|
||||
}
|
||||
$('#searchHistoryDiv').show();
|
||||
$("#notFound").hide();
|
||||
addHistory();
|
||||
$.popup(".popup-about02")
|
||||
$("input").blur()
|
||||
});
|
||||
function addHistory(){
|
||||
var history = recover()
|
||||
if(history.length>0){
|
||||
var ul = '<ul>'
|
||||
$(history).each(function(){
|
||||
ul += '<li data-region="'+this.district+'" data-cityAddress="'+this.city+'" data-name="'+this.name+'" data-addr="'+this.address+'"><a class="item-link item-content close-popup"><div class="item-inner"><div class="item-title-row"><div class="item-title"><font>'+this.name+'</font><br><small>'+this.city+this.district+this.address+'</small></div></div></div></a></li>';
|
||||
})
|
||||
ul += '</ul>'
|
||||
$('#districtList').empty().html(ul)
|
||||
|
||||
}else{
|
||||
$("#districtList").empty();
|
||||
}
|
||||
}
|
||||
|
||||
//点击清空
|
||||
$("#clearSearchHistory").click(function(){
|
||||
$.cookie('history',JSON.stringify([]) ,{ expires: 7});
|
||||
$("#districtList").empty();
|
||||
$.popup(".popup-about02")
|
||||
});
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* 扩展Jquery 新增validate
|
||||
*/
|
||||
(function ($) {
|
||||
$.isMobile = function (text) {
|
||||
return $.trim(text) != "" && /^1[3|4|5|7|8][0-9]\d{8}$/.test(text);
|
||||
}
|
||||
$.isBlank = function (text) {
|
||||
return $.trim(text) == "";
|
||||
}
|
||||
$.isLengthEq = function (text) {
|
||||
return $.trim(text) != "" && text.length == 4;
|
||||
}
|
||||
$.isPositiveInteger = function (text) {
|
||||
return $.trim(text) != "" && /^\d+$/.test(text);
|
||||
}
|
||||
$.isPositiveFloat = function (text) {
|
||||
return $.trim(text) != "" && /^\d+(\.\d+)?$/.test(text);
|
||||
}
|
||||
$.fn.isMobile = function () {
|
||||
return $.isMobile($.trim(this.val()));
|
||||
}
|
||||
$.fn.isBlank = function () {
|
||||
if ($.trim(this.val()) == "") {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
$.fn.lengthEq = function (length) {
|
||||
return $.trim(this.val()) != "" && this.val().length == 4;
|
||||
}
|
||||
$.fn.isPositiveInteger = function () {
|
||||
return $.isPositiveInteger($.trim(this.val()));
|
||||
}
|
||||
$.fn.isPositiveFloat = function () {
|
||||
return $.isPositiveFloat($.trim(this.val()));
|
||||
}
|
||||
|
||||
})($)
|
||||
Reference in New Issue
Block a user