import { LoadingController , Platform } from 'ionic-angular' ; import { Injectable } from '@angular/core' ; declare var Wechat ; declare var QQSDK ; @ Injectable ( ) export class AppShare { title : string = "女装尖货 - 单件月销1.8万" ; description : string = "行业精选女装 好货任你挑" ; link : string = "http://dress.tongedev.cn" ; image : string = "https://mmbiz.qlogo.cn/mmbiz_png/khImeKLbVF7u5qdXdicpapLl9diadj5db6xHxdlVgxmYPxkYOR8WyVgOw4tn3EHEsvd9hlfu7zEpgVLYkLh28Nibg/0?wx_fmt=png" ; constructor ( public loadingCtrl , platform ) { if ( platform . is ( 'ios' ) ) { this . link = "https://itunes.apple.com/cn/app/女装尖货-单件月销1-8万/id1194942857?mt=8" ; } else if ( platform . is ( 'android' ) ) { this . link = "http://a.app.qq.com/o/simple.jsp?pkgname=cn.tongedev.dress" ; } else { this . link = "http://dress.tongedev.cn" ; } } wxShare ( scene ) { var loading = this . loadingCtrl . create ( { showBackdrop : false } ) ; loading . present ( ) ; try { Wechat . share ( { message : { title : this . title , description : this . description , thumb : this . image , mediaTagName : "TEST-TAG-001" , messageExt : "" , messageAction : "" , media : { type : Wechat . Type . WEBPAGE , webpageUrl : this . link } } , scene : scene == 0 ? Wechat . Scene . SESSION : Wechat . Scene . Timeline } , function ( ) { } , function ( reason ) { } ) ; } catch ( error ) { console . log ( error ) ; } finally { loading . dismiss ( ) ; } } qqShare ( scene ) { var loading = this . loadingCtrl . create ( { showBackdrop : false } ) ; loading . present ( ) ; try { var args = { } ; if ( scene == 0 ) { args . scene = QQSDK . Scene . QQ ; } else { args . scene = QQSDK . Scene . QQZone ; } args . url = this . link ; args . title = this . title ; args . description = this . description ; args . image = this . image ; QQSDK . shareNews ( function ( ) { loading . dismiss ( ) ; } , function ( failReason ) { loading . dismiss ( ) ; } , args ) ; } catch ( error ) { console . log ( error ) ; } finally { loading . dismiss ( ) ; } } }