Commit 74c318e9 by 陈玉桐

add绑定设备

parent dceeb5d5
{ {
"pages": [ "pages": [
"pages/index/index", "pages/index/index",
"pages/getCodeIndex/getCodeIndex",
"pages/handBind/handBind",
"pages/message/message", "pages/message/message",
"pages/user/user", "pages/user/user",
"pages/userEdit/userEdit", "pages/userEdit/userEdit",
......
var app = getApp();
Page({
data: {
},
onLoad: function () {
},
// 扫码绑定
scanBind: function (e) {
let me = this;
// 请求前加Loading
wx.showLoading({
title: '加载中',
mask: true
})
wx.scanCode({ //扫描API
success(res) { //扫描成功
console.log(res.result)
setTimeout(function(){
wx.request({
url: app.globalData.apiUrl + 'users/personalCenter',
method: 'POST',
data: {
token: wx.getStorageSync('token')
},
success: function (res) {
// 请求成功后关闭Loading
wx.hideLoading();
if(res.data.errno==200){
wx.showToast({
title: 'sn:'+res.data.data.seexSn,
// mask: true,
icon: 'none',
duration: 2000
});
if(res.data.data.seexSn){
// 绑定成功
wx.showToast({
title: '绑定成功',
mask: true,
// icon: 'none',
duration: 2000
});
wx.redirectTo({
url: '/pages/index/index'
})
}else{
wx.showToast({
title: '设备不存在',
// mask: true,
icon: 'none',
duration: 2000
});
}
}else{
wx.showModal({
title: '提示',
showCancel: false,
content: res.data.msg
})
}
}
})
},300)
// wx.request({
// url: app.globalData.apiUrl + 'devices/seexSn',
// method: 'POST',
// data: {
// token: wx.getStorageSync('token'),
// url: res.result
// },
// success: function (res) {
// if(res.data.errno==200){
// console.log(res.data.data.seexSn)
// wx.request({
// url: app.globalData.apiUrl + 'devices/bind',
// method: 'POST',
// data: {
// token: wx.getStorageSync('token'),
// seexSn: res.data.data.seexSn
// },
// success: function (res) {
// // 请求成功后关闭Loading
// wx.hideLoading();
// if(res.data.errno==200){
// // 绑定成功
// wx.showToast({
// title: '绑定成功',
// mask: true,
// // icon: 'none',
// duration: 2000
// });
// wx.redirectTo({
// url: '/pages/index/index'
// })
// }else{
// wx.showModal({
// title: '提示',
// showCancel: false,
// content: res.data.msg
// })
// }
// }
// })
// }else{
// // 打印错误信息
// console.log(res.data.msg)
// wx.showToast({
// title: res.data.msg,
// // mask: true,
// icon: 'none',
// duration: 2000
// });
// }
// }
// })
}
})
},
// 手动绑定
handBind: function (e) {
// 跳转到输入SN码页面
wx.navigateTo({
url: '/pages/handBind/handBind'
})
}
})
{
"navigationBarTitleText": "扫码绑定",
"usingComponents": {}
}
\ No newline at end of file
<view id="getCode">
<!-- 背景图片 -->
<view id="scanBtnBgBox">
<image id="scanBtnBg" src="../../assets/bg_linkdevice.png" />
<!-- 提示语 -->
<view id="getCodeTip">
<view>您好!</view>
<view>请绑定已购买设备。</view>
</view>
<!-- 提示图片 -->
<image id="tipIcon" src="../../assets/qrtips.png" />
<!-- 按钮 -->
<view id="getCodeBtnBox">
<button class="getCodeBtn" id="scanBtn" bindtap="scanBind">扫码绑定</button>
<button class="getCodeBtn" id="handBtn" bindtap="handBind">手动绑定</button>
</view>
</view>
</view>
#getCode{
background: #97979C;
min-height: 100vh;
}
#scanBtnBgBox{
position:absolute;
left:30rpx;
top:30rpx;
right:30rpx;
bottom:0;
height:87%;
}
#scanBtnBg{
width: 100%;
height: 100%;
}
#getCodeBtnBox{
position: absolute;
bottom: 60rpx;
width: 100%;
}
#scanBtn{
margin-bottom: 30rpx;
}
.getCodeBtn{
width:91%;
height: 94rpx;
line-height: 94rpx;
font-size: 36rpx;
color: #FFFFFF;
background: #33D1C4;
border-radius: 10rpx;
}
/* 提示语 */
#getCodeTip{
position: absolute;
top: 0;
left: 0;
font-size: 38rpx;
color: #30C0D1;
padding-left: 30rpx;
padding-top: 60rpx;
}
/* 提示图片 */
#tipIcon{
width: 220rpx;
height: 60rpx;
position: absolute;
top: 196rpx;
left: 50%;
transform: translateX(-50%);
}
\ No newline at end of file
var app = getApp();
Page({
data: {
SN: ''
},
onLoad: function () {
},
// sn码
snChange: function(e) {
this.setData({
SN: e.detail.value
})
},
// 开始绑定
bind: function(e) {
let me = this;
console.log(me.data.SN)
if(me.data.SN==''){
wx.showModal({
title: '提示',
showCancel: false,
content: 'SN码不能为空!'
})
return
}
// 请求前加Loading
wx.showLoading({
title: '加载中',
mask: true
})
wx.request({
url: app.globalData.apiUrl + 'devices/bind',
method: 'POST',
data: {
token: wx.getStorageSync('token'),
seexSn: me.data.SN
},
success: function (res) {
// 请求成功后关闭Loading
wx.hideLoading();
if(res.data.errno==200){
// 绑定成功
wx.showToast({
title: '绑定成功',
mask: true,
// icon: 'none',
duration: 2000
});
wx.redirectTo({
url: '/pages/index/index'
})
}else{
wx.showModal({
title: '提示',
showCancel: false,
content: res.data.msg
})
}
}
})
}
})
{
"navigationBarTitleText": "绑定设备",
"usingComponents": {}
}
\ No newline at end of file
<view id="handBind">
<view id="handBindCon">
<view id="handBindInputBox">
<view id="handBindTitle">请输入您的设备SN码</view>
<input id="snInput" bindinput="snChange" placeholder-style="color:#888;" bindinput="snChange" maxlength="20" type="text" placeholder="SN码由13位数字和字母组合而成" />
</view>
</view>
<!-- 提示 -->
<view id="handBindTip">
<view id="handBindTipTitle">
<image src="../../assets/tips.png" />
<text>在哪可以找到我的SN码</text>
</view>
<view class="handBindTipItem">
• 开启眼保仪 > 我的 > 关于我们,最下方写着SN
<view>码的字母数字组合;</view>
</view>
<view class="handBindTipItem">• 眼保仪的外包装盒。</view>
</view>
<!-- 开始绑定按钮 -->
<view id="handBindBtnCon">
<view id="handBindBtnBox">
<button id="bindBtn" bindtap="bind">开始绑定</button>
</view>
</view>
</view>
#handBind{
background: #EFEFF4;
min-height: 100vh;
}
/* 输入框 */
#handBindCon{
padding: 30rpx;
}
#handBindInputBox{
background: #FFFFFF;
padding: 60rpx 30rpx;
border-radius: 10rpx;
}
#handBindTitle{
font-size: 38rpx;
color: #4F5051;
margin-bottom: 30rpx;
}
#snInput{
font-size: 32rpx;
color: #4F5051;
padding: 20rpx 24rpx;
background: #EFEFF4;
border-radius: 4rpx;
}
/* 提示 */
#handBindTip{
padding: 0 60rpx;
margin-top: 40rpx;
}
#handBindTipTitle{
display: flex;
align-items: center;
font-size: 32rpx;
color: #4F5051;
margin-bottom: 20rpx;
}
#handBindTipTitle>image{
width: 29rpx;
height: 29rpx;
margin-right: 7rpx;
}
.handBindTipItem{
font-size: 28rpx;
color: #888888;
margin-bottom: 20rpx;
}
.handBindTipItem>view{
margin-left: 24rpx;
}
/* 按钮 */
#handBindBtnCon{
position: absolute;
width: 100%;
bottom: 80rpx;
}
#handBindBtnBox{
padding: 0 36rpx;
}
#bindBtn{
width: 100%;
height: 94rpx;
line-height: 94rpx;
font-size: 36rpx;
color: #FFFFFF;
background: #33D1C4;
border-radius: 10rpx;
}
\ No newline at end of file
...@@ -566,7 +566,7 @@ Page({ ...@@ -566,7 +566,7 @@ Page({
let indexTimer = setInterval(function(){ let indexTimer = setInterval(function(){
// console.log(timestamp) // console.log(timestamp)
times++ times++
console.log(times) // console.log(times)
if(times>4){ if(times>4){
me.setData({ me.setData({
watchImgText: '正在加载,马上就好了...', watchImgText: '正在加载,马上就好了...',
...@@ -762,10 +762,14 @@ Page({ ...@@ -762,10 +762,14 @@ Page({
url: '/pages/setting/setting' url: '/pages/setting/setting'
}) })
}else{ }else{
wx.showModal({ // wx.showModal({
title: '提示', // title: '提示',
showCancel: false, // showCancel: false,
content: "您未绑定设备部分功能将无法使用" // content: "您未绑定设备部分功能将无法使用"
// })
// 未绑定设备 → 绑定设备页面
wx.navigateTo({
url: '/pages/getCodeIndex/getCodeIndex'
}) })
} }
}, },
...@@ -776,10 +780,14 @@ Page({ ...@@ -776,10 +780,14 @@ Page({
url: '/pages/plan/plan' url: '/pages/plan/plan'
}) })
}else{ }else{
wx.showModal({ // wx.showModal({
title: '提示', // title: '提示',
showCancel: false, // showCancel: false,
content: "您未绑定设备部分功能将无法使用" // content: "您未绑定设备部分功能将无法使用"
// })
// 未绑定设备 → 绑定设备页面
wx.navigateTo({
url: '/pages/getCodeIndex/getCodeIndex'
}) })
} }
}, },
...@@ -834,10 +842,14 @@ Page({ ...@@ -834,10 +842,14 @@ Page({
} }
}) })
}else{ }else{
wx.showModal({ // wx.showModal({
title: '提示', // title: '提示',
showCancel: false, // showCancel: false,
content: "您未绑定设备部分功能将无法使用" // content: "您未绑定设备部分功能将无法使用"
// })
// 未绑定设备 → 绑定设备页面
wx.navigateTo({
url: '/pages/getCodeIndex/getCodeIndex'
}) })
} }
}, },
...@@ -846,10 +858,14 @@ Page({ ...@@ -846,10 +858,14 @@ Page({
let me = this let me = this
if(me.data.bindDeviceStatus==1){ if(me.data.bindDeviceStatus==1){
}else{ }else{
wx.showModal({ // wx.showModal({
title: '提示', // title: '提示',
showCancel: false, // showCancel: false,
content: "您未绑定设备部分功能将无法使用" // content: "您未绑定设备部分功能将无法使用"
// })
// 未绑定设备 → 绑定设备页面
wx.navigateTo({
url: '/pages/getCodeIndex/getCodeIndex'
}) })
return return
} }
...@@ -901,7 +917,7 @@ Page({ ...@@ -901,7 +917,7 @@ Page({
var refreshTimer = setInterval(function(){ var refreshTimer = setInterval(function(){
// console.log(timestamp) // console.log(timestamp)
times++ times++
console.log(times) // console.log(times)
if(times>4){ if(times>4){
me.setData({ me.setData({
watchImgText: '正在加载,马上就好了...', watchImgText: '正在加载,马上就好了...',
...@@ -984,10 +1000,14 @@ Page({ ...@@ -984,10 +1000,14 @@ Page({
url: '/pages/mine/mine' url: '/pages/mine/mine'
}) })
}else{ }else{
wx.showModal({ // wx.showModal({
title: '提示', // title: '提示',
showCancel: false, // showCancel: false,
content: "您未绑定设备部分功能将无法使用" // content: "您未绑定设备部分功能将无法使用"
// })
// 未绑定设备 → 绑定设备页面
wx.navigateTo({
url: '/pages/getCodeIndex/getCodeIndex'
}) })
} }
}, },
...@@ -998,10 +1018,14 @@ Page({ ...@@ -998,10 +1018,14 @@ Page({
url: '/pages/trainReport/trainReport' url: '/pages/trainReport/trainReport'
}) })
}else{ }else{
wx.showModal({ // wx.showModal({
title: '提示', // title: '提示',
showCancel: false, // showCancel: false,
content: "您未绑定设备部分功能将无法使用" // content: "您未绑定设备部分功能将无法使用"
// })
// 未绑定设备 → 绑定设备页面
wx.navigateTo({
url: '/pages/getCodeIndex/getCodeIndex'
}) })
} }
}, },
...@@ -1012,10 +1036,14 @@ Page({ ...@@ -1012,10 +1036,14 @@ Page({
url: '/pages/trainSort/trainSort' url: '/pages/trainSort/trainSort'
}) })
}else{ }else{
wx.showModal({ // wx.showModal({
title: '提示', // title: '提示',
showCancel: false, // showCancel: false,
content: "您未绑定设备部分功能将无法使用" // content: "您未绑定设备部分功能将无法使用"
// })
// 未绑定设备 → 绑定设备页面
wx.navigateTo({
url: '/pages/getCodeIndex/getCodeIndex'
}) })
} }
}, },
...@@ -1026,10 +1054,14 @@ Page({ ...@@ -1026,10 +1054,14 @@ Page({
url: '/pages/starSort/starSort' url: '/pages/starSort/starSort'
}) })
}else{ }else{
wx.showModal({ // wx.showModal({
title: '提示', // title: '提示',
showCancel: false, // showCancel: false,
content: "您未绑定设备部分功能将无法使用" // content: "您未绑定设备部分功能将无法使用"
// })
// 未绑定设备 → 绑定设备页面
wx.navigateTo({
url: '/pages/getCodeIndex/getCodeIndex'
}) })
} }
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment