Authored by 王水玲

有货有赚 复制粘贴

@@ -27,8 +27,7 @@ class HaveGainApplyPage extends Page { @@ -27,8 +27,7 @@ class HaveGainApplyPage extends Page {
27 } 27 }
28 28
29 init() { 29 init() {
30 - let ua = navigator.userAgent.toLowerCase();  
31 - let isWeixin = ua.indexOf('micromessenger') !== -1; 30 + let that = this;
32 let clipboard = new Clipboard('.added', { 31 let clipboard = new Clipboard('.added', {
33 text: function() { 32 text: function() {
34 return '有货有赚'; 33 return '有货有赚';
@@ -42,31 +41,40 @@ class HaveGainApplyPage extends Page { @@ -42,31 +41,40 @@ class HaveGainApplyPage extends Page {
42 }); 41 });
43 42
44 clipboard.on('success', function(e) { 43 clipboard.on('success', function(e) {
45 - let hasFooter = {  
46 - leftBtnText: '取消',  
47 - rightBtnText: '去添加'  
48 - };  
49 -  
50 - if (isWeixin) {  
51 - hasFooter = {  
52 - centerBtnText: '确认'  
53 - };  
54 - }  
55 -  
56 - dialog.showDialog({  
57 - dialogText: '“有货有赚”服务号已经复制,请去微信搜索添加',  
58 - hasClass: 'dialog-text-apply',  
59 - hasFooter: hasFooter  
60 - }, function() {  
61 - window.location.href = 'weixin://';  
62 - });  
63 - 44 + that.copyDialog();
64 e.clearSelection(); 45 e.clearSelection();
65 }); 46 });
66 47
  48 + clipboard.on('error', function() {
  49 + that.copyDialog();
  50 + });
  51 +
67 this.bindEvents(); 52 this.bindEvents();
68 } 53 }
69 54
  55 + copyDialog() {
  56 + let ua = navigator.userAgent.toLowerCase();
  57 + let isWeixin = ua.indexOf('micromessenger') !== -1;
  58 + let hasFooter = {
  59 + leftBtnText: '取消',
  60 + rightBtnText: '去添加'
  61 + };
  62 +
  63 + if (isWeixin) {
  64 + hasFooter = {
  65 + centerBtnText: '确认'
  66 + };
  67 + }
  68 +
  69 + dialog.showDialog({
  70 + dialogText: '“有货有赚”服务号已经复制,请去微信搜索添加',
  71 + hasClass: 'dialog-text-apply',
  72 + hasFooter: hasFooter
  73 + }, function() {
  74 + window.location.href = 'weixin://';
  75 + });
  76 + }
  77 +
70 bindEvents() { 78 bindEvents() {
71 let that = this; 79 let that = this;
72 80
@@ -15,8 +15,7 @@ class HaveGainVerifyPage extends Page { @@ -15,8 +15,7 @@ class HaveGainVerifyPage extends Page {
15 } 15 }
16 16
17 init() { 17 init() {
18 - let ua = navigator.userAgent.toLowerCase();  
19 - let isWeixin = ua.indexOf('micromessenger') !== -1; 18 + let that = this;
20 let clipboard = new Clipboard('.add-btn', { 19 let clipboard = new Clipboard('.add-btn', {
21 text: function() { 20 text: function() {
22 return '有货有赚'; 21 return '有货有赚';
@@ -24,26 +23,35 @@ class HaveGainVerifyPage extends Page { @@ -24,26 +23,35 @@ class HaveGainVerifyPage extends Page {
24 }); 23 });
25 24
26 clipboard.on('success', function(e) { 25 clipboard.on('success', function(e) {
27 - let hasFooter = {  
28 - leftBtnText: '取消',  
29 - rightBtnText: '去添加'  
30 - }; 26 + that.copyDialog();
  27 + e.clearSelection();
  28 + });
31 29
32 - if (isWeixin) {  
33 - hasFooter = {  
34 - centerBtnText: '确认'  
35 - };  
36 - } 30 + clipboard.on('error', function() {
  31 + that.copyDialog();
  32 + });
  33 + }
37 34
38 - dialog.showDialog({  
39 - dialogText: '“有货有赚”服务号已经复制,请去微信搜索添加',  
40 - hasClass: 'dialog-text-apply',  
41 - hasFooter: hasFooter  
42 - }, function() {  
43 - window.location.href = 'weixin://';  
44 - }); 35 + copyDialog() {
  36 + let ua = navigator.userAgent.toLowerCase();
  37 + let isWeixin = ua.indexOf('micromessenger') !== -1;
  38 + let hasFooter = {
  39 + leftBtnText: '取消',
  40 + rightBtnText: '去添加'
  41 + };
45 42
46 - e.clearSelection(); 43 + if (isWeixin) {
  44 + hasFooter = {
  45 + centerBtnText: '确认'
  46 + };
  47 + }
  48 +
  49 + dialog.showDialog({
  50 + dialogText: '“有货有赚”服务号已经复制,请去微信搜索添加',
  51 + hasClass: 'dialog-text-apply',
  52 + hasFooter: hasFooter
  53 + }, function() {
  54 + window.location.href = 'weixin://';
47 }); 55 });
48 } 56 }
49 } 57 }