
android 多渠道打包白屏问题的解决
多渠道打包,当applicationId ,与包名不一致时,Uni-app会出现白屏问题
原因,PdrR 不能引用到 包资源文件
解决方案:
1、在工程 新建包io.dcloud ,创建PdrR.java
2、复制源码到创建的java文件里面,修改 init()方法
public static void init(Context var0) {
if (var0 != null) {
a = " ";//你的包名,Androidmanifest里的包名
}
}
3、Rebuild project 一下,会报错,因为同时存在两个PdrR.java文件(忽略报的警告)
4、去app/build/intermediates/javac/ 你的app包名/ 目录下找到 编译生成的PdrR.class文件
5、用压缩器打开5plus.aar 包,打开里面的classes.jar,把自己生成的PdrR.class 进行替换
直接用解压文件打开,然后找到原先的PdrR.class删除,然后复制进去jar包里面即可
6、重新导入修改的aar包
多渠道打包,当applicationId ,与包名不一致时,Uni-app会出现白屏问题
原因,PdrR 不能引用到 包资源文件
解决方案:
1、在工程 新建包io.dcloud ,创建PdrR.java
2、复制源码到创建的java文件里面,修改 init()方法
public static void init(Context var0) {
if (var0 != null) {
a = " ";//你的包名,Androidmanifest里的包名
}
}
3、Rebuild project 一下,会报错,因为同时存在两个PdrR.java文件(忽略报的警告)
4、去app/build/intermediates/javac/ 你的app包名/ 目录下找到 编译生成的PdrR.class文件
5、用压缩器打开5plus.aar 包,打开里面的classes.jar,把自己生成的PdrR.class 进行替换
直接用解压文件打开,然后找到原先的PdrR.class删除,然后复制进去jar包里面即可
6、重新导入修改的aar包

力谱云社区团购解决方案:开发制作社区团购APP
新年新气象,新市场鼓动新风口。随着2018年末社区团购一夕爆红的乐观市场走势,以及对应社区团购APP的可观盈利,在新的一年中,市场春风拂过,大量传统企业家们,对社区团购APP已不再是简单的观望不前,而是摩拳擦掌,想要快速进入社区团购这一新零售赛道。那么在社区团购APP制作前应该先做哪些准备工作?今天就先带您了解一下社区团购APP的最新动态,以及如何通过制作APP的渠道从电商平台模式转化为社区团购模式?

社区团购资本大批入场,企业争相跑马圈地新零售
据了解,目前社区团购APP,仅在今年年初就斩获了近50亿的资本投入,在头部社区团购企业兴盛优选、松鼠拼拼、食享会之后,专家推测,还将有更多传统企业、甚至草根创业者将跻身社区团购。目前,社区团购企业所打造的APP平台模式,在技术方面并无颇多创新,因此,是否拥有线下门店经营,成为了社区团购企业在运营方面的分水岭。
无门店运营模式:以食享会、你我您等为例,他们的平台直接略过线下门店,通过节省店面、人力成本,快速的城市拓展,进行市场方面的跑马圈地。
有门店运营模式:以拥有线下门店的兴盛优选为例,拥有良好的线下用户体验,供应链优势明显,平台口碑正面效应能持续性扩散。
如上所知,社区团购的运营模式易于复制推广,因而诸多坐拥生鲜、日用品供应链,以及本身做生鲜水果类的商家企业,也开始纷纷谋求进行社区团购的商业模式探索。
力谱云SaaS+PaaS云计算技术创新河,高效、低成本、功能齐备受瞩目
其实,之所以力谱云的研发技术,能突破高成本的应用开发瓶颈,为企业提供低于传统App开发成本90%的效能,关键在于“SaaS+PaaS”云计算模式的创新引入。APP制作这项技术层面的创新之举,不仅大幅降低了技术开发门槛,更能提升研发效率,这也成为了诸多中小企业进行移动互联网产业升级的福音。目前,力谱云推出了社区分销、社交团购、服务预订和入住、以及订货和供应链,这四大维度的核心解决方案,支持B2C、B2B、O2O、OMO、B2B2C等多种复杂商业平台模式,提供从研发到运营的全程技术护航,支持苹果App+安卓App+微信小程序+微商城+移动网站的平台打造,让企业线上运营渠道全面贯通,并可通过丰富前沿的营销工具,打出平台销售佳绩。
力谱云的一站式社区团购解决方案
对此,力谱云所提出的一站式社区团购APP制作解决方案,力图在渠道方面,助力企业一站式开发iOS App/安卓App、微商城、小程序、移动网站,让社区团长灵活营销使用。在营销方面,为企业配置数余种营销工具如拼团App、秒杀App、分销App等,助力企业刺激销量增长。在管理方面,企业方不仅可以通过PC端管理后台,进行订单、会员数据的统筹管理,还可通过配送端、移动管理端等多种移动运营App,辅助企业日常运营、跟进物流、进行核销等工作,让社区团购模式,真正通过高新技术,进行快捷、高效、低成本地落地开展。
如果你的企业正身处三四五线城市,有供应链,有人脉圈,只要有社区就有企业可发挥的目标人群。通过力谱云,即刻加入到目前最前沿的营销风口——社区团购吧!
新年新气象,新市场鼓动新风口。随着2018年末社区团购一夕爆红的乐观市场走势,以及对应社区团购APP的可观盈利,在新的一年中,市场春风拂过,大量传统企业家们,对社区团购APP已不再是简单的观望不前,而是摩拳擦掌,想要快速进入社区团购这一新零售赛道。那么在社区团购APP制作前应该先做哪些准备工作?今天就先带您了解一下社区团购APP的最新动态,以及如何通过制作APP的渠道从电商平台模式转化为社区团购模式?
社区团购资本大批入场,企业争相跑马圈地新零售
据了解,目前社区团购APP,仅在今年年初就斩获了近50亿的资本投入,在头部社区团购企业兴盛优选、松鼠拼拼、食享会之后,专家推测,还将有更多传统企业、甚至草根创业者将跻身社区团购。目前,社区团购企业所打造的APP平台模式,在技术方面并无颇多创新,因此,是否拥有线下门店经营,成为了社区团购企业在运营方面的分水岭。
无门店运营模式:以食享会、你我您等为例,他们的平台直接略过线下门店,通过节省店面、人力成本,快速的城市拓展,进行市场方面的跑马圈地。
有门店运营模式:以拥有线下门店的兴盛优选为例,拥有良好的线下用户体验,供应链优势明显,平台口碑正面效应能持续性扩散。
如上所知,社区团购的运营模式易于复制推广,因而诸多坐拥生鲜、日用品供应链,以及本身做生鲜水果类的商家企业,也开始纷纷谋求进行社区团购的商业模式探索。
力谱云SaaS+PaaS云计算技术创新河,高效、低成本、功能齐备受瞩目
其实,之所以力谱云的研发技术,能突破高成本的应用开发瓶颈,为企业提供低于传统App开发成本90%的效能,关键在于“SaaS+PaaS”云计算模式的创新引入。APP制作这项技术层面的创新之举,不仅大幅降低了技术开发门槛,更能提升研发效率,这也成为了诸多中小企业进行移动互联网产业升级的福音。目前,力谱云推出了社区分销、社交团购、服务预订和入住、以及订货和供应链,这四大维度的核心解决方案,支持B2C、B2B、O2O、OMO、B2B2C等多种复杂商业平台模式,提供从研发到运营的全程技术护航,支持苹果App+安卓App+微信小程序+微商城+移动网站的平台打造,让企业线上运营渠道全面贯通,并可通过丰富前沿的营销工具,打出平台销售佳绩。
力谱云的一站式社区团购解决方案
对此,力谱云所提出的一站式社区团购APP制作解决方案,力图在渠道方面,助力企业一站式开发iOS App/安卓App、微商城、小程序、移动网站,让社区团长灵活营销使用。在营销方面,为企业配置数余种营销工具如拼团App、秒杀App、分销App等,助力企业刺激销量增长。在管理方面,企业方不仅可以通过PC端管理后台,进行订单、会员数据的统筹管理,还可通过配送端、移动管理端等多种移动运营App,辅助企业日常运营、跟进物流、进行核销等工作,让社区团购模式,真正通过高新技术,进行快捷、高效、低成本地落地开展。
如果你的企业正身处三四五线城市,有供应链,有人脉圈,只要有社区就有企业可发挥的目标人群。通过力谱云,即刻加入到目前最前沿的营销风口——社区团购吧!
收起阅读 »
自定义组件嵌套的折磨
昨天一天时间浪费在了组件上,本想着代码复用一下的,自己封装了list和list-item的组件,谁知道通过组件slot嵌套进去的组件没法传数据,我就蒙了,我以为自己哪里写错了;但是再无数次的摧残之后,我将list-item组件单独提出来试了一下,数据传进去了,神奇了,太神奇了,当时我有种一万头XXX飞奔而过的感觉......
代码大概是这样的
<template>
<view>
// 这样子,title和value死活传不进去
<list>
<list-item title="姓名" value="张三" />
<list-item title="姓名" value="张三" />
</list>
// 这样子,它就传进去了,莫名其妙
<list-item title="姓名" value="张三" />
<list-item title="姓名" value="张三" />
</view>
</template>
心如死灰呀,,我还是老老实实的复制粘贴吧............
昨天一天时间浪费在了组件上,本想着代码复用一下的,自己封装了list和list-item的组件,谁知道通过组件slot嵌套进去的组件没法传数据,我就蒙了,我以为自己哪里写错了;但是再无数次的摧残之后,我将list-item组件单独提出来试了一下,数据传进去了,神奇了,太神奇了,当时我有种一万头XXX飞奔而过的感觉......
代码大概是这样的
<template>
<view>
// 这样子,title和value死活传不进去
<list>
<list-item title="姓名" value="张三" />
<list-item title="姓名" value="张三" />
</list>
// 这样子,它就传进去了,莫名其妙
<list-item title="姓名" value="张三" />
<list-item title="姓名" value="张三" />
</view>
</template>
心如死灰呀,,我还是老老实实的复制粘贴吧............
收起阅读 »
uniapp 实现 NFC标签读取 和 写入
uniapp 开发,找了很久没找到相关的NFC读写的代码;解决相关问题也用了些时间,希望文章有用;
最开始没有找到uniapp中的,NFC贴上手机后对应的响应事件;
有发帖提问怎么解决;
链接:uniapp怎么监听h5+的event事件http://ask.dcloud.net.cn/question/66505
在uniapp中:封装在 onShow 和onHide
代码基本同之前磊子提供的一样,全部放在methods 里面;
listenNFCStatus()
在onLoad的时候调用;
读写是在onShow的时候调用;
下面这段
nfcAdapter.disableForegroundDispatch(main);
打算放在onHide但是出现三方脚本错误的报错;
没法解决;就没放 = =;
但是单独的读没有任何影响,这是我写了读出数据会有个消息弹框,响应NFC并读取数据的方法是在onShow里面的;
手机息屏重新打开,扔会出发onShow,自动又调用了一次读取数据,所以遇到bug就是NFC的响应事件和手机息屏事件冲突;
暂时加了个计数器 count ,第一次进入的时候不调用读取;并且在hide和show加了时间戳,通过onHide 和 onShow响应的时间差,来判断是否触发读取事件;
如果有小伙伴知道怎么弄求分享
uniapp支持 plus.globalEvent.addEventListener('newintent', e =>{}); 后,之前因为懒没有改,后来出现bug了,就抽空改了下,突然想起来修改这个;
我是加载onReady内的;
var that = this ;
plus.globalEvent.addEventListener('newintent', e =>{
console.log("newIntent");
that.readData();
});
将之前在onShow 和onHide 全部删掉。当时设置的onShow 和 onHide 的时间差是400,这样搞会出问题,当数据或者长时间放置等其他时候,会造成无法调起nfc这个。还是需要用安卓的newIntent。
需要放在 应用层级,app.vue 下。后期写个完整的贴
附上整体js代码,部分自己的function已删除;
var NfcAdapter;
var NdefRecord;
var NdefMessage;
var waiting
var readyRead = false;
var nfcAdapter,main , pendingIntent,intentFiltersArray,techListsArray, IntentFilter
export default {
data() {
return {
currentNFCInfo: [], //NFC 读取消息;
bannerShow: false,
remark:"",
message: "",
count:0,
timestampHide:"",
timestampShow:""
};
},
methods: {
listenNFCStatus() {
try {
console.log('Init NFC...');
main = plus.android.runtimeMainActivity();
var Intent = plus.android.importClass('android.content.Intent');
var Activity = plus.android.importClass('android.app.Activity');
var PendingIntent = plus.android.importClass('android.app.PendingIntent');
IntentFilter = plus.android.importClass('android.content.IntentFilter');
NfcAdapter = plus.android.importClass('android.nfc.NfcAdapter');
nfcAdapter = NfcAdapter.getDefaultAdapter(main);
var intent = new Intent(main, main.getClass());
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
pendingIntent = PendingIntent.getActivity(main, 0, intent, 0);
var ndef = new IntentFilter("android.nfc.action.TECH_DISCOVERED");
ndef.addDataType("*/*");
intentFiltersArray = [ndef];
techListsArray = [
["android.nfc.tech.IsoDep"],
["android.nfc.tech.NfcA"],
["android.nfc.tech.NfcB"],
["android.nfc.tech.NfcF"],
["android.nfc.tech.Ndef"],
["android.nfc.tech.NfcV"],
["android.nfc.tech.NdefFormatable"],
["android.nfc.tech.MifareClassic"],
["android.nfc.tech.MifareUltralight"]
];
} catch (e) {
console.error(e);
}
},
handle_nfc_data() {
NdefRecord = plus.android.importClass("android.nfc.NdefRecord");
NdefMessage = plus.android.importClass("android.nfc.NdefMessage");
// main = plus.android.runtimeMainActivity();
var intent = main.getIntent();
console.log("action type:" + intent.getAction());
if ("android.nfc.action.TECH_DISCOVERED" == intent.getAction()) {
if (readyRead) {
this.__read(intent);
readyRead = false;
}
} else {
// waiting.close();
console.log("nfc读取失败")
}
},
__read(intent) {
try {
var content = "";
waiting = plus.nativeUI.showWaiting("请将NFC标签靠近!");
waiting.setTitle('请勿移开标签\n正在读取数据...');
var tag = plus.android.importClass("android.nfc.Tag");
waiting.close();
var Parcelable = plus.android.importClass("android.os.Parcelable");
// var rawmsgs = intent.getParcelableArrayExtra("android.nfc.extra.NDEF_MESSAGES");
var rawmsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
if (rawmsgs != null && rawmsgs.length > 0) {
waiting.close();
// console.log(JSON.stringify(rawmsgs[0]));
var records = rawmsgs[0].getRecords();
var result = records[0].getPayload();
// console.log(result)
if (result != null) {
var s = plus.android.newObject("java.lang.String", result);
console.log(s);
this.currentNFCInfo = s;
} else {
this.currentNFCInfo = "";
}
} else {
console.log("NFC获取失败");
uni.showToast({
title: "NFC获取失败.",
icon: "none"
});
}
} catch (e) {
console.log(e);
console.log("NFC获取失败,丢出异常");
waiting.close();
uni.showToast({
title: "NFC获取失败,丢出异常.",
icon: "none"
});
//TODO handle the exception
}
},
readData() {
readyRead = true;
// waiting = plus.nativeUI.showWaiting("请将NFC标签靠近!");
setTimeout(this.handle_nfc_data, 1000);
}
},
onLoad: function(option) {
this.listenNFCStatus()
},
onShow: function(){
console.log('page Show');
this.timestampShow = (new Date()).getTime();
console.log(this.timestampShow)
var TimeScale = this.timestampShow - this.timestampHide;
console.log(TimeScale);
nfcAdapter.enableForegroundDispatch(main, pendingIntent, intentFiltersArray, techListsArray);
if(this.count++ == 0){
// this.listenNFCStatus()
return false;
}else if(TimeScale > 400){
return false;
}else{
this.readData();
}
},
onHide:function(){
console.log("onHide");
this.timestampHide = (new Date()).getTime();
console.log(this.timestampHide);
}
}
写入分开写了,也是一样的写法
__write(intent) {
try {
waiting = plus.nativeUI.showWaiting("请将NFC标签靠近!");
waiting.setTitle('请勿移开标签\n正在写入...');
// var text = document.getElementById('text').value;
console.log("text=" + this.writeCode);
var textBytes = plus.android.invoke(this.writeCode, "getBytes");
var textRecord = new NdefRecord(NdefRecord.TNF_MIME_MEDIA,
plus.android.invoke("text/plain", "getBytes"), plus.android.invoke("", "getBytes"), textBytes);
var message = new NdefMessage([textRecord]);
var Ndef = plus.android.importClass('android.nfc.tech.Ndef');
var NdefFormatable = plus.android.importClass('android.nfc.tech.NdefFormatable');
var tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
var ndef = Ndef.get(tag);
if (ndef != null) {
var size = message.toByteArray().length;
console.log("size=" + size);
ndef.connect();
if (!ndef.isWritable()) {
console.log("tag不允许写入");
waiting.close();
uni.showToast({
title: "tag不允许写入.",
icon: "none"
});
return;
}
if (ndef.getMaxSize() < size) {
console.log("文件大小超出容量");
waiting.close();
uni.showToast({
title: "文件大小超出容量.",
icon: "none"
});
return;
}
// console.log('写入数据:' + JSON.stringify(message) + ' __TYPE__: ' + JSON.stringify(message.__TYPE__));
console.log("message:" + message)
ndef.writeNdefMessage(message);
waiting.close();
console.log("写入数据成功.");
uni.showToast({
title: "写入数据成功.",
icon: "none"
});
this.writeCode = "XJD:" + this.detailObj.code;
this.updateCode(); //数据写入成功后,数据关联成功;
return;
} else {
var format = NdefFormatable.get(tag);
if (format != null) {
try {
format.connect();
format.format(message);
console.log("格式化tag并且写入message")
waiting.close();
return;
} catch (e) {
console.log("格式化tag失败.");
waiting.close();
uni.showToast({
title: "格式化tag失败.",
icon: "none"
});
return;
}
} else {
console.log("Tag不支持NDEF");
uni.showToast({
title: "Tag不支持NDEF",
icon: "none"
});
waiting.close();
return;
}
}
} catch (e) {
console.log("error=" + e);
waiting.close();
console.log('写入失败');
}
},
writeData() {
readyWriteData = true;
// waiting = plus.nativeUI.showWaiting("请将NFC标签靠近!");
setTimeout(this.handle_nfc_data, 1000);
},
最近新增了,可读写nfcv格式的标签
http://ask.dcloud.net.cn/article/36108
有其他小伙伴解决了或者有更好的方式可以多多交流
uniapp 开发,找了很久没找到相关的NFC读写的代码;解决相关问题也用了些时间,希望文章有用;
最开始没有找到uniapp中的,NFC贴上手机后对应的响应事件;
有发帖提问怎么解决;
链接:uniapp怎么监听h5+的event事件http://ask.dcloud.net.cn/question/66505
在uniapp中:封装在 onShow 和onHide
代码基本同之前磊子提供的一样,全部放在methods 里面;
listenNFCStatus()
在onLoad的时候调用;
读写是在onShow的时候调用;
下面这段
nfcAdapter.disableForegroundDispatch(main);
打算放在onHide但是出现三方脚本错误的报错;
没法解决;就没放 = =;
但是单独的读没有任何影响,这是我写了读出数据会有个消息弹框,响应NFC并读取数据的方法是在onShow里面的;
手机息屏重新打开,扔会出发onShow,自动又调用了一次读取数据,所以遇到bug就是NFC的响应事件和手机息屏事件冲突;
暂时加了个计数器 count ,第一次进入的时候不调用读取;并且在hide和show加了时间戳,通过onHide 和 onShow响应的时间差,来判断是否触发读取事件;
如果有小伙伴知道怎么弄求分享
uniapp支持 plus.globalEvent.addEventListener('newintent', e =>{}); 后,之前因为懒没有改,后来出现bug了,就抽空改了下,突然想起来修改这个;
我是加载onReady内的;
var that = this ;
plus.globalEvent.addEventListener('newintent', e =>{
console.log("newIntent");
that.readData();
});
将之前在onShow 和onHide 全部删掉。当时设置的onShow 和 onHide 的时间差是400,这样搞会出问题,当数据或者长时间放置等其他时候,会造成无法调起nfc这个。还是需要用安卓的newIntent。
需要放在 应用层级,app.vue 下。后期写个完整的贴
附上整体js代码,部分自己的function已删除;
var NfcAdapter;
var NdefRecord;
var NdefMessage;
var waiting
var readyRead = false;
var nfcAdapter,main , pendingIntent,intentFiltersArray,techListsArray, IntentFilter
export default {
data() {
return {
currentNFCInfo: [], //NFC 读取消息;
bannerShow: false,
remark:"",
message: "",
count:0,
timestampHide:"",
timestampShow:""
};
},
methods: {
listenNFCStatus() {
try {
console.log('Init NFC...');
main = plus.android.runtimeMainActivity();
var Intent = plus.android.importClass('android.content.Intent');
var Activity = plus.android.importClass('android.app.Activity');
var PendingIntent = plus.android.importClass('android.app.PendingIntent');
IntentFilter = plus.android.importClass('android.content.IntentFilter');
NfcAdapter = plus.android.importClass('android.nfc.NfcAdapter');
nfcAdapter = NfcAdapter.getDefaultAdapter(main);
var intent = new Intent(main, main.getClass());
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
pendingIntent = PendingIntent.getActivity(main, 0, intent, 0);
var ndef = new IntentFilter("android.nfc.action.TECH_DISCOVERED");
ndef.addDataType("*/*");
intentFiltersArray = [ndef];
techListsArray = [
["android.nfc.tech.IsoDep"],
["android.nfc.tech.NfcA"],
["android.nfc.tech.NfcB"],
["android.nfc.tech.NfcF"],
["android.nfc.tech.Ndef"],
["android.nfc.tech.NfcV"],
["android.nfc.tech.NdefFormatable"],
["android.nfc.tech.MifareClassic"],
["android.nfc.tech.MifareUltralight"]
];
} catch (e) {
console.error(e);
}
},
handle_nfc_data() {
NdefRecord = plus.android.importClass("android.nfc.NdefRecord");
NdefMessage = plus.android.importClass("android.nfc.NdefMessage");
// main = plus.android.runtimeMainActivity();
var intent = main.getIntent();
console.log("action type:" + intent.getAction());
if ("android.nfc.action.TECH_DISCOVERED" == intent.getAction()) {
if (readyRead) {
this.__read(intent);
readyRead = false;
}
} else {
// waiting.close();
console.log("nfc读取失败")
}
},
__read(intent) {
try {
var content = "";
waiting = plus.nativeUI.showWaiting("请将NFC标签靠近!");
waiting.setTitle('请勿移开标签\n正在读取数据...');
var tag = plus.android.importClass("android.nfc.Tag");
waiting.close();
var Parcelable = plus.android.importClass("android.os.Parcelable");
// var rawmsgs = intent.getParcelableArrayExtra("android.nfc.extra.NDEF_MESSAGES");
var rawmsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
if (rawmsgs != null && rawmsgs.length > 0) {
waiting.close();
// console.log(JSON.stringify(rawmsgs[0]));
var records = rawmsgs[0].getRecords();
var result = records[0].getPayload();
// console.log(result)
if (result != null) {
var s = plus.android.newObject("java.lang.String", result);
console.log(s);
this.currentNFCInfo = s;
} else {
this.currentNFCInfo = "";
}
} else {
console.log("NFC获取失败");
uni.showToast({
title: "NFC获取失败.",
icon: "none"
});
}
} catch (e) {
console.log(e);
console.log("NFC获取失败,丢出异常");
waiting.close();
uni.showToast({
title: "NFC获取失败,丢出异常.",
icon: "none"
});
//TODO handle the exception
}
},
readData() {
readyRead = true;
// waiting = plus.nativeUI.showWaiting("请将NFC标签靠近!");
setTimeout(this.handle_nfc_data, 1000);
}
},
onLoad: function(option) {
this.listenNFCStatus()
},
onShow: function(){
console.log('page Show');
this.timestampShow = (new Date()).getTime();
console.log(this.timestampShow)
var TimeScale = this.timestampShow - this.timestampHide;
console.log(TimeScale);
nfcAdapter.enableForegroundDispatch(main, pendingIntent, intentFiltersArray, techListsArray);
if(this.count++ == 0){
// this.listenNFCStatus()
return false;
}else if(TimeScale > 400){
return false;
}else{
this.readData();
}
},
onHide:function(){
console.log("onHide");
this.timestampHide = (new Date()).getTime();
console.log(this.timestampHide);
}
}
写入分开写了,也是一样的写法
__write(intent) {
try {
waiting = plus.nativeUI.showWaiting("请将NFC标签靠近!");
waiting.setTitle('请勿移开标签\n正在写入...');
// var text = document.getElementById('text').value;
console.log("text=" + this.writeCode);
var textBytes = plus.android.invoke(this.writeCode, "getBytes");
var textRecord = new NdefRecord(NdefRecord.TNF_MIME_MEDIA,
plus.android.invoke("text/plain", "getBytes"), plus.android.invoke("", "getBytes"), textBytes);
var message = new NdefMessage([textRecord]);
var Ndef = plus.android.importClass('android.nfc.tech.Ndef');
var NdefFormatable = plus.android.importClass('android.nfc.tech.NdefFormatable');
var tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
var ndef = Ndef.get(tag);
if (ndef != null) {
var size = message.toByteArray().length;
console.log("size=" + size);
ndef.connect();
if (!ndef.isWritable()) {
console.log("tag不允许写入");
waiting.close();
uni.showToast({
title: "tag不允许写入.",
icon: "none"
});
return;
}
if (ndef.getMaxSize() < size) {
console.log("文件大小超出容量");
waiting.close();
uni.showToast({
title: "文件大小超出容量.",
icon: "none"
});
return;
}
// console.log('写入数据:' + JSON.stringify(message) + ' __TYPE__: ' + JSON.stringify(message.__TYPE__));
console.log("message:" + message)
ndef.writeNdefMessage(message);
waiting.close();
console.log("写入数据成功.");
uni.showToast({
title: "写入数据成功.",
icon: "none"
});
this.writeCode = "XJD:" + this.detailObj.code;
this.updateCode(); //数据写入成功后,数据关联成功;
return;
} else {
var format = NdefFormatable.get(tag);
if (format != null) {
try {
format.connect();
format.format(message);
console.log("格式化tag并且写入message")
waiting.close();
return;
} catch (e) {
console.log("格式化tag失败.");
waiting.close();
uni.showToast({
title: "格式化tag失败.",
icon: "none"
});
return;
}
} else {
console.log("Tag不支持NDEF");
uni.showToast({
title: "Tag不支持NDEF",
icon: "none"
});
waiting.close();
return;
}
}
} catch (e) {
console.log("error=" + e);
waiting.close();
console.log('写入失败');
}
},
writeData() {
readyWriteData = true;
// waiting = plus.nativeUI.showWaiting("请将NFC标签靠近!");
setTimeout(this.handle_nfc_data, 1000);
},
最近新增了,可读写nfcv格式的标签
http://ask.dcloud.net.cn/article/36108
有其他小伙伴解决了或者有更好的方式可以多多交流
收起阅读 »
HX里面如何将css样式格式化成一个样式一行
找了很多资料,摸索了很久,终于找到了文件。
多年习惯,css样式喜欢一个样式一行,这样一眼可以看到更多信息。此处区别于ctrl+shift+k格式化成所有样式全部在一行。
文件路径:HBuilderX/plugins/format/node_modules/js-beautify/js/src/css/beautifier.js
注释295行、298行、369行。
同时配置该文件:HBuilderX/plugins/format/jsbeautifyrc.js
增加以下配置项:
"css": {
"newline_between_rules": false,
"selector_separator_newline": false,
"preserve_newlines": false
}
丸美解决
找了很多资料,摸索了很久,终于找到了文件。
多年习惯,css样式喜欢一个样式一行,这样一眼可以看到更多信息。此处区别于ctrl+shift+k格式化成所有样式全部在一行。
文件路径:HBuilderX/plugins/format/node_modules/js-beautify/js/src/css/beautifier.js
注释295行、298行、369行。
同时配置该文件:HBuilderX/plugins/format/jsbeautifyrc.js
增加以下配置项:
"css": {
"newline_between_rules": false,
"selector_separator_newline": false,
"preserve_newlines": false
}
丸美解决

uni-app下截屏分享二维码页面
官方文档只有一个监听截屏事件的,而且还不支持app的,看了其他人的帖子等等都没直接找到可以复制的代码,看了看html5+api http://ask.dcloud.net.cn/question/5344和https://ask.dcloud.net.cn/article/35036这两个帖子,写了如下代码,安卓上可以用,就是不知道在ios上可行啊!?分享下喽~
<template>
<view class="content">
<view class="nav-top">1.让朋友的手机扫描下面的二维码即可安装</view>
<view class="main">
<view class="lay1"><view class="line"></view></view>
<view class="lay2">
<view class="qr">
<view class="qr-img">
<image
src="../../static/qr.png"
style="height: 200upx;width: 200upx;"
></image>
</view>
<view class="qr-txt">扫描二维码下载安装包</view>
</view>
</view>
<view class="lay3"><view class="line"></view></view>
</view>
<view class="code-btn">
<view class="line-btn"><view class="btn" @tap="capture()">点击保存至手机相册</view></view>
</view>
</view>
</template>
<script>
export default{
methods: {
capture() {
var pages = getCurrentPages();
var page = pages[pages.length - 1];
console.log('当前页:'+pages.length-1);
var bitmap=null;
var currentWebview = page.$getAppWebview();
bitmap = new plus.nativeObj.Bitmap('amway_img');
// 将webview内容绘制到Bitmap对象中
currentWebview.draw(bitmap,function(){
console.log('截屏绘制图片成功');
bitmap.save( "_doc/a.jpg"
,{}
,function(i){
console.log('保存图片成功:'+JSON.stringify(i));
uni.saveImageToPhotosAlbum({
filePath: i.target,
success: function () {
bitmap.clear(); //销毁Bitmap图片
uni.showToast({
title: '保存图片成功',
mask: false,
duration: 1500
});
}
});
}
,function(e){
console.log('保存图片失败:'+JSON.stringify(e));
});
},function(e){
console.log('截屏绘制图片失败:'+JSON.stringify(e));
});
//currentWebview.append(amway_bit);
}
},
}
</script>
<style>
page {
background-color: #2d355c;
}
.content {
}
.nav-top {
color: #ffffff;
font-size: 35upx;
text-align: center;
margin: 20upx 0;
}
.main {
position: relative;
width: 100%;
margin-top: 50upx;
}
.main .lay1 {
position: absolute;
top: 0;
bottom: 0;
right: 0;
left: 0;
z-index: 3000;
}
.main .lay1 .line {
height: 100upx;
width: 100%;
border-radius: 50px;
background-color: #e28f0b;
margin-top: 100upx;
}
.lay2 {
position: absolute;
top: 0;
bottom: 0;
right: 0;
left: 0;
z-index: 4000;
}
.lay2 .qr {
width: 70%;
margin: 0 auto;
height: 700upx;
background-color: #3958ab;
}
.qr-img {
text-align: center;
padding-top: 50%;
}
.qr-txt {
color: #ffffff;
text-align: center;
margin-top: 50upx;
}
.lay3 {
position: absolute;
top: 0;
bottom: 0;
right: 0;
left: 0;
z-index: 4000;
text-align: center;
}
.lay3 .line {
height: 100upx;
width: 85%;
border-radius: 50px;
background-color: #e28f0b;
margin: 40upx auto;
box-shadow: #cccccc 0px 3px 10px;
}
.code-btn {
width: 100%;
color: #ffffff;
height: 100%;
text-align: center;
}
.line-btn {
position: absolute;
bottom: 200upx;
left: 0upx;
right: 0upx;
width: 100%;
display: flex;
justify-content: center;
}
.btn {
width: 400upx;
padding: 35upx;
background-color: #e28f0b;
border-radius: 50px;
}
.btn:active{
background-color: #FEC607;
}
</style>
官方文档只有一个监听截屏事件的,而且还不支持app的,看了其他人的帖子等等都没直接找到可以复制的代码,看了看html5+api http://ask.dcloud.net.cn/question/5344和https://ask.dcloud.net.cn/article/35036这两个帖子,写了如下代码,安卓上可以用,就是不知道在ios上可行啊!?分享下喽~
<template>
<view class="content">
<view class="nav-top">1.让朋友的手机扫描下面的二维码即可安装</view>
<view class="main">
<view class="lay1"><view class="line"></view></view>
<view class="lay2">
<view class="qr">
<view class="qr-img">
<image
src="../../static/qr.png"
style="height: 200upx;width: 200upx;"
></image>
</view>
<view class="qr-txt">扫描二维码下载安装包</view>
</view>
</view>
<view class="lay3"><view class="line"></view></view>
</view>
<view class="code-btn">
<view class="line-btn"><view class="btn" @tap="capture()">点击保存至手机相册</view></view>
</view>
</view>
</template>
<script>
export default{
methods: {
capture() {
var pages = getCurrentPages();
var page = pages[pages.length - 1];
console.log('当前页:'+pages.length-1);
var bitmap=null;
var currentWebview = page.$getAppWebview();
bitmap = new plus.nativeObj.Bitmap('amway_img');
// 将webview内容绘制到Bitmap对象中
currentWebview.draw(bitmap,function(){
console.log('截屏绘制图片成功');
bitmap.save( "_doc/a.jpg"
,{}
,function(i){
console.log('保存图片成功:'+JSON.stringify(i));
uni.saveImageToPhotosAlbum({
filePath: i.target,
success: function () {
bitmap.clear(); //销毁Bitmap图片
uni.showToast({
title: '保存图片成功',
mask: false,
duration: 1500
});
}
});
}
,function(e){
console.log('保存图片失败:'+JSON.stringify(e));
});
},function(e){
console.log('截屏绘制图片失败:'+JSON.stringify(e));
});
//currentWebview.append(amway_bit);
}
},
}
</script>
<style>
page {
background-color: #2d355c;
}
.content {
}
.nav-top {
color: #ffffff;
font-size: 35upx;
text-align: center;
margin: 20upx 0;
}
.main {
position: relative;
width: 100%;
margin-top: 50upx;
}
.main .lay1 {
position: absolute;
top: 0;
bottom: 0;
right: 0;
left: 0;
z-index: 3000;
}
.main .lay1 .line {
height: 100upx;
width: 100%;
border-radius: 50px;
background-color: #e28f0b;
margin-top: 100upx;
}
.lay2 {
position: absolute;
top: 0;
bottom: 0;
right: 0;
left: 0;
z-index: 4000;
}
.lay2 .qr {
width: 70%;
margin: 0 auto;
height: 700upx;
background-color: #3958ab;
}
.qr-img {
text-align: center;
padding-top: 50%;
}
.qr-txt {
color: #ffffff;
text-align: center;
margin-top: 50upx;
}
.lay3 {
position: absolute;
top: 0;
bottom: 0;
right: 0;
left: 0;
z-index: 4000;
text-align: center;
}
.lay3 .line {
height: 100upx;
width: 85%;
border-radius: 50px;
background-color: #e28f0b;
margin: 40upx auto;
box-shadow: #cccccc 0px 3px 10px;
}
.code-btn {
width: 100%;
color: #ffffff;
height: 100%;
text-align: center;
}
.line-btn {
position: absolute;
bottom: 200upx;
left: 0upx;
right: 0upx;
width: 100%;
display: flex;
justify-content: center;
}
.btn {
width: 400upx;
padding: 35upx;
background-color: #e28f0b;
border-radius: 50px;
}
.btn:active{
background-color: #FEC607;
}
</style>
收起阅读 »

关于 using unregistered native plugin 'DCloud-RichAlert' 问题
最近很多人询问此问题 "using unregistered native plugin 'DCloud-RichAlert" 插件无法运行!".
导致出现此问题的原因及解决方案:
1、请升级 HBuilderX 到1.6.2以上版本,然后重新打自定义基座包。注意是自定义基座包!!!!。运行时请勾选自定义基座!
2、插件没有放入到指定文件夹下。具体配置请查看 http://ask.dcloud.net.cn/article/35412
3、android目前不支持插件在模拟器下运行,所以要使用真机运行测试。
最近很多人询问此问题 "using unregistered native plugin 'DCloud-RichAlert" 插件无法运行!".
导致出现此问题的原因及解决方案:
1、请升级 HBuilderX 到1.6.2以上版本,然后重新打自定义基座包。注意是自定义基座包!!!!。运行时请勾选自定义基座!
2、插件没有放入到指定文件夹下。具体配置请查看 http://ask.dcloud.net.cn/article/35412
3、android目前不支持插件在模拟器下运行,所以要使用真机运行测试。 收起阅读 »

HBuilderX scss/sass 使用教程
1. 安装node-sass插件
在HBuilderX中,使用scss/sass
是需要安装node-sass编译插件
的。
点击菜单【工具】【插件安装】
如果安装失败,请见:http://ask.dcloud.net.cn/article/35468
2. 编译scss文件
选中scss文件,鼠标右键,点击菜单【外部命令】【sass】【编译sass/scss】
3. 编译风格与样式输出
目前,node-sass的默认编译风格如下:
{
'include-path': process.cwd(),
'indent-type': 'space',
'indent-width': 2,
linefeed: 'lf',
'output-style': 'nested', // 嵌套输出
precision: 5,
quiet: false,
recursive: true
}
修改编译风格的方法,打开sass配置文件,修改command。
比如:
$ "command": "${programPath} ${file} ${fileBasename}.css --output-style compact"
风格为:展开输出expanded、紧凑型compact、压缩输出compressed
1. 安装node-sass插件
在HBuilderX中,使用scss/sass
是需要安装node-sass编译插件
的。
点击菜单【工具】【插件安装】
如果安装失败,请见:http://ask.dcloud.net.cn/article/35468
2. 编译scss文件
选中scss文件,鼠标右键,点击菜单【外部命令】【sass】【编译sass/scss】
3. 编译风格与样式输出
目前,node-sass的默认编译风格如下:
{
'include-path': process.cwd(),
'indent-type': 'space',
'indent-width': 2,
linefeed: 'lf',
'output-style': 'nested', // 嵌套输出
precision: 5,
quiet: false,
recursive: true
}
修改编译风格的方法,打开sass配置文件,修改command。
比如:
$ "command": "${programPath} ${file} ${fileBasename}.css --output-style compact"
风格为:展开输出expanded、紧凑型compact、压缩输出compressed
收起阅读 »