要掃的二維碼屿脐,通過草料二維碼生成的涕蚤,這個網(wǎng)站挺好的,用起來比較簡單方便的诵,可以直接輸入文字生成二維碼万栅,也可以放入鏈接生成二維碼。
草料二維碼:https://cli.im/
index.wxml
<view class="container">
<button bindtap='getScancode'>綁定車輛</button>
</view>
index.js
//index.js
//獲取應(yīng)用實(shí)例
const app = getApp()
Page({
data: {
result: ''
},
onLoad: function() {
},
getScancode: function() {
var _this = this;
// 允許從相機(jī)和相冊掃碼
wx.scanCode({
success: (res) => {
wx.navigateTo({
url: '../navigator/navigator?title=' + res.result
})
var result = res.result;
_this.setData({
result: result,
})
}
})
}
})
navigator.wxml
<view> {{title}} </view>
navigator.js
Page({
data: {},
onLoad: function (options) {
// 生命周期函數(shù)--監(jiān)聽頁面加載
this.setData({
title: options.title
})
}
})
簡單的效果:沒有寫css相關(guān)的代碼了西疤,主要是實(shí)現(xiàn)這個過程
更加詳細(xì)的demo:(項(xiàng)目之中實(shí)現(xiàn)了一下)
index.wxml
<!-- 底部的按鈕 -->
<button class='Scancode' bindtap='getScancode'>綁定車輛</button>
index.wxss
/* 底部按鈕 */
.Scancode {
font-size: 39rpx;
background: #010101;
position: fixed;
bottom: 35rpx;
display: flex;
width: 90%;
justify-content: center;
color: #fff;
border-radius:10rpx;
margin-left:30rpx;
margin-right: 30rpx;
z-index:999;
}
index.js
//index.js
//獲取應(yīng)用實(shí)例
const app = getApp()
Page({
data: {
result: ''
},
onLoad: function() {
},
getScancode: function() {
var _this = this;
// 允許從相機(jī)和相冊掃碼
wx.scanCode({
success: (res) => {
wx.navigateTo({
url: '../bind/bind?title=' + res.result
})
var result = res.result;
_this.setData({
result: result,
})
}
})
}
})
要跳轉(zhuǎn)到bind
bind.wxml
<view class='page_row'>
<view class="search">
<input class='carid' placeholder=" {{title}}" focus="{{focus}}" />
<input class='carnumber' placeholder="請輸入車牌號和駕駛證號碼" focus="{{focus}}" />
<button type="primary" size="{{primarySize}}" loading="{{loading}}" plain="{{plain}}" disabled="{{disabled}}" bindtap="primary"> 綁定</button>
</view>
<view class='tip'>
定位標(biāo)簽和車輛綁定后即可看跟蹤車輛位置
</view>
</view>
bind.wxss
.search input {
height: 100rpx;
border-radius: 5px;
border: 1px solid #d0d0d0;
margin: 100rpx 30rpx;
padding: 0 15rpx;
}
.search button {
border-radius: 5px;
border: 1px solid #d0d0d0;
margin: 100rpx 30rpx;
}
.tip {
text-align: center;
font-size: 34rpx;
}
/* 搜索列表名稱 */
.list_name {
position: relative;
width: 100%;
height: 90rpx;
line-height: 90rpx;
border-bottom: 1rpx solid #ddd;
}
/* 列表名稱 */
.lab_name {
position: absolute;
left: 30rpx;
}
bind.js
Page({
data: {
focus: false,
inputValue: ''
},
onLoad: function(options) {
// 生命周期函數(shù)--監(jiān)聽頁面加載
this.setData({
title: options.title
})
}
})
要掃的二維碼
效果
其余的二維碼工具烦粒;一個文藝的在線生成漂亮的二維碼工具網(wǎng)站
順手寫的demo放在了github上面了,有需要的可以直接點(diǎn)擊鏈接下載代赁。
github地址:https://github.com/wangxiaoting666/bind
原文作者:祈澈姑娘扰她。 技術(shù)博客:http://www.reibang.com/u/05f416aefbe1
90后前端妹子一枚,愛編程芭碍,愛運(yùn)營徒役,愛折騰。長期堅持總結(jié)工作中遇到的技術(shù)問題窖壕。