mirror of
https://shylinux.com/x/volcanos
synced 2025-04-25 16:58:06 +08:00
opt mp
This commit is contained in:
parent
587cc84830
commit
0b9bda4fe6
@ -13,6 +13,7 @@ App({
|
|||||||
typeof cb == "function" && cb(res)
|
typeof cb == "function" && cb(res)
|
||||||
}})
|
}})
|
||||||
},
|
},
|
||||||
|
toast(title) {wx.showToast({title: title})},
|
||||||
onLaunch() {var app = this
|
onLaunch() {var app = this
|
||||||
wx.login({success(res) {app.request("login", {code: res.code}, function(msg) {app.conf.sessid = msg.Result()
|
wx.login({success(res) {app.request("login", {code: res.code}, function(msg) {app.conf.sessid = msg.Result()
|
||||||
wx.getSetting({success(res) {res.authSetting['scope.userInfo'] && wx.getUserInfo({success(res) {
|
wx.getSetting({success(res) {res.authSetting['scope.userInfo'] && wx.getUserInfo({success(res) {
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
"window": {
|
"window": {
|
||||||
"backgroundTextStyle": "light",
|
"backgroundTextStyle": "light",
|
||||||
"navigationBarBackgroundColor": "#fff",
|
"navigationBarBackgroundColor": "#fff",
|
||||||
"navigationBarTitleText": "WeChat",
|
"navigationBarTitleText": "终端工具链",
|
||||||
"navigationBarTextStyle": "black"
|
"navigationBarTextStyle": "black"
|
||||||
},
|
},
|
||||||
"style": "v2",
|
"style": "v2",
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
/**app.wxss**/
|
|
||||||
.container {
|
|
||||||
height: 100%;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
padding: 200rpx 0;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
@ -3,18 +3,62 @@ const app = getApp()
|
|||||||
var utils = require("../../utils/util.js")
|
var utils = require("../../utils/util.js")
|
||||||
Page({
|
Page({
|
||||||
data: {
|
data: {
|
||||||
|
picture: "",
|
||||||
|
content: "",
|
||||||
|
comment: "",
|
||||||
list: [],
|
list: [],
|
||||||
},
|
},
|
||||||
show() {var page = this
|
show() {var page = this
|
||||||
page.setData({list: (wx.getStorageSync("qrcode")||[]).reverse()})
|
page.setData({list: (wx.getStorageSync("qrcode")||[]).reverse()})
|
||||||
},
|
},
|
||||||
click(event) {var page = this
|
onScan(event) {var page = this
|
||||||
wx.showActionSheet({itemList:["保存"], success(res) {
|
wx.scanCode({success(res) {
|
||||||
wx.saveImageToPhotosAlbum({filePath: event.target.dataset.path, success(res) {
|
page.setData({content: res.result})
|
||||||
wx.showToast({title: "success"})
|
app.download("login?type="+encodeURIComponent(res.scanType)+"&scan="+encodeURIComponent(res.result), {}, function(res) {
|
||||||
}})
|
page.setData({picture: res.tempFilePath})
|
||||||
|
})
|
||||||
|
}})
|
||||||
|
},
|
||||||
|
onCopy(event) {var page = this
|
||||||
|
wx.setClipboardData({data: page.data.content, success(res) {
|
||||||
|
app.toast("复制成功")
|
||||||
|
}})
|
||||||
|
},
|
||||||
|
onSave(event) {var page = this
|
||||||
|
wx.saveImageToPhotosAlbum({filePath: page.data.picture, success(res) {
|
||||||
|
app.toast("保存成功")
|
||||||
|
}})
|
||||||
|
},
|
||||||
|
onList(event) {var page = this
|
||||||
|
wx.saveFile({tempFilePath: page.data.picture, success(res) {
|
||||||
|
var list = wx.getStorageSync("qrcode") || []
|
||||||
|
list.push({time: utils.Time(), index: list.length,
|
||||||
|
path: res.savedFilePath, content: page.data.content, comment: page.data.comment,
|
||||||
|
})
|
||||||
|
wx.setStorageSync("qrcode", list)
|
||||||
|
app.toast("保存成功")
|
||||||
|
page.show()
|
||||||
|
}})
|
||||||
|
},
|
||||||
|
onClear(event) {var page = this
|
||||||
|
var list = wx.getStorageSync("qrcode") || []
|
||||||
|
for (var i = 0; i < list.length; i++) {
|
||||||
|
wx.removeSavedFile({filePath: list[i].path, success(res) {}})
|
||||||
|
}
|
||||||
|
wx.setStorageSync("qrcode", [])
|
||||||
|
app.toast("删除成功")
|
||||||
|
page.show()
|
||||||
|
},
|
||||||
|
onClick(event) {var page = this, data = event.target.dataset
|
||||||
|
wx.showActionSheet({itemList:["显示", "删除", "复制文本", "保存图片"], success(res) {
|
||||||
|
switch (res.tapIndex) {
|
||||||
|
case 0: page.setData({picture: data.picture, content: data.content, comment: data.comment}); break
|
||||||
|
case 1: wx.removeSavedFile({filePath: data.picture, success(res) {app.toast("删除成功")}}); break
|
||||||
|
case 1: wx.setClipboardData({data: data.content, success(res) {app.toast("复制成功")}}); break
|
||||||
|
case 2: wx.saveImageToPhotosAlbum({filePath: data.picture, success(res) {app.toast("保存成功")}}); break
|
||||||
|
case 3:
|
||||||
|
}
|
||||||
}})
|
}})
|
||||||
console.log(event)
|
|
||||||
},
|
},
|
||||||
onscan(event) {var page = this
|
onscan(event) {var page = this
|
||||||
wx.scanCode({success(res) {
|
wx.scanCode({success(res) {
|
||||||
|
@ -1,9 +1,19 @@
|
|||||||
<view class="container">
|
<view class="display">
|
||||||
<button bindtap="onscan">扫一扫</button>
|
<view><image class="picture" src="{{picture}}"></image></view>
|
||||||
<view>
|
<view class="content"><text>扫描内容: </text><textarea class="content" value="{{content}}"/></view>
|
||||||
<view wx:for="{{list}}" class="output">
|
<button bindtap="onScan" type="primary" size="default">扫描二维码</button>
|
||||||
<image src="{{item.path}}" bindtap="click" data-index="{{index}}" data-path="{{item.path}}"></image>
|
<button bindtap="onCopy">复制文本到粘贴板</button>
|
||||||
<view><text>{{item.time}}</text></view>
|
<button bindtap="onSave">保存图片到相册</button>
|
||||||
</view>
|
<view class="comment"><text>收藏备注: </text><textarea class="comment" value="{{comment}}"/></view>
|
||||||
</view>
|
<button bindtap="onList">添加到本地收藏</button>
|
||||||
|
<button bindtap="onClear" type="warn">清空本地收藏</button>
|
||||||
|
<view>
|
||||||
|
<view wx:for="{{list}}" class="output">
|
||||||
|
<image src="{{item.path}}" bindtap="onClick"
|
||||||
|
data-index="{{index}}" data-picture="{{item.path}}" data-content="{{item.content}}" data-comment="{{item.comment}}"
|
||||||
|
></image>
|
||||||
|
<view><text>{{item.time}}</text></view>
|
||||||
|
<view><text>{{item.comment}}</text></view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
@ -1,3 +1,29 @@
|
|||||||
|
.display {
|
||||||
|
text-align:center;
|
||||||
|
padding:20px;
|
||||||
|
}
|
||||||
|
.display button {
|
||||||
|
width:100%;
|
||||||
|
}
|
||||||
|
.picture {
|
||||||
|
border:solid 2px green;
|
||||||
|
}
|
||||||
|
view.content {
|
||||||
|
text-align:left;
|
||||||
|
font-size:14px;
|
||||||
|
color:gray;
|
||||||
|
}
|
||||||
|
textarea {
|
||||||
|
height:45px;
|
||||||
|
overflow:auto;
|
||||||
|
border:solid 2px gray;
|
||||||
|
width:calc(100% - 4px);
|
||||||
|
}
|
||||||
|
view.comment {
|
||||||
|
text-align:left;
|
||||||
|
font-size:14px;
|
||||||
|
color:gray;
|
||||||
|
}
|
||||||
.output {
|
.output {
|
||||||
text-align:center;
|
text-align:center;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user