pages.js 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869
  1. // 收入
  2. $(document).on("pageInit","#user_center-income", function(e, pageId, $page) {
  3. var nowyer=year;
  4. var income_type = GetQueryString("type");
  5. //var displayyear=new Array('2010年', '2011年', '2012年', '2013年', '2014年', '2015年', '2016年', '2017年')
  6. $("#Date").picker({
  7. toolbarTemplate: '<header class="bar bar-nav">\
  8. <button class="button button-link pull-right close-picker">确定</button>\
  9. <h1 class="title">请选择年份月份</h1>\
  10. </header>',
  11. onClose:function(){
  12. var val=$("#Date").val();
  13. var date=val.split(" ");
  14. $("#year").text(date[0]);
  15. $("#month").text(date[1]);
  16. yes_counted_url = APP_ROOT+"/wap/index.php?ctl=user_center&act=income&type=0&year="+date[0]+"&month="+date[1];
  17. no_counted_url = APP_ROOT+"/wap/index.php?ctl=user_center&act=income&type=1&year="+date[0]+"&month="+date[1];
  18. //location.href= tmpl+"index.php?ctl=user_center&act=income&year="+date[0]+"&month="+date[1];
  19. $.ajax({
  20. url:APP_ROOT+"/wap/index.php?ctl=user_center&act=income&year="+date[0]+"&month="+date[1]+"&type="+income_type,
  21. type:"post",
  22. dataType:"html",
  23. success:function(result){
  24. $(".content").find(".incomelist").html($(result).find(".content").find(".incomelist").html());
  25. }
  26. });
  27. },
  28. cols: [
  29. {
  30. textAlign: 'center',
  31. //如果你希望显示文案和实际值不同,可以在这里加一个displayValues: [.....]
  32. displayValues: [nowyer-5+'年',nowyer-4+'年',nowyer-3+'年',nowyer-2+'年',nowyer-1+'年',nowyer+'年'],
  33. values: [nowyer-5,nowyer-4,nowyer-3,nowyer-2,nowyer-1,nowyer]
  34. },
  35. {
  36. textAlign: 'center',
  37. displayValues: ['1月', '2月', '3月', '4月', '5月', '6月', '7月','8月','9月','10月','11月','12月'],
  38. values: ['1', '2', '3', '4', '5', '6', '7','8','9','10','11','12']
  39. }
  40. ]
  41. });
  42. $(".J-view-income").on('click',function(){
  43. var iscounted = Number($(this).attr("data-iscounted"));
  44. iscounted ? location.href = yes_counted_url : location.href = no_counted_url;
  45. });
  46. });
  47. // 收入
  48. $(document).on("pageInit","#user_center-goods_income_details", function(e, pageId, $page) {
  49. var nowyer=year;
  50. var income_type = GetQueryString("type");
  51. //var displayyear=new Array('2010年', '2011年', '2012年', '2013年', '2014年', '2015年', '2016年', '2017年')
  52. $("#Date").picker({
  53. toolbarTemplate: '<header class="bar bar-nav">\
  54. <button class="button button-link pull-right close-picker">确定</button>\
  55. <h1 class="title">请选择年份月份</h1>\
  56. </header>',
  57. onClose:function(){
  58. var val=$("#Date").val();
  59. var date=val.split(" ");
  60. $("#year").text(date[0]);
  61. $("#month").text(date[1]);
  62. yes_goods_url = APP_ROOT+"/wap/index.php?ctl=user_center&act=goods_income_details&type=1&year="+date[0]+"&month="+date[1];
  63. no_goods_url = APP_ROOT+"/wap/index.php?ctl=user_center&act=goods_income_details&type=2&year="+date[0]+"&month="+date[1];
  64. invalid_goods_url = APP_ROOT+"/wap/index.php?ctl=user_center&act=goods_income_details&type=3&year="+date[0]+"&month="+date[1];
  65. //location.href= tmpl+"index.php?ctl=user_center&act=income&year="+date[0]+"&month="+date[1];
  66. $.ajax({
  67. url:APP_ROOT+"/wap/index.php?ctl=user_center&act=goods_income_details&year="+date[0]+"&month="+date[1]+"&type="+income_type,
  68. type:"post",
  69. dataType:"html",
  70. success:function(result){
  71. $(".content").find(".incomelist").html($(result).find(".content").find(".incomelist").html());
  72. }
  73. });
  74. },
  75. cols: [
  76. {
  77. textAlign: 'center',
  78. //如果你希望显示文案和实际值不同,可以在这里加一个displayValues: [.....]
  79. displayValues: [nowyer-5+'年',nowyer-4+'年',nowyer-3+'年',nowyer-2+'年',nowyer-1+'年',nowyer+'年'],
  80. values: [nowyer-5,nowyer-4,nowyer-3,nowyer-2,nowyer-1,nowyer]
  81. },
  82. {
  83. textAlign: 'center',
  84. displayValues: ['1月', '2月', '3月', '4月', '5月', '6月', '7月','8月','9月','10月','11月','12月'],
  85. values: ['1', '2', '3', '4', '5', '6', '7','8','9','10','11','12']
  86. }
  87. ]
  88. });
  89. $(".J-view-goods").on('click',function(){
  90. var iscounted = Number($(this).attr("data-iscounted"));
  91. if(iscounted == 1){
  92. location.href = yes_goods_url;
  93. }
  94. else if(iscounted == 2){
  95. location.href = no_goods_url;
  96. }
  97. else{
  98. location.href = invalid_goods_url;
  99. }
  100. });
  101. });
  102. // 分享页面
  103. $(document).on("pageInit","#page-share-index", function(e, pageId, $page) {
  104. // 点击弹出下载提示窗
  105. $(".show_pop_wp").on('click',function(){
  106. $(".pop_wp").css({display:"flex"});
  107. });
  108. $(".pop_close").on('click',function(){
  109. $(".pop_wp").css({display:"none"});
  110. });
  111. var width = $(window).width();
  112. var height = $(window).height();
  113. console.log("live_in:"+live_in);
  114. if(live_in==1){
  115. if(live_url || live_url2){
  116. (function () {
  117. var player = new qcVideo.Player("id_video_container", {
  118. "live_url": live_url,
  119. "live_url2": live_url2,
  120. "width": width,
  121. "height": 320,
  122. "h5_start_patch":{
  123. "url": head_image_url,
  124. "stretch": true
  125. }
  126. }, {
  127. playStatus: function (status,type){
  128. //TODO
  129. console.log(status);
  130. if(status == "playing"){
  131. player.resize(width, height);
  132. if(!device || device=='iphone'){
  133. $(".live_info").show();
  134. $(".pop_download").hide();
  135. }
  136. }
  137. else{
  138. player.resize(width, 320);
  139. }
  140. }
  141. });
  142. $("#startplay").on('click',function(){
  143. $("#liveing").show();
  144. $("#preVedio").hide();
  145. player.play();
  146. });
  147. })();
  148. }else{
  149. (function () {
  150. var player = new qcVideo.Player("id_video_container", {
  151. "channel_id": channel_id,
  152. "app_id": app_id,
  153. "width": width,
  154. "height": 320,
  155. "h5_start_patch":{
  156. "url": head_image_url,
  157. "stretch": true
  158. }
  159. }, {
  160. playStatus: function (status){
  161. //TODO
  162. console.log(status);
  163. if(status == "playing"){
  164. player.resize(width, height);
  165. if(!device || device=='iphone'){
  166. $(".live_info").show();
  167. $(".pop_download").hide();
  168. }
  169. }
  170. else{
  171. player.resize(width, 320);
  172. }
  173. }
  174. });
  175. $("#startplay").on('click',function(){
  176. $("#liveing").show();
  177. $("#preVedio").hide();
  178. player.play();
  179. });
  180. })();
  181. }
  182. }else if(live_in==3){
  183. (function () {
  184. var player = new qcVideo.Player("id_video_container", {
  185. "file_id": file_id,
  186. "app_id": app_id,
  187. "width":width,
  188. "height":320
  189. }, {
  190. playStatus: function (status,type){
  191. //TODO
  192. console.log(status);
  193. if(status == "playing"){
  194. player.resize(width, height);
  195. if(!device || device=='iphone'){
  196. $(".live_info").show();
  197. $(".pop_download").hide();
  198. }
  199. }
  200. else{
  201. player.resize(width, 320);
  202. }
  203. }
  204. });
  205. $("#startplay").on('click',function(){
  206. $("#liveing").show();
  207. $("#preVedio").hide();
  208. player.play();
  209. });
  210. })();
  211. /*var player = new qcVideo.Player("id_video_container", {
  212. "width":width,
  213. "height":height,
  214. "stretch_full":1,
  215. "stop_time":60,
  216. "third_video": {
  217. "urls":{
  218. 20 : urls//演示地址,请替换实际地址
  219. }
  220. }
  221. });*/
  222. }else{
  223. }
  224. wx.ready(function () {
  225. // 在这里调用 API
  226. wx.onMenuShareTimeline({
  227. title: wx_title, // 分享标题
  228. link: wx_link, // 分享链接
  229. imgUrl: wx_img, // 分享图标
  230. success: function () {
  231. // 用户确认分享后执行的回调函数
  232. },
  233. cancel: function () {
  234. // 用户取消分享后执行的回调函数
  235. }
  236. });
  237. wx.onMenuShareAppMessage({
  238. title: wx_title, // 分享标题
  239. desc: wx_desc, // 分享描述
  240. link: wx_link, // 分享链接
  241. imgUrl: wx_img, // 分享图标
  242. type: 'link', // 分享类型,music、video或link,不填默认为link
  243. // dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空
  244. success: function () {
  245. // 用户确认分享后执行的回调函数
  246. },
  247. cancel: function () {
  248. // 用户取消分享后执行的回调函数
  249. }
  250. });
  251. wx.onMenuShareQQ({
  252. title: wx_title, // 分享标题
  253. desc: wx_desc, // 分享描述
  254. link: wx_link, // 分享链接
  255. imgUrl: wx_img, // 分享图标
  256. success: function () {
  257. // 用户确认分享后执行的回调函数
  258. },
  259. cancel: function () {
  260. // 用户取消分享后执行的回调函数
  261. }
  262. });
  263. wx.onMenuShareQZone({
  264. title: wx_title, // 分享标题
  265. desc: wx_desc, // 分享描述
  266. link: wx_link, // 分享链接
  267. imgUrl: wx_img, // 分享图标
  268. success: function () {
  269. // 用户确认分享后执行的回调函数
  270. },
  271. cancel: function () {
  272. // 用户取消分享后执行的回调函数
  273. }
  274. });
  275. wx.error(function(res){
  276. // config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
  277. });
  278. });
  279. function addMsg(msg) {
  280. var time = webim.Tool.formatTimeStamp(msg.getTime());
  281. var data = convertMsg(msg);
  282. if(! data){
  283. return;
  284. }
  285. if(typeof data !== 'object'){
  286. data = {
  287. "user_level": 122,
  288. "nick_name": "[群提示消息]",
  289. "text": data,
  290. };
  291. }
  292. if (data.type == 2 && showBarrage && player) {
  293. var barrage = [
  294. { "type": "content", "content": data.text, "time": "0" },
  295. ];
  296. player.addBarrage(barrage);
  297. }
  298. $('#chat-box').append('<li><p><a href="javascript:;" class="name"><i class="ico_level"></i>' + data.nick_name + '</a>' + data.text + '</p></li>');
  299. }
  300. var listeners = {
  301. loginSuccess: function () {
  302. im_message.applyJoinBigGroup(avChatRoomId);
  303. },
  304. recieveGroupMsg: function (newMsgList) {
  305. for (var j in newMsgList) {//遍历新消息
  306. var newMsg = newMsgList[j];
  307. addMsg(newMsg);
  308. }
  309. var el = $('#video_sms_list');
  310. el.scrollTop(el.prop("scrollHeight"));
  311. },
  312. sendMsgOk: function (msg) {
  313. $('#input-chat-speak').val('');
  314. },
  315. };
  316. if(typeof loginInfo !== 'undefined'){
  317. im_message.init(loginInfo, listeners);
  318. }
  319. });
  320. $(document).on("pageInit","#page-pai_podcast-goods,#page-pai_podcast-order,#page-pai_user-goods,#page-pai_user-order", function(e, pageId, $page) {
  321. // 查看物流
  322. $(document).on('click', '.J-view_express',function(e) {
  323. $.alert($(this).attr("data-express"));
  324. });
  325. if(pageId == 'page-pai_podcast-goods' || pageId == 'page-pai_user-goods'){
  326. var ajax_url;
  327. pageId == 'page-pai_podcast-goods' ? ajax_url=TMPL+'index.php?ctl=pai_podcast&act=goods&post_type=json&is_true='+is_true : ajax_url=TMPL+'index.php?ctl=pai_user&act=goods&post_type=json&is_true='+is_true;
  328. $.ajax({
  329. url: ajax_url,
  330. data: {},
  331. type: 'POST',
  332. dataType: 'json',
  333. success:function(data){
  334. if(data.status == 1){
  335. var data_list = data.data.list;
  336. var data_leftTime;
  337. for (var i = 0; i < data_list.length; i++) {
  338. data_list[i].status == 0 ? data_leftTime = data_list[i].pai_left_time : data_leftTime = data_list[i].expire_time;
  339. $(".card-footer").eq(i).find(".left_time").attr("data-leftTime",data_leftTime);
  340. console.log(data_list[i].expire_time);
  341. };
  342. $(".left_time").each(function(){
  343. var leftTime = Math.abs(parseInt($(this).attr("data-leftTime")));
  344. left_time(leftTime,$(this));
  345. });
  346. }
  347. else{
  348. $.toast(data.error,1000);
  349. }
  350. },
  351. error:function(){
  352. $.hideIndicator();
  353. $.toast('请求失败,请检查网络',1000);
  354. }
  355. });
  356. }
  357. else{
  358. // 倒计时
  359. $(".left_time").each(function(){
  360. var leftTime = Math.abs(parseInt($(this).attr("data-leftTime")));
  361. left_time(leftTime,$(this));
  362. });
  363. }
  364. // 监听设备处于锁屏或者浏览器/页面处于后台运行状态
  365. document.addEventListener("visibilitychange", function (e) {
  366. var reload_ajax_url;
  367. switch (pageId)
  368. {
  369. case 'page-pai_podcast-goods':
  370. reload_ajax_url = TMPL+"index.php?ctl=pai_podcast&act=goods&post_type=json&page_size=99999999999&is_true="+is_true;
  371. break;
  372. case 'page-pai_user-goods':
  373. reload_ajax_url = TMPL+"index.php?ctl=pai_user&act=goods&post_type=json&page_size=99999999999&is_true="+is_true;
  374. break;
  375. case 'page-pai_podcast-order':
  376. var order_sn,pai_id;
  377. GetQueryString("order_sn") ? order_sn = GetQueryString("order_sn") : '';
  378. GetQueryString("pai_id") ? pai_id = GetQueryString("pai_id") : '';
  379. reload_ajax_url = TMPL+"index.php?ctl=pai_podcast&act=order&post_type=json&is_true="+is_true+"&order_sn="+order_sn+"&pai_id="+pai_id;
  380. break;
  381. case 'page-pai_user-order':
  382. var order_sn,pai_id;
  383. GetQueryString("order_sn") ? order_sn = GetQueryString("order_sn") : '';
  384. GetQueryString("pai_id") ? pai_id = GetQueryString("pai_id") : '';
  385. reload_ajax_url = TMPL+"index.php?ctl=pai_user&act=order&post_type=json&is_true="+is_true+"&order_sn="+order_sn+"&pai_id="+pai_id;
  386. break;
  387. }
  388. if(!e.path[0].hidden){ // e.path为页面中document的集合
  389. $.ajax({
  390. url: reload_ajax_url,
  391. data: {},
  392. type: 'POST',
  393. dataType: 'json',
  394. beforeSend:function(){
  395. $.showIndicator();
  396. },
  397. success:function(data){
  398. $.hideIndicator();
  399. if(data.status == 1){
  400. if(pageId == 'page-pai_podcast-goods' || pageId == 'page-pai_user-goods'){
  401. var data_list = data.data.list;
  402. for (var i = 0; i < data_list.length; i++) {
  403. $(".card-footer").eq(i).find(".left_time").attr("data-leftTime",data_list[i].expire_time);
  404. console.log(data_list[i].expire_time);
  405. };
  406. $(".left_time").each(function(){
  407. var leftTime = Math.abs(parseInt($(this).attr("data-leftTime")));
  408. left_time(leftTime,$(this));
  409. });
  410. }
  411. else{
  412. var data_list = data.data;
  413. $(".left_time").each(function(){
  414. left_time(data_list.expire_time,$(this));
  415. });
  416. }
  417. }
  418. else{
  419. $.toast(data.error,1000);
  420. }
  421. },
  422. error:function(){
  423. $.hideIndicator();
  424. $.toast('请求失败,请检查网络',1000);
  425. }
  426. });
  427. }
  428. }, false);
  429. // 充值
  430. $(".J_recharge").on('click',function(){
  431. var json = new Object();
  432. json.android_page = 'com.fanwe.live.activity.LiveRechargeActivity';
  433. json.ios_page = 'chargerViewController';
  434. json = JSON.stringify(json);
  435. App.start_app_page(json);
  436. });
  437. // 继续参拍
  438. $(document).on('click', '.J-join_live',function(e) {
  439. var pai_id = $(this).attr('data-id');
  440. $.ajax({
  441. url:TMPL+"index.php?ctl=pai_user&act=go_video&post_type=json&itype=shop&videoType=1&pai_id="+pai_id,
  442. type:"post",
  443. dataType:"html",
  444. beforeSend:function(){
  445. $.showIndicator();
  446. },
  447. success:function(result){
  448. $.hideIndicator();
  449. result = JSON.parse(result);
  450. var roomId = result.roomId;
  451. var groupId = result.groupId;
  452. var createrId = result.createrId;
  453. var loadingVideoImageUrl = result.loadingVideoImageUrl;
  454. var videoType=1;
  455. if(result.status == 1){
  456. if(roomId>0){
  457. var json = new Object(); json.roomId = roomId.toString(),json.videoType=videoType.toString(), json.groupId = groupId.toString(), json.createrId = createrId.toString(), json.loadingVideoImageUrl = loadingVideoImageUrl.toString(), json = JSON.stringify(json);
  458. App.join_live(json);
  459. }
  460. else{
  461. $.toast("请求失败,房间已关闭");
  462. return false;
  463. }
  464. }
  465. else{
  466. $.toast(result.error ? result.error : '操作失败');
  467. return false;
  468. }
  469. },
  470. error:function(){
  471. $.hideIndicator();
  472. $.toast("请求失败,请检查网络");
  473. }
  474. });
  475. });
  476. // 观众端
  477. if(pageId == 'page-pai_user-goods' || pageId == 'page-pai_user-order'){
  478. // 进入竞拍详情(未生成订单)
  479. $(document).on('click', '.J-pai_live',function(e) {
  480. var id = $(this).attr("data-id");
  481. var json = new Object();
  482. json.android_page = 'com.fanwe.auction.activity.AuctionGoodsDetailActivity';
  483. json.ios_page = 'detailViewController';
  484. json.data = new Object();
  485. json.data.id = id;
  486. json.data.is_anchor = 0;
  487. json = JSON.stringify(json);
  488. App.start_app_page(json);
  489. });
  490. // 提醒约会
  491. $(document).on('click', '.J-remind_podcast_to_date',function(e) {
  492. var order_sn = Number($(this).attr('data-order_sn')), to_podcast_id = Number($(this).attr('data-to_podcast_id'));
  493. handleAjax.handle(TMPL+"index.php?ctl=pai_podcast&act=remind_podcast_to_date",{order_sn:order_sn, to_podcast_id:to_podcast_id}).done(function(resp){
  494. $.toast("已成功提醒",1000);
  495. }).fail(function(err){
  496. $.toast(err,1000);
  497. });
  498. });
  499. // 提醒主播确认约会
  500. $(document).on('click', '.J-remind_podcast_to_confirm_date',function(e) {
  501. var order_sn = Number($(this).attr('data-order_sn')), to_podcast_id = Number($(this).attr('data-to_podcast_id'));
  502. handleAjax.handle(TMPL+"index.php?ctl=pai_podcast&act=remind_podcast_to_confirm_date",{order_sn:order_sn, to_podcast_id:to_podcast_id}).done(function(resp){
  503. $.toast("已成功提醒",1000);
  504. //$.toast(resp,1000);
  505. //setTimeout(function(){
  506. // location.reload();
  507. // $.showPreloader();
  508. //},1000);
  509. }).fail(function(err){
  510. $.toast(err,1000);
  511. });
  512. });
  513. // 确认约会
  514. $(document).on('click', '.J-buyer_confirm_date',function(e) {
  515. var order_sn = Number($(this).attr('data-order_sn')), to_podcast_id = Number($(this).attr('data-to_podcast_id')), confirm_tip = $(this).attr('data-confirm-tip');
  516. $.confirm(confirm_tip,
  517. function () {
  518. handleAjax.handle(TMPL+"index.php?ctl=pai_podcast&act=buyer_confirm_date",{order_sn:order_sn, to_podcast_id:to_podcast_id}).done(function(resp){
  519. is_true==1 ? $.toast("确认收货成功",1000) : $.toast("确认约会成功",1000);
  520. setTimeout(function(){
  521. location.reload();
  522. $.showPreloader();
  523. },1000);
  524. }).fail(function(err){
  525. $.toast(err,1000);
  526. });
  527. }
  528. );
  529. });
  530. // 申请退款(我要投诉)
  531. $(document).on('click', '.J-buyer_to_complaint',function(e) {
  532. var order_sn = Number($(this).attr('data-order_sn')), to_podcast_id = Number($(this).attr('data-to_podcast_id'));
  533. handleAjax.handle(TMPL+"index.php?ctl=pai_podcast&act=buyer_to_complaint",{order_sn:order_sn, to_podcast_id:to_podcast_id}).done(function(resp){
  534. $.toast("已成功提交<br/>请等待客服联系",1000);
  535. setTimeout(function(){
  536. location.reload();
  537. $.showPreloader();
  538. },1000);
  539. }).fail(function(err){
  540. $.toast(err,1000);
  541. });
  542. });
  543. // 主动撤销退款
  544. $(document).on('click', '#J-oreder_revocation',function(e) {
  545. var order_sn = Number($(this).attr('data-order_sn')), to_podcast_id = Number($(this).attr('data-to_podcast_id'));
  546. handleAjax.handle(TMPL+"index.php?ctl=pai_podcast&act=oreder_revocation",{order_sn:order_sn, to_podcast_id:to_podcast_id}).done(function(resp){
  547. $.toast(resp,1000);
  548. setTimeout(function(){
  549. location.reload();
  550. $.showPreloader();
  551. },1000);
  552. }).fail(function(err){
  553. $.toast(err,1000);
  554. });
  555. });
  556. // 付款
  557. $(document).on('click', '.J-pay_diamonds',function(e) {
  558. if($('#pay_balance').is(':checked')) {
  559. var order_sn = Number($(this).attr('data-order_sn'));
  560. var pai_id = Number($(this).attr('data-pai_id'));
  561. handleAjax.handle(TMPL+"index.php?ctl=pai_user&act=pay_diamonds",{order_sn:order_sn}).done(function(resp){
  562. $.toast(resp,1000);
  563. setTimeout(function(){
  564. location.href = APP_ROOT+"/index.php?ctl=pai_user&act=order&order_sn="+order_sn+"&pai_id="+pai_id;
  565. $.showPreloader();
  566. },1000);
  567. }).fail(function(err){
  568. $.toast(err,1000);
  569. });
  570. }
  571. else{
  572. $.toast("请选择支付方式");
  573. return false;
  574. }
  575. });
  576. // 买家要求退货
  577. $(document).on('click', '#J-buyer_confirm_to_refund',function(e) {
  578. var order_sn = Number($(this).attr('data-order_sn')), to_podcast_id = Number($(this).attr('data-to_podcast_id'));
  579. handleAjax.handle(TMPL+"index.php?ctl=pai_podcast&act=buyer_confirm_to_refund",{order_sn:order_sn, to_podcast_id:to_podcast_id}).done(function(resp){
  580. $.toast(resp,1000);
  581. setTimeout(function(){
  582. location.reload();
  583. $.showPreloader();
  584. },1000);
  585. }).fail(function(err){
  586. $.toast(err,1000);
  587. });
  588. });
  589. // 联系卖家
  590. $(document).on('click', '#J-link',function(e){
  591. $.alert($(this).attr("data-link"));
  592. });
  593. }
  594. // 主播端
  595. if(pageId == 'page-pai_podcast-goods' || pageId == 'page-pai_podcast-order'){
  596. // 主播端提醒买家付款
  597. $(document).on('click', '.J-remind_buyer_pay',function(e) {
  598. var order_sn = Number($(this).attr('data-order_sn')), to_buyer_id = Number($(this).attr('data-to_buyer_id'));
  599. handleAjax.handle(TMPL+"index.php?ctl=pai_podcast&act=remind_buyer_pay",{order_sn:order_sn, to_buyer_id:to_buyer_id}).done(function(resp){
  600. $.toast(resp,1000);
  601. }).fail(function(err){
  602. $.toast(err,1000);
  603. });
  604. });
  605. // 提醒买家约会
  606. $(document).on('click', '.J-remind_buyer_to_date',function(e) {
  607. var order_sn = Number($(this).attr('data-order_sn')), to_buyer_id = Number($(this).attr('data-to_buyer_id'));
  608. handleAjax.handle(TMPL+"index.php?ctl=pai_podcast&act=remind_buyer_to_date",{order_sn:order_sn, to_buyer_id:to_buyer_id}).done(function(resp){
  609. $.toast(resp,1000);
  610. }).fail(function(err){
  611. $.toast(err,1000);
  612. });
  613. });
  614. // 确认完成约会
  615. $(document).on('click', '.J-confirm_virtual_auction',function(e) {
  616. var order_sn = Number($(this).attr('data-order_sn')), to_buyer_id = Number($(this).attr('data-to_buyer_id')), confirm_tip = $(this).attr('data-confirm-tip');
  617. $.confirm(confirm_tip,function(){
  618. handleAjax.handle(TMPL+"index.php?ctl=pai_podcast&act=confirm_virtual_auction",{order_sn:order_sn, to_buyer_id:to_buyer_id}).done(function(resp){
  619. $.toast(resp,1000);
  620. setTimeout(function(){
  621. location.reload();
  622. $.showPreloader();
  623. },1000);
  624. }).fail(function(err){
  625. $.toast(err,1000);
  626. });
  627. });
  628. });
  629. // 提醒买家确认完成约会
  630. $(document).on('click', '.J-remind_buyer_receive',function(e) {
  631. var order_sn = Number($(this).attr('data-order_sn')), to_buyer_id = Number($(this).attr('data-to_buyer_id'));
  632. handleAjax.handle(TMPL+"index.php?ctl=pai_podcast&act=remind_buyer_receive",{order_sn:order_sn, to_buyer_id:to_buyer_id}).done(function(resp){
  633. $.toast(resp,1000);
  634. }).fail(function(err){
  635. $.toast(err,1000);
  636. });
  637. });
  638. // 进入竞拍详情(未生成订单)
  639. $(document).on('click', '.J-pai_live',function(e) {
  640. var id = $(this).attr("data-id");
  641. var json = new Object();
  642. json.android_page = 'com.fanwe.auction.activity.AuctionGoodsDetailActivity';
  643. json.ios_page = 'detailViewController';
  644. json.data = new Object();
  645. json.data.id = id;
  646. json.data.is_anchor = 1;
  647. json = JSON.stringify(json);
  648. App.start_app_page(json);
  649. });
  650. // 同意退款(确认收取退货)
  651. $(document).on('click', '#J-return_virtual_pai',function(e) {
  652. var order_sn = Number($(this).attr('data-order_sn')), to_buyer_id = Number($(this).attr('data-to_buyer_id'));
  653. handleAjax.handle(TMPL+"index.php?ctl=pai_podcast&act=return_virtual_pai",{order_sn:order_sn, to_buyer_id:to_buyer_id}).done(function(resp){
  654. $.toast(resp,1000);
  655. setTimeout(function(){
  656. location.reload();
  657. $.showPreloader();
  658. },1000);
  659. }).fail(function(err){
  660. $.toast(err,1000);
  661. });
  662. });
  663. // 申请售后
  664. $(document).on('click', '#J-complaint_virtual_goods',function(e) {
  665. var order_sn = Number($(this).attr('data-order_sn')), to_buyer_id = Number($(this).attr('data-to_buyer_id'));
  666. handleAjax.handle(TMPL+"index.php?ctl=pai_podcast&act=complaint_virtual_goods",{order_sn:order_sn, to_buyer_id:to_buyer_id}).done(function(resp){
  667. $.toast(resp,1000);
  668. }).fail(function(err){
  669. $.toast(err,1000);
  670. });
  671. });
  672. // 提醒卖家发货
  673. $(document).on('click', '.J-remind_seller_delivery',function(e) {
  674. var order_sn = Number($(this).attr('data-order_sn'));
  675. handleAjax.handle(TMPL+"index.php?ctl=pai_podcast&act=remind_seller_delivery",{order_sn:order_sn}).done(function(resp){
  676. $.toast("已成功提醒",1000);
  677. }).fail(function(err){
  678. $.toast(err,1000);
  679. });
  680. });
  681. }
  682. });
  683. $(document).on("pageInit","#page-pai_user-virtual_order_details", function(e, pageId, $page) {
  684. // 充值
  685. $(".J_recharge").on('click',function(){
  686. var json = new Object();
  687. json.android_page = 'com.fanwe.live.activity.LiveRechargeDiamondsActivity';
  688. json.ios_page = 'chargerViewController';
  689. json = JSON.stringify(json);
  690. App.start_app_page(json);
  691. });
  692. // 付款
  693. $('.J-pay_diamonds').on('click',function(e) {
  694. var order_type = $(this).attr("data-ordertype");
  695. switch(order_type){
  696. case "h5shop":
  697. if($("input[name='pay-money']:checked").val()) {
  698. var order_sn = Number($(this).attr('data-order_sn'));
  699. var order_id = Number($(this).attr('data-order_id'));
  700. var pay_id = $("input[name='pay-money']:checked").val();
  701. var purchase_type = Number($(this).attr('data-purchase_type'));
  702. $.ajax({
  703. url: TMPL+"/wap/index.php?ctl=pay&act=shop_h5_pay&post_type=json",
  704. data: {order_id:order_id, purchase_type:purchase_type,order_sn:order_sn,pay_id:pay_id,shop_info:shop_info},
  705. type: 'POST',
  706. dataType: 'json',
  707. success:function(data){
  708. if(data.status == 1){
  709. try{
  710. App.pay_sdk(JSON.stringify(data.pay.sdk_code));
  711. return false;
  712. }
  713. catch(e){
  714. $.toast("SDK调用失败");
  715. return false;
  716. }
  717. }else{
  718. $.hideIndicator();
  719. $.toast(data.error,1000);
  720. }
  721. },
  722. error:function(){
  723. $.hideIndicator();
  724. $.toast('请求失败,请检查网络',1000);
  725. }
  726. });
  727. }
  728. else{
  729. $.toast("请选择支付方式");
  730. return false;
  731. }
  732. break;
  733. case "to_podcast":
  734. if($("input[name='pay-money']:checked").val()) {
  735. var order_sn = Number($(this).attr('data-order_sn'));
  736. var order_id = Number($(this).attr('data-order_id'));
  737. var pay_id = $("input[name='pay-money']:checked").val();
  738. var purchase_type = Number($(this).attr('data-purchase_type'));
  739. $.ajax({
  740. url: TMPL+"/wap/index.php?ctl=pay&act=shop_h5_pay&post_type=json",
  741. data: {order_id:order_id, purchase_type:purchase_type,order_sn:order_sn,pay_id:pay_id,shop_info:shop_info},
  742. type: 'POST',
  743. dataType: 'json',
  744. success:function(data){
  745. if(data.status == 1){
  746. try{
  747. App.pay_sdk(JSON.stringify(data.pay.sdk_code));
  748. return false;
  749. }
  750. catch(e){
  751. $.toast("SDK调用失败");
  752. return false;
  753. }
  754. }else{
  755. $.hideIndicator();
  756. $.toast(data.error,1000);
  757. }
  758. },
  759. error:function(){
  760. $.hideIndicator();
  761. $.toast('请求失败,请检查网络',1000);
  762. }
  763. });
  764. }
  765. else{
  766. $.toast("请选择支付方式");
  767. return false;
  768. }
  769. break;
  770. default:
  771. if($('#pay_balance').is(':checked')){
  772. var order_sn = Number($(this).attr('data-order_sn'));
  773. var pai_id = Number($(this).attr('data-pai_id'));
  774. $.ajax({
  775. url: TMPL+"index.php?ctl=pai_user&act=pay_diamonds&post_type=json&itype=shop&order_sn="+order_sn,
  776. data: '',
  777. type: 'POST',
  778. dataType: 'json',
  779. beforeSend:function(){
  780. $.showIndicator();
  781. },
  782. success:function(resp){
  783. $.hideIndicator();
  784. $.toast(resp.error,1000);
  785. setTimeout(function(){
  786. if(resp.status != 1){
  787. $.toast(resp.error,1000);
  788. }else{
  789. window.location.href = TMPL+"index.php?ctl=pai_user&act=order&order_sn="+resp.order_sn+"&pai_id="+pai_id;
  790. $.showPreloader();
  791. }
  792. },1000);
  793. },
  794. error:function(){
  795. $.hideIndicator();
  796. $.toast("请求出错",1000);
  797. }
  798. });
  799. }
  800. else{
  801. $.toast("请选择支付方式");
  802. return false;
  803. }
  804. break;
  805. }
  806. });
  807. });
  808. // 我的等级
  809. $(document).on("pageInit","#page-user_center-grade", function(e, pageId, $page) {
  810. up_score == '满级' ? document.getElementById('grade_progress').style.width = '100%' : document.getElementById('grade_progress').style.width = ((u_score/up_score)*100).toFixed(2)+'%';
  811. });
  812. // 支付结果
  813. $(document).on("pageInit","#page-pay_success", function(e, pageId, $page) {
  814. // 继续参拍
  815. $(document).on('click', '.J-join_live',function(e) {
  816. // App.join_live(data_json);
  817. App.js_shopping_comeback_live_app();
  818. });
  819. });
  820. //sdk支付回调
  821. function js_pay_sdk(status){
  822. if(status == 1){
  823. window.location.href = TMPL+'/wap/index.php?ctl=shop&act=shop_order&page=1';
  824. $.showPreloader();
  825. //App.js_shopping_comeback_live_app();
  826. }
  827. }