微信小程序开发工具模块化开发(微信小程序开发工具模块化开发方案)

小程序开发 1487
今天给各位分享微信小程序开发工具模块化开发的知识,其中也会对微信小程序开发工具模块化开发方案进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!本文目录一览: 1、微信小程序蓝牙模块开发

今天给各位分享微信小程序开发工具模块化开发的知识,其中也会对微信小程序开发工具模块化开发方案进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

微信小程序蓝牙模块开发

//index.js

//获取应用实例

const app = getApp()

const util = require('../../utils/util.js')

const bletool = require('../../utils/bletool.js')

Page({

data: {

// lists: [{ 'order_no': '1111', 'car_no': '321', 'car_type': '尚好捷', 'order_date': '2018-01-02 08:00', 'order_money': '16.00', 'order_time': '4' }],

car_no: '',

order_no: '',

lists: [],

bleList: [], //蓝牙设备数组

serviceId: '',//592B3370-3900-9A71-4535-35D4212D2837

serviceMac: '',//C9:9B:4C:E7:DE:10

service_psd: '',//855525B837253705595800000329

service_uuid: '',

deviceId:'',

characteristics:[] //特征值

},

onLoad: function (options) {

this.initBle();

},

onReady: function () {

// 页面渲染完成

},

onShow: function () {

if (app.globalData.car_no.length0){

this.getDeviceInfo();

}

},

onHide: function () {

// 页面隐藏

},

onUnload: function () {

// 页面关闭

app.globalData.car_no=''

},

//蓝牙相关

//初始化蓝牙

initBle: function () {

var that = this;

wx.onBluetoothAdapterStateChange(function (res) {

console.log('adapterState changed, now is', res)

app.globalData.ble_state = res.available;

if (res.available) {

that.initBle();

} else {

util.showToast('手机蓝牙已关闭');

app.globalData.ble_isonnectting = false;

}

})

//打开蓝牙适配器

wx.openBluetoothAdapter({

success: function (res) {

console.log('打开蓝牙适配器成功');

that.getBluetoothAdapterState();

app.globalData.ble_state = true;

that.onBluetoothDeviceFound();

},

fail: function (res) {

// fail

console.log(res)

util.showToast('请打开手机蓝牙');

},

complete: function (res) {

// complete

}

})

},

onBluetoothDeviceFound:function(){

var that = this;

//监听扫描

wx.onBluetoothDeviceFound(function (res) {

// res电脑模拟器返回的为数组;手机返回的为蓝牙设备对象

console.log('监听搜索新设备:', res);

that.updateBleList([res])

})

},

getBluetoothAdapterState: function () {

var that = this;

wx.getBluetoothAdapterState({

success: function (res) {

var available = res.available;

var discovering = res.discovering;

if (!available) {

util.showToast('蓝牙不可用');

} else {

if (!discovering) {

// that.startBluetoothDevicesDiscovery();

}

}

}

})

},

startBluetoothDevicesDiscovery: function () {

var that = this;

var services = [];

services.push(this.data.serviceId);

wx.showLoading({

title: '设备搜索中'

});

setTimeout(function () {

wx.hideLoading();

if (app.globalData.deviceId.length==0){

util.showModal('设备搜索失败,请重试');

}

}, 10000)

if(bletool.isIOS()){

wx.startBluetoothDevicesDiscovery({

services: services,

allowDuplicatesKey: true,

success: function (res) {

console.log('ios搜索成功');

console.log(res);

},

fail: function (err) {

console.log(err);

}

});

}else{

wx.startBluetoothDevicesDiscovery({

// services: services,

allowDuplicatesKey: true,

success: function (res) {

console.log('Android搜索成功');

console.log(res);

},

fail: function (err) {

console.log(err);

wx.hideLoading();

that.startBluetoothDevicesDiscovery();

// that.getBluetoothAdapterState();

util.showToast('搜索失败');

}

});

}

},

startConnectDevices: function (ltype, array) {

var that = this;

clearTimeout(that.getConnectedTimer);

that.getConnectedTimer = null;

wx.stopBluetoothDevicesDiscovery({

success: function (res) {

// success

}

})

app.globalData.ble_isonnectting = true;

console.log('连接前:'+that.deviceId);

wx.createBLEConnection({

deviceId: that.deviceId,

success: function (res) {

if (res.errCode == 0) {

console.log('连接成功:');

that.getService(that.deviceId);

}

},

fail: function (err) {

console.log('连接失败:', err);

wx.hideLoading();

util.showModal('设备连接失败,请重试');

// if (ltype == 'loop') {

// that.connectDeviceIndex += 1;

// that.loopConnect(array);

// } else {

// that.startBluetoothDevicesDiscovery();

// that.getConnectedBluetoothDevices();

// }

app.globalData.ble_isonnectting = false;

},

complete: function () {

}

});

},

getService: function (deviceId) {

var that = this;

// 监听蓝牙连接

wx.onBLEConnectionStateChange(function (res) {

console.log(res);

app.globalData.ble_isonnectting = res.connected

if (!res.connected) {

util.showToast('连接断开');

}

});

// 获取蓝牙设备service值

wx.getBLEDeviceServices({

deviceId: deviceId,

success: function (res) {

console.log('获取蓝牙设备service值');

console.log(res);

that.getCharacter(deviceId, res.services);

}

})

},

getCharacter: function (deviceId, services) {

var that = this;

services.forEach(function (value, index, array) {

if (value.isPrimary) {

that.setData({

service_uuid: value.uuid,

deviceId: deviceId

})

app.globalData.service_uuid= value.uuid;

app.globalData.deviceId=deviceId;

}

});

//监听通知

wx.onBLECharacteristicValueChange(function (res) {

// callback

console.log('value change', res)

const hex = bletool.buf2char(res.value)

console.log('返回的数据:', hex)

//配对密码

if (hex.indexOf('855800000106') != -1) {

wx.hideLoading();

var charact_write = that.data.characteristics[1]

bletool.writeDataToDevice(that.data.deviceId, that.data.service_uuid, charact_write, that.data.service_psd);

wx.showToast({

title: '设备已连接',

icon: 'success',

duration: 3000

})

setTimeout(function () {

bletool.writeDataToDevice(that.data.deviceId, that.data.service_uuid, charact_write, '235525B837253705590400000273');

}, 2000)

} else if (hex.indexOf('23040000') != -1) {

//启动成功

that.starRenting();

}

})

wx.getBLEDeviceCharacteristics({

deviceId: deviceId,

serviceId: that.getServiceUUID(),

success: function (res) {

wx.getBLEDeviceCharacteristics({

deviceId: deviceId,

serviceId: that.getServiceUUID(),

success: function (res) {

console.log('特征', res)

that.setData({

characteristics:res.characteristics

})

app.globalData.characteristics = res.characteristics;

var charact_read = res.characteristics[0]

},

loopConnect: function (devicesId) {

var that = this;

var listLen = devicesId.length;

if (devicesId[this.connectDeviceIndex]) {

this.deviceId = devicesId[this.connectDeviceIndex];

this.startConnectDevices('loop', devicesId);

} else {

console.log('已配对的设备小程序蓝牙连接失败');

that.startBluetoothDevicesDiscovery();

that.getConnectedBluetoothDevices();

}

},

//更新数据 devices为数组类型

updateBleList: function (devices) {

console.log('设备数据:',devices);

var newData = this.data.bleList

var that = this

var tempDevice = null;

for (var i = 0; i devices.length; i++) {

//ios设备

if (devices[i].devices != null) {

if (devices[i].devices.length 0) {

tempDevice = devices[i].devices[0];

}

else {

continue

}

}

//安卓

else {

tempDevice = devices[i];

}

if (!this.isExist(tempDevice)) {

newData.push(tempDevice)

}

}

console.log('数据:');

console.log(newData)

this.setData({

bleList: newData

})

if (!app.globalData.ble_isonnectting) {

var that = this;

this.data.bleList.forEach(function (value, index, array) {

//找到对应id的设备,ios判断服务id安卓判断mac地址

var deviceId = value['deviceId'];

if(bletool.isIOS()){

let advertisServiceUUID = value['advertisServiceUUIDs'][0];

if (advertisServiceUUID == that.data.serviceId.toUpperCase()){

that.deviceId = deviceId;

console.log(that.deviceId);

that.startConnectDevices();

}

}else{

if (deviceId == that.data.serviceMac) {

that.deviceId = deviceId;

console.log(that.deviceId);

that.startConnectDevices();

}

}

});

}

},

//是否已存在 存在返回true 否则false

isExist: function (device) {

var tempData = this.data.bleList

for (var i = 0; i tempData.length; i++) {

if (tempData[i].deviceId == device.deviceId) {

return true

}

}

return false

},

//服务uuid

getServiceUUID: function () {

return bletool.stringTransition(this.data.service_uuid);

},

getDeviceInfo: function () {

let car_no = app.globalData.car_no;

var that = this;

wx.request({

url: app.globalData.serverURL + '?c=cara=getDeviceInfoopen_id=' + app.globalData.open_id + 'car_no=' + car_no,

method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT

header: { 'content-type': 'application/json' }, // 设置请求的 header

success: function (res) {

// success

var data = res.data;

console.log(data);

if (data.result == 1) {

app.globalData.serviceId = data.data.service_id;

app.globalData.serviceMac = data.data.service_mac,

app.globalData.service_psd = '85' + data.data.service_psd + '5800000329';

that.setData({

serviceId: data.data.service_id,

serviceMac: data.data.service_mac,

service_psd: '85' + data.data.service_psd+'5800000329',

})

app.startBluetoothDevicesDiscovery();

// that.onBLECharacteristicValueChange();

} else {

util.showModal(data.msg);

}

},

fail: function () {

},

complete: function () {

// complete

}

});

},

})

超市O2O微信小程序模式如何定制开发?

超市O2O微信小程序开发主要有三种模式:

第一种,基于现成模板进行编辑的模式。

这种模式下,模板是最为首要的,用户首先选择一个最为接近需求的模板,然后采用编辑、配置的方式对模板的名字、标题、栏目名称/数量、图片等进行修改。

优点

快,非常简单,如果图片素材等提前准备到位了,通过模板编辑配置的模式开发微信小程序,一般1、2个小时就能搞定!

缺点

1)找到匹配度足够满意的模板并不容易:这种模式比较依赖于模板供应方的模板库丰富程度,一般来说,最终用户的需求都是千变万化的,往往都是各有各的诉求,即便模板平台方提供的模板数量很丰富,却仍然会经常出现找遍了模板库也找不到满意的恰当的模板的情况。

2)几乎没法做较深度的个性化定制:一旦希望做点比换图片、改标题更复杂点的个性化扩展,就会发现这种模式是一个死胡同,这种模式的工具里,几乎没有厂商能支持比较深度的功能个性化修改、定制。

第二种,模板+拖拽制作。

这种模式下,工具平台方会提供一些比较典型的行业、场景模板,同时还会提供比较丰富的相关功能模块,这些功能模块可以自由“装卸”到模板上去。模板比较全面地体现了相关类别小程序的整体框架,用户基于该模板框架,结合自身的具体需求,通过拖拽方式对各种各样的模块进行自由组合,从而实现各种各样的个性化需求。

优点

比较简单快捷,对制作者几乎没有技术背景的要求,同时还有比较大的个性化拓展可能性。基于“模板+拖拽式制作”的模式做微信小程序开发,一般制作周期按天计算,2、3天能做出一个中等复杂度的小程序应用。

缺点

这类模式的工具很容易做成"慢性毒药",具备一定麻痹性:对实际应用场景而言,单纯这种模式的个性化能力其实依然远远不够;但由于往往呈现的是“能任意定制”的形象,所以这类工具其实很有麻痹性,用户使用到后期往往有上了贼船的感觉——说好的自由定制呢?发现依旧很多地方不能改,依然这不能实现,那也没法实现。而此时,往往已经有相当的运营投入和数据沉淀,要想重头再来找人从零开始帮另行定制一套,影响太大,伤筋动骨啊!

第三种,组件化的快速开发模式。

能到“组件化”这个层面,足以表明这种模式其实已经开始颇有点专业开发的味道了。

这种模式下,主要特征是将各种比较通用的代码模块封装成一个个组件,未来开发中不用重复编写这些模块的代码,而是直接拖用组件。

优点

因为是在代码层面进行开发,对小程序的功能实现有最大的掌控度。也是因为进入了代码层面,所以对于一些特殊需求的复杂小程序,就能根据需要随时全面开展性能优化了。此外,由于组件化,开发速度也还比较高。

缺点

难度大,需要有的一定的编码基础;完成一个小程序开发的时间一般都不短,即便比较成熟高效的可视化组件式开发工具,也得需要半个月之久。

麦口科技如何定制开发或快速模板模块化微信小程序?

小程序的定制开发可以选择一些一键生成的小程序。

微尘小程序就是如此的,拖拽就可以生成。

微信小程序模块化开发哪家好

小程序开发已经活跃了很长一段时间,然而还是有很多人并不熟知,所以才会让有心人有机可乘。需要记住的是微信小程序没有官方的第三方开发平台!小程序开发行业非常繁杂,很多公司都能做,但选择专业的小程序开发公司,这一点非常重要就要擦亮眼睛来选择了。

选择平台除了合同细节,还一定要了解清楚这家公司的背景口碑,多看看公司开发的成功案例,看做的成功案例与自己心目中的网站效果是否一致。有丰富的开发微信小程序的经验,能根据客户的要求设计出一套别具风格的网站,还可根据用户的体验上做出合理的页面布局调整和功能结构调整,让平台增加在同行业的核心竞争力。

另外建议:购买时不光要产品好、公司好、售后服务也要好。在微信小程序网站在运行中总会有各种各样的问题,如平台的前后台操作、网站运营中出现的系统问题及漏洞等各种问题,开发公司能否及时有效的解决,这些都是我们在购买系统选择服务公司的一个重要考核点。

总之,天上不会掉馅饼,不要总想着占便宜,钻空子。跟一次付款终身免费维护相比,那些后期收一定维护费的小程序开发商能提供更好的产品和服务更有信服力。具体哪家好,需要自己亲自体验。

微信小程序之自定义模态弹窗(带动画)实例

首先看看官方提供的模态弹窗

api如下:

示例:

这样的模态弹窗,充其量只能做个alert,提示一下信息。

但是并不能使用它来处理复杂性的弹窗业务,因此写了Michael从新自定义了一个,采用了仿原生的样式写法

wxml****:

wxss:

js:

相关连接:

------------------------------------------------------------

微信开发者工具的快捷键

微信小程序的文件结构 —— 微信小程序教程系列(1)

微信小程序的生命周期实例演示 —— 微信小程序教程系列(2)

微信小程序的动态修改视图层的数据 —— 微信小程序教程系列(3)

微信小程序的新建页面 —— 微信小程序教程系列(4)

微信小程序的如何使用全局属性 —— 微信小程序教程系列(5)

微信小程序的页面跳转 —— 微信小程序教程系列(6)

微信小程序标题栏和导航栏的设置 —— 微信小程序教程系列(7)

微信小程序的作用域和模块化 —— 微信小程序教程系列(8)

微信小程序视图层的数据绑定 —— 微信小程序教程系列(9)

微信小程序视图层的条件渲染 —— 微信小程序教程系列(10)

微信小程序视图层的列表渲染 —— 微信小程序教程系列(11)

微信小程序视图层的模板 —— 微信小程序教程系列(12)

微信小程序之wxss —— 微信小程序教程系列(13)

微信小程序的网络请求 —— 微信小程序教程系列(14)

微信小程序的百度地图获取地理位置 —— 微信小程序教程系列(15)

微信小程序使用百度api获取天气信息 —— 微信小程序教程系列(16)

微信小程序获取系统日期和时间 —— 微信小程序教程系列(17)

微信小程序之上拉加载和下拉刷新 —— 微信小程序教程系列(18)

微信小程序之组件 —— 微信小程序教程系列(19)

微信小程序之微信登陆 —— 微信小程序教程系列(20)

------------------------------------------------------------

微信小程序之顶部导航栏实例 —— 微信小程序实战系列(1)

微信小程序之上拉加载(分页加载)实例 —— 微信小程序实战系列(2)

微信小程序之轮播图实例 —— 微信小程序实战系列(3)

微信小程序之仿android fragment之可滑动的底部导航栏实例 —— 微信小程序实战系列(4)

微信小程序之登录页实例 —— 微信小程序实战系列(5)

微信小程序之自定义toast实例 —— 微信小程序实战系列(6)

微信小程序之自定义抽屉菜单(从下拉出)实例 —— 微信小程序实战系列(7)

微信小程序之自定义模态弹窗(带动画)实例 —— 微信小程序实战系列(8)

------------------------------------------------------------

微信小程序之侧栏分类 —— 微信小程序实战商城系列(1)

微信小程序之仿淘宝分类入口 —— 微信小程序实战商城系列(2)

微信小程序之购物数量加减 —— 微信小程序实战商城系列(3)

微信小程序之商品属性分类 —— 微信小程序实战商城系列(4)

微信小程序之购物车 —— 微信小程序实战商城系列(5)

未完待续。。。

更多小程序的教程:

谢谢观看,不足之处,敬请指导

关于微信小程序开发工具模块化开发和微信小程序开发工具模块化开发方案的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

扫码二维码