初始上传
This commit is contained in:
2
public/static/js/Tdrag.min.js
vendored
Executable file
2
public/static/js/Tdrag.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
1689
public/static/js/common.js
Executable file
1689
public/static/js/common.js
Executable file
File diff suppressed because it is too large
Load Diff
155
public/static/js/coupon_select.js
Executable file
155
public/static/js/coupon_select.js
Executable file
@@ -0,0 +1,155 @@
|
||||
(function (){
|
||||
function CouponSelect(param){
|
||||
param = param || {};
|
||||
let that = this;
|
||||
that.selectedIds = param.selectedIds || [];
|
||||
that.selectedList = [];
|
||||
that.tableElem = param.tableElem;
|
||||
that.selectElem = param.selectElem;
|
||||
that.layui = null;
|
||||
|
||||
if(typeof that.selectedIds == 'string' && that.selectedIds){
|
||||
that.selectedIds = that.selectedIds.split(',');
|
||||
}
|
||||
|
||||
that.init(()=>{
|
||||
that.bindEvent();
|
||||
that.getSelectedList(()=>{
|
||||
that.renderTable();
|
||||
})
|
||||
$(that.selectElem).on('click', ()=>{
|
||||
ns.selectCoupon({
|
||||
select_id:that.selectedIds.toString(),
|
||||
success:function (res){
|
||||
that.selectedList = res;
|
||||
that.selectedListToIds();
|
||||
that.renderTable();
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
CouponSelect.prototype.getSelectedData = function (){
|
||||
let that = this;
|
||||
return {
|
||||
selectedIds:that.selectedIds,
|
||||
selectedList:that.selectedList,
|
||||
}
|
||||
}
|
||||
|
||||
CouponSelect.prototype.init = function (callback){
|
||||
let that = this;
|
||||
layui.use(['form', 'laytpl'], function() {
|
||||
that.layui = layui;
|
||||
callback && callback();
|
||||
})
|
||||
}
|
||||
|
||||
CouponSelect.prototype.getSelectedList = function (callback){
|
||||
let that = this;
|
||||
$.ajax({
|
||||
url: ns.url("coupon://shop/coupon/couponselect"),
|
||||
data: {
|
||||
page:1,
|
||||
page_size:0,
|
||||
coupon_type_ids:that.selectedIds.toString() || -1,
|
||||
},
|
||||
dataType: 'JSON', //服务器返回json格式数据
|
||||
type: 'POST', //http请求类型
|
||||
success: function(res) {
|
||||
that.selectedList = res.data.list;
|
||||
that.selectedListToIds();
|
||||
callback && callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
CouponSelect.prototype.selectedListToIds = function (){
|
||||
let that = this;
|
||||
let selectedIds = [];
|
||||
that.selectedList.forEach((item)=>{
|
||||
selectedIds.push(item.coupon_type_id);
|
||||
})
|
||||
that.selectedIds = selectedIds;
|
||||
}
|
||||
|
||||
CouponSelect.prototype.renderTable = function (){
|
||||
let that = this;
|
||||
that.layui.laytpl(templete).render(that.selectedList, function (html) {
|
||||
$(that.tableElem).html(html);
|
||||
})
|
||||
}
|
||||
|
||||
CouponSelect.prototype.bindEvent = function (){
|
||||
let that = this;
|
||||
$(that.tableElem).on('click', '.table-btn .delete-btn', function (){
|
||||
let index = $(this).parents('tr').data('index');
|
||||
that.selectedList.splice(index, 1);
|
||||
that.selectedListToIds();
|
||||
that.renderTable();
|
||||
})
|
||||
}
|
||||
|
||||
var templete = `
|
||||
<table class="layui-table" id="coupon_selected" lay-skin="line">
|
||||
<colgroup>
|
||||
<col width="16%">
|
||||
<col width="16%">
|
||||
<col width="16%">
|
||||
<col width="16%">
|
||||
<col width="16%">
|
||||
<col width="16%">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>优惠券名称</th>
|
||||
<th>优惠内容</th>
|
||||
<th>活动商品</th>
|
||||
<th>有效期</th>
|
||||
<th>适用场景</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{# d.forEach((item, index)=>{ }}
|
||||
<tr data-index="{{index}}">
|
||||
<td>{{item.coupon_name}}</td>
|
||||
<td>
|
||||
{{# if(item.type == 'reward'){ }}
|
||||
<div class="text">满{{item.at_least.replace('.00','')}}减{{item.money.replace('.00','')}}元</div>
|
||||
{{# }else{ }}
|
||||
<div class="text">满{{item.at_least.replace('.00','')}}打{{item.discount.replace('.00','')}}折<br/>最多可抵{{item.discount_limit.replace('.00','')}}元</div>
|
||||
{{# } }}
|
||||
</td>
|
||||
<td>{{item.goods_type_name}}</td>
|
||||
<td>
|
||||
{{# if(d.validity_type == 0){ }}
|
||||
至 {{ ns.time_to_date(d.end_time) }}
|
||||
{{# } else if(d.validity_type == 1) { }}
|
||||
领取后,{{ d.fixed_term }}天有效
|
||||
{{# } else { }}
|
||||
长期有效
|
||||
{{# } }}
|
||||
</td>
|
||||
<td>{{item.use_channel_name}}</td>
|
||||
<td>
|
||||
<div class="table-btn">
|
||||
<a class="layui-btn delete-btn">删除</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{{# }) }}
|
||||
{{# if(d.length == 0){ }}
|
||||
<tr>
|
||||
<td class="goods-empty" colspan="4">
|
||||
<div>尚未选择赠送优惠券</div>
|
||||
</td>
|
||||
</tr>
|
||||
{{# } }}
|
||||
</tbody>
|
||||
</table>
|
||||
`;
|
||||
|
||||
window.CouponSelect = CouponSelect;
|
||||
})()
|
||||
179
public/static/js/coupon_select_new.js
Executable file
179
public/static/js/coupon_select_new.js
Executable file
@@ -0,0 +1,179 @@
|
||||
(function () {
|
||||
function CouponSelect(param) {
|
||||
param = param || {};
|
||||
let that = this;
|
||||
that.selectedIds = param.selectedIds || [];
|
||||
that.selectedList = [];
|
||||
that.tableElem = param.tableElem;
|
||||
that.selectElem = param.selectElem;
|
||||
that.layui = null;
|
||||
that.couponNew = param.couponNew || '';
|
||||
|
||||
if (typeof that.selectedIds == 'string' && that.selectedIds) {
|
||||
that.selectedIds = that.selectedIds.split(',');
|
||||
}
|
||||
|
||||
that.init(() => {
|
||||
that.bindEvent();
|
||||
that.getSelectedList(() => {
|
||||
that.renderTable();
|
||||
})
|
||||
$(that.selectElem).on('click', () => {
|
||||
ns.selectCoupon({
|
||||
select_id: that.selectedIds.toString(),
|
||||
success: function (res) {
|
||||
console.log(res)
|
||||
that.selectedList = res;
|
||||
that.selectedListToIds();
|
||||
that.renderTable();
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
CouponSelect.prototype.getSelectedData = function () {
|
||||
let that = this;
|
||||
return {
|
||||
selectedIds: that.selectedIds,
|
||||
selectedList: that.selectedList,
|
||||
}
|
||||
}
|
||||
|
||||
CouponSelect.prototype.init = function (callback) {
|
||||
let that = this;
|
||||
layui.use(['form', 'laytpl'], function () {
|
||||
that.layui = layui;
|
||||
callback && callback();
|
||||
})
|
||||
}
|
||||
|
||||
CouponSelect.prototype.getSelectedList = function (callback) {
|
||||
let that = this;
|
||||
$.ajax({
|
||||
url: ns.url("coupon://shop/coupon/couponselect"),
|
||||
data: {
|
||||
page: 1,
|
||||
page_size: 0,
|
||||
coupon_type_ids: that.selectedIds.toString() || -1,
|
||||
},
|
||||
dataType: 'JSON', //服务器返回json格式数据
|
||||
type: 'POST', //http请求类型
|
||||
success: function (res) {
|
||||
that.selectedList = res.data.list;
|
||||
that.selectedListToIds();
|
||||
callback && callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
CouponSelect.prototype.selectedListToIds = function () {
|
||||
let that = this;
|
||||
let selectedIds = [];
|
||||
that.selectedList.forEach((item) => {
|
||||
selectedIds.push(item.coupon_type_id);
|
||||
})
|
||||
that.selectedIds = selectedIds;
|
||||
}
|
||||
|
||||
CouponSelect.prototype.renderTable = function () {
|
||||
|
||||
let that = this;
|
||||
console.log(that.couponNew)
|
||||
for (var key in that.selectedList) {
|
||||
that.selectedList[key].send_num = 1;
|
||||
var item = that.selectedList[key];
|
||||
if (that.couponNew && typeof that.couponNew === 'string') {
|
||||
var couponNewObj = JSON.parse(that.couponNew)
|
||||
for (var key1 in couponNewObj) {
|
||||
if (parseInt(couponNewObj[key1].id) == parseInt(item.coupon_type_id)) {
|
||||
console.log(item)
|
||||
that.selectedList[key].send_num = couponNewObj[key1].num
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
that.layui.laytpl(templete).render(that.selectedList, function (html) {
|
||||
$(that.tableElem).html(html);
|
||||
})
|
||||
}
|
||||
|
||||
CouponSelect.prototype.bindEvent = function () {
|
||||
let that = this;
|
||||
$(that.tableElem).on('click', '.table-btn .delete-btn', function () {
|
||||
let index = $(this).parents('tr').data('index');
|
||||
that.selectedList.splice(index, 1);
|
||||
that.selectedListToIds();
|
||||
that.renderTable();
|
||||
})
|
||||
}
|
||||
|
||||
var templete = `
|
||||
<table class="layui-table" id="coupon_selected" lay-skin="line">
|
||||
<colgroup>
|
||||
<col width="16%">
|
||||
<col width="16%">
|
||||
<col width="16%">
|
||||
<col width="16%">
|
||||
<col width="16%">
|
||||
<col width="16%">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>优惠券名称</th>
|
||||
<th>优惠内容</th>
|
||||
<th>活动商品</th>
|
||||
<th>有效期</th>
|
||||
<th>适用场景</th>
|
||||
<th>发放数量</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{# d.forEach((item, index)=>{ }}
|
||||
<tr data-index="{{index}}">
|
||||
<td>{{item.coupon_name}}</td>
|
||||
<td>
|
||||
{{# if(item.type == 'reward'){ }}
|
||||
<div class="text">满{{item.at_least.replace('.00','')}}减{{item.money.replace('.00','')}}元</div>
|
||||
{{# }else{ }}
|
||||
<div class="text">满{{item.at_least.replace('.00','')}}打{{item.discount.replace('.00','')}}折<br/>最多可抵{{item.discount_limit.replace('.00','')}}元</div>
|
||||
{{# } }}
|
||||
</td>
|
||||
<td>{{item.goods_type_name}}</td>
|
||||
<td>
|
||||
{{# if(d.validity_type == 0){ }}
|
||||
至 {{ ns.time_to_date(d.end_time) }}
|
||||
{{# } else if(d.validity_type == 1) { }}
|
||||
领取后,{{ d.fixed_term }}天有效
|
||||
{{# } else { }}
|
||||
长期有效
|
||||
{{# } }}
|
||||
</td>
|
||||
<td>{{item.use_channel_name}}</td>
|
||||
<td>
|
||||
<div class="table-btn layui-input-inline">
|
||||
<input type="number" name="send_coupon_num" value="{{item.send_num}}" class="layui-input send_num_{{item.coupon_type_id}}" min="1" onchange="if(value<1 ){value= 1;}value = Math.floor(value);">
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="table-btn">
|
||||
<a class="layui-btn delete-btn">删除</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{{# }) }}
|
||||
{{# if(d.length == 0){ }}
|
||||
<tr>
|
||||
<td class="goods-empty" colspan="4">
|
||||
<div>尚未选择赠送优惠券</div>
|
||||
</td>
|
||||
</tr>
|
||||
{{# } }}
|
||||
</tbody>
|
||||
</table>
|
||||
`;
|
||||
|
||||
window.CouponSelect = CouponSelect;
|
||||
})()
|
||||
4
public/static/js/jquery-3.1.1.js
vendored
Executable file
4
public/static/js/jquery-3.1.1.js
vendored
Executable file
File diff suppressed because one or more lines are too long
117
public/static/js/jquery.cookie.js
Executable file
117
public/static/js/jquery.cookie.js
Executable file
@@ -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);
|
||||
};
|
||||
|
||||
}));
|
||||
30
public/static/js/jquery.printarea.js
Executable file
30
public/static/js/jquery.printarea.js
Executable file
@@ -0,0 +1,30 @@
|
||||
(function($) {
|
||||
var printAreaCount = 0;
|
||||
$.fn.printArea = function()
|
||||
{
|
||||
var ele = $(this);
|
||||
var idPrefix = "printArea_";
|
||||
removePrintArea( idPrefix + printAreaCount );
|
||||
printAreaCount++;
|
||||
var iframeId = idPrefix + printAreaCount;
|
||||
var iframeStyle = 'position:absolute;width:0px;height:0px;left:-730px;top:-730px;';
|
||||
iframe = document.createElement('IFRAME');
|
||||
$(iframe).attr({ style : iframeStyle,id : iframeId});
|
||||
document.body.appendChild(iframe);
|
||||
var doc = iframe.contentWindow.document;
|
||||
$(document).find("link").filter(function(){
|
||||
return $(this).attr("rel").toLowerCase() == "stylesheet";
|
||||
}).each(function(){
|
||||
doc.write('<link type="text/css" rel="stylesheet" href="' + $(this).attr("href") + '" >');
|
||||
});
|
||||
doc.write('<div class="' + $(ele).attr("class") + '">' + $(ele).html() + '</div>');
|
||||
doc.close();
|
||||
var frameWindow = iframe.contentWindow;
|
||||
frameWindow.close();
|
||||
frameWindow.focus();
|
||||
frameWindow.print();
|
||||
}
|
||||
var removePrintArea = function(id){
|
||||
$( "iframe#" + id ).remove();
|
||||
};
|
||||
})(jQuery);
|
||||
218
public/static/js/map_address.js
Executable file
218
public/static/js/map_address.js
Executable file
@@ -0,0 +1,218 @@
|
||||
//author 周
|
||||
// var map, marker, infoWindow, geolocation, geocoder;//地图加载默认参数
|
||||
mapClass = function(id, lnglat, map_success_back){
|
||||
/*******************************************************地图加载事件start**********************************************************/
|
||||
//加载地图,调用浏览器定位服务
|
||||
_this = this;
|
||||
|
||||
this.init(id, lnglat, map_success_back);//初始化函数
|
||||
};
|
||||
mapClass.prototype = {
|
||||
init : function(id, lnglat, map_success_back){
|
||||
_this.setAttr();
|
||||
|
||||
_this.map_callback = map_success_back;
|
||||
|
||||
var msp_json = {
|
||||
zoom: _this.zoom
|
||||
}
|
||||
if(lnglat["lat"] != ''|| lnglat["lng"] != '' ){
|
||||
msp_json["center"] = [lnglat["lng"], lnglat["lat"]]//初始化地图中心点}
|
||||
}
|
||||
_this.map = new AMap.Map(id, msp_json);
|
||||
|
||||
//加载地图插件
|
||||
_this.map.plugin('AMap.Geolocation', function() {
|
||||
_this.geolocation = new AMap.Geolocation({
|
||||
enableHighAccuracy: false,//是否使用高精度定位,默认:true
|
||||
timeout: 1, //超过10秒后停止定位,默认:无穷大
|
||||
buttonOffset: new AMap.Pixel(2.5, 2.5),//定位按钮与设置的停靠位置的偏移量,默认:Pixel(10, 20)
|
||||
zoomToAccuracy: false, //定位成功后调整地图视野范围使定位位置及精度范围视野内可见,默认:false
|
||||
buttonPosition:'RB',
|
||||
showMarker: false, //定位成功后在定位到的位置显示点标记,默认:true
|
||||
});
|
||||
_this.map.plugin(["AMap.ToolBar"], function() {
|
||||
_this.map.addControl(new AMap.ToolBar());
|
||||
});
|
||||
|
||||
// _this.geolocation.getCurrentPosition();
|
||||
|
||||
_this.marker = new AMap.Marker({
|
||||
map:_this.map,
|
||||
bubble:true
|
||||
})
|
||||
_this.infoWindow = new AMap.InfoWindow({
|
||||
content: '',
|
||||
offset: {x: 0, y: -30}
|
||||
});
|
||||
|
||||
|
||||
_this.map.plugin('AMap.Geocoder',function(){
|
||||
_this.geocoder = new AMap.Geocoder({
|
||||
radius: 500 //范围,默认:500
|
||||
});
|
||||
});
|
||||
AMap.event.addListener(_this.geolocation, 'complete', function(data){
|
||||
_this.map_change = false;
|
||||
_this.markerMove(data.position, data.formattedAddress, data.addressComponent);
|
||||
|
||||
});//返回定位信息
|
||||
AMap.event.addListener(_this.geolocation, 'error', function(){}); //返回定位出错信息
|
||||
|
||||
});
|
||||
_this.map.on('click',function(e){
|
||||
if(_this.map_click){
|
||||
_this.map_change = false;
|
||||
_this.geocoder.getAddress(e.lnglat,function(status,result){
|
||||
if(status == 'complete'){
|
||||
_this.markerMove(e.lnglat, result.regeocode.formattedAddress,result.regeocode.addressComponent);
|
||||
}else{
|
||||
_this.markerMove(e.lnglat, "定位失败");
|
||||
}
|
||||
})
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
if(_this.map_callback != undefined){
|
||||
_this.map_callback(_this);
|
||||
}
|
||||
|
||||
},
|
||||
getCurrentPosition : function (){
|
||||
_this.geolocation.getCurrentPosition();
|
||||
|
||||
},
|
||||
onComplete : function(data){
|
||||
// console.log(data);
|
||||
// if (_this.location) {
|
||||
_this.map_change = false;
|
||||
_this.markerMove(data.position, data.formattedAddress, data.addressComponent);
|
||||
// }else{
|
||||
// _this.location = true;
|
||||
// if(_this.map_callback != undefined){
|
||||
// _this.map_callback(_this);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
},
|
||||
onError : function(){
|
||||
|
||||
},
|
||||
markerMove : function(position, address, data){
|
||||
var address_detail = address;
|
||||
address_detail = address_detail.replace(data.province,'');
|
||||
address_detail = address_detail.replace(data.city,'');
|
||||
address_detail = address_detail.replace(data.district,'');
|
||||
address_detail = address_detail.replace(data.township,'');
|
||||
|
||||
_this.marker.setPosition(position);
|
||||
_this.infoWindow.setContent("<p>当前位置:<span class='text-color'>" + address + "</span>");
|
||||
// _this.infoWindow.setPosition("<p>当前位置:<span style='color:#0689e1;'>" + address + "</span>");
|
||||
// _this.infoWindow.setPosition();
|
||||
_this.infoWindow.open(_this.map, position);
|
||||
_this.map.setZoomAndCenter(20, _this.marker.getPosition());//设置地图放大级别及居中
|
||||
|
||||
_this.address.province_name = data.province;
|
||||
if(data.city == ""){
|
||||
_this.address.city_name = data.province;
|
||||
}else{
|
||||
_this.address.city_name = data.city;
|
||||
}
|
||||
_this.address.district_name = data.district;
|
||||
_this.address.township_name = data.township;
|
||||
_this.address.area = _this.address.province_name+","+_this.address.city_name+","+_this.address.district_name+","+_this.address.township_name;
|
||||
|
||||
_this.address.longitude = position.lng;
|
||||
_this.address.latitude = position.lat;
|
||||
_this.address.address = address_detail;
|
||||
if(!_this.map_change){
|
||||
console.log( _this.address);
|
||||
mapChangeCallBack();
|
||||
}else{
|
||||
selectCallBack();
|
||||
|
||||
}
|
||||
},
|
||||
mapChange : function(address){
|
||||
if (_this.map_change) {
|
||||
|
||||
var province_name = _this.address.province > 0 ? _this.address.province_name : '';
|
||||
var city_name = _this.address.province > 0 && _this.address.city > 0 ? _this.address.city_name : '';
|
||||
var districts_name = _this.address.province > 0 && _this.address.city > 0 && _this.address.district > 0 ? _this.address.district_name : '';
|
||||
// var township_name = _this.address.province > 0 && _this.address.city > 0 && _this.address.district > 0 && _this.address.township > 0 ? _this.address.township_name : '';
|
||||
// var address_detail = _this.address.province > 0 && _this.address.city > 0 && _this.address.district > 0 && _this.address.township > 0 ? _this.address.detail_address : '';
|
||||
var address_detail = _this.address.province > 0 && _this.address.city > 0 && _this.address.district > 0 ? _this.address.detail_address : '';
|
||||
if(!address){
|
||||
// address = province_name + city_name + districts_name + township_name + address_detail;
|
||||
address = province_name + city_name + districts_name + address_detail;
|
||||
}
|
||||
_this.geocoder.getLocation(address, function (status, result) {
|
||||
if (status === 'complete' && result.info === 'OK') {
|
||||
_this.markerMove(result.geocodes[0].location, result.geocodes[0].formattedAddress, result.geocodes[0].addressComponent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
setAttr : function(){
|
||||
_this.map = "";
|
||||
_this.marker = "";
|
||||
_this.infoWindow = "";
|
||||
_this.geolocation = "";
|
||||
_this.geocoder = "";
|
||||
_this.location = false;
|
||||
_this.map_change = true;
|
||||
_this.map_click = true;
|
||||
_this.zoom = 15;
|
||||
_this.address = {
|
||||
province : "",
|
||||
province_name : "",
|
||||
city : "",
|
||||
city_name : "",
|
||||
district : "",
|
||||
district_name : "",
|
||||
township : "",
|
||||
township_name : "",
|
||||
address : "",
|
||||
longitude : "",
|
||||
latitude : "",
|
||||
area : ""
|
||||
};
|
||||
},
|
||||
destroy : function(){
|
||||
_this.map.destroy( );//销毁地图
|
||||
},
|
||||
setMapCircle : function(radius_num, position){
|
||||
if(radius_num == undefined && radius_num <= 0){
|
||||
return;
|
||||
}
|
||||
_this.map.clearMap();
|
||||
// var circle_arr = map.getAllOverlays('circle');
|
||||
// if(circle_arr.length > 0){{
|
||||
// map.remove(circle)
|
||||
// }
|
||||
|
||||
if(position != undefined){
|
||||
var center_position = new AMap.LngLat(position['lon'], position['lat'])
|
||||
}else{
|
||||
var center_position = _this.marker.getPosition();
|
||||
}
|
||||
var circle = new AMap.Circle({
|
||||
center: center_position,// 圆心位置
|
||||
radius: radius_num*1000, //半径
|
||||
strokeColor: "#F33", //线颜色
|
||||
strokeOpacity: 1, //线透明度
|
||||
strokeWeight: 3, //线粗细度
|
||||
fillColor: "#ee2200", //填充颜色
|
||||
fillOpacity: 0.35//填充透明度
|
||||
});
|
||||
_this.map.add(_this.marker);
|
||||
circle.setMap(_this.map);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
150
public/static/js/multi_tree_select.js
Executable file
150
public/static/js/multi_tree_select.js
Executable file
@@ -0,0 +1,150 @@
|
||||
(function (){
|
||||
let typeConfig = {
|
||||
category:{
|
||||
title:'选择分类',
|
||||
url:'shop/goodscategory/getCategoryTree',
|
||||
},
|
||||
area:{
|
||||
title:'选择地区',
|
||||
url:'shop/address/getAreaTree',
|
||||
},
|
||||
};
|
||||
function MultiTreeSelect(param){
|
||||
param = param || {};
|
||||
let that = this;
|
||||
that.disabledIds = param.disabledIds || '';
|
||||
that.selectedIds = param.selectedIds || '';
|
||||
that.selectedNames = '';
|
||||
that.elem = param.elem;
|
||||
that.treeType = param.treeType || 'category';
|
||||
that.treeData = [];
|
||||
that.layui = null;
|
||||
that.success = param.success || null;
|
||||
|
||||
that.init(()=>{
|
||||
that.getTreeData();
|
||||
$(that.elem).click(()=>{
|
||||
that.open(()=>{
|
||||
that.renderTree();
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
MultiTreeSelect.prototype.init = function (callback){
|
||||
let that = this;
|
||||
layui.use(['form', 'tree', 'laytpl'], function() {
|
||||
that.layui = layui;
|
||||
callback && callback();
|
||||
})
|
||||
}
|
||||
|
||||
MultiTreeSelect.prototype.open = function (callback){
|
||||
let that = this;
|
||||
layer.open({
|
||||
title: typeConfig[that.treeType].title,
|
||||
skin: 'layer-tips-class',
|
||||
type: 1,
|
||||
area: ['500px', '500px'],
|
||||
content: '<div style="height: 100%;overflow-y: auto;" id="multi_tree_select_container"></div>',
|
||||
btn: ['确认', '取消'],
|
||||
yes: function (index, layero) {
|
||||
that.getSelectedData();
|
||||
that.success && that.success({
|
||||
selectedIds:that.selectedIds,
|
||||
selectedNames:that.selectedNames,
|
||||
})
|
||||
layer.close(index);
|
||||
},
|
||||
btn2: function (index, layero) {
|
||||
layer.close(index);
|
||||
},
|
||||
success:function (){
|
||||
that.layui.form.render();
|
||||
callback && callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
MultiTreeSelect.prototype.getTreeData = function (callback){
|
||||
let that = this;
|
||||
$.ajax({
|
||||
url: ns.url(typeConfig[that.treeType].url),
|
||||
data: {},
|
||||
type: "POST",
|
||||
dataType: "JSON",
|
||||
success: function (res) {
|
||||
that.treeData = res.data;
|
||||
callback && callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
MultiTreeSelect.prototype.renderTree = function(){
|
||||
let that = this;
|
||||
that.layui.tree.render({
|
||||
elem: '#multi_tree_select_container',
|
||||
data: that.treeData,
|
||||
showCheckbox:true,
|
||||
id:'#multi_tree_select_container',
|
||||
});
|
||||
if(that.disabledIds){
|
||||
let disabled_id_arr = that.disabledIds.split(',');
|
||||
for(let i in disabled_id_arr){
|
||||
$("input[name='layuiTreeCheck_"+ disabled_id_arr[i] +"']").prop('disabled', true).next().addClass('layui-checkbox-disbaled layui-disabled').next().addClass('layui-disabled').append('(不可选)');
|
||||
}
|
||||
}
|
||||
if(that.selectedIds){
|
||||
let selected_id_arr = that.selectedIds.split(',');
|
||||
for(let i in selected_id_arr){
|
||||
$("input[name='layuiTreeCheck_"+ selected_id_arr[i] +"']").prop('checked', true).next().addClass('layui-form-checked');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MultiTreeSelect.prototype.getSelectedData = function (){
|
||||
let that = this;
|
||||
let selectedTreeData = that.layui.tree.getChecked("#multi_tree_select_container");
|
||||
let selectedData = that.getSelectedIdsAndNames(selectedTreeData, that.treeData);
|
||||
that.selectedIds = selectedData.id_arr.join(',');
|
||||
that.selectedNames = selectedData.name_arr.join('、');
|
||||
}
|
||||
|
||||
MultiTreeSelect.prototype.getSelectedIdsAndNames = function(tree_selected, tree_all){
|
||||
let name_arr = [];
|
||||
let id_arr = [];
|
||||
let selected_num = 0;
|
||||
for(let i in tree_selected){
|
||||
let item_selected = tree_selected[i];
|
||||
let item_all = null;
|
||||
tree_all.forEach((item)=>{
|
||||
if(item.id === item_selected.id){
|
||||
item_all = item;
|
||||
return;
|
||||
}
|
||||
})
|
||||
if(!item_all) throw '对比数据有误';
|
||||
let title = item_selected.title;
|
||||
id_arr.push(item_selected.id);
|
||||
if(item_selected.child_num > 0){
|
||||
let res = this.getSelectedIdsAndNames(item_selected.children, item_all.children);
|
||||
if(res.selected_num == item_all.child_num){
|
||||
selected_num ++;
|
||||
}else{
|
||||
title += '('+ res.name_arr.join('、') +')';
|
||||
}
|
||||
id_arr = id_arr.concat(res.id_arr);
|
||||
}else{
|
||||
selected_num ++;
|
||||
}
|
||||
name_arr.push(title);
|
||||
}
|
||||
return {
|
||||
selected_num : selected_num,
|
||||
name_arr : name_arr,
|
||||
id_arr : id_arr,
|
||||
};
|
||||
}
|
||||
|
||||
window.MultiTreeSelect = MultiTreeSelect;
|
||||
})()
|
||||
224
public/static/js/qq_map.js
Executable file
224
public/static/js/qq_map.js
Executable file
@@ -0,0 +1,224 @@
|
||||
//author 周
|
||||
// var map, marker, infoWindow, geolocation, geocoder;//地图加载默认参数
|
||||
mapClass = function(id, lnglat, map_success_back){
|
||||
/*******************************************************地图加载事件start**********************************************************/
|
||||
//加载地图,调用浏览器定位服务
|
||||
_this = this;
|
||||
|
||||
this.init(id, lnglat, map_success_back);//初始化函数
|
||||
};
|
||||
mapClass.prototype = {
|
||||
init : async function(id, lnglat, map_success_back){
|
||||
_this.setAttr();
|
||||
|
||||
_this.map_callback = map_success_back;
|
||||
|
||||
var center;
|
||||
if(lnglat["lat"] != ''|| lnglat["lng"] != '' ){
|
||||
center = new TMap.LatLng(lnglat.lat,lnglat.lng);
|
||||
} else {
|
||||
await _this.getCurrentPosition(function(res){
|
||||
if (res.status == 0) {
|
||||
var location = res.result.location;
|
||||
center = new TMap.LatLng(location.lat, location.lng);
|
||||
}
|
||||
})
|
||||
}
|
||||
_this.map = new TMap.Map(document.getElementById(id), {
|
||||
center: center,//设置地图中心点坐标
|
||||
zoom: 17 //设置地图缩放级别
|
||||
});
|
||||
|
||||
// 创建中心点标记
|
||||
_this.marker = new TMap.MultiMarker({
|
||||
map: _this.map,
|
||||
geometries: [
|
||||
{
|
||||
id: 'center',
|
||||
position: _this.map.getCenter(),
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
_this.infoWindow = new TMap.InfoWindow({
|
||||
content: "", //信息窗口内容
|
||||
position: center,//显示信息窗口的坐标
|
||||
map: _this.map,
|
||||
offset: {x: 0, y: -50}
|
||||
});
|
||||
_this.infoWindow.close(); // 初始化关闭窗体
|
||||
|
||||
_this.map.on('click',function(e){
|
||||
if(_this.map_click){
|
||||
_this.map_change = false;
|
||||
_this.getAddress(e.latLng,function(result){
|
||||
_this.markerMove(e.latLng, result.address, result.addressComponents);
|
||||
})
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
if(map_success_back != undefined){
|
||||
map_success_back(_this);
|
||||
}
|
||||
},
|
||||
getAddress(LatLng, callback){
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
dataType: "JSON",
|
||||
url: ns.url("shop/address/locationToDetail"),
|
||||
data: {location:LatLng.lat+','+LatLng.lng},
|
||||
success: function (res) {
|
||||
if(res.status == 0){
|
||||
res.result.address_component.country = res.result.address_component.nation;
|
||||
callback({
|
||||
address:res.result.address,
|
||||
location:res.result.location,
|
||||
addressComponents:res.result.address_component,
|
||||
});
|
||||
}else{
|
||||
layer.msg(res.message || '查询地址失败');
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
getCurrentPosition : async function (callback){
|
||||
var ipLocation = new TMap.service.IPLocation();
|
||||
await ipLocation.locate({}).then(function(res){
|
||||
callback(res)
|
||||
})
|
||||
},
|
||||
markerMove : function(position, address, data){
|
||||
var center = new TMap.LatLng(position.lat, position.lng);
|
||||
var address_detail = address;
|
||||
address_detail = address_detail.replace(data.country,'');
|
||||
address_detail = address_detail.replace(data.province,'');
|
||||
address_detail = address_detail.replace(data.city,'');
|
||||
address_detail = address_detail.replace(data.district,'');
|
||||
|
||||
_this.marker.updateGeometries([
|
||||
{
|
||||
id: 'center',
|
||||
position: center
|
||||
}
|
||||
]);
|
||||
_this.infoWindow.open()
|
||||
_this.infoWindow.setPosition(center);
|
||||
_this.infoWindow.setContent("<p>当前位置:<span class='text-color'>" + address + "</span>");
|
||||
_this.map.setCenter(position);
|
||||
|
||||
_this.address.province_name = data.province;
|
||||
if(data.city == ""){
|
||||
_this.address.city_name = data.province;
|
||||
}else{
|
||||
_this.address.city_name = data.city;
|
||||
}
|
||||
_this.address.district_name = data.district;
|
||||
_this.address.township_name = data.street;
|
||||
_this.address.area = _this.address.province_name+","+_this.address.city_name+","+_this.address.district_name+","+_this.address.township_name;
|
||||
|
||||
_this.address.longitude = position.lng;
|
||||
_this.address.latitude = position.lat;
|
||||
_this.address.address = address_detail;
|
||||
if(!_this.map_change){
|
||||
mapChangeCallBack();
|
||||
}else{
|
||||
selectCallBack();
|
||||
}
|
||||
},
|
||||
mapChange : function(address){
|
||||
if (_this.map_change) {
|
||||
var province_name = _this.address.province > 0 ? _this.address.province_name : '';
|
||||
var city_name = _this.address.province > 0 && _this.address.city > 0 ? _this.address.city_name : '';
|
||||
var districts_name = _this.address.province > 0 && _this.address.city > 0 && _this.address.district > 0 ? _this.address.district_name : '';
|
||||
var address_detail = _this.address.province > 0 && _this.address.city > 0 && _this.address.district > 0 ? _this.address.detail_address : '';
|
||||
if(!address){
|
||||
address = province_name +','+ city_name +','+ districts_name +','+ address_detail;
|
||||
}
|
||||
_this.getLocation(address, function (result) {
|
||||
_this.markerMove(result.location, result.address, result.addressComponents);
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
getLocation(address, callback){
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
dataType: "JSON",
|
||||
url: ns.url("shop/address/addressToDetail"),
|
||||
data: {address:address},
|
||||
success: function (res) {
|
||||
if(res.status == 0){
|
||||
res.result.address_components.country = '中国';
|
||||
callback({
|
||||
address:address,
|
||||
location:res.result.location,
|
||||
addressComponents:res.result.address_components,
|
||||
});
|
||||
}else{
|
||||
layer.msg(res.message || '查询地址失败');
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
setAttr : function(){
|
||||
_this.map = "";
|
||||
_this.marker = "";
|
||||
_this.infoWindow = "";
|
||||
_this.geolocation = "";
|
||||
_this.geocoder = "";
|
||||
_this.location = false;
|
||||
_this.map_change = true;
|
||||
_this.map_click = true;
|
||||
_this.zoom = 15;
|
||||
_this.address = {
|
||||
province : "",
|
||||
province_name : "",
|
||||
city : "",
|
||||
city_name : "",
|
||||
district : "",
|
||||
district_name : "",
|
||||
township : "",
|
||||
township_name : "",
|
||||
address : "",
|
||||
longitude : "",
|
||||
latitude : "",
|
||||
area : ""
|
||||
};
|
||||
},
|
||||
destroy : function(){
|
||||
_this.map.destroy( );//销毁地图
|
||||
},
|
||||
setMapCircle : function(radius_num, position){
|
||||
if(radius_num == undefined && radius_num <= 0){
|
||||
return;
|
||||
}
|
||||
_this.map.clearMap();
|
||||
// var circle_arr = map.getAllOverlays('circle');
|
||||
// if(circle_arr.length > 0){{
|
||||
// map.remove(circle)
|
||||
// }
|
||||
|
||||
if(position != undefined){
|
||||
var center_position = new AMap.LngLat(position['lon'], position['lat'])
|
||||
}else{
|
||||
var center_position = _this.marker.getPosition();
|
||||
}
|
||||
var circle = new AMap.Circle({
|
||||
center: center_position,// 圆心位置
|
||||
radius: radius_num*1000, //半径
|
||||
strokeColor: "#F33", //线颜色
|
||||
strokeOpacity: 1, //线透明度
|
||||
strokeWeight: 3, //线粗细度
|
||||
fillColor: "#ee2200", //填充颜色
|
||||
fillOpacity: 0.35//填充透明度
|
||||
});
|
||||
_this.map.add(_this.marker);
|
||||
circle.setMap(_this.map);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
1
public/static/js/qrcode.min.js
vendored
Executable file
1
public/static/js/qrcode.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
644
public/static/js/tdrag.js
Executable file
644
public/static/js/tdrag.js
Executable file
@@ -0,0 +1,644 @@
|
||||
/*! Tdrag 0.0.1 */
|
||||
/**
|
||||
* Created by Tezml on 2016/5/26
|
||||
* You can modify my source code, if you have a good idea or a problem can be encountered by e-mail: tezml@tezml.com to find me.
|
||||
* 如果你想在项目中使用该插件,请不要删除该注释。
|
||||
*/
|
||||
;(function($,window,document,undefined){
|
||||
jQuery(function() {
|
||||
//插件制作
|
||||
|
||||
|
||||
$.fn.Tdrag = function (opt) {
|
||||
var call = {
|
||||
scope: null,//父级
|
||||
grid: null,//网格
|
||||
axis:"all",//上下或者左右
|
||||
pos:false,//是否记住位置
|
||||
handle:null,//手柄
|
||||
moveClass:"tezml",//移动时不换位加的class
|
||||
dragChange:false,//是否开启拖拽换位
|
||||
changeMode:"point",//point & sort
|
||||
cbStart:function(){},//移动前的回调函数
|
||||
cbMove:function(){},//移动中的回调函数
|
||||
cbEnd:function(){},//移动结束时候的回调函数
|
||||
cbChange:function(){},//移动结束时候的回调函数
|
||||
random:false,//是否自动随机排序
|
||||
randomInput:null,//点击随机排序的按钮
|
||||
animation_options:{//运动时的参数
|
||||
duration:800,//每次运动的时间
|
||||
easing:"ease-out"//移动时的特效,ease-out、ease-in、linear
|
||||
},
|
||||
disable:false,//禁止拖拽
|
||||
disableInput:null//禁止拖拽的按钮
|
||||
};
|
||||
var dragfn = new Dragfn(this, opt);
|
||||
if (opt && $.isEmptyObject(opt) == false) {
|
||||
dragfn.options = $.extend(call, opt);
|
||||
} else {
|
||||
dragfn.options = call;
|
||||
}
|
||||
dragfn.firstRandom=true;
|
||||
var ele = dragfn.$element;
|
||||
dragfn.pack(ele,false);
|
||||
if(dragfn.options.randomInput!=null){
|
||||
$(dragfn.options.randomInput).bind("click",function(){
|
||||
dragfn.pack(ele,true);
|
||||
})
|
||||
}
|
||||
//加载拓展jquery的函数
|
||||
dragfn.loadJqueryfn()
|
||||
|
||||
};
|
||||
|
||||
//依赖构造函数
|
||||
var Dragfn = function (ele, opt) {
|
||||
this.$element = ele;
|
||||
this.options = opt;
|
||||
};
|
||||
//构造函数方法
|
||||
Dragfn.prototype = {
|
||||
init: function (obj) {
|
||||
var self = this;
|
||||
self.ele=self.$element;
|
||||
self.handle=$(obj);//手柄
|
||||
self.options = self.options;
|
||||
self.disable = self.options.disable;
|
||||
self._start = false;
|
||||
self._move = false;
|
||||
self._end = false;
|
||||
self.disX = 0;
|
||||
self.disY = 0;
|
||||
self.zIndex=1000;
|
||||
self.moving=false;
|
||||
self.moves="";
|
||||
//设置鼠标移上去的样式
|
||||
$(obj).css('cursor','move');
|
||||
$(obj).children('img').css({'width':'100%','height':'100%'});
|
||||
|
||||
//追加拉伸的块
|
||||
$(obj).append(`<div class="draw_move" style='position:absolute;left:0;top:0;height:5px;width:5px;background:transparent ;cursor:se-resize;display:none' data-position="left_top"></div>
|
||||
<div class="draw_move" style='position:absolute;right:0;top:0;height:5px;width:5px;background:transparent;cursor: ne-resize;display:none' data-position="right-top"></div>
|
||||
<div class="draw_move" style='position:absolute;left:0;bottom:0;height:5px;width:5px;background:transparent;cursor: sw-resize;display:none' data-position="left-bottom"></div>
|
||||
<div class="draw_move" style='position:absolute;right:0;bottom:0;height:5px;width:5px;background:rgb(122, 191, 238);cursor: se-resize;display:none' data-position="right-bottom"></div>
|
||||
`);
|
||||
|
||||
//父级
|
||||
self.box = $.type(self.options.scope)==="string" ? self.options.scope : null;
|
||||
|
||||
//手柄
|
||||
if(self.options.handle!=null){
|
||||
self.handle=$(obj).find(self.options.handle);
|
||||
}
|
||||
var parents = $(obj).parents('.design-sketch');
|
||||
$(obj).children('.draw_move').on("mousedown", function (ev) {
|
||||
// 阻止冒泡,避免缩放时触发移动事件
|
||||
ev.stopPropagation();
|
||||
ev.preventDefault()
|
||||
var obj_child = $(this),position = obj_child.data('position');
|
||||
var pos = {
|
||||
'w': obj.offsetWidth,
|
||||
'h': obj.offsetHeight,
|
||||
'x': ev.clientX,
|
||||
'y': ev.clientY
|
||||
};
|
||||
parents.on('mousemove',function(even){
|
||||
even.preventDefault();
|
||||
// 设置图片的最小缩放为30*30
|
||||
var w = Math.max(14, even.clientX - pos.x + pos.w);
|
||||
var h = Math.max(14,even.clientY - pos.y + pos.h);
|
||||
// 设置图片的最大宽高
|
||||
w = w >= parents[0].offsetWidth-obj.offsetLeft ? parents[0].offsetWidth-obj.offsetLeft : w;
|
||||
h = h >= parents[0].offsetHeight-obj.offsetTop ? parents[0].offsetHeight-obj.offsetTop : h;
|
||||
|
||||
obj.style.height = h + 'px';
|
||||
obj.style.overflow = 'hidden';
|
||||
//字体大小改变
|
||||
obj.style.width = w + 'px';
|
||||
obj.style.lineHeight = 1;
|
||||
self.options.cbChange(obj.style,self);
|
||||
|
||||
})
|
||||
parents.on('mouseleave',function(){
|
||||
parents.unbind("mousemove");
|
||||
parents.unbind("onmouseup");
|
||||
})
|
||||
obj_child.on('mouseup',function(){
|
||||
parents.unbind("mousemove");
|
||||
parents.unbind("onmouseup");
|
||||
})
|
||||
parents.on('mouseup',function(){
|
||||
parents.unbind("mousemove");
|
||||
parents.unbind("onmouseup");
|
||||
})
|
||||
});
|
||||
//三个事件
|
||||
self.handle.on("mousedown", function (ev) {
|
||||
self.start(ev, obj);
|
||||
obj.setCapture && obj.setCapture();
|
||||
return false;
|
||||
});
|
||||
$(obj).on("mousemove", function (ev) {
|
||||
self.move(ev, obj);
|
||||
});
|
||||
if(self.options.dragChange) {
|
||||
$(obj).on("mousemove", function (ev) {
|
||||
self.move(ev, obj);
|
||||
});
|
||||
$(obj).on("mouseup", function (ev) {
|
||||
self.end(ev, obj);
|
||||
});
|
||||
}else{
|
||||
$(document).on("mousemove", function (ev) {
|
||||
self.move(ev, obj);
|
||||
});
|
||||
$(document).on("mouseup", function (ev) {
|
||||
self.end(ev, obj);
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
//jquery调取函数时候用
|
||||
loadJqueryfn: function(){
|
||||
var self=this;
|
||||
$.extend({
|
||||
//返回按照index排序的回调函数
|
||||
sortBox:function(obj){
|
||||
var arr=[];
|
||||
for (var s = 0; s < $(obj).length; s++) {
|
||||
arr.push($(obj).eq(s));
|
||||
}
|
||||
for ( var i = 0; i < arr.length; i++) {
|
||||
for ( var j = i + 1; j < arr.length; j++) {
|
||||
if(Number(arr[i].attr("index")) > Number(arr[j].attr("index"))){
|
||||
var temp = arr[i];
|
||||
arr[i] = arr[j];
|
||||
arr[j] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
return arr
|
||||
},
|
||||
//随机排序函数
|
||||
randomfn:function(obj){
|
||||
self.pack($(obj),true);
|
||||
},
|
||||
//开启拖拽
|
||||
disable_open:function(){
|
||||
self.disable=false;
|
||||
},
|
||||
//禁止拖拽
|
||||
disable_cloose:function(){
|
||||
self.disable=true;
|
||||
}
|
||||
});
|
||||
},
|
||||
toDisable: function(){
|
||||
var self=this;
|
||||
if(self.options.disableInput!=null){
|
||||
$(self.options.disableInput).bind("click",function(){
|
||||
if(self.disable==true){
|
||||
self.disable=false
|
||||
}else{
|
||||
self.disable=true
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
start: function (ev, obj) {
|
||||
var self = this;
|
||||
self.moved=obj;
|
||||
if (self.disable == true) {
|
||||
return false
|
||||
}
|
||||
self._start = true;
|
||||
$(obj).find('.draw_move').show();
|
||||
$(obj).siblings().find('.draw_move').hide();
|
||||
var oEvent = ev || event;
|
||||
self.disX = oEvent.clientX - obj.offsetLeft;
|
||||
self.disY = oEvent.clientY - obj.offsetTop;
|
||||
$(obj).css("zIndex",self.zIndex++);
|
||||
self.options.cbStart();
|
||||
},
|
||||
move: function (ev, obj) {
|
||||
var self = this;
|
||||
if (self._start != true) {
|
||||
return false
|
||||
}
|
||||
if(obj!=self.moved){
|
||||
return false
|
||||
}
|
||||
self._move = true;
|
||||
var oEvent = ev || event;
|
||||
var l = oEvent.clientX - self.disX;
|
||||
var t = oEvent.clientY - self.disY;
|
||||
//有父级限制
|
||||
if (self.box != null) {
|
||||
var rule = self.collTestBox(obj,self.box);
|
||||
if (l > rule.lmax) {
|
||||
l = rule.lmax;
|
||||
} else if (l < rule.lmin) {
|
||||
l = rule.lmin;
|
||||
}
|
||||
if (t > rule.tmax) {
|
||||
t = rule.tmax;
|
||||
} else if (t < rule.tmin) {
|
||||
t = rule.tmin;
|
||||
}
|
||||
}
|
||||
if(self.options.axis=="all"){
|
||||
obj.style.left = self.grid(obj, l, t).left + 'px';
|
||||
obj.style.top = self.grid(obj, l, t).top + 'px';
|
||||
}else if(self.options.axis=="y"){
|
||||
obj.style.top = self.grid(obj, l, t).top + 'px';
|
||||
}else if(self.options.axis=="x"){
|
||||
obj.style.left = self.grid(obj, l, t).left + 'px';
|
||||
}
|
||||
/* if(self.options.changeWhen=="move") {
|
||||
if (self.options.changeMode == "sort") {
|
||||
self.sortDrag(obj);
|
||||
} else if (self.options.changeMode == "point") {
|
||||
self.pointmoveDrag(obj);
|
||||
}
|
||||
}else{
|
||||
self.moveAddClass(obj);
|
||||
}*/
|
||||
if(self.options.pos==true){
|
||||
self.moveAddClass(obj);
|
||||
}
|
||||
self.options.cbMove(obj,self);
|
||||
|
||||
},
|
||||
end: function (ev, obj) {
|
||||
var self = this;
|
||||
if (self._start != true) {
|
||||
return false
|
||||
}
|
||||
if(self.options.changeMode=="sort"&&self.options.pos==true){
|
||||
self.sortDrag(obj);
|
||||
}else if(self.options.changeMode=="point"&&self.options.pos==true){
|
||||
self.pointDrag(obj);
|
||||
}
|
||||
if(self.options.pos==true){
|
||||
self.animation(obj, self.aPos[$(obj).attr("index")]);
|
||||
}
|
||||
self.options.cbEnd(obj.style,self);
|
||||
if(self.options.handle!=null){
|
||||
$(obj).find(self.options.handle).unbind("onmousemove");
|
||||
$(obj).find(self.options.handle).unbind("onmouseup");
|
||||
}else{
|
||||
$(obj).unbind("onmousemove");
|
||||
$(obj).unbind("onmouseup");
|
||||
}
|
||||
obj.releaseCapture && obj.releaseCapture();
|
||||
self._start = false;
|
||||
|
||||
},
|
||||
//算父级的宽高
|
||||
collTestBox: function (obj, obj2) {
|
||||
var self = this;
|
||||
var l1 = 0;
|
||||
var t1 = 0;
|
||||
var l2 = $(obj2).innerWidth() - $(obj).outerWidth();
|
||||
var t2 = $(obj2).innerHeight() - $(obj).outerHeight();
|
||||
return {
|
||||
lmin: l1,//取的l最小值
|
||||
tmin: t1,//取的t最小值
|
||||
lmax: l2,//取的l最大值
|
||||
tmax: t2//取的t最大值
|
||||
}
|
||||
|
||||
},
|
||||
//算父级宽高时候干掉margin
|
||||
grid: function (obj, l, t) {//cur:[width,height]
|
||||
var self = this;
|
||||
var json = {
|
||||
left: l,
|
||||
top: t
|
||||
};
|
||||
if ($.isArray(self.options.grid) && self.options.grid.length == 2) {
|
||||
var gx = self.options.grid[0];
|
||||
var gy = self.options.grid[1];
|
||||
json.left = Math.floor((l + gx / 2) / gx) * gx;
|
||||
json.top = Math.floor((t + gy / 2) / gy) * gy;
|
||||
return json
|
||||
} else if (self.options.grid == null) {
|
||||
return json
|
||||
} else {
|
||||
console.log("grid参数传递格式错误");
|
||||
return false
|
||||
}
|
||||
},
|
||||
findNearest: function(obj){
|
||||
var self=this;
|
||||
var iMin=new Date().getTime();
|
||||
var iMinIndex=-1;
|
||||
var ele=self.ele;
|
||||
for(var i=0;i<ele.length;i++){
|
||||
if(obj==ele[i]){
|
||||
continue;
|
||||
}
|
||||
if(self.collTest(obj,ele[i])){
|
||||
var dis=self.getDis(obj,ele[i]);
|
||||
if(dis<iMin){
|
||||
iMin=dis;
|
||||
iMinIndex=i;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(iMinIndex==-1){
|
||||
return null;
|
||||
}else{
|
||||
return ele[iMinIndex];
|
||||
}
|
||||
},
|
||||
getDis: function(obj,obj2){
|
||||
var self=this;
|
||||
var l1=obj.offsetLeft+obj.offsetWidth/2;
|
||||
var l2=obj2.offsetLeft+obj2.offsetWidth/2;
|
||||
|
||||
var t1=obj.offsetTop+obj.offsetHeight/2;
|
||||
var t2=obj2.offsetTop+obj2.offsetHeight/2;
|
||||
|
||||
var a=l2-l1;
|
||||
var b=t1-t2;
|
||||
|
||||
return Math.sqrt(a*a+b*b);
|
||||
},
|
||||
collTest: function(obj,obj2){
|
||||
var self=this;
|
||||
var l1=obj.offsetLeft;
|
||||
var r1=obj.offsetLeft+obj.offsetWidth;
|
||||
var t1=obj.offsetTop;
|
||||
var b1=obj.offsetTop+obj.offsetHeight;
|
||||
|
||||
var l2=obj2.offsetLeft;
|
||||
var r2=obj2.offsetLeft+obj2.offsetWidth;
|
||||
var t2=obj2.offsetTop;
|
||||
var b2=obj2.offsetTop+obj2.offsetHeight;
|
||||
|
||||
if(r1<l2 || r2<l1 || t2>b1 || b2<t1){
|
||||
return false;
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
},
|
||||
//初始布局转换
|
||||
pack: function(ele,click){
|
||||
var self=this;
|
||||
self.toDisable();
|
||||
if(self.options.pos==false){
|
||||
for (var i = 0; i < ele.length; i++) {
|
||||
$(ele[i]).css("position", "absolute");
|
||||
$(ele[i]).css("margin", "0");
|
||||
self.init(ele[i]);
|
||||
}
|
||||
}else if(self.options.pos==true) {
|
||||
var arr = [];
|
||||
if (self.options.random || click) {
|
||||
while (arr.length < ele.length) {
|
||||
var n = self.rnd(0, ele.length);
|
||||
if (!self.finInArr(arr, n)) {//没找到
|
||||
arr.push(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (self.options.random == false || click != true) {
|
||||
var n = 0;
|
||||
while (arr.length < ele.length) {
|
||||
arr.push(n);
|
||||
n++
|
||||
}
|
||||
}
|
||||
|
||||
//如果是第二次以后随机列表,那就重新排序后再随机,因为我智商不够使,不会排了
|
||||
if (self.firstRandom == false) {
|
||||
var sortarr = [];
|
||||
var n = 0;
|
||||
while (sortarr.length < ele.length) {
|
||||
sortarr.push(n);
|
||||
n++
|
||||
}
|
||||
for (var i = 0; i < ele.length; i++) {
|
||||
$(ele[i]).attr("index", sortarr[i]);
|
||||
$(ele[i]).css("left", self.aPos[sortarr[i]].left);
|
||||
$(ele[i]).css("top", self.aPos[sortarr[i]].top);
|
||||
}
|
||||
}
|
||||
|
||||
//布局转化
|
||||
self.aPos = [];
|
||||
if (self.firstRandom == false) {
|
||||
//不是第一次
|
||||
for (var j = 0; j < ele.length; j++) {
|
||||
self.aPos[j] = {
|
||||
left: ele[$(ele).eq(j).attr("index")].offsetLeft,
|
||||
top: ele[$(ele).eq(j).attr("index")].offsetTop
|
||||
};
|
||||
}
|
||||
} else {
|
||||
//第一次
|
||||
for (var j = 0; j < ele.length; j++) {
|
||||
self.aPos[j] = {left: ele[j].offsetLeft, top: ele[j].offsetTop};
|
||||
}
|
||||
}
|
||||
//第二个循环布局转化
|
||||
for (var i = 0; i < ele.length; i++) {
|
||||
$(ele[i]).attr("index", arr[i]);
|
||||
$(ele[i]).css("left", self.aPos[arr[i]].left);
|
||||
$(ele[i]).css("top", self.aPos[arr[i]].top);
|
||||
$(ele[i]).css("position", "absolute");
|
||||
$(ele[i]).css("margin", "0");
|
||||
self.init(ele[i]);
|
||||
}
|
||||
self.firstRandom = false;
|
||||
}
|
||||
},
|
||||
//移动时候加class
|
||||
moveAddClass: function(obj){
|
||||
var self=this;
|
||||
var oNear=self.findNearest(obj);
|
||||
$(self.$element).removeClass(self.options.moveClass);
|
||||
if(oNear && $(oNear).hasClass(self.options.moveClass)==false){
|
||||
$(oNear).addClass(self.options.moveClass);
|
||||
}
|
||||
|
||||
},
|
||||
//给li排序
|
||||
sort: function(){
|
||||
var self=this;
|
||||
var arr_li=[];
|
||||
for (var s = 0; s < self.$element.length; s++) {
|
||||
arr_li.push(self.$element[s]);
|
||||
}
|
||||
for ( var i = 0; i < arr_li.length; i++) {
|
||||
for ( var j = i + 1; j < arr_li.length; j++) {
|
||||
if(Number($(arr_li[i]).attr("index")) > Number($(arr_li[j]).attr("index"))){
|
||||
var temp = arr_li[i];
|
||||
arr_li[i] = arr_li[j];
|
||||
arr_li[j] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
return arr_li;
|
||||
},
|
||||
//点对点的方式换位
|
||||
pointDrag: function(obj){
|
||||
var self=this;
|
||||
//先拍序
|
||||
var oNear=self.findNearest(obj);
|
||||
if (oNear) {
|
||||
self.animation(obj,self.aPos[$(oNear).attr("index")]);
|
||||
self.animation(oNear, self.aPos[$(obj).attr("index")]);
|
||||
var tmp;
|
||||
tmp = $(obj).attr("index");
|
||||
$(obj).attr("index", $(oNear).attr("index"));
|
||||
$(oNear).attr("index", tmp);
|
||||
$(oNear).removeClass(self.options.moveClass);
|
||||
} else if (self.options.changeWhen == "end") {
|
||||
self.animation(obj, self.aPos[$(obj).attr("index")]);
|
||||
}
|
||||
|
||||
},
|
||||
//排序的方式换位
|
||||
sortDrag: function(obj){
|
||||
var self=this;
|
||||
//先拍序
|
||||
var arr_li=self.sort();
|
||||
//换位置
|
||||
var oNear=self.findNearest(obj);
|
||||
if(oNear){
|
||||
if(Number($(oNear).attr("index"))>Number($(obj).attr("index"))){
|
||||
//前换后
|
||||
var obj_tmp=Number($(obj).attr("index"));
|
||||
$(obj).attr("index",Number($(oNear).attr("index"))+1);
|
||||
for (var i = obj_tmp; i < Number($(oNear).attr("index"))+1; i++) {
|
||||
self.animation(arr_li[i],self.aPos[i-1]);
|
||||
self.animation(obj,self.aPos[$(oNear).attr("index")]);
|
||||
$(arr_li[i]).removeClass(self.options.moveClass);
|
||||
$(arr_li[i]).attr("index",Number($(arr_li[i]).attr("index"))-1);
|
||||
}
|
||||
|
||||
}else if(Number($(obj).attr("index"))>Number($(oNear).attr("index"))){
|
||||
//后换前
|
||||
var obj_tmp=Number($(obj).attr("index"));
|
||||
$(obj).attr("index",$(oNear).attr("index"));
|
||||
for (var i = Number($(oNear).attr("index")); i < obj_tmp; i++) {
|
||||
self.animation(arr_li[i],self.aPos[i+1]);
|
||||
self.animation(obj,self.aPos[Number($(obj).attr("index"))]);
|
||||
$(arr_li[i]).removeClass(self.options.moveClass);
|
||||
$(arr_li[i]).attr("index",Number($(arr_li[i]).attr("index"))+1);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
self.animation(obj,self.aPos[$(obj).attr("index")]);
|
||||
}
|
||||
|
||||
},
|
||||
//运动函数(后期再加参数)
|
||||
animation: function(obj,json){
|
||||
var self=this;
|
||||
//考虑默认值
|
||||
var options=self.options.animation_options; /*|| {};
|
||||
options.duration=self.options.animation_options.duration || 800;
|
||||
options.easing=options.easing.duration.easing || 'ease-out';*/
|
||||
var self=this;
|
||||
var count=Math.round(options.duration/30);
|
||||
var start={};
|
||||
var dis={};
|
||||
for(var name in json){
|
||||
start[name]=parseFloat(self.getStyle(obj,name));
|
||||
if(isNaN(start[name])){
|
||||
switch(name){
|
||||
case 'left':
|
||||
start[name]=obj.offsetLeft;
|
||||
break;
|
||||
case 'top':
|
||||
start[name]=obj.offsetTop;
|
||||
break;
|
||||
case 'width':
|
||||
start[name]=obj.offsetWidth;
|
||||
break;
|
||||
case 'height':
|
||||
start[name]=obj.offsetHeight;
|
||||
break;
|
||||
case 'marginLeft':
|
||||
start[name]=obj.offsetLeft;
|
||||
break;
|
||||
case 'borderWidth':
|
||||
start[name]=0;
|
||||
break;
|
||||
//...
|
||||
}
|
||||
}
|
||||
dis[name]=json[name]-start[name];
|
||||
}
|
||||
|
||||
var n=0;
|
||||
|
||||
clearInterval(obj.timer);
|
||||
obj.timer=setInterval(function(){
|
||||
n++;
|
||||
for(var name in json){
|
||||
switch(options.easing){
|
||||
case 'linear':
|
||||
var a=n/count;
|
||||
var cur=start[name]+dis[name]*a;
|
||||
break;
|
||||
case 'ease-in':
|
||||
var a=n/count;
|
||||
var cur=start[name]+dis[name]*a*a*a;
|
||||
break;
|
||||
case 'ease-out':
|
||||
var a=1-n/count;
|
||||
var cur=start[name]+dis[name]*(1-a*a*a);
|
||||
break;
|
||||
}
|
||||
|
||||
if(name=='opacity'){
|
||||
obj.style.opacity=cur;
|
||||
obj.style.filter='alpha(opacity:'+cur*100+')';
|
||||
}else{
|
||||
obj.style[name]=cur+'px';
|
||||
}
|
||||
}
|
||||
|
||||
if(n==count){
|
||||
clearInterval(obj.timer);
|
||||
options.complete && options.complete();
|
||||
}
|
||||
},30);
|
||||
},
|
||||
getStyle: function(obj,name){
|
||||
return (obj.currentStyle || getComputedStyle(obj,false))[name];
|
||||
},
|
||||
//随机数
|
||||
rnd: function(n,m){
|
||||
return parseInt(Math.random()*(m-n)+n);
|
||||
},
|
||||
//在数组中找
|
||||
finInArr: function(arr,n){
|
||||
for(var i = 0 ; i < arr.length; i++){
|
||||
if(arr[i] == n){//存在
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
})
|
||||
})(jQuery,window,document);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
11944
public/static/js/vue.js
Executable file
11944
public/static/js/vue.js
Executable file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user