欢迎来到258分享网,纯净的网络源码分享基地!

258资源分享网

全部作品
全部作品
网站源码
微信源码
素材特效
源码插件
视频教程
建站学院
热门搜索: 织梦  农业种植  农业  安全设置  官方
258资源分享 > 建站学院 > 微信开发 > 第三方 App 分享微信小程序链接(android),module.exports 模块化基础 ...

推荐下载

HTML5响应式自适应网咯设计

2020-05-12   浏览:738

高端HTML5响应式企业通用网

2020-05-06   浏览:519

html5响应式外贸网站英文版

2020-05-08   浏览:506

HTML5自适应律师工作室类网

2020-04-04   浏览:502

HTML5影视传媒文化公司类网

2020-05-12   浏览:497

第三方 App 分享微信小程序链接(android),module.exports 模块化基础 ...

发布时间:2020-11-27  

private void sendMiniApps(String articlePk, String title, String content,

String url, Bitmap icon) {

 

WXMiniProgramObject miniProgram = new WXMiniProgramObject();

//低版本微信打开 URL

miniProgram.webpageUrl = url;

//跳转的小程序的原始 ID

miniProgram.userName = WechatShareUtils.MINI_APPS_ID;

//小程序的 Path

miniProgram.path = WechatShareUtils.getMiniAppPath(articlePk);

 

WXMediaMessage msg = new WXMediaMessage(miniProgram);

final String shareTitle = WechatShareUtils.getValidTitle(title);

if (!TextUtils.isEmpty(shareTitle)) {

msg.title = title;

}

 

final String shareDescription = WechatShareUtils.getValidDescription(content);

if (!TextUtils.isEmpty(shareDescription)) {

msg.description = shareDescription;

}

 

if (icon != null) {

msg.setThumbImage(icon);

} else {

Bitmap temp = BitmapFactory.decodeResource(context.getResources(),

R.drawable.icon_wechat);

msg.setThumbImage(temp);

}

 

Log.i("TAG", "sendMiniApps title: " + title);

 

//使用此方法会出现无法分享的问题

// Bitmap thumbBmp = Bitmap.createScaledBitmap(icon, 150, 150, true);

// icon.recycle();

// msg.thumbData = BitmapUtils.bitmapToByteArray(thumbBmp, true);

 

 

SendMessageToWX.Req req = new SendMessageToWX.Req();

req.transaction = buildTransaction("miniProgram");

req.message = msg;

req.scene = WXSceneSession;

api.sendReq(req);

 

}

参考:微信开发平台

 

二:module.exports 模块化基础  

作者:山水之间,来自原文地址

第三方 App 分享微信小程序链接(android),module.exports 模块化基础 ...

文件 目录如上图:

看到网上写的模块化都比较复杂,写个入门版的 好让大家理解理解

//common.js

 

var studentList = [

{

name: "xiaoming",

age: "22",

hobby: "sleep"

},

{

name: "xiaohong",

age: "22",

hobby: {

one: "eat",

two: "eatfood"

}

 

}

]

 

//模块化

module.exports = {

studentList: studentList

}

//index.js

 

var common = require("../aa/common.js")

//获取应用实例

var app = getApp()

Page({

data: {

},

 

onLoad: function () {

this.setData({

studentList:common.studentList

});

}

})

//index.html

 

<block wx:for="{{studentList}}" wx:for-item="item" wx:for-index="idx">

<view>

{{item.name}}

</view>

</block>

因为取的是name,所以最后输出的是xiaoming 和xiaohong。