123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882 |
- $('html').css('height','100%');
- $('body').css('height','100%');
- $.fn.autoTextarea = function(options) {
- var defaults={
- maxHeight:null,
- minHeight:24
- };
- var opts = $.extend({},defaults,options);
- return $(this).each(function() {
- $(this).bind("paste cut keydown keyup focus blur",function(){
- var height,style=this.style;
- this.style.height = opts.minHeight + 'px';
- if (this.scrollHeight > opts.minHeight) {
- if (opts.maxHeight && this.scrollHeight > opts.maxHeight) {
- height = opts.maxHeight;
- style.overflowY = 'scroll';
- } else {
- height = this.scrollHeight;
- style.overflowY = 'hidden';
- }
- style.height = height + 'px';
- }
- });
- });
- };
- $('.thumbnail img').picLazyLoad();
- var specialId = (function () {
- var special_id = $('body').attr('data-special_id');
- return special_id;
- })();
- var Comment_type = '';
- var need_scroll = true;
- var event = function (obj, eventType, callback) {
- obj.live(eventType, callback);
- };
- var ajax = function (url, callback, error) {
- $.ajax({
- type: "get",
- async: false,
- url: url,
- dataType: "jsonp",
- jsonp: "callback",
- jsonpCallback: "flightHandler",
- success: callback,
- error: error || function () {
- $('.loader').hide();
- alert('网络错误');
- }
- });
- };
- var GetQueryString = function(name) {
- var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
- var r = window.location.search.substr(1).match(reg);
- if (r != null)return unescape(r[2]);
- return null;
- };
- var statShow = function () {
- if ($('.percentage').length > 0) {
- setTimeout(function () {
- for (var i = 0; i < $('.percentage').length; i++) {
- var num = $('.percentage')[i].innerHTML;
- $('.stat')[i].style.width = num;
- }
- }, 300);
- clearInterval(a);
- }
- };
- var a = setInterval(statShow, 10);
- var Vote = function (type) {
- var _self = this;
- this.type = type;
- this.answer = [];
- this.getAnswers = function () {
- return this.answer;
- };
- this.obj = $('input[name="submit_vote"]');
- this.M = function () {
- var options = function () {
- var options = [];
- for (var i = 0; i < $('.vote_options label').length; i++) {
- var option = $.trim($('.vote_options label').eq(i).text());
- options.push(option);
- }
- return options;
- };
- var sum_num = function (datas) {
- var sum = 0;
- for (var i = 0; i < datas.length; i++) {
- sum += parseFloat(datas[i]);
- }
- return sum;
- };
- return {
- result: function (data) {
- var option_items = options();
- var sum = sum_num(data);
- var vote_res = [];
- for (var i = 0; i < data.length; i++) {
- var g = {};
- g.name = option_items[i];
- g.num = parseInt(data[i]);
- g.percentage = data[i] ? Math.round(data[i] / sum * 100) : 0;
- vote_res.push(g);
- }
- return vote_res;
- }
- }
- };
- this.V = function (datas) {
- var resData = datas;
- var html = '<div class="results">';
- for (var i = 0; i < resData.length; i++) {
- html += '<div class="result">' +
- '<div class="result_option">' + resData[i].name + '</div>' +
- '<div class="status">' +
- '<div class="status_line">' +
- '<div class="stat"></div>' +
- '<div class="status_bg"></div>' +
- '</div>' +
- '<span class="num">' + resData[i].num + '票</span>' +
- '<span class="percentage">' + resData[i].percentage + '%</span>' +
- '</div>' +
- '</div>';
- }
- html += '</div>';
- return html;
- };
- this.C = function () {
- event(_self.obj, 'change', function () {
- switch (_self.type) {
- case 0:
- case 1 : {
- _self.answer = [];
- $.each(_self.obj, function () {
- if (this.checked) {
- _self.answer.push($(this).val());
- }
- });
- break;
- }
- case 2: {
- var val = $(this).val();
- if ($(this).prop('checked')) {
- if (_self.answer.length >= 2) {
- for (var g = 0; g < _self.obj.length; g++) {
- if (_self.obj.eq(g).val() == _self.answer[0]) {
- _self.obj.eq(g).prop('checked', false);
- _self.answer.splice(0, 1);
- _self.answer.push(val);
- break;
- }
- }
- }
- else {
- _self.answer = [];
- $.each(_self.obj, function () {
- if (this.checked) {
- _self.answer.push($(this).val());
- }
- });
- }
- }
- else {
- _self.answer = [];
- $.each(_self.obj, function () {
- if (this.checked) {
- _self.answer.push($(this).val());
- }
- });
- }
- }
- }
- });
- };
- };
- var Question = function (obj, handleType) {
- this.obj = obj;
- this.handleType = handleType;
- this.answer = [];
- this.getAnswer = function () {
- return this.answer;
- };
- this.C = function () {
- var _self = this;
- _self.obj.on('change', function () {
- switch (_self.handleType) {
- case 0:
- case 1 : {
- _self.answer = [];
- $.each(_self.obj, function () {
- if (this.checked) {
- _self.answer.push($(this).val());
- }
- });
- break;
- }
- case 2: {
- var val = $(this).val();
- if ($(this).prop('checked')) {
- if (_self.answer.length >= 2) {
- for (var g = 0; g < _self.obj.length; g++) {
- if (_self.obj.eq(g).val() == _self.answer[0]) {
- _self.obj.eq(g).prop('checked', false);
- _self.answer.splice(0, 1);
- _self.answer.push(val);
- break;
- }
- }
- }
- else {
- _self.answer = [];
- $.each(_self.obj, function () {
- if (this.checked) {
- _self.answer.push($(this).val());
- }
- });
- }
- }
- else {
- _self.answer = [];
- $.each(_self.obj, function () {
- if (this.checked) {
- _self.answer.push($(this).val());
- }
- });
- }
- break;
- }
- }
- });
- }
- };
- var QuestionList = function () {
- var question_items = [];
- (function (question_items) {
- var questions = $('.question').length;
- var num = 0;
- var question_nums = 'q' + num;
- for (var j = 0; j < questions; j++) {
- question_nums = new Question($('input[name="question' + num + '"]'), parseInt($('.question_type').eq(j).attr('data-type')));
- question_items.push(question_nums);
- question_nums.C();
- num++;
- }
- })(question_items);
- this.getAnswers = function () {
- var answers = [];
- for (var i = 0; i < question_items.length; i++) {
- if (question_items[i].getAnswer().length == 0) {
- continue;
- }
- var question = {};
- question.index = i;
- question.answer = question_items[i].getAnswer();
- answers.push(question);
- }
- return answers;
- };
- };
- var ReplyItem = function (comment, members) {
- var proxy = function () {
- var getNickName = function (userId) {
- for (var i = 0; i < members.length; i++) {
- if (members[i]['member_id'] == userId) {
- return members[i]['nickname'];
- }
- }
- };
- var getAvatar = function (userId) {
- for (var i = 0; i < members.length; i++) {
- if (members[i]['member_id'] == userId) {
- return members[i]['avatar'];
- }
- }
- };
- var getTime = function (time) {
- var date = '';
- var location = parseInt(new Date().getTime()/1000);
- var diffHour = parseInt((location - time)/60/60);
- var diffMinutes = parseInt((location - time)/60);
- if(diffHour <= 0){
- if(diffMinutes >= 0 && diffMinutes < 5) {
- date = "刚刚";
- }
- else {
- date = diffMinutes + "分钟前";
- }
- }
- if(diffHour < 24 && diffHour > 0){
- date = diffHour + '小时前';
- }
- if(diffHour > 24){
- var milliseconds = time * 1000;//秒变微秒
- var dat = new Date(milliseconds);//生成日期
- var month = dat.getMonth() + 1; //取得月
- var date1 = dat.getDate(); //取得天
- var hour = dat.getHours();//取得小时
- var minutes = dat.getMinutes();//取得分钟
- if (hour < 10) {
- hour = '0' + dat.getHours();
- }
- if (minutes < 10) {
- minutes = '0' + dat.getMinutes();
- }
- date = month + '月' + date1 + '日' + hour + ':' + minutes;
- }
- return date;
- };
- return {
- getNickName: getNickName,
- getAvatar: getAvatar,
- getTime: getTime
- }
- };
- var commentdata = comment;
- var sub = '';
- var subnum = 0;
- if(comment) {
- var defaultSubNum = comment['sub_comments'];
- }
- var load_btn = '';
- var loadpage = 2;
- var isLike = function () {
- var like = '';
- if (commentdata['supported'] == false) {
- like = '<a href="javascript:void(0)" class="like_btn" data-comment_id="' + commentdata['comment_id'] + '">' +
- '<span class="like_num">' + commentdata['likes'] + '</span><span class="like_icon_null"></span></a>';
- }
- else {
- like = '<a href="javascript:void(0)" class="like_btn active" data-comment_id="' + commentdata['comment_id'] + '">' +
- '<span class="like_num">' + commentdata['likes'] + '</span><span class="like_icon_null like_icon"></span></a>';
- }
- return like;
- };
- var parentHTML = function () {
- var html = '<div class="comment_item parent_reply" data-comment_id="' + commentdata['comment_id'] + '">' +
- '<div class="subject">' +
- '<div class="subject_box">' +
- '<div class="subject_image">' +
- '<img src="' + proxy().getAvatar(commentdata['user_id']) + '" alt="熊猫美妆">' +
- '</div>' +
- '<div class="subject_name">' +
- '<p class="name reply_people" data-parent="true" data-comment_id="' + commentdata['comment_id'] + '">' + proxy().getNickName(commentdata['user_id']) + '</p>' +
- '<p class="time">' + proxy().getTime(commentdata['addtime']) + '</p>' +
- '</div>' +
- '</div>' +
- '<div class="like">' + isLike() +
- '</div>' +
- '</div>' +
- '<p class="msg">' + commentdata['content'] + sub +
- '</p>' + load_btn +
- '</div>';
- return html;
- };
- var subHTML = function (comment) {
- var subHtml = '<p class="reply">' +
- '<span class="reply_people" data-comment_id="' + comment['comment_id'] + '">' + proxy().getNickName(comment['user_id']) + '</span>' +
- '回复' +
- '<span class="reply_people" data-comment_id="' + comment['comment_id'] + '" data-response_id="' + comment['response_id'] + '">' +
- proxy().getNickName(comment['to_user']) + '</span>:' + comment['content'] + '</p>';
- return subHtml;
- };
- var empty = function () {
- var empty = '<p class="reply_empty">精彩评论虚位以待</p>';
- return empty;
- };
- return {
- exportHTML: function () {
- return parentHTML();
- },
- addSub: function (comment) {
- sub += subHTML(comment);
- },
- insert: function (comment) {
- return subHTML(comment);
- },
- empty: function () {
- $('.comment_list').append(empty());
- },
- addSubnum: function () {
- subnum++;
- },
- addLoadBtn: function () {
- load_btn = '<div class="button_load_more" data-page="' + loadpage + '">查看更多评论</div>';
- },
- getLoadMore: function () {
- return defaultSubNum > subnum;
- }
- }
- };
- var ReplyList = function () {
- var created = function (replys) {
- var replyList = [];
- var replyIndex = replyList.length;
- if (!replys || replys['comments'].length == 0) {
- return;
- }
- for (var i = 0; i < replys['comments'].length; i++) {
- if (replys['comments'][i]['to_user'] == 0) {
- replyList.push(new ReplyItem(replys['comments'][i], replys['members']));
- replyIndex++;
- }
- else {
- replyList[replyIndex - 1].addSub(replys['comments'][i]);
- replyList[replyIndex - 1].addSubnum();
- }
- }
- return replyList;
- };
- var exportHTML = function (replyItem) {
- var datas = created(replyItem);
- if ($('.reply_empty').length > 0) {
- $('.reply_empty').css('display', 'none');
- }
- for (var i = 0; i < datas.length; i++) {
- if (datas[i].getLoadMore()) {
- datas[i].addLoadBtn();
- }
- $('.comment_list').append(datas[i].exportHTML());
- }
- };
- var specialReply = function (replyItem) {
- var datas = created(replyItem);
- if ($('.reply_empty').length > 0) {
- $('.reply_empty').css('display', 'none');
- }
- for (var i = 0; i < datas.length; i++) {
- $('.comment_list').prepend(datas[i].exportHTML());
- }
- };
- var curpage = 1;
- var isLoad = false;
- var getDate = function () {
- // window.location.protocol + "//" + window.location.host +'/mobile/index.php?act=member_ugc&op=comments&client_type=ajax&special_id='+specialId
- isLoad = true;
- $('.loader').show();
- ajax(window.location.protocol + "//" + window.location.host +'/mobile/index.php?act=member_ugc&op=comments&client_type=ajax&special_id=' + specialId + '&curpage=' + curpage, function (data) {
- $('.loader').hide();
- isLoad = false;
- if (data.code !== 200) {
- alert(data.message);
- }
- else {
- var replyDatas = data.datas;
- if (replyDatas['comments'].length == 0) {
- $('.comment_list').append(new ReplyItem().empty());
- return;
- }
- exportHTML(replyDatas);
- if(need_scroll && GetQueryString('need_scroll')) {
- need_scroll = false;
- $('.comment_label').trigger('click');
- }
- if (replyDatas.mobile_page['hasmore'] == true) {
- curpage++;
- document.getElementsByClassName('wrapper')[0].addEventListener('scroll',loadEvent);
- }
- else {
- document.getElementsByClassName('wrapper')[0].removeEventListener('scroll',loadEvent);
- }
- }
- }, function () {
- $('.loader').hide();
- $('.comment_list').append(new ReplyItem().empty());
- })
- };
- var loadEvent = function () {
- var scrollTop = $(this).scrollTop();
- var scrollHeight = $('.content').height();
- var windowHeight = $(this).offset().height;
- if ((scrollTop + windowHeight) - scrollHeight > 40 && isLoad == false) {
- getDate();
- }
- };
- (function () {
- getDate();
- })();
- return {
- exportHTML: exportHTML,
- specialReply: specialReply
- }
- };
- var CommentsBox = function () {
- var maxSize = 150;
- var show = function () {
- $('.pop').show();
- $('.answer_comments').show();
- $('#comments').focus();
- $(document).on("touchmove", function (event) {
- event.preventDefault();
- });
- };
- var inputFocus = function(){
- $('#comments').focus(function(){
- interval = setInterval(function() {
- document.body.scrollTop = document.body.scrollHeight;
- }, 100);
- }).blur(function(){
- clearInterval(interval);
- })
- };
- var close = function () {
- $('.pop').hide();
- $('.answer_comments').hide();
- $('#comments').blur().val('');
- $('.surplus').html(maxSize);
- $(document).off("touchmove");
- };
- var surplusInput = function () {
- event($('#comments'), 'input', function () {
- var val = $(this).val().length;
- var surplus = 0;
- if (val <= maxSize) {
- surplus = maxSize - val;
- }
- else {
- $(this).val($(this).val().substring(0, maxSize));
- }
- $('.surplus').html(surplus);
- })
- };
- var res = {
- comment_id: '',
- response_id: ''
- };
- event($('.reply_people'), 'click', function () {
- if ($(this).hasClass('name')) {
- $(this).parents('.comment_item').addClass('insert');
- }
- else {
- $(this).parent('p').addClass('insert');
- }
- res.response_id = '';
- res.comment_id = '';
- var to_user_name = $(this).text();
- commentsBox.setPlaceHolder('回复' + to_user_name).show();
- Comment_type = 'res_people';
- if ($(this).attr('data-response_id') !== '' || $(this).attr('data-response_id')) {
- res.response_id = $(this).attr('data-response_id');
- res.comment_id = $(this).attr('data-comment_id');
- }
- else {
- res.comment_id = $(this).attr('data-comment_id');
- }
- });
- var submitComments = function () {
- var url = '';
- event($('.comments_submit'), 'click', function () {
- if ($('#comments').val() == '') {
- $('#comments').focus();
- return;
- }
- $('.loader').show();
- var textVal = $('#comments').val();
- if (Comment_type == 'special_id') {
- url = window.location.protocol + "//" + window.location.host +'/mobile/index.php?act=member_ugc&op=comment&client_type=ajax&special_id=' + specialId + '&content=' + encodeURI(textVal);
- ajax(url, function (data) {
- $('.loader').hide();
- if (data.code !== 200) {
- alert(data.message);
- return;
- }
- replyList.specialReply(data.datas);
- commentsBox.close();
- })
- }
- else {
- if (res.response_id) {
- url = window.location.protocol + "//" + window.location.host +'/mobile/index.php?act=member_ugc&op=comment&client_type=ajax&special_id=' + specialId + '&content=' + encodeURI(textVal) + '&response_id=' + res.response_id + '&comment_id=' + res.comment_id;
- }
- else {
- url = window.location.protocol + "//" + window.location.host +'/mobile/index.php?act=member_ugc&op=comment&client_type=ajax&special_id=' + specialId + '&content=' + encodeURI(textVal) + '&comment_id=' + res.comment_id;
- }
- ajax(url, function (data) {
- $('.loader').hide();
- if (data.code !== 200) {
- alert(data.message);
- return;
- }
- var insertData = data.datas;
- var sub = new ReplyItem(insertData['comments'][0], insertData['members']);
- if ($('.insert').hasClass('comment_item')) {
- if ($('.insert .reply').length > 0) {
- $('.insert .reply').last().after(sub.insert(insertData['comments'][0], insertData['members']));
- }
- else {
- $('.insert .msg').after(sub.insert(insertData['comments'][0], insertData['members']));
- }
- }
- else {
- $('.insert').after(sub.insert(insertData['comments'][0], insertData['members']));
- }
- $('.insert').removeClass('insert');
- commentsBox.close();
- })
- }
- });
- };
- var setPlaceHolder = function (content) {
- $('#comments').attr('placeholder', content);
- return this;
- };
- (function () {
- // close();
- surplusInput();
- submitComments();
- inputFocus();
- })();
- return {
- show: show,
- setPlaceHolder: setPlaceHolder,
- close:close
- }
- };
- var PageVideo = function () {
- var createDom = function (videosrc, videoposter) {
- var a = document.createElement('video');
- a.poster = videoposter;
- a.src = videosrc;
- a.controls = true;
- return a;
- };
- this.append = function () {
- for (var i = 0; i < $('.video_box').length; i++) {
- var videoSrc = $('.video_box').eq(i).attr('data-src');
- var videoVideoposter = $('.video_box').eq(i).attr('data-poster');
- $('.video_box').eq(i).append(createDom(videoSrc, videoVideoposter));
- }
- };
- };
- var vote = new Vote(parseInt($('.vote_type').attr('data-type')));
- vote.C();
- var Pagevideo = new PageVideo();
- Pagevideo.append();
- var questionList = new QuestionList();
- var commentsBox = new CommentsBox();
- var replyList = new ReplyList();
- event($('.msg_btn'), 'click', function ()
- {
- if(from_app && !logined)
- {
- call_native_handler('on_native_click','{"action":"login"}',function(data)
- {
- var jsdata = JSON.parse(data);
- if(!jsdata.login) {
- return;
- }
- else {
- logined = true;
- commentsBox.setPlaceHolder('我来说两句').show();
- Comment_type = 'special_id';
- }
- });
- }
- else {
- commentsBox.setPlaceHolder('我来说两句').show();
- Comment_type = 'special_id';
- }
- });
- $('#submit_btn').on('click', function () {
- var _self = $(this);
- $('.loader').show();
- $(this).addClass('button_null');
- var allAnswers = {};
- var voteAnswers = vote.getAnswers() || [];
- var resAnswers = questionList.getAnswers() || [];
- if ($('.vote').length > 0 && voteAnswers.length == 0) {
- $(this).removeClass('button_null');
- $('.loader').hide();
- alert('亲!请完成投票');
- return;
- }
- if ($('.vote').length > 0) {
- allAnswers.vote = voteAnswers;
- }
- if ($('.question_list').length > 0) {
- allAnswers.question = resAnswers;
- }
- var url = window.location.protocol + "//" + window.location.host + "/mobile/index.php?act=special&op=submit&client_type=ajax&special_id=" + specialId + '&content=' + encodeURI(JSON.stringify(allAnswers));
- // var url = 'http://192.168.0.200/mobile/index.php?act=special&op=submit&client_type=ajax&special_id=' + special_id + '&content=' + encodeURI(JSON.stringify(allAnswers));
- ajax(url, function (data) {
- $('.loader').hide();
- if (data.code !== 200) {
- alert(data.message);
- $('.loader').hide();
- return;
- }
- _self.css('display', 'none');
- if ($('.vote').length > 0) {
- $('.vote_options').css('display', 'none');
- var voteRes = vote.M().result(data.datas['vote_result']);
- $('.vote_pro').after(vote.V(voteRes));
- statShow();
- }
- var answerDiff = data.datas['answer_diff'];
- if ($('.question_list').length > 0) {
- for (var i = 0; i < answerDiff.length; i++) {
- if (answerDiff[i]['correct']) {
- for (var j = 0; j < answerDiff[i]['origin'].length; j++) {
- $('.question_options').eq(answerDiff[i]['index']).find('.label').eq(answerDiff[i]['origin'][j]).css('color', 'green');
- }
- }
- else {
- for (var u = 0; u < answerDiff[i]['origin'].length; u++) {
- for (var g = 0; g < answerDiff[i]['submit'].length; g++) {
- if (answerDiff[i]['origin'][u] == answerDiff[i]['submit'][g]) {
- $('.question_options').eq(answerDiff[i]['index']).find('.label').eq(answerDiff[i]['origin'][u]).css('color', 'green');
- }
- else {
- $('.question_options').eq(answerDiff[i]['index']).find('.label').eq(answerDiff[i]['origin'][u]).css('color', 'green');
- $('.question_options').eq(answerDiff[i]['index']).find('.label').eq(answerDiff[i]['submit'][g]).css('color', 'red');
- }
- }
- }
- }
- }
- }
- if (data.datas['bonus_url'] !== "") {
- $('.pop').show();
- $('.bonus_page').attr('href', data.datas["bonus_url"]).addClass('fade-in').show();
- $('.close_icon').addClass('rotate').show();
- $('.bonus_page img').attr('src',data.datas["sender_avatar"]);
- }
- $('input[type="radio"]').attr('disabled', 'disabled');
- $('input[type="checkbox"]').attr('disabled', 'disabled');
- });
- });
- event($('.like_btn'), 'click', function () {
- $('.loader').show();
- var url = '';
- var $this = $(this);
- if ($(this).attr('data-comment_id')) {
- var comment_id = $(this).attr('data-comment_id');
- // window.location.protocol + "//" + window.location.host
- url = window.location.protocol + "//" + window.location.host + '/mobile/index.php?act=member_ugc&op=support&client_type=ajax&special_id=' + specialId + '&comment_id=' + comment_id;
- ajax(url, function (data) {
- $('.loader').hide();
- if (data.code !== 200) {
- alert(data.message);
- $('.loader').hide();
- return;
- }
- var localLike = $this.find('.like_num').text();
- if (data.datas['supported'] == true) {
- $this.find('.like_num').text(parseInt(localLike) + 1);
- }
- else {
- $this.find('.like_num').text(parseInt(localLike) - 1);
- }
- $this.toggleClass('active');
- $this.find('.like_icon_null').toggleClass('like_icon');
- });
- }
- else {
- //window.location.protocol + "//" + window.location.host
- url = window.location.protocol + "//" + window.location.host + '/mobile/index.php?act=member_ugc&op=support&client_type=ajax&special_id=' + specialId;
- ajax(url, function (data) {
- $('.loader').hide();
- if (data.code !== 200) {
- alert(data.message);
- $('.loader').hide();
- return;
- }
- $this.find('.like_icon_null').toggleClass('like_icon');
- })
- }
- });
- $('.close_icon').on('click',function(){
- $('.pop').hide();
- $('.bonus_page').hide();
- $('.close_icon').hide();
- });
- event($('.button_load_more'), 'click', function () {
- var comment_id = $(this).parent('.comment_item').attr('data-comment_id');
- var curpage = $(this).attr('data-page');
- console.log(comment_id);
- var url = window.location.protocol + "//" + window.location.host + '/mobile/index.php?act=member_ugc&op=comments&client_type=ajax&special_id=' + specialId + '&comment_id=' + comment_id + '&curpage=' + curpage;
- ajax(url, function (data) {
- $('.loader').hide();
- if (data.code !== 200) {
- alert(data.message);
- return;
- }
- console.log(data);
- })
- });
- event($('.comment_label'),'click',function(){
- var container = $('.wrapper'),
- scrollTo = $('.comment');
- container.scrollTop(
- scrollTo.offset().top - container.offset().top + container.scrollTop() - 50
- );
- });
- event($('.pop'),'click',function(){
- commentsBox.close();
- $('.close_icon').trigger('click');
- });
- event($('.share_icon_null'),'touchend',function(){
- call_native_handler('on_native_click','{"action":"share_page","params":{"title":"' + title + '","sub_title":"'+sub_title + '","img_url":"' +img_url +'","url":"' +url + '"}}');
- });
- register_js_hander('onKeyboardClose',function(data,callback) {
- commentsBox.close();
- });
- $("#comments").autoTextarea({
- maxHeight:300
- });
- function app()
- {
- var app=navigator.userAgent.toLowerCase(),//判断设备
- app_nav=navigator.appVersion.toLowerCase(),
- href='';
- if (app_nav.indexOf('iphone')>-1&&app.indexOf('iphone')){
- href='http://a.app.qq.com/o/simple.jsp?pkgname=com.lrlz.beautyshop';
- } else if (app.indexOf('micromessenger')>-1 && app_nav.indexOf('android')>-1) {
- href = "http://p.lrlz.com/hfive/android_down/index.html";
- }
- else {
- href="javascript:void(0)";
- }
- return href;
- }
- var open_href = app();
- $('.open_app_btn').attr('href',open_href);
|