Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/wechat_app/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// app.js
App({
onLaunch() {
// 展示本地存储能力
const logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)

// 登录
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
}
})
},
globalData: {
userInfo: null,
selble:"", //所选择蓝牙的mac
bleUtil:"", //蓝牙助手
}
})
16 changes: 16 additions & 0 deletions src/wechat_app/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"pages":[
"pages/selble/selble",
"pages/index/index",
"pages/logs/logs"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "Weixin",
"navigationBarTextStyle":"black"
},
"style": "v2",
"lazyCodeLoading": "requiredComponents",
"sitemapLocation": "sitemap.json"
}
220 changes: 220 additions & 0 deletions src/wechat_app/app.wxss
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
/**app.wxss**/
page{
background: #EFF2F6;
}
.container {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
padding: 200rpx 0;
box-sizing: border-box;
}
.match_screen{
width: 100vw;
height: 100vh
}
.flex_row, .flex_column {
display: flex;
}

.flex_row {
flex-direction: row;
}

.flex_column {
flex-direction: column;
}

.flex_vcenter, .flex_center {
align-items: center;
}

.flex_hcenter, .flex_center {
justify-content: center;
}



.flex_wrap {
flex-wrap: wrap;
}

.flex_space {
justify-content: space-between;
}

.flex_grow_1 {
flex-grow: 1;
}

.flex_end {
justify-content: flex-end;
}

.flex_start {
justify-content: flex-start;
}

.border_bottom_class {
border-bottom: 1px solid rgba(204, 204, 204, 1);
}

.border_bottom_class_foucs {
border-bottom: 1px solid rgba(46, 152, 233, 1);
}

.table_boot_two {
width: 16.6666667%;
}

.table_boot_three {
width: 25%;
}

.table_boot_four {
width: 33.33%;
}

.table_boot_nine {
width: 75%;
}

.table_boot_six {
width: 50%;
}

.table_boot_ten {
width: 83.3333333%;
}

.table_boot_eight {
width: 66.666667%;
}

.table_boot_seven {
width: 58.3333333%;
}

.table_boot_height_six {
height: 50%;
}

.table_boot_height_one {
height: 8.333333%;
}

.table_boot_height_two {
height: 16.6666667%;
}

.table_boot_height_three {
height: 25%;
}

.table_boot_height_four {
height: 33.33333333%;
}

.table_boot_height_five {
height: 41.6666667%;
}

.table_boot_height_seven {
height: 58.3333333%;
}

.table_boot_height_eight {
height: 66.666667%;
}

.table_boot_height_nine {
height: 75%;
}

.table_boot_height_ten {
height: 83.3333333%;
}

.table_boot_height_ele {
height: 91.66667%;
}

.table_boot_height_twle {
height: 100%;
}

.white_back{
background: #fff;
}

.pos_fixed {
position: fixed;
z-index: -1;
}

.text_center {
text-align: center;
}


.btn_yellow_class,.btn_yellow_class:active,.btn_yellow_class_dissable{
width:90%;
margin-left: 5%;
border-radius:4px;
color: #fff;
font-size:100%;
font-family:PingFangSC-Heavy;
font-weight:800;
}

.btn_yellow_class{
background:rgba(0,120,253,1);
}

.btn_yellow_class:active{
background:rgb(5, 100, 207);
}

.btn_yellow_class_dissable{
background:rgba(204,204,204,1);
}

.no_data_back{
width: 100vw;
height: 60vh
}

.no_data_img{
width: 20vw;
height: 20vw;
}

.no_data_hint{
font-size: 80%;
color:#B0B0B0;
}

.btn_disable{
position: fixed;
right: 3vw;
color: white;
font-size: 80%;
background:linear-gradient(180deg,rgba(189,189,189,1) 0%,rgba(102,102,102,1) 100%,rgba(204,204,204,1) 100%);
border-radius:10px;
}

.btn_normal,.btn_normal:active{
font-size: 80%;
color: white;
border-radius:10px;
}

.btn_normal{
background:linear-gradient(180deg,rgba(255,255,255,1) 0%,rgba(255,112,191,1) 0%,rgba(69,178,255,1) 0%,rgba(0,126,255,1) 100%);
}

.btn_normal:active{
background:rgba(0,126,255,1);
}
Binary file added src/wechat_app/images/ic_ble.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/wechat_app/images/ic_sel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/wechat_app/images/ic_unsel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
110 changes: 110 additions & 0 deletions src/wechat_app/pages/index/handler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
let regeneratorRuntime = require("../../utils/runtime.js");
var util = require("../../utils/util.js");
const app = getApp();
var isSend = false;

//同步请求
/**
* request请求,GET 默认header
*/
function sendBleMsg(data,that) {
that.appendLogs("发送数据 " + data + " 中",that);
return new Promise((success, fail) => {
var isSuccess = false;
app.globalData.bleUtil.sendMsg(data, function (res) {
isSuccess = true;
if (res.errCode == 0) {
that.appendLogs("发送数据 " + data + " 成功",that);
success(true);
} else {
that.appendLogs("发送数据 " + data + " 失败",that);
success(false);
}
}, false);
//3秒后若没有发送成功,则认为发送失败
setTimeout(function(res){
if(!isSuccess){
success(false);
that.appendLogs("发送数据 " + data + " 失败",that);
}
},3000);
});
}

function sleep(times,that) {
return new Promise((success, fail) => {
setTimeout(function (res) {
success(true);
that.appendLogs("延迟 " + times + " 毫秒",that);
}, times);
});
}



var sendList = async (sendlist,sendtimes,that) => {
var i = 0;
isSend = true;
while(isSend){
let result = await sendBleMsg(sendlist[i],that);
if(!result){
stop(that);
return;
}
await sleep(sendtimes,that);
i++;
if(i > sendlist.length - 1){
i = 0;
}
}
}


var sendCoustomList = async (sendlist,title,that) => {
that.appendLogs("开始发送功能 " + title ,that);
that.setData({
isRund:true
})
isSend = true;
while(isSend){
for(var x in sendlist){
if(sendlist[x].opertype == "DE"){
await sleep(sendlist[x].value,that);
} else if(sendlist[x].opertype == "SEND"){
let result = await sendBleMsg(sendlist[x].value,that);
if(!result){
stop(that);
return;
}
}
}
if(that.data.ismenuRund){
isSend = true;
} else {
isSend = false;
}
}

that.setData({
isRund:false
})
that.appendLogs("功能 " + title + "发送完毕",that);

}


var stop = function(that){
isSend = false;
if(that){
that.setData({
isRund:false
})
that.appendLogs("停止发送",that);
}
}

module.exports = {
sendList: sendList,
stop,
sendCoustomList
}
Loading