Home Web Front-end HTML Tutorial HTML5 implements the function of sharing to WeChat friends, QQ friends, QQ space Weibo QR code

HTML5 implements the function of sharing to WeChat friends, QQ friends, QQ space Weibo QR code

May 22, 2018 pm 02:38 PM
h5 html5 friend

This article mainly introduces the example code of HTML5 to realize the function of sharing to WeChat friends, QQ friends, QQ space Weibo QR code. It is very good and has reference value. Friends in need can refer to it

This is the sharing button:

1

2

3

4

5

6

<button onclick="call()">通用分享</button>

<button onclick="call(&#39;wechatFriend&#39;)">微信好友</button>

<button onclick="call(&#39;wechatTimeline&#39;)">朋友圈</button>

<button onclick="call(&#39;qqFriend&#39;)">QQ</button>

<button onclick="call(&#39;qZone&#39;)">QQ空间</button>

<button onclick="call(&#39;weibo&#39;)">微博</button>

Copy after login

This is the js calling code:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

<script type="text/javascript" src="NativeShare.js"></script>

<script type="text/javascript">

    var nativeShare = new NativeShare()

    var shareData = {

        title: &#39;分享标题&#39;,

        desc: &#39;&#39;,

        // 如果是微信该link的域名必须要在微信后台配置的安全域名之内的。

        link: &#39;https://www.baidu.com&#39;,

        icon: &#39;https://www.baidu.com&#39;,

        // 不要过于依赖以下两个回调,很多浏览器是不支持的

        success: function() {

            console.log("success")

        },

        fail: function() {

            console.log("fail")

        }

    }

    nativeShare.setShareData(shareData)

    function call(command) {

        try {

            nativeShare.call(command)

        } catch (err) {

            // 如果不支持,你可以在这里做降级处理

            alert(err.message)

            // console.log("err.message")

        }

    }

</script>

Copy after login

This is the sharing js file NativeShare.js:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

358

359

360

361

362

363

364

365

366

367

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

386

387

388

389

390

391

392

393

394

395

396

397

398

399

400

401

402

403

404

405

406

407

408

409

410

411

412

413

414

415

416

417

418

419

420

421

422

423

424

425

426

427

428

429

430

431

432

433

434

435

436

437

438

439

440

441

442

443

444

445

446

447

448

449

450

451

452

453

454

455

456

457

458

459

460

461

462

463

464

465

466

467

468

469

470

471

472

473

474

475

476

477

478

479

480

481

482

483

484

485

486

487

488

489

490

491

492

493

494

495

496

497

498

499

500

501

502

503

504

505

506

507

508

509

510

511

512

513

514

515

516

517

518

519

520

521

522

523

524

525

526

527

528

529

530

531

532

533

534

535

536

537

538

539

540

541

542

543

544

545

546

547

548

549

550

551

552

553

554

555

556

557

558

559

560

561

562

563

564

565

566

567

568

569

570

571

572

573

574

575

576

577

578

579

580

581

582

583

584

585

586

587

588

589

590

591

592

593

594

595

596

597

598

599

600

601

602

603

604

605

606

607

608

609

610

611

612

613

614

615

616

617

618

619

620

621

622

623

624

625

626

627

628

629

630

631

632

633

634

635

636

637

638

639

640

641

642

643

644

645

646

647

648

649

650

651

652

653

654

655

656

657

658

659

660

661

662

663

664

665

666

667

668

669

670

671

672

673

674

675

676

677

678

679

680

681

682

683

684

685

686

687

688

689

690

691

692

693

694

695

696

697

!function(e,t){

"object"==typeof exports&&"object"==typeof module?module.exports=t():

"function"==typeof define&&define.amd?define([],t):

"object"==typeof exports?exports["NativeShare.js"]=t():

e["NativeShare.js"]=t(

)}

(this,function(){

return function(e){

function t(r){

if(n[r])return n[r].exports;

var o=n[r]={i:r,l:!1,exports:

{

}

};

return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};

return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{

configurable:!1,enumerable:!0,get:r})},

t.n=function(e){

var n=e&&e.__esModule?function(){

return e.default}:function(){return e};

return t.d(n,"a",n),n},

t.o=function(e,t){

return Object.prototype.hasOwnProperty.call(e,t)

},t.p="",t(t.s=0)

}

([function(e,t,n){"use strict";

function r(){}

function o(e){

var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:r,n=document.getElementsByTagName("script")[0],o=document.createElement("script");

o.src=e,o.async=!0,n.parentNode.insertBefore(o,n),o.onload=t

}

function i(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");

for(var n=Object(e),r=1;r<arguments.length;r++){

var o=arguments[r];

if(null!=o)

for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&(n[i]=o[i])

}

return n

}

function a(e){

if(se)

location.href=e;

else{

var t=document.createElement("iframe");

t.style.display="none",

t.src=e,document.body.appendChild(t),

setTimeout(function(){

t&&t.parentNode&&t.parentNode.removeChild(t)},2e3)}}

function c(e){

var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=[];

for(var r in e)t?n.push(r+"="+encodeURIComponent(e[r])):n.push(r+"="+e[r]);

return n.join("&")}

function u(e){

var t=document.createElement("a");

return t.href=e,t.hostname}

function l(e){

Oe?Oe.content=e:document.head.insertAdjacentHTML("beforeend",&#39;<meta name="description" content="&#39;+e+&#39;">&#39;)

}

function f(e){

je?je.href=e:document.head.insertAdjacentHTML("beforeend",&#39;<link rel="shortcut icon" href="&#39;+e+&#39;">&#39;)

}

function s(e){

document.title=e

}

function p(e)

{

return c({share_id:924053302,url:_e.encode(e.link),

title:_e.encode(e.title),

description:_e.encode(e.desc),

previewimageUrl:_e.encode(e.icon),image_url:_e.encode(e.icon)})

}

function h(){

a((se?"mqqapi://share/to_fri?src_type=web&version=1&file_type=news":"mqqapi://share/to_fri?src_type=isqqBrowser&version=1&file_type=news")+"&"+p(Se))

}

function b(){

a((se?"mqqapi://share/to_fri?file_type=news&src_type=web&version=1&generalpastboard=1&shareType=1&cflag=1&objectlocation=pasteboard&callback_type=scheme&callback_name=QQ41AF4B2A":"mqqapi://share/to_qzone?src_type=isqqBrowser&version=1&file_type=news&req_type=1")+"&"+p(Se))

}

function y(){

var e={url:Se.link,title:Se.title,pic:Se.icon,desc:Se.desc};

location.href="

function d(){

var e={url:Se.link,title:Se.title,pic:Se.icon};

location.href="

function w(e,t){

if(!(e instanceof t))

throw new TypeError("Cannot call a class as a function")

}

function v(e,t,n){

return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e

}

function g(e,t){

if(!(e instanceof t))

throw new TypeError("Cannot call a class as a function")

}

function m(e,t){

if(!e)

throw new ReferenceError("this hasn&#39;t been initialised - super() hasn&#39;t been called");

return!t||"object"!=typeof t&&"function"!=typeof t?e:t}

function _(e,t){

if("function"!=typeof t&&null!==t)

throw new TypeError("Super expression must either be null or a function, not "+typeof t);

e.prototype=Object.create(t&&t.prototype,

{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),

t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)

}

function O(e,t,n){

return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}

function j(e,t){

if(!(e instanceof t))

throw new TypeError("Cannot call a class as a function")

}

function S(e,t){

if(!e)

throw new ReferenceError("this hasn&#39;t been initialised - super() hasn&#39;t been called");

return!t||"object"!=typeof t&&"function"!=typeof t?e:t

}

function k(e,t){

if("function"!=typeof t&&null!==t)

throw new TypeError("Super expression must either be null or a function, not "+typeof t);

e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),

t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)

}

function P(e,t,n){

return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e

}

function C(e,t){

if(!(e instanceof t))

throw new TypeError("Cannot call a class as a function")

}

function q(e,t){

if(!e)

throw new ReferenceError("this hasn&#39;t been initialised - super() hasn&#39;t been called");

return!t||"object"!=typeof t&&"function"!=typeof t?e:t

}

function T(e,t){

if("function"!=typeof t&&null!==t)

throw new TypeError("Super expression must either be null or a function, not "+typeof t);

e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),

t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)

}

function E(e,t){

if(!(e instanceof t))

throw new TypeError("Cannot call a class as a function")

}

function D(e,t){

if(!e)

throw new ReferenceError("this hasn&#39;t been initialised - super() hasn&#39;t been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t

}

function x(e,t){

if("function"!=typeof t&&null!==t)

throw new TypeError("Super expression must either be null or a function, not "+typeof t);

e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),

t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)

}

function Q(e,t){

if(!(e instanceof t))

throw new TypeError("Cannot call a class as a function")

}

function M(e,t){

if(!e)

throw new ReferenceError("this hasn&#39;t been initialised - super() hasn&#39;t been called");

return!t||"object"!=typeof t&&"function"!=typeof t?e:t

}

function N(e,t){

if("function"!=typeof t&&null!==t)

throw new TypeError("Super expression must either be null or a function, not "+typeof t);

e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),

t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)

}

function A(e,t){

if(!(e instanceof t))

throw new TypeError("Cannot call a class as a function")

}

function U(e,t){

if(!e)

throw new ReferenceError("this hasn&#39;t been initialised - super() hasn&#39;t been called");

return!t||"object"!=typeof t&&"function"!=typeof t?e:t

}

function B(e,t){

if("function"!=typeof t&&null!==t)

throw new TypeError("Super expression must either be null or a function, not "+typeof t);

e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),

t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)

}

function R(e,t){

if(!(e instanceof t))

throw new TypeError("Cannot call a class as a function")

}

function W(e,t){

if(!e)throw new ReferenceError("this hasn&#39;t been initialised - super() hasn&#39;t been called");

return!t||"object"!=typeof t&&"function"!=typeof t?e:t

}

function I(e,t){

if("function"!=typeof t&&null!==t)

throw new TypeError("Super expression must either be null or a function, not "+typeof t);

e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),

t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)

}

function z(e,t){

if(!(e instanceof t))

throw new TypeError("Cannot call a class as a function")

}

function F(e,t){

if(!e)throw new ReferenceError("this hasn&#39;t been initialised - super() hasn&#39;t been called");

return!t||"object"!=typeof t&&"function"!=typeof t?e:t

}

function L(e,t){

if("function"!=typeof t&&null!==t)

throw new TypeError("Super expression must either be null or a function, not "+typeof t);

e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),

t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)

}

function Z(e,t){

if(!(e instanceof t))

throw new TypeError("Cannot call a class as a function")

}

function J(e,t){

if(!e)

throw new ReferenceError("this hasn&#39;t been initialised - super() hasn&#39;t been called");

return!t||"object"!=typeof t&&"function"!=typeof t?e:t

}

function H(e,t){

if("function"!=typeof t&&null!==t)

throw new TypeError("Super expression must either be null or a function, not "+typeof t);

e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),

t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)

}

function X(e,t){

if(!(e instanceof t))

throw new TypeError("Cannot call a class as a function")

}

function G(e,t){

if(!e)

throw new ReferenceError("this hasn&#39;t been initialised - super() hasn&#39;t been called");

return!t||"object"!=typeof t&&"function"!=typeof t?e:t

}

function K(e,t){

if("function"!=typeof t&&null!==t)

throw new TypeError("Super expression must either be null or a function, not "+typeof t);

e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),

t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)

}

function V(e,t){

if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")

}

function Y(e,t){

if(!e)throw new ReferenceError("this hasn&#39;t been initialised - super() hasn&#39;t been called");

return!t||"object"!=typeof t&&"function"!=typeof t?e:t

}

function $(e,t){

if("function"!=typeof t&&null!==t)

throw new TypeError("Super expression must either be null or a function, not "+typeof t);

e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),

t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)

}

function ee(e,t){

if(!(e instanceof t))

throw new TypeError("Cannot call a class as a function")

}

function te(e,t){

if(!e)

throw new ReferenceError("this hasn&#39;t been initialised - super() hasn&#39;t been called");

return!t||"object"!=typeof t&&"function"!=typeof t?e:t

}

function ne(e,t){

if("function"!=typeof t&&null!==t)

throw new TypeError("Super expression must either be null or a function, not "+typeof t);

e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),

t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)

}

function re(e,t){

if(!(e instanceof t))

throw new TypeError("Cannot call a class as a function")

}

function oe(e,t){

if(!e)throw new ReferenceError("this hasn&#39;t been initialised - super() hasn&#39;t been called");

return!t||"object"!=typeof t&&"function"!=typeof t?e:t

}

function ie(e,t){

if("function"!=typeof t&&null!==t)

throw new TypeError("Super expression must either be null or a function, not "+typeof t);

e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),

t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)

}

Object.defineProperty(t,"__esModule",{value:!0});

var ae,

ce=navigator.userAgent,

ue=/(iPad).*OS\s([\d_]+)/.test(ce),

le=/(iPod)(.*OS\s([\d_]+))?/.test(ce),

fe=!ue&&/(iPhone\sOS)\s([\d_]+)/.test(ce),

se=ue||le||fe,pe=/(Android);

?[\s\/]+([\d.]+)?/.test(ce),

he=/micromessenger/i.test(ce),

be=/QQ\/([\d\.]+)/.test(ce),

ye=/Qzone\//.test(ce),

de=/MQQBrowser/i.test(ce)&&!he&&!be,

we=/UCBrowser/i.test(ce),

ve=/mobile.*baidubrowser/i.test(ce),

ge=/SogouMobileBrowser/i.test(ce),

me=/baiduboxapp/i.test(ce),

_e={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",

encode:function(e){

var t,n,r,o,i,a,c,u="",l=0;

for(e=_e._utf8_encode(e);l<e.length;)

t=e.charCodeAt(l++),

n=e.charCodeAt(l++),

r=e.charCodeAt(l++),

o=t>>2,i=(3&t)<<4|n>>4,a=(15&n)<<2|r>>6,

c=63&r,

isNaN(n)?a=c=64:isNaN(r)&&(c=64),

u=u+this._keyStr.charAt(o)+this._keyStr.charAt(i)+this._keyStr.charAt(a)+this._keyStr.charAt(c);

return u

},

_utf8_encode:

function(e){

e=e.replace(/\r\n/g,"\n");

for(var t="",n=0;n<e.length;n++){

var r=e.charCodeAt(n);

r<128?t+=String.fromCharCode(r):r>127&&r<2048?(t+=String.fromCharCode(r>>6|192),

t+=String.fromCharCode(63&r|128)):(t+=String.fromCharCode(r>>12|224),t+=String.fromCharCode(r>>6&63|128),

t+=String.fromCharCode(63&r|128))}return t

}

},

Oe=document.querySelector("meta[name=description]"),

je=document.querySelector("link[rel*=icon]"),

Se={link:location.href,title:function(){return document.title}(),

desc:function(){

return Object(Oe).content||""}(),

icon:function(){

return Object(je).href||location.protocol+"//"+location.hostname+"/favicon.ico"}(),

from:"",success:r,fail:r,trigger:r},

ke=function(){

function e(e,t){

for(var n=0;n<t.length;n++){

var r=t[n];

r.enumerable=r.enumerable||!1,

r.configurable=!0,

"value"in r&&(r.writable=!0),

Object.defineProperty(e,r.key,r)}}

return function(t,n,r){

return n&&e(t.prototype,n),r&&e(t,r),t}}(),

Pe=function(){

function e(t){

w(this,e),

this._shareData=Se,

this._config={syncDescToTag:!1,syncIconToTag:!1,syncTitleToTag:!1},

this.setConfig(t)

}

return ke(e,[{key:"getShareData",

value:function(){

return i({},this._shareData)}},

{

key:"setShareData",

value:function(){

var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};

i(this._shareData,e),

this._config.syncDescToTag&&l(this._shareData.desc),

this._config.syncIconToTag&&f(this._shareData.icon),

this._config.syncTitleToTag&&s(this._shareData.title)}},

{

key:"setConfig",

value:function(){

var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};

i(this._config,e)}},{key:"getConfig",

value:function(){

return i({},this._config)}}]),e}(),

Ce=Pe,

qe=function(){

function e(e,t){

for(var n=0;n<t.length;n++){

var r=t[n];

r.enumerable=r.enumerable||!1,

r.configurable=!0,"value"in r&&(r.writable=!0),

Object.defineProperty(e,r.key,r)}}

return function(t,n,r){

return n&&e(t.prototype,n),r&&e(t,r),t}}(),

Te=function(e){

function t(e){

g(this,t);

var n=m(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));

return o(" return _(t,e),qe(t,[{key:"call",

value:function(){

var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default",t=arguments[1];

this.setShareData(t);

var n=this.getShareData(),

r=this.constructor.commamdMap[String(e).toLowerCase()];

browser.app.share({title:n.title,description:n.desc,url:n.link,img_url:n.icon,from:n.from,to_app:r})}}]),t}(Ce);

Te.commamdMap=(ae={},

v(ae,"wechattimeline",8),

v(ae,"wechatfriend",1),

v(ae,"qqfriend",4),

v(ae,"qzone",3),

v(ae,"weibo",11),

v(ae,"copyurl",10),

v(ae,"more",5),

v(ae,"generateqrcode",7),

v(ae,"default",void 0),ae);

var Ee,De=Te,

xe=function(){function e(e,t){

for(var n=0;n<t.length;n++){

var r=t[n];

r.enumerable=r.enumerable||!1,

r.configurable=!0,

"value"in r&&(r.writable=!0),

Object.defineProperty(e,r.key,r)}}

return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),

Qe=function(e){

function t(e){

return j(this,t),

S(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))}return k(t,e),

xe(t,[{key:"call",value:function(){

var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default",

t=arguments[1];

this.setShareData(t);

var n=this.getShareData(),

r=this.constructor.commamdMap[String(e).toLowerCase()];

ucbrowser.web_shareEX?ucbrowser.web_shareEX(JSON.stringify({title:n.title,content:n.desc,sourceUrl:n.link,imageUrl:n.icon,source:n.from,target:r})):ucbrowser.web_share(title,desc,link,r,"",from,"")}}]),t}(Ce);

Qe.commamdMap=(

Ee={},

O(Ee,"wechattimeline","kWeixinFriend"),

O(Ee,"wechatfriend","kWeixin"),

O(Ee,"qqfriend","kQQ"),

O(Ee,"qzone","kQZone"),

O(Ee,"weibo","kSinaWeibo"),

O(Ee,"default",void 0),Ee);

var Me,Ne=Qe,Ae=function(){

function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];

r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}

return function(t,n,r){

return n&&e(t.prototype,n),r&&e(t,r),t}}(),

Ue=function(e){

function t(e){

return C(this,t),q(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))

}

return T(t,e),Ae(t,[{key:"call",

value:function(){

var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default",

t=arguments[1];

this.setShareData(t);

var n=this.getShareData(),

r=this.constructor.commamdMap[String(e).toLowerCase()];

ucweb.startRequest("shell.page_share",[n.title,n.desc,n.link,r,"",n.from,n.icon])}}]),t}(Ce);

Ue.commamdMap=(Me={},P(Me,"wechattimeline","WechatTimeline"),

P(Me,"wechatfriend","WechatFriends"),

P(Me,"qqfriend","QQ"),P(Me,"qzone","Qzone"),

P(Me,"weibo","SinaWeibo"),

P(Me,"default",""),Me);

var Be=Ue,

Re=function(){

function e(e,t){for(var n=0;n<t.length;n++){

var r=t[n];

r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),

Object.defineProperty(e,r.key,r)}

}

return function(t,n,r){

return n&&e(t.prototype,n),r&&e(t,r),t}}(),

We=function(e){

function t(e){

return E(this,t),

D(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))}return x(t,e),

Re(t,[{key:"call",

value:function(e,t){

this.setShareData(t);

var n=this.getShareData();

_flyflowNative.exec("bd_utils","shareWebPage",JSON.stringify({title:n.title,content:n.desc,landurl:n.link,imageurl:n.icon,shareSource:n.from}),"")}}]),t}(Ce),

Ie=We,

ze=function(){

function e(e,t){

for(var n=0;n<t.length;n++){

var r=t[n];

r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),

Object.defineProperty(e,r.key,r)}}

return function(t,n,r){

return n&&e(t.prototype,n),r&&e(t,r),t}}(),

Fe=function(e){

function t(e){

return Q(this,t),

M(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))}

return N(t,e),

ze(t,[{key:"call",value:function(e,t){

this.setShareData(t);

var n=this.getShareData();

location.href="baidubrowserapp://bd_utils?action=shareWebPage&params="+encodeURIComponent(JSON.stringify({title:n.title,content:n.desc,imageurl:n.icon,landurl:n.link,mediaType:0,share_type:"webpage"}))}}]),t}(Ce),

Le=Fe,

Ze=function(){function e(e,t){

for(var n=0;n<t.length;n++){

var r=t[n];

r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}

return function(t,n,r){

return n&&e(t.prototype,n),r&&e(t,r),t}}(),

Je=function(e){

function t(e){

return A(this,t),U(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))}

return B(t,e),Ze(t,[{key:"call",

value:function(e,t){

this.setShareData(t);

var n=this.getShareData();

SogouMse.Utility.shareWithInfo({shareTitle:n.title,shareContent:n.desc,shareImageUrl:n.icon,shareUrl:n.link})}}]),t}(Ce),He=Je,Xe=function(){function e(e,t){

for(var n=0;n<t.length;n++){

var r=t[n];

r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),

Object.defineProperty(e,r.key,r)}}return function(t,n,r){

return n&&e(t.prototype,n),r&&e(t,r),t}}(),Ge=function e(t,n,r){null===t&&(t=Function.prototype);

var o=Object.getOwnPropertyDescriptor(t,n);if(void 0===o){var i=Object.getPrototypeOf(t);

return null===i?void 0:e(i,n,r)

}

if("value"in o)return o.value;

var a=o.get;

if(void 0!==a)

return a.call(r)},

Ke=function(e){

function t(e){R(this,t);

var n=W(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));

return n.setConfig(e),n}return I(t,e),Xe(t,[{key:"call",value:function(e,t){this.setShareData(t)}},

{

key:"setConfig",value:function(e){

Ge(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setConfig",this).call(this,e),

this.init(this.getConfig().wechatConfig)}},{key:"init",value:function(e){var t=this;e&&o("

var n=t._shareData,r={};

Object.defineProperty(r,"trigger",{get:function(){

return

function(){i(r,{title:n.title,desc:n.desc,link:n.link,imgUrl:n.icon,type:n.type,

dataUrl:n.dataUrl,success:n.success,fail:n.fail,cancel:n.fail}),n.trigger.apply(n,arguments)}},

set:function(e){n.trigger=e},enumerable:!0}),wx.ready(function(){

wx.onMenuShareAppMessage(r),

wx.onMenuShareQQ(r),

wx.onMenuShareQZone(r),

wx.onMenuShareWeibo(r),

wx.onMenuShareTimeline(r)})})}}]),t}(Ce),

Ve=Ke,

Ye=function(){

function e(e,t){

for(var n=0;n<t.length;n++){var r=t[n];

r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),

Object.defineProperty(e,r.key,r)}}

return function(t,n,r){

return n&&e(t.prototype,n),

r&&e(t,r),t}}(),

$e=function(e){

function t(e){

return z(this,t),F(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))}

return L(t,e),Ye(t,[{key:"call",

value:function(){

var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default",t=arguments[1];

if(this.setShareData(t),"weibo"!==(e=String(e).toLowerCase()))

throw"qqfriend"===e?h():"qzone"===e&&b(),

new Error("the browser may not support command "+e+"!");

d()}}]),t}(Ce),et=$e,

tt=function(){

function e(e,t){

for(var n=0;n<t.length;n++){var r=t[n];

r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),

Object.defineProperty(e,r.key,r)}}

return function(t,n,r){

return n&&e(t.prototype,n),r&&e(t,r),t}}(),

nt=function(e){

function t(e){Z(this,t);

var n=J(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));

return n.init(),n}return H(t,e),tt(t,[{key:"call",

value:function(){

var e=(arguments.length>0&&void 0!==arguments[0]&&arguments[0],arguments[1]);

this.setShareData(e),mqq.ui.showShareMenu()}},{

key:"init",

value:function(){var e=this;o("

function(){

var t=e._shareData;

mqq.ui.setOnShareHandler(function(e){

mqq.ui.shareMessage({back:!0,share_type:e,title:t.title,desc:t.desc,share_url:t.link,

image_url:t.icon,sourceName:t.from},

function(e){

0===e.retCode?t.success(e):t.fail(e)})})})}}]),t}(Ce),

rt=nt,

ot=function(){

function e(e,t){

for(var n=0;n<t.length;n++){var r=t[n];

r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),

Object.defineProperty(e,r.key,r)}}

return function(t,n,r){

return n&&e(t.prototype,n),r&&e(t,r),t}}(),it=function e(t,n,r){

null===t&&(t=Function.prototype);

var o=Object.getOwnPropertyDescriptor(t,n);

if(void 0===o)

{

var i=Object.getPrototypeOf(t);

return null===i?void 0:e(i,n,r)}if("value"in o)return o.value;

var a=o.get;

if(void 0!==a)return a.call(r)

},

at=function(e){

function t(e){X(this,t);

var n=G(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));

return n.init(),n}return K(t,e),ot(t,[{key:"setShareData",

value:function(e){

it(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setShareData",this).call(this,e);

var n=this.getShareData();

u(n.link)!==location.hostname&&(n.link=location.href,console.warn("安卓的QQ自带浏览器分享url必须跟页面url同一个域名,已自动为你设置为当前页面的url"));

try{mqq.data.setShareInfo({share_url:n.link,title:n.title,desc:n.desc,image_url:n.icon},

function(e){!0!==e&&console.warn(e)})}catch(e){}}},

{key:"call",

value:function(){

var e=(arguments.length>0&&void 0!==arguments[0]&&arguments[0],arguments[1]);

this.setShareData(e),mqq.ui.showShareMenu()}},{key:"init",value:function(){var e=this;o("

function e(e,t){

for(var n=0;n<t.length;n++){

var r=t[n];

r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),

Object.defineProperty(e,r.key,r)}}

return

function(t,n,r){

return n&&e(t.prototype,n),r&&e(t,r),t}}(),

lt=function(e){

function t(e){

V(this,t);

var n=Y(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));

return n.init(),n}

return $(t,e),

ut(t,[{key:"call",value:function(){

var e=this,

t=(arguments.length>0&&void 0!==arguments[0]&&arguments[0],arguments[1]);

this.setShareData(t);

for(var n=this.getShareData(),r=[],o=[],i=[],a=[],c=0;c<5;c++)

r.push(n.icon),

a.push(n.link),

o.push(n.title),

i.push(n.desc);

QZAppExternal.setShare(

function(t){0!=t.code&&(e.hasSomethingWrong=!0)},{type:"share",image:r,title:o,summary:i,shareURL:a})}},{key:"setShareData",value:function(e){

try{this.call("default",e)}catch(e){}}},{key:"init",value:function(){

var e=this;o("

function(){

e.call("default")})}}]),t}(Ce),

ft=lt,

st=function(){

function e(e,t){

for(var n=0;n<t.length;n++){

var r=t[n];

r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),

Object.defineProperty(e,r.key,r)}}

return function(t,n,r){

return n&&e(t.prototype,n),r&&e(t,r),t}}(),

pt=function(e){

function t(e){return ee(this,t),te(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))}

return ne(t,e),

st(t,[{key:"call",

value:function(e,t){

this.setShareData(t);

var n=this.getShareData();

window.NativeShareFailCallback=n.fail,window.NativeShareSuccessCallback=n.success,

location.href="baiduboxapp://callShare?"+["options="+encodeURIComponent(JSON.stringify({title:n.title,imageUrl:"",mediaType:"all",

content:n.desc,linkUrl:n.link,iconUrl:n.icon})),"errorcallback=window.NativeShareFailCallback","successcallback=window.NativeShareSuccessCallback"].join("&")}}]),t}(Ce),

ht=pt,

bt=function(){function e(e,t){

for(var n=0;n<t.length;n++){

var r=t[n];

r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),

Object.defineProperty(e,r.key,r)}}

return function(t,n,r){

return n&&e(t.prototype,n),r&&e(t,r),t}}(),

yt=function(e){

function t(e){return re(this,t),

oe(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e))}

return ie(t,e),

bt(t,[{key:"call",

value:function(e,t){

this.setShareData(t);

var n=this.getShareData();

window.NativeShareFailCallback=n.fail,window.NativeShareSuccessCallback=n.success,prompt("BdboxApp:"+JSON.stringify({obj:"Bdbox_android_utils",func:"callShare",args:[&#39;{\n                           

imageUrl: "",\n                           

mediaType: "all",\n                          

title: "&#39;+n.title+&#39;",\n                           

content: "&#39;+n.desc+&#39;",\n                           

linkUrl: "&#39;+n.link+&#39;",\n                           

iconUrl: "&#39;+n.icon+&#39;"\n                       

}&#39;,"window.NativeShareSuccessCallback","window.NativeShareFailCallback"]}))}}]),t}(Ce),dt=yt;

n.d(t,"Share",function(){return Ce}),

n.d(t,"QQMobileBrowser",function(){return De}),

n.d(t,"UCIosBrowser",function(){return Ne}),

n.d(t,"UCAndroidBrowser",function(){return Be}),

n.d(t,"BaiduAndroidBrowser",function(){return Ie}),

n.d(t,"BaiduIosBrowser",function(){return Le}),

n.d(t,"SogouIosBrowser",function(){return He}),

n.d(t,"BaiduIos",function(){return ht}),

n.d(t,"BaiduAndroid",function(){return dt}),

n.d(t,"Wechat",function(){return Ve}),

n.d(t,"Others",function(){return et}),

n.d(t,"QQIos",function(){return rt}),

n.d(t,"QQAndroid",function(){return ct}),

n.d(t,"QZone",function(){return ft}),

n.d(t,"shareToQQ",

function(){

return h}),

n.d(t,"shareToQZone",function(){return b}),

n.d(t,"shareToWeibo4Web",function(){return d}),

n.d(t,"shareToQZone4Web",

function(){return y});

var wt=void 0;

wt=he?Ve:be&&se?rt:be&&pe?ct:ye?ft:de?De:we&&se?Ne:we&&pe?Be:ve&&pe?Ie:ve&&se?Le:ge&&se?He:me&&se?ht:me&&pe?dt:et,window.NativeShare=wt,t.default=wt}])});

Copy after login


Related recommendations:

HTML5 example of implementing WeChat jssdk recording and playing voice

How to use and create HTML5 video subtitles

The above is the detailed content of HTML5 implements the function of sharing to WeChat friends, QQ friends, QQ space Weibo QR code. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1268
29
C# Tutorial
1246
24
Table Border in HTML Table Border in HTML Sep 04, 2024 pm 04:49 PM

Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

Nested Table in HTML Nested Table in HTML Sep 04, 2024 pm 04:49 PM

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

HTML margin-left HTML margin-left Sep 04, 2024 pm 04:48 PM

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

HTML Table Layout HTML Table Layout Sep 04, 2024 pm 04:54 PM

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

HTML Input Placeholder HTML Input Placeholder Sep 04, 2024 pm 04:54 PM

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

HTML Ordered List HTML Ordered List Sep 04, 2024 pm 04:43 PM

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

HTML onclick Button HTML onclick Button Sep 04, 2024 pm 04:49 PM

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.

Moving Text in HTML Moving Text in HTML Sep 04, 2024 pm 04:45 PM

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

See all articles