平板端快衣店
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.
 
 
 
 
 

662 lines
20 KiB

<!-- 新增库存页 -->
<template>
<view class="page1" style="overflow: scroll;padding-bottom: 150rpx;">
<view class="box">
<view 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>
</view>
</template>
<script>
var plugin = requirePlugin("WechatSI")
let manager = plugin.getRecordRecognitionManager()
export default {
data() {
return {
voiceText:'',
isVoice: false,
voiceData:{},
recordState: false,
productPicture: [],
}
},
onShow() {
uni.authorize({
scope: 'scope.record',
success() {
},fail(){
this.tui.toast("您未授权,语音功能可能会出现错误")
}
})
},
onLoad(option) {
},
methods: {
//按住语音识别,开始
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(){
let that = this;
if (this.voiceText == '') {
this.tui.toast('识别内容不能为空')
return
}
let convertedStr = this.voiceText;
if (convertedStr.indexOf(',发货人') != -1) {
convertedStr = convertedStr.replace(/,发货人/g, '发货人')
}
if (convertedStr.indexOf('发货人,') != -1) {
convertedStr = convertedStr.replace(/发货人,/g, '发货人')
}
if (convertedStr.indexOf('发货人::') != -1) {
convertedStr = convertedStr.replace(/发货人::/g, '发货人')
}
if (convertedStr.indexOf('发货人:') != -1) {
convertedStr = convertedStr.replace(/发货人:/g, '发货人')
}
if (convertedStr.indexOf('发货人') != -1) {
convertedStr = convertedStr.replace(/发货人/g, '发货人:')
}
if (convertedStr.indexOf(',发货电话') != -1) {
convertedStr = convertedStr.replace(/,发货电话/g, '发货电话')
}
if (convertedStr.indexOf('发货电话,') != -1) {
convertedStr = convertedStr.replace(/发货电话,/g, '发货电话')
}
if (convertedStr.indexOf('发货电话::') != -1) {
convertedStr = convertedStr.replace(/发货电话::/g, '发货电话')
}
if (convertedStr.indexOf('发货电话:') != -1) {
convertedStr = convertedStr.replace(/发货电话:/g, '发货电话')
}
if (convertedStr.indexOf('发货电话') != -1) {
convertedStr = convertedStr.replace(/发货电话/g, ',发货电话:')
}
if (convertedStr.indexOf(',收货人') != -1) {
convertedStr = convertedStr.replace(/,收货人/g, '收货人')
}
if (convertedStr.indexOf('收货人,') != -1) {
convertedStr = convertedStr.replace(/收货人,/g, '收货人')
}
if (convertedStr.indexOf('收货人::') != -1) {
convertedStr = convertedStr.replace(/收货人::/g, '收货人')
}
if (convertedStr.indexOf('收货人:') != -1) {
convertedStr = convertedStr.replace(/收货人:/g, '收货人')
}
if (convertedStr.indexOf('收货人') != -1) {
convertedStr = convertedStr.replace(/收货人/g, ',收货人:')
}
if (convertedStr.indexOf(',收货电话') != -1) {
convertedStr = convertedStr.replace(/,收货电话/g, '收货电话')
}
if (convertedStr.indexOf('收货电话,') != -1) {
convertedStr = convertedStr.replace(/收货电话,/g, '收货电话')
}
if (convertedStr.indexOf('收货电话::') != -1) {
convertedStr = convertedStr.replace(/收货电话::/g, '收货电话')
}
if (convertedStr.indexOf('收货电话:') != -1) {
convertedStr = convertedStr.replace(/收货电话:/g, '收货电话')
}
if (convertedStr.indexOf('收货电话') != -1) {
convertedStr = convertedStr.replace(/收货电话/g, ',收货电话:')
}
if (convertedStr.indexOf(',到达站') != -1) {
convertedStr = convertedStr.replace(/,到达站/g, '到达站')
}
if (convertedStr.indexOf('到达站,') != -1) {
convertedStr = convertedStr.replace(/到达站,/g, '到达站')
}
if (convertedStr.indexOf('到达站::') != -1) {
convertedStr = convertedStr.replace(/到达站::/g, '到达站')
}
if (convertedStr.indexOf('到达站:') != -1) {
convertedStr = convertedStr.replace(/到达站:/g, '到达站')
}
if (convertedStr.indexOf('到达站') != -1) {
convertedStr = convertedStr.replace(/到达站/g, ',到达站:')
}
if (convertedStr.indexOf(',重量') != -1) {
convertedStr = convertedStr.replace(/,重量/g, '重量')
}
if (convertedStr.indexOf('重量,') != -1) {
convertedStr = convertedStr.replace(/重量,/g, '重量')
}
if (convertedStr.indexOf('重量::') != -1) {
convertedStr = convertedStr.replace(/重量::/g, '重量')
}
if (convertedStr.indexOf('重量:') != -1) {
convertedStr = convertedStr.replace(/重量:/g, '重量')
}
if (convertedStr.indexOf('重量') != -1) {
convertedStr = convertedStr.replace(/重量/g, ',重量:')
}
if (convertedStr.indexOf(',数量') != -1) {
convertedStr = convertedStr.replace(/,数量/g, '数量')
}
if (convertedStr.indexOf('数量,') != -1) {
convertedStr = convertedStr.replace(/数量,/g, '数量')
}
if (convertedStr.indexOf('数量::') != -1) {
convertedStr = convertedStr.replace(/数量::/g, '数量')
}
if (convertedStr.indexOf('数量:') != -1) {
convertedStr = convertedStr.replace(/数量:/g, '数量')
}
if (convertedStr.indexOf('数量') != -1) {
convertedStr = convertedStr.replace(/数量/g, ',数量:')
}
if (convertedStr.indexOf(',结算方式') != -1) {
convertedStr = convertedStr.replace(/,结算方式/g, '结算方式')
}
if (convertedStr.indexOf('结算方式,') != -1) {
convertedStr = convertedStr.replace(/结算方式,/g, '结算方式')
}
if (convertedStr.indexOf('结算方式::') != -1) {
convertedStr = convertedStr.replace(/结算方式::/g, '结算方式')
}
if (convertedStr.indexOf('结算方式:') != -1) {
convertedStr = convertedStr.replace(/结算方式:/g, '结算方式')
}
if (convertedStr.indexOf('结算方式') != -1) {
convertedStr = convertedStr.replace(/结算方式/g, ',结算方式:')
}
if (convertedStr.indexOf(',小费') != -1) {
convertedStr = convertedStr.replace(/,小费/g, '小费')
}
if (convertedStr.indexOf('小费,') != -1) {
convertedStr = convertedStr.replace(/小费,/g, '小费')
}
if (convertedStr.indexOf('小费::') != -1) {
convertedStr = convertedStr.replace(/小费::/g, '小费')
}
if (convertedStr.indexOf('小费:') != -1) {
convertedStr = convertedStr.replace(/小费:/g, '小费')
}
if (convertedStr.indexOf('小费') != -1) {
convertedStr = convertedStr.replace(/小费/g, ',小费:')
}
convertedStr = this.spliceMsg(convertedStr)
this.voiceData = this.extractInfo(convertedStr);
if(this.voiceData.weight){
this.voiceData.weight = this.voiceData.weight.replace(/[^0-9]/g, "");
}
if(this.voiceData.count){
this.voiceData.count = this.voiceData.count.replace(/[^0-9]/g, "");
}
this.voiceData.freight = this.voiceData.weight * this.voiceData.count
if(this.voiceData.arrivalStation.indexOf('。') != -1){
this.voiceData.arrivalStation = this.voiceData.arrivalStation.replace(/\。/g, '')
}
this.$forceUpdate()
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>