瀏覽代碼

【C端地图初始化】

master
chenshengle 3 年之前
當前提交
bf12d8613a
共有 12 個文件被更改,包括 2201 次插入0 次删除
  1. +99
    -0
      common/js/h5_game_common.js
  2. +117
    -0
      common/js/jquery.cookie.js
  3. +4
    -0
      common/js/jquery.min.js
  4. +313
    -0
      common/js/jquery.rotate.js
  5. +1568
    -0
      common/js/swiper.jquery.min.js
  6. +2
    -0
      common/mapJsSDK/fengmap.analyser.min.js
  7. +1
    -0
      common/mapJsSDK/fengmap.effect.min.js
  8. +1
    -0
      common/mapJsSDK/fengmap.map.min.js
  9. +1
    -0
      common/mapJsSDK/fengmap.plugin.min.js
  10. +5
    -0
      squareMap/css/index.css
  11. +24
    -0
      squareMap/index.html
  12. +66
    -0
      squareMap/js/index.js

+ 99
- 0
common/js/h5_game_common.js 查看文件

@@ -0,0 +1,99 @@
var $maskRule = $("#mask-rule"),//规则遮罩层
$mask = $("#mask"),//红包遮罩层
$winning = $(".winning"),//红包
$card = $("#card"),
$close = $("#close");
//link = false;//判断是否在链接跳转中
//规则
$(".rule").click(function () {
$maskRule.show();
});
$('.b1').click(function(){
$('.t_w').hide();
$('.b1').hide();
})
$('#share').click(function(){
$('.t_w').show();
$('.b1').show();
})
$('.t_w').click(function(){
$('.t_w').hide();
$('.b1').hide();
})
$("#close-rule").click(function () {
$maskRule.hide();
});
$('#warnning-box-bg').click(function(){
$('#warnning-box-bg').hide();
$('#warnning-box').hide();
})
$("#w-button").click(function () {
$('#warnning-box-bg').hide();
$('#warnning-box').hide();
});
/*获取地址栏参数*/
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]);
return null;
}
/*权重计算*/
function roll(args){
let sum_weight = 0;
let result = null;

const items = args.slice().map(item => (sum_weight += item.weight) && item); // 计算总权重
const random = Math.ceil(Math.random() * sum_weight); // 随机抽取的物品位置
let start = 0; // 区间的开始,第一个是为0

while (items.length) {
const item = items.shift(); // 取出第一个商品
const end = start + item.weight; // 计算区间的结束
if (random > start && random <= end) { // 如果随机数在这个区间内,说明抽中了该商品,终止循环
result = item;
break;
}
start = end; // 当前区间的结束,作为下一个区间的开始
}

return result ? result.item : null;

}
/*中奖信息提示*/
function win() {
//遮罩层显示
$mask.show();
$winning.addClass("reback");
setTimeout(function () {
$card.addClass("pull");
}, 500);

//关闭弹出层
$("#close,.win,.btn").click(function () {
//$close.click(function () {
$mask.hide();
$winning.removeClass("reback");
$card.removeClass("pull");
});
/*$(".win,.btn").click(function () {
link = true;
});*/
}

//此处可以在commonjs中合并
function queryString(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.search);
if(results === null) {
return "";
}
else {
return decodeURIComponent(results[1].replace(/\+/g, " "));
}
}




+ 117
- 0
common/js/jquery.cookie.js 查看文件

@@ -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);
};

}));

+ 4
- 0
common/js/jquery.min.js
文件差異過大導致無法顯示
查看文件


+ 313
- 0
common/js/jquery.rotate.js 查看文件

@@ -0,0 +1,313 @@
// VERSION: 2.2 LAST UPDATE: 13.03.2012
/*
* Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
*
* Made by Wilq32, wilq32@gmail.com, Wroclaw, Poland, 01.2009
* Website: http://code.google.com/p/jqueryrotate/
*/

// Documentation removed from script file (was kinda useless and outdated)

(function($) {
var supportedCSS,styles=document.getElementsByTagName("head")[0].style,toCheck="transformProperty WebkitTransform OTransform msTransform MozTransform".split(" ");
for (var a=0;a<toCheck.length;a++) if (styles[toCheck[a]] !== undefined) supportedCSS = toCheck[a];
// Bad eval to preven google closure to remove it from code o_O
// After compresion replace it back to var IE = 'v' == '\v'
var IE = eval('"v"=="\v"');

jQuery.fn.extend({
rotate:function(parameters)
{
if (this.length===0||typeof parameters=="undefined") return;
if (typeof parameters=="number") parameters={angle:parameters};
var returned=[];
for (var i=0,i0=this.length;i<i0;i++)
{
var element=this.get(i);
if (!element.Wilq32 || !element.Wilq32.PhotoEffect) {

var paramClone = $.extend(true, {}, parameters);
var newRotObject = new Wilq32.PhotoEffect(element,paramClone)._rootObj;

returned.push($(newRotObject));
}
else {
element.Wilq32.PhotoEffect._handleRotation(parameters);
}
}
return returned;
},
getRotateAngle: function(){
var ret = [];
for (var i=0,i0=this.length;i<i0;i++)
{
var element=this.get(i);
if (element.Wilq32 && element.Wilq32.PhotoEffect) {
ret[i] = element.Wilq32.PhotoEffect._angle;
}
}
return ret;
},
stopRotate: function(){
for (var i=0,i0=this.length;i<i0;i++)
{
var element=this.get(i);
if (element.Wilq32 && element.Wilq32.PhotoEffect) {
clearTimeout(element.Wilq32.PhotoEffect._timer);
}
}
}
});

// Library agnostic interface

Wilq32=window.Wilq32||{};
Wilq32.PhotoEffect=(function(){

if (supportedCSS) {
return function(img,parameters){
img.Wilq32 = {
PhotoEffect: this
};
this._img = this._rootObj = this._eventObj = img;
this._handleRotation(parameters);
}
} else {
return function(img,parameters) {
// Make sure that class and id are also copied - just in case you would like to refeer to an newly created object
this._img = img;

this._rootObj=document.createElement('span');
this._rootObj.style.display="inline-block";
this._rootObj.Wilq32 =
{
PhotoEffect: this
};
img.parentNode.insertBefore(this._rootObj,img);
if (img.complete) {
this._Loader(parameters);
} else {
var self=this;
// TODO: Remove jQuery dependency
jQuery(this._img).bind("load", function()
{
self._Loader(parameters);
});
}
}
}
})();

Wilq32.PhotoEffect.prototype={
_setupParameters : function (parameters){
this._parameters = this._parameters || {};
if (typeof this._angle !== "number") this._angle = 0 ;
if (typeof parameters.angle==="number") this._angle = parameters.angle;
this._parameters.animateTo = (typeof parameters.animateTo==="number") ? (parameters.animateTo) : (this._angle);

this._parameters.step = parameters.step || this._parameters.step || null;
this._parameters.easing = parameters.easing || this._parameters.easing || function (x, t, b, c, d) { return -c * ((t=t/d-1)*t*t*t - 1) + b; }
this._parameters.duration = parameters.duration || this._parameters.duration || 1000;
this._parameters.callback = parameters.callback || this._parameters.callback || function(){};
if (parameters.bind && parameters.bind != this._parameters.bind) this._BindEvents(parameters.bind);
},
_handleRotation : function(parameters){
this._setupParameters(parameters);
if (this._angle==this._parameters.animateTo) {
this._rotate(this._angle);
}
else {
this._animateStart();
}
},

_BindEvents:function(events){
if (events && this._eventObj)
{
// Unbinding previous Events
if (this._parameters.bind){
var oldEvents = this._parameters.bind;
for (var a in oldEvents) if (oldEvents.hasOwnProperty(a))
// TODO: Remove jQuery dependency
jQuery(this._eventObj).unbind(a,oldEvents[a]);
}

this._parameters.bind = events;
for (var a in events) if (events.hasOwnProperty(a))
// TODO: Remove jQuery dependency
jQuery(this._eventObj).bind(a,events[a]);
}
},

_Loader:(function()
{
if (IE)
return function(parameters)
{
var width=this._img.width;
var height=this._img.height;
this._img.parentNode.removeChild(this._img);
this._vimage = this.createVMLNode('image');
this._vimage.src=this._img.src;
this._vimage.style.height=height+"px";
this._vimage.style.width=width+"px";
this._vimage.style.position="absolute"; // FIXES IE PROBLEM - its only rendered if its on absolute position!
this._vimage.style.top = "0px";
this._vimage.style.left = "0px";

/* Group minifying a small 1px precision problem when rotating object */
this._container = this.createVMLNode('group');
this._container.style.width=width;
this._container.style.height=height;
this._container.style.position="absolute";
this._container.setAttribute('coordsize',width-1+','+(height-1)); // This -1, -1 trying to fix ugly problem with small displacement on IE
this._container.appendChild(this._vimage);
this._rootObj.appendChild(this._container);
this._rootObj.style.position="relative"; // FIXES IE PROBLEM
this._rootObj.style.width=width+"px";
this._rootObj.style.height=height+"px";
this._rootObj.setAttribute('id',this._img.getAttribute('id'));
this._rootObj.className=this._img.className;
this._eventObj = this._rootObj;
this._handleRotation(parameters);
}
else
return function (parameters)
{
this._rootObj.setAttribute('id',this._img.getAttribute('id'));
this._rootObj.className=this._img.className;
this._width=this._img.width;
this._height=this._img.height;
this._widthHalf=this._width/2; // used for optimisation
this._heightHalf=this._height/2;// used for optimisation
var _widthMax=Math.sqrt((this._height)*(this._height) + (this._width) * (this._width));

this._widthAdd = _widthMax - this._width;
this._heightAdd = _widthMax - this._height; // widthMax because maxWidth=maxHeight
this._widthAddHalf=this._widthAdd/2; // used for optimisation
this._heightAddHalf=this._heightAdd/2;// used for optimisation
this._img.parentNode.removeChild(this._img);
this._aspectW = ((parseInt(this._img.style.width,10)) || this._width)/this._img.width;
this._aspectH = ((parseInt(this._img.style.height,10)) || this._height)/this._img.height;
this._canvas=document.createElement('canvas');
this._canvas.setAttribute('width',this._width);
this._canvas.style.position="relative";
this._canvas.style.left = -this._widthAddHalf + "px";
this._canvas.style.top = -this._heightAddHalf + "px";
this._canvas.Wilq32 = this._rootObj.Wilq32;
this._rootObj.appendChild(this._canvas);
this._rootObj.style.width=this._width+"px";
this._rootObj.style.height=this._height+"px";
this._eventObj = this._canvas;
this._cnv=this._canvas.getContext('2d');
this._handleRotation(parameters);
}
})(),

_animateStart:function()
{
if (this._timer) {
clearTimeout(this._timer);
}
this._animateStartTime = +new Date;
this._animateStartAngle = this._angle;
this._animate();
},
_animate:function()
{
var actualTime = +new Date;
var checkEnd = actualTime - this._animateStartTime > this._parameters.duration;

// TODO: Bug for animatedGif for static rotation ? (to test)
if (checkEnd && !this._parameters.animatedGif)
{
clearTimeout(this._timer);
}
else
{
if (this._canvas||this._vimage||this._img) {
var angle = this._parameters.easing(0, actualTime - this._animateStartTime, this._animateStartAngle, this._parameters.animateTo - this._animateStartAngle, this._parameters.duration);
this._rotate((~~(angle*10))/10);
}
if (this._parameters.step) {
this._parameters.step(this._angle);
}
var self = this;
this._timer = setTimeout(function()
{
self._animate.call(self);
}, 10);
}

// To fix Bug that prevents using recursive function in callback I moved this function to back
if (this._parameters.callback && checkEnd){
this._angle = this._parameters.animateTo;
this._rotate(this._angle);
this._parameters.callback.call(this._rootObj);
}
},

_rotate : (function()
{
var rad = Math.PI/180;
if (IE)
return function(angle)
{
this._angle = angle;
this._container.style.rotation=(angle%360)+"deg";
}
else if (supportedCSS)
return function(angle){
this._angle = angle;
this._img.style[supportedCSS]="rotate("+(angle%360)+"deg)";
}
else
return function(angle)
{
this._angle = angle;
angle=(angle%360)* rad;
// clear canvas
this._canvas.width = this._width+this._widthAdd;
this._canvas.height = this._height+this._heightAdd;
// REMEMBER: all drawings are read from backwards.. so first function is translate, then rotate, then translate, translate..
this._cnv.translate(this._widthAddHalf,this._heightAddHalf); // at least center image on screen
this._cnv.translate(this._widthHalf,this._heightHalf); // we move image back to its orginal
this._cnv.rotate(angle); // rotate image
this._cnv.translate(-this._widthHalf,-this._heightHalf); // move image to its center, so we can rotate around its center
this._cnv.scale(this._aspectW,this._aspectH); // SCALE - if needed ;)
this._cnv.drawImage(this._img, 0, 0); // First - we draw image
}

})()
}

if (IE)
{
Wilq32.PhotoEffect.prototype.createVMLNode=(function(){
document.createStyleSheet().addRule(".rvml", "behavior:url(#default#VML)");
try {
!document.namespaces.rvml && document.namespaces.add("rvml", "urn:schemas-microsoft-com:vml");
return function (tagName) {
return document.createElement('<rvml:' + tagName + ' class="rvml">');
};
} catch (e) {
return function (tagName) {
return document.createElement('<' + tagName + ' xmlns="urn:schemas-microsoft.com:vml" class="rvml">');
};
}
})();
}

})(jQuery);

+ 1568
- 0
common/js/swiper.jquery.min.js
文件差異過大導致無法顯示
查看文件


+ 2
- 0
common/mapJsSDK/fengmap.analyser.min.js
文件差異過大導致無法顯示
查看文件


+ 1
- 0
common/mapJsSDK/fengmap.effect.min.js
文件差異過大導致無法顯示
查看文件


+ 1
- 0
common/mapJsSDK/fengmap.map.min.js
文件差異過大導致無法顯示
查看文件


+ 1
- 0
common/mapJsSDK/fengmap.plugin.min.js
文件差異過大導致無法顯示
查看文件


+ 5
- 0
squareMap/css/index.css 查看文件

@@ -0,0 +1,5 @@
#fengmap{
width: 100%;
height: 100vh;
background-color: aqua
}

+ 24
- 0
squareMap/index.html 查看文件

@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">

<link rel="stylesheet" href="./css/index.css">
</head>
<body>
<div id="fengmap"></div>
</body>
</html>
<script src="../common/mapJsSDK/fengmap.map.min.js"></script>
<script src="../common/mapJsSDK/fengmap.analyser.min.js"></script>
<script src="../common/mapJsSDK/fengmap.plugin.min.js"></script>
<script src="../common/mapJsSDK/fengmap.effect.min.js"></script>
<script src="https://s3.pstatp.com/cdn/expire-1-M/jquery/3.1.1/jquery.min.js"></script>
<script src="./js/index.js"></script>
<script>
document.write("<s"+"cript type='text/javascript' src='../common/js/h5_game_common.js?version="+Math.random()+"'></scr"+"ipt>");
document.write("<s"+"cript type='text/javascript' src='./js/index.js?version="+Math.random()+"'></scr"+"ipt>");
</script>

+ 66
- 0
squareMap/js/index.js 查看文件

@@ -0,0 +1,66 @@
$(function(){
let baseUrl='https://ciformall.youlane.cn/C';
if(window.location.origin=='https://gametest.malls.iformall.com'){
baseUrl='https://ctest.malls.iformall.com/C'
}else if(window.location.origin=='https://game.malls.iformall.com'){
baseUrl='https://c.malls.iformall.com/C'
}else if(window.location.origin=='https://game.youlane.cn'){
baseUrl='https://ciformall.youlane.cn/C'
}
init()
function init(){
$.ajax({
url:baseUrl + "/api/fengniaomap/getConfig",
type:"GET",
dataType: "json", //返回数据格式为json
headers: {
'content-type':'application/json',
"token":"c34103fa-1d40-4ba7-95a4-28975e1d9143:789:wx-cuser",
// "token":getQueryString('token')
},
success:function(res){

const data = res.data;
let mapOptions = {
appName: data.appName,
key: data.key,
mapID: data.mapId,
container: document.getElementById("fengmap"),
mapURL: `/api/mapfile/${data.tenantId}/`,
themeURL: `/api/mapfile/${data.tenantId}/theme/`,
themeID: data.themeID,
}
let zoomOptions = {
position: 3, //分为左上 1、左下2、右上3、右下4。
offset: { x: 0, y: 50 } //控件位置偏移。{x:10,y:10},基于原始位置的x,y方向的偏移。
};
let compassOptions = {
position: 2 //分为左上 1、左下2、右上3、右下4。
};
let map = new fengmap.FMMap(mapOptions);
map.on("loaded", function() {
let toolbar = new fengmap.FMToolbar(toolbarOptions); //楼层控件
let zoomToolbar = new fengmap.FMZoomControl(zoomOptions); //缩放控件
let compass = new fengmap.FMCompass(compassOptions); //指南针控件
// let earch = new fengmap.FMSearchRequest()
toolbar.addTo(map);
zoomToolbar.addTo(map);
compass.addTo(map);
compass.on("click", function() {
map.setRotation({
rotation: 0,
animate: true,
duration: 0.3,
finish: function() {
console.log("setRotation");
}
});
});
});
}
})
}
})

Loading…
取消
儲存