main.js 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. var href = window.location.href;
  2. if(href.indexOf('?')!=-1){
  3. href=window.location.href.split('?')[0];
  4. } else {
  5. if(href.indexOf('#')!=-1){
  6. href=window.location.href.split('#')[0];
  7. }
  8. }
  9. href = href + "?";
  10. var isAnswer=false;
  11. $(function() {
  12. var obj1 = dc("page1"),
  13. obj2 = dc("page2"),
  14. obj3 = dc("page3"),
  15. obj4 = dc("page4"),
  16. obj5 = dc("page5"),
  17. obj6 = dc("page6"),
  18. obj7 = dc("page7"),
  19. obj8 = dc("page8"),
  20. obj9 = dc("page9");
  21. $('.bg_1').append('<div class="top_title"><img src="http://h5.iamberry.com/iamberry/wechat/test/images/2-1.png"><div class="one_1"><img src="http://h5.iamberry.com/iamberry/wechat/test/images/1-1.png"></div></div><div id="action" style="position: relative;text-align: center;"></div></div>');
  22. document.addEventListener("touchmove", function(b) {
  23. b.preventDefault()
  24. }, false);
  25. $("#page1").on("swipeUp", function() {
  26. Mobilebone.transition(obj2, obj1, false)
  27. });
  28. $("#page2").on("swipeUp", function() {
  29. Mobilebone.transition(obj3, obj2, false)
  30. });
  31. $("#page3").on("swipeUp", function() {
  32. Mobilebone.transition(obj4, obj3, false)
  33. });
  34. $("#page4").on("swipeUp", function() {
  35. Mobilebone.transition(obj5, obj4, false)
  36. });
  37. $("#page5").on("swipeUp", function() {
  38. Mobilebone.transition(obj6, obj5, false)
  39. });
  40. $("#page6").on("swipeUp", function() {
  41. Mobilebone.transition(obj9, obj6, false)
  42. });
  43. $("#page8").off().on("swipeUp", function() {
  44. Mobilebone.transition(obj9, obj8, false)
  45. });
  46. $("#page9").on("swipeUp", function() {
  47. Mobilebone.transition(obj1, obj9, false)
  48. });
  49. $("#page1").on("swipeDown", function() {
  50. Mobilebone.transition(obj9, obj1, true)
  51. });
  52. $("#page2").on("swipeDown", function() {
  53. Mobilebone.transition(obj1, obj2, true)
  54. });
  55. $("#page3").on("swipeDown", function() {
  56. Mobilebone.transition(obj2, obj3, true)
  57. });
  58. $("#page4").on("swipeDown", function() {
  59. Mobilebone.transition(obj3, obj4, true)
  60. });
  61. $("#page5").on("swipeDown", function() {
  62. Mobilebone.transition(obj4, obj5, true)
  63. });
  64. $("#page6").on("swipeDown", function() {
  65. Mobilebone.transition(obj5, obj6, true)
  66. });
  67. $("#page8").on("swipeDown", function() {
  68. Mobilebone.transition(obj6, obj8, true)
  69. });
  70. $("#page9").on("swipeDown", function() {
  71. Mobilebone.transition(obj6, obj9, true)
  72. });
  73. });
  74. window.onload=function(){
  75. get2WM();
  76. // getConfig();
  77. setTimeout(function(){
  78. $('#action').append('<div class="left1"><img src="http://h5.iamberry.com/iamberry/wechat/test/images/1-2.png"></div><div class="right1"><img src="http://h5.iamberry.com/iamberry/wechat/test/images/1-3.png"></div><div class="left1-2"><img src="http://h5.iamberry.com/iamberry/wechat/test/images/1-4.png"></div><div class="right1-2"><img src="http://h5.iamberry.com/iamberry/wechat/test/images/1-5.png"></div>')
  79. $('.left1').addClass('smallbig1');
  80. $('.right1').addClass('smallbig2');
  81. $('.left1-2').addClass('smallbig3');
  82. $('.right1-2').addClass('smallbig4');
  83. $(".loading-bg").hide();
  84. },300);
  85. };
  86. function dc(objectid) {
  87. if(document.getElementById && document.getElementById(objectid)) {
  88. return document.getElementById(objectid);// w3c dom
  89. } else if (document.all && document.all(objectid)) {
  90. return document.all(objectid);// msie 4 dom
  91. } else if (document.layers && document.layers[objectid]) {
  92. return document.layers[objectid];// nn 4 dom.. note: this won't find nested layers
  93. } else {
  94. return false;
  95. }
  96. }
  97. $(".ul_qes>li").each(function(){
  98. $(this).click(function(){
  99. $(this).children().prop("checked",true);
  100. if(isAnswer){
  101. $(".btn_submit").off().css('background-color','#c9c9ca');
  102. }else{
  103. $(".btn_submit").css('background-color','#d90049');
  104. }
  105. });
  106. });
  107. getConfig();
  108. function getConfig(){
  109. $.ajax({
  110. type: 'get',
  111. url: '/iamberry/config/get',
  112. data: {appid: "", url: window.location.href},
  113. dataType: 'json',
  114. timeout: 10000,
  115. context: $('body'),
  116. success: function(data){
  117. setConfig(data);
  118. },
  119. error: function(xhr, type){
  120. console.log('Ajax error!' + xhr)
  121. }
  122. });
  123. }
  124. /**配置JS-SDK*/
  125. function setConfig(config){
  126. wx.config({
  127. debug: false,
  128. appId: config.appId,
  129. timestamp: config.timestamp,
  130. nonceStr: config.nonceStr,
  131. signature: config.signature,
  132. jsApiList: [
  133. 'checkJsApi',
  134. 'onMenuShareTimeline',
  135. 'onMenuShareAppMessage',
  136. 'hideMenuItems',
  137. 'showMenuItems'
  138. ]
  139. });
  140. wx.ready(function(){
  141. wxReadySuccess();
  142. });
  143. }
  144. function get2WM(){
  145. var shareUrl = '';
  146. var quaryStr = '';
  147. if(href.indexOf('?')!=-1){
  148. quaryStr = window.location.href.split('?')[1];
  149. }
  150. $.ajax({
  151. url:'/iamberry/wechat/member/shareDrpUrl?dates=' + new Date().getTime() + '&' + quaryStr,
  152. dataType: 'json',
  153. type: 'POST',
  154. data: {},
  155. timeout: 15000,
  156. success: function(dt) {
  157. console.log(dt);
  158. if(dt.status) {
  159. $("#share-2wm-image").attr("src", dt.data.qrcodeUrl);
  160. if(dt.data.shareUrl.indexOf('?')!=-1){
  161. shareUrl = href + dt.data.shareUrl.split('?')[1];
  162. }
  163. //console.log("----ture---22--" + shareUrl);
  164. } else {
  165. //console.log("----false-");
  166. var nowHref = window.location.href;
  167. if(nowHref.indexOf('?')!=-1){
  168. shareUrl = href + nowHref.split('?')[1];
  169. if(shareUrl.indexOf('#')!=-1){
  170. shareUrl = shareUrl.split('#')[0];
  171. }
  172. }
  173. $("#share-2wm-image").attr("src", dt.data.qrcodeUrl);
  174. }
  175. // 重新注册分享
  176. url = shareUrl;
  177. console.log("url:" + url);
  178. getConfig();
  179. },
  180. error: function(xhr, type, errorThrown) {
  181. // errorfn(xhr);
  182. }
  183. });
  184. }
  185. /** 分享时、分享后调用方法 */
  186. var url;
  187. function shareMessage() {
  188. url = url || href;
  189. console.log("configURL:" + url);
  190. alert(url);
  191. wx.onMenuShareTimeline({ //分享到朋友圈,只有标题、图标,没有内容简介
  192. title: "8秒冲好一瓶奶!", link: url, imgUrl: "http://h5.iamberry.com/iamberry/common/shop/images/logo_head.png",
  193. success: function () {
  194. },
  195. cancel: function () {
  196. }
  197. });
  198. wx.onMenuShareAppMessage({ // 分享给好友,有标题、内容简介、图标
  199. title: "8秒冲好一瓶奶!", desc: "精准配比、精准温度、精准奶量,只需轻轻一按!", link: url, imgUrl: "http://h5.iamberry.com/iamberry/common/shop/images/logo_head.png",
  200. success: function () {
  201. },
  202. cancel: function () {
  203. // alert("share app error:");
  204. }
  205. });
  206. }
  207. function wxReadySuccess() {
  208. // wx.getNetworkType({success: function (res) {}});
  209. wx.showMenuItems({
  210. menuList: [
  211. "menuItem:share:appMessage",
  212. "menuItem:share:timeline"
  213. ] // 要显示的菜单项,所有menu项见附录3
  214. });
  215. wx.hideMenuItems({
  216. menuList: [
  217. "menuItem:copyUrl",
  218. "menuItem:openWithSafari",
  219. "menuItem:originPage",
  220. "menuItem:share:email",
  221. "menuItem:dayMode",
  222. "menuItem:setFont",
  223. "menuItem:nightMode",
  224. "menuItem:share:qq",
  225. "menuItem:dayMode",
  226. "menuItem:exposeArticle",
  227. "menuItem:nightMode",
  228. "menuItem:openWithQQBrowser",
  229. "menuItem:share:QZone",
  230. "menuItem:favorite",
  231. "menuItem:share:facebook"
  232. ] // 要隐藏的菜单项,所有menu项见附录3
  233. });
  234. url = url || href;
  235. console.log("configURL:" + url);
  236. // alert(url);
  237. wx.onMenuShareTimeline({ //分享到朋友圈,只有标题、图标,没有内容简介
  238. title: "8秒冲好一瓶奶!", link: url, imgUrl: "http://h5.iamberry.com/iamberry/common/shop/images/logo_head.png",
  239. success: function () {
  240. },
  241. cancel: function () {
  242. }
  243. });
  244. wx.onMenuShareAppMessage({ // 分享给好友,有标题、内容简介、图标
  245. title: "8秒冲好一瓶奶!", desc: "精准配比、精准温度、精准奶量,只需轻轻一按!", link: url, imgUrl: "http://h5.iamberry.com/iamberry/common/shop/images/logo_head.png",
  246. success: function () {
  247. },
  248. cancel: function () {
  249. // alert("share app error:");
  250. }
  251. });
  252. // shareMessage();
  253. }