JS turntable Big Draw Custom probability

Source: Internet
Author: User

Company projects to engage in preferential activities, so that a turntable lottery draw to let him turn up in accordance with the probability of stopping in fact all the trouble, but the probability if set in the front-end will be a big security hole, so whether for security or later maintenance problems to write the probability into the background configuration and then read the configuration. Then the problem comes, we need to the background of the probability results and the front-end of their own turntable to correspond, my general idea is that, after the return of the probability results, the corresponding can be set a prize, and then give each of the prizes a constant identity, according to the return of the identification of our front-end to the corresponding turntable pointer stay position. Our backstage tip lazy he didn't want to change the interface, just let me go to the corresponding configuration of the prize name, OK, so it is finished.

var mydraw;//click on the Carousel method name
var $btn = $ ('. Turntablebox ');
$ (' #playnum '). HTML (playnum);
var isture = false;
var mypricename;
var Prizevalue;
if (isture = = True) {
$ ('. Turntablebox '). Unbind ("Touchend", Mydraw);
}else{
$ ('. Turntablebox '). Bind ("Touchend", Mydraw);
}
function Zhuanpan () {
$.ajax ({
Type: "Post",
URL: "",
Async:false,
data:{
Account:account,
Usertype:usertype
},
Beforesend:function () {
$ ('. Turntablebox '). Unbind ("Touchend", Mydraw);
},
Success:function (data) {
Console.log (data);
Mypricename = Data.data.prizeName;
Prizevalue = data.data.prizevalue;//Product value
Localstorage.setitem ("Prizevalue", Prizevalue);
},error:function (XMLHttpRequest, Textstatus, Errorthrown) {
Alert ("Turntable-" +xmlhttprequest.status);
Alert ("Turntable-" +xmlhttprequest.readystate);
Alert ("Turntable-" +textstatus);
},
Complete:function () {
$ ('. Turntablebox '). Bind ("Touchend", Mydraw);
}
});

}
var clickfunc = function () {
Zhuanpan ();
var data = Mypricename;
if (data = = ' 0 ') {
Rotatefunc (18, ' Congratulations on getting 0 ');
SetTimeout (hongbao,6000)
}
if (data = = ' 1 ') {
Rotatefunc (54, ' Congratulations on getting 1 ');
}
if (data = = ' 2 ') {
Rotatefunc (90, ' Congratulations on getting 2! ');
}
if (data = = ' 3 ') {
Rotatefunc (126, ' Congratulations on getting 3! ');
}
if (data = = ' 4 ') {
Rotatefunc (162, ' Congratulations on getting 4 ');
}
if (data = = ' 5 ') {
Rotatefunc (198, ' Congratulations on getting 5! ');
}
if (data = = ' 6 ') {
Rotatefunc (234, ' Congratulations on getting 6! ');
}
if (data = = ' 7 ') {
Rotatefunc (270, ' Congratulations on getting 7! ');
}
if (data = = ' 8 ') {
Rotatefunc (306, ' Congratulations on getting 8! ');
}
if (data = = ' 9 ') {
Rotatefunc (342, ' 9! ');
}

}
$btn. Bind (' Touchend ', Mydraw =function () {
Sharetimes ();//Draw number
if (isture) return; If you exit on execution
Isture = true; Flag for in execution
To determine if you are logged in or not, perform the following function
if (1 = = 2) {
$ (' #playnum '). html (' 0 ');
Alert ("Please login First");
Isture = false;
} else {//Login to execute the following
if (playnum <= 0) {//When the draw number is 0, execute
Alert ("Sorry, you have no more times!");
$ ('. Myalert '). html (' Sorry, you don't have a lottery number! '). Show (). delay (FadeOut);
$ (' #playnum '). HTML (0);
Isture = false;
} else {//the number of times it is executed
$ ('. Turntablebox '). Bind ("Touchend", Mydraw);
Playnum = playnum-1; The number of times minus 1 when the carousel is executed
if (playnum <= 0) {
Playnum = 0;
}
$ (' #playnum '). HTML (playnum);
Clickfunc ();
}
}
});

var rotatefunc = function (angle, text) {
Isture = true;
$btn. Stoprotate ();
$btn. Rotate ({
Angle:10,
duration:1500,//rotation time
Animateto:angle + 1080,//Let it be based on the result plus 1080 degrees rotation
Callback:function () {
Isture = false; Flag for execution complete
$ ('. Myalert '). HTML (text). Show (). Delay (FadeOut).
}
});

};

}

In the age of the programmer, we need to keep our arms warm.

JS turntable Big Draw Custom probability

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.