You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
653 lines
17 KiB
653 lines
17 KiB
<!-- 新增库存页 -->
|
|
<template>
|
|
<view class="page1" style="overflow: scroll;padding-bottom: 150rpx;">
|
|
<view class="box">
|
|
<view @tap="getData" style="display: flex;height: 80rpx;line-height: 80rpx;">
|
|
<view class="circle">
|
|
寄
|
|
</view>
|
|
<view style='width: 80%;padding-left: 5px;'>
|
|
<text>{{voiceData.senderName}}</text>
|
|
<text style="padding-left: 5px;">{{voiceData.senderPhone}}</text>
|
|
</view>
|
|
<view style="font-size: 26rpx;font-weight: bold;">
|
|
地址簿
|
|
</view>
|
|
</view>
|
|
<view style="display: flex;height: 80rpx;line-height: 80rpx;border-top: 1px solid #eee;">
|
|
<view class="circle" style="background:red;color: #fff;">
|
|
收
|
|
</view>
|
|
<view style='width: 80%;padding-left: 5px;'>
|
|
<text>{{voiceData.receiverName}}</text>
|
|
<text style="padding-left: 5px;">{{voiceData.receiverPhone}}</text>
|
|
</view>
|
|
<!-- <view style="font-size: 26rpx;font-weight: bold;">
|
|
地址簿
|
|
</view> -->
|
|
</view>
|
|
</view>
|
|
<view class="box">
|
|
<view class="content">
|
|
<view class="name-box">出发站</view>
|
|
<view style="width: 80%;">
|
|
<input type="text" placeholder="请输入到达站点" class="input-box" value="沧州" disabled>
|
|
</view>
|
|
</view>
|
|
<view class="content">
|
|
<view class="name-box">到达站</view>
|
|
<view style="width: 80%;">
|
|
<input type="text" placeholder="请输入到达站点" v-model="voiceData.arrivalStation" class="input-box">
|
|
</view>
|
|
</view>
|
|
<view class="content">
|
|
<view class="name-box">重量(KG)</view>
|
|
<view style="width: 80%;">
|
|
<input type="text" placeholder="请输入重量" v-model="voiceData.weight" class="input-box">
|
|
</view>
|
|
</view>
|
|
<view class="content">
|
|
<view class="name-box">数量</view>
|
|
<view style="width: 80%;">
|
|
<input type="text" placeholder="请输入数量" v-model="voiceData.count" class="input-box">
|
|
</view>
|
|
</view>
|
|
<view class="content">
|
|
<view class="name-box">运费</view>
|
|
<view style="width: 80%;">
|
|
<input type="text" placeholder="请输入运费" v-model="voiceData.freight" class="input-box">
|
|
</view>
|
|
</view>
|
|
<view class="content">
|
|
<view class="name-box">结算方式</view>
|
|
<view style="width: 80%;">
|
|
<input type="text" placeholder="请输入结算方式" v-model="voiceData.methodOfSettlement" class="input-box">
|
|
</view>
|
|
</view>
|
|
<view class="content">
|
|
<view class="name-box">小费</view>
|
|
<view style="width: 80%;">
|
|
<input type="text" placeholder="没有小费可不输入" v-model="voiceData.tips" class="input-box">
|
|
</view>
|
|
</view>
|
|
<view class="content" style="height:150rpx;">
|
|
<view class="name-box">图片上传</view>
|
|
<view class="upload-img" @tap="pictureAdd"
|
|
style="background: #eee;text-align: center;line-height: 160rpx;">
|
|
<uni-icons type="camera" size="28" color="#777"></uni-icons>
|
|
</view>
|
|
<view style="overflow-x: scroll;display: flex;width: 350rpx;">
|
|
<view v-if="productPicture !=''" v-for="(item,index) in productPicture" :key="index"
|
|
style="width: 160rpx;height: 160rpx;margin-left: 20rpx;">
|
|
<img :src="item" alt="" class="upload-img">
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="box">
|
|
<view class="content">
|
|
<view class="name-box">包装形式</view>
|
|
<view style="width: 80%;">
|
|
<input type="text" placeholder="请输入货物包装形式" class="input-box">
|
|
</view>
|
|
</view>
|
|
<view class="content">
|
|
<view class="name-box">运输费用</view>
|
|
<view style="width: 80%;">
|
|
<input type="text" placeholder="请输入运输费用" class="input-box">
|
|
</view>
|
|
</view>
|
|
<view class="content">
|
|
<view class="name-box">保价</view>
|
|
<view style="width: 80%;">
|
|
<input type="text" placeholder="请输入保价" class="input-box">
|
|
</view>
|
|
</view>
|
|
<view class="content">
|
|
<view class="name-box">代收货款</view>
|
|
<view style="width: 80%;">
|
|
<input type="text" placeholder="请输入代收货款" class="input-box">
|
|
</view>
|
|
</view>
|
|
<view class="content">
|
|
<view class="name-box">手续费</view>
|
|
<view style="width: 80%;">
|
|
<input type="text" placeholder="请输入手续费" class="input-box">
|
|
</view>
|
|
</view>
|
|
<view class="content">
|
|
<view class="name-box">备注</view>
|
|
<view style="width: 80%;">
|
|
<input type="text" placeholder="请输入备注" class="input-box">
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="bottom-btn">
|
|
<view @tap="toggle"
|
|
style="background: linear-gradient(90deg, #FF9797, #FFC1E0);margin: 10rpx auto;height: 80rpx;width: 45%;border-radius: 10px;text-align: center;line-height: 80rpx;">
|
|
语音录入
|
|
</view>
|
|
<view
|
|
style="background: linear-gradient(90deg, #60F3FF, #088FEB);margin: 10rpx auto;height: 80rpx;width: 45%;border-radius: 10px;text-align: center;line-height: 80rpx;">
|
|
确定
|
|
</view>
|
|
</view>
|
|
<!-- 语音识别弹出层 -->
|
|
<uni-popup ref="popup" background-color="#fff" @change="yuyinChange">
|
|
<view class="voice-popup-content">
|
|
<view class="voice-popup-title">
|
|
<text>语音录入</text>
|
|
<uni-icons @tap='$refs.popup.close()' type="closeempty" color='red' size="16"
|
|
style="height:40rpx;line-height: 40rpx;position: absolute !important;bottom:0;right: 30rpx;"></uni-icons>
|
|
</view>
|
|
<view style="width: 100%;line-height: 40rpx;font-size: 11px;color: #777;">
|
|
示例:
|
|
</view>
|
|
<view
|
|
style="width: 100%;line-height: 40rpx;font-size: 11px;color: #777;display: flex;text-align: center;">
|
|
<view style="flex: 1;">发货人:</view>
|
|
<view style="flex: 1;">发货电话:</view>
|
|
</view>
|
|
<view
|
|
style="width: 100%;line-height: 40rpx;font-size: 11px;color: #777;display: flex;text-align: center;">
|
|
|
|
<view style="flex: 1;">收货人:</view>
|
|
<view style="flex: 1;">收货电话:</view>
|
|
</view>
|
|
<view
|
|
style="width: 100%;line-height: 40rpx;font-size: 11px;color: #777;display: flex;text-align: center;">
|
|
<view style="flex: 1;">重量:</view>
|
|
<view style="flex: 1;">数量:</view>
|
|
</view>
|
|
<view
|
|
style="width: 100%;line-height: 40rpx;font-size: 11px;color: #777;display: flex;text-align: center;">
|
|
|
|
<view style="flex: 1;">小费:</view>
|
|
<view style="flex: 1;">到达站:</view>
|
|
</view>
|
|
<view class="voice-popup-container">
|
|
<textarea name="" id="" style="width:100%;height:240rpx;border:1px solid #eee;margin:0;"
|
|
v-model="voiceText" placeholder="请按照事例要求录入信息"></textarea>
|
|
<view>
|
|
<text style="color:red;font-size:22rpx;">*长按“语音”按钮录入,系统将自动识别</text>
|
|
</view>
|
|
<view class="voice-popup-bottom">
|
|
<view class="voice-popup-btn" @tap="clearText">清空</view>
|
|
<view class="voice-popup-btn" @tap="getVoiceData">确认</view>
|
|
</view>
|
|
</view>
|
|
<view class="voice-btn" @touchstart="kaishi" @touchend="jieshu">
|
|
<img src="/static/images/maikefeng.png" style="width: 80%;height: 80%;margin: 10%;" alt="">
|
|
</view>
|
|
</view>
|
|
</uni-popup>
|
|
<view class="voice-model" v-if="recordState == true">
|
|
<img src="/static/images/maikefeng.png" alt="">
|
|
<view class="voice-text">语音识别中...</view>
|
|
</view>
|
|
<view class="mask-model" v-if="isVoice">貌似没有检测到您上次的语音录入信息,正在反复识别中</view>
|
|
<canvas canvas-id="myCanvas" style="width: 1700px; height: 2200px;"></canvas>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
var plugin = requirePlugin("WechatSI")
|
|
let manager = plugin.getRecordRecognitionManager()
|
|
export default {
|
|
data() {
|
|
return {
|
|
voiceText: '',
|
|
isVoice: false,
|
|
voiceData: {},
|
|
recordState: false,
|
|
productPicture: [],
|
|
canvas: null,
|
|
tempFilePath: '',
|
|
messages: ['消息1', '消息2', '消息3'],
|
|
base64:''
|
|
}
|
|
},
|
|
onShow() {
|
|
uni.authorize({
|
|
scope: 'scope.record',
|
|
success() {
|
|
|
|
},
|
|
fail() {
|
|
this.tui.toast("您未授权,语音功能可能会出现错误")
|
|
}
|
|
})
|
|
},
|
|
onLoad(option) {
|
|
this.getUserData()
|
|
},
|
|
methods: {
|
|
getUserData(){
|
|
console.log(__wxConfig.envVersion)
|
|
uni.request({
|
|
url: 'https://api.weixin.qq.com/cgi-bin/token',
|
|
data: {
|
|
grant_type: 'client_credential',
|
|
appid: 'wx6d7d4fb58d1502db',
|
|
secret: '3a2c8cd00926764bbd12fd7361e01f1d'
|
|
},
|
|
method: 'GET',
|
|
dataType: 'json',
|
|
success: (res) => {
|
|
console.log('access_token',res.data.access_token)
|
|
uni.request({
|
|
url: 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=' + res.data
|
|
.access_token,
|
|
data: {
|
|
page: 'package1/index/downStearmList',
|
|
scene:'khid=1833763951914127361',
|
|
env_version: "develop",
|
|
},
|
|
responseType: 'arraybuffer',
|
|
method: 'POST',
|
|
dataType: 'json',
|
|
success: (res1) => {
|
|
let base64 = wx.arrayBufferToBase64(res1.data)
|
|
console.log('base64',base64)
|
|
const time = new Date().getTime();
|
|
const imgPath = wx.env.USER_DATA_PATH + "/poster" + time + "share" + ".png";
|
|
const file = wx.getFileSystemManager();
|
|
file.writeFileSync(imgPath, base64, "base64");
|
|
this.base64 = imgPath
|
|
},
|
|
fail: (res) => {
|
|
this.tui.toast("网络不给力,请稍后再试~")
|
|
}
|
|
})
|
|
},
|
|
fail: (res) => {
|
|
this.tui.toast("网络不给力,请稍后再试~")
|
|
}
|
|
})
|
|
},
|
|
getData() {
|
|
let that = this
|
|
uni.showLoading({
|
|
title:'生成中...'
|
|
})
|
|
const ctx = uni.createCanvasContext('myCanvas', this);
|
|
//背景图
|
|
let imgA = 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/0f96ca9700b741d486dd23bbe4e0f970.jpg';
|
|
uni.downloadFile({
|
|
url: imgA,
|
|
success: (res2) => {
|
|
|
|
if (res2.statusCode === 200) {
|
|
// // 绘制第一张图片
|
|
ctx.drawImage(res2.tempFilePath, 0, 0, 1700, 2200);
|
|
ctx.draw()
|
|
// 绘制第二张图片
|
|
ctx.drawImage(that.base64, 650, 850, 400, 400);
|
|
ctx.draw(true);
|
|
// 设置字体样式
|
|
ctx.font = 'bold 200px SimSun';
|
|
// 设置文字颜色
|
|
ctx.fillStyle = '#088FEB';
|
|
|
|
var text = '天逸的店';
|
|
var textWidth = ctx.measureText(text).width;
|
|
console.log(textWidth)
|
|
// 计算居中位置
|
|
var x = (1700 - textWidth) / 2;
|
|
|
|
// 绘制文字
|
|
ctx.fillText(text, x, 700);
|
|
ctx.draw(true)
|
|
setTimeout(ress=>{
|
|
uni.canvasToTempFilePath({
|
|
x: 0,
|
|
y: 0,
|
|
width: 1700,
|
|
height: 2200,
|
|
destWidth: 1701,
|
|
destHeight: 2200,
|
|
canvasId: 'myCanvas',
|
|
success: (res3) => {
|
|
uni.previewImage({
|
|
urls: [res3.tempFilePath]
|
|
})
|
|
uni.hideLoading()
|
|
// uni.saveImageToPhotosAlbum({
|
|
// filePath: res3.tempFilePath,
|
|
// success: function () {
|
|
// console.log('save success');
|
|
// }
|
|
// });
|
|
}
|
|
});
|
|
},500)
|
|
}
|
|
}
|
|
});
|
|
|
|
},
|
|
//按住语音识别,开始
|
|
kaishi() {
|
|
if (this.isVoice == false) {
|
|
this.recordState = true
|
|
uni.vibrateShort();
|
|
manager.start({
|
|
duration: 60000,
|
|
lang: "zh_CN"
|
|
});
|
|
}
|
|
},
|
|
//松开语音识别,结束
|
|
jieshu() {
|
|
this.recordState = false
|
|
manager.stop()
|
|
},
|
|
extractInfo(str) {
|
|
const info = {};
|
|
const regexes = [{
|
|
name: 'senderName',
|
|
regex: /发货人:(.*?),/
|
|
},
|
|
{
|
|
name: 'senderPhone',
|
|
regex: /发货电话:(.*?),/
|
|
},
|
|
{
|
|
name: 'receiverName',
|
|
regex: /收货人:(.*?),/
|
|
},
|
|
{
|
|
name: 'receiverPhone',
|
|
regex: /收货电话:(.*?),/
|
|
},
|
|
{
|
|
name: 'weight',
|
|
regex: /重量:(.*?),/
|
|
},
|
|
{
|
|
name: 'count',
|
|
regex: /数量:(.*?),/
|
|
},
|
|
{
|
|
name: 'methodOfSettlement',
|
|
regex: /结算方式:(.*?),/
|
|
},
|
|
{
|
|
name: 'tips',
|
|
regex: /小费:(.*?),/
|
|
},
|
|
{
|
|
name: 'arrivalStation',
|
|
regex: /到达站:(.*)/
|
|
}
|
|
];
|
|
|
|
regexes.forEach(({
|
|
name,
|
|
regex
|
|
}) => {
|
|
const match = str.match(regex);
|
|
if (match && match[1]) {
|
|
// 去除可能的前后空格
|
|
info[name] = match[1].trim();
|
|
}
|
|
});
|
|
|
|
return info;
|
|
},
|
|
yuyinChange() {
|
|
console.log("yuyin")
|
|
this.isVoice = false
|
|
},
|
|
getVoiceData() {
|
|
this.$refs.popup.close()
|
|
},
|
|
spliceMsg(res) {
|
|
let regex = /嗯|啊|儿|阿|恩/g;
|
|
return res.replace(regex, '')
|
|
},
|
|
//弹出
|
|
toggle(type, id) {
|
|
this.initRecord();
|
|
this.voiceText = ''
|
|
this.$refs.popup.open('center')
|
|
},
|
|
//清空语音输入的文字
|
|
clearText() {
|
|
this.voiceText = ''
|
|
},
|
|
//语音识别功能初始化
|
|
initRecord() {
|
|
let that = this;
|
|
manager.stop()
|
|
// 识别结束事件
|
|
manager.onStop = (res) => {
|
|
that.voiceText = res.result
|
|
}
|
|
|
|
// 识别错误事件
|
|
manager.onError = (res) => {
|
|
if (res.retcode == '-30011') {
|
|
that.isVoice = true
|
|
}
|
|
if (res.retcode == '-30004') {
|
|
// uni.hideLoading()
|
|
that.isVoice = false
|
|
uni.hideToast()
|
|
uni.showToast({
|
|
title: "未识别到声音信息,请重新录入",
|
|
icon: 'none'
|
|
})
|
|
}
|
|
if (res.retcode == '-40001') {
|
|
uni.showToast({
|
|
title: '使用次数超限制,请联系管理员!',
|
|
icon: 'none'
|
|
})
|
|
}
|
|
}
|
|
},
|
|
pictureAdd() {
|
|
let that = this
|
|
uni.chooseMedia({
|
|
count: 9,
|
|
mediaType: ['image'],
|
|
sourceType: ['album', 'camera'],
|
|
success(res) {
|
|
uni.showLoading({
|
|
title: '加载中...',
|
|
mask: true
|
|
})
|
|
for (let i = 0; i < res.tempFiles.length; i++) {
|
|
that.upLoadFile(res.tempFiles[i].tempFilePath)
|
|
}
|
|
|
|
}
|
|
})
|
|
},
|
|
async upLoadFile(path) {
|
|
let that = this;
|
|
let hiver_token = uni.getStorageSync("hiver_token")
|
|
await uni.uploadFile({
|
|
url: that.tui.interfaceUrl() + '/upload/file',
|
|
filePath: path,
|
|
name: 'file',
|
|
header: {
|
|
"content-type": "multipart/form-data",
|
|
'accessToken': hiver_token
|
|
},
|
|
formData: {},
|
|
success: (uploadFileRes) => {
|
|
let pathData = JSON.parse(uploadFileRes.data)
|
|
that.productPicture.push(pathData.result)
|
|
that.$forceUpdate()
|
|
},
|
|
fail: (err) => {
|
|
uni.hideLoading();
|
|
uni.showToast({
|
|
title: JSON.stringify(err),
|
|
icon: 'none'
|
|
})
|
|
}
|
|
});
|
|
await setTimeout(res => {
|
|
uni.hideLoading();
|
|
}, 1000)
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
page,
|
|
.page1 {
|
|
background: #eee;
|
|
height: 100%;
|
|
}
|
|
|
|
.box {
|
|
width: 95%;
|
|
margin: 20rpx auto 0;
|
|
background: #fff;
|
|
border-radius: 10px;
|
|
padding: 10px;
|
|
}
|
|
|
|
.bottom-btn {
|
|
position: fixed;
|
|
bottom: 0;
|
|
height: 100rpx;
|
|
background: #fff;
|
|
width: 100%;
|
|
font-size: 36rpx;
|
|
color: #fff;
|
|
display: flex;
|
|
z-index: 99
|
|
}
|
|
|
|
.circle {
|
|
width: 40rpx;
|
|
height: 40rpx;
|
|
text-align: center;
|
|
line-height: 40rpx;
|
|
border-radius: 40rpx;
|
|
background: blue;
|
|
color: #fff;
|
|
font-size: 22rpx;
|
|
margin-top: 20rpx;
|
|
}
|
|
|
|
.content {
|
|
display: flex;
|
|
height: 80rpx;
|
|
line-height: 80rpx;
|
|
}
|
|
|
|
.input-box {
|
|
width: 100%;
|
|
height: 60rpx;
|
|
line-height: 60rpx;
|
|
display: inline-block;
|
|
margin-top: 5px;
|
|
border-bottom: 1px solid #eee;
|
|
padding-left: 10px;
|
|
}
|
|
|
|
.name-box {
|
|
width: 20%;
|
|
}
|
|
|
|
.voice-popup-content {
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 15px;
|
|
width: 500rpx;
|
|
border-radius: 10px;
|
|
height: 720rpx;
|
|
background-color: #fff;
|
|
}
|
|
|
|
.voice-popup-title {
|
|
font-size: 36rpx;
|
|
font-weight: bold;
|
|
text-align: center;
|
|
position: relative;
|
|
}
|
|
|
|
.voice-popup-container {
|
|
margin-top: 20rpx;
|
|
}
|
|
|
|
.voice-popup-bottom {
|
|
display: flex;
|
|
height: 80rpx;
|
|
color: #fff;
|
|
line-height: 80rpx;
|
|
margin-top: 30rpx;
|
|
}
|
|
|
|
.voice-popup-btn {
|
|
flex: 1;
|
|
text-align: center;
|
|
background: linear-gradient(90deg, #FF9797, #FFC1E0);
|
|
}
|
|
|
|
.voice-popup-btn:last-child {
|
|
background: linear-gradient(90deg, #60F3FF, #088FEB);
|
|
}
|
|
|
|
.voice-model {
|
|
width: 300rpx;
|
|
height: 300rpx;
|
|
display: flex;
|
|
justify-content: center;
|
|
flex-flow: column;
|
|
position: fixed;
|
|
top: 50%;
|
|
left: 50%;
|
|
background: rgba(0, 0, 0, 0.5);
|
|
border-radius: 20rpx;
|
|
color: #fff;
|
|
text-align: center;
|
|
margin-left: -150rpx;
|
|
z-index: 999;
|
|
}
|
|
|
|
.voice-model img {
|
|
width: 200rpx;
|
|
height: 200rpx;
|
|
margin: 0 auto;
|
|
}
|
|
|
|
.voice-btn {
|
|
position: absolute;
|
|
bottom: -250rpx;
|
|
left: 30%;
|
|
width: 180rpx;
|
|
height: 180rpx;
|
|
background: #eee;
|
|
border-radius: 50%;
|
|
}
|
|
|
|
.mask-model {
|
|
width: 60%;
|
|
height: 100rpx;
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
margin: auto;
|
|
text-align: center;
|
|
background: rgba(0, 0, 0, 0.7);
|
|
color: #eee;
|
|
padding: 5px;
|
|
border-radius: 5px;
|
|
z-index: 99;
|
|
}
|
|
|
|
.upload-img {
|
|
width: 160rpx;
|
|
height: 160rpx;
|
|
}
|
|
</style>
|