### 声音插件使用说明
**位置:**
<script charset="UTF-8" src="__PUBLIC__/base/js/play_audit.js"></script>
**调用:**
先引用上述位置,然后在扫码页的js文件直调用PalyAudit()和playCreatMuice()。
以下是一个扫码页js的案例,仅供参考:
~~~
//唯一码查货
$(function(){
//记录扫描数,初始值为0
var i = 0;
//逗号隔开唯一码的字符集,赋值给form表单隐藏域里,保存时提交给后台
var nos = "";
//存储唯一码数组,用来判断唯一码有无重复扫描
var arrayObj = new Array();
$('#only_depot').keyup(function(){
//一个敲击回车按钮的动作触发的方法
if(window.event.keyCode==13){
//获取输入的唯一码
var no=$(this).val();
//ajax的URL地址
var url=$(this).attr('url');
//勾选删除框时,值为1,没选值为undefind
var del=$('input[name="delete"]:checked').val();
//商品导入列表id
var import_list_id=$('#import_list_id').val();
//notice_id值
var notice_id = $('#notice_id').val();
//当del值等于1时,说明要删除该唯一码商品列表信息。
if(del == 1){
if (arrayObj.length == 0) {
$.post(url, {'no': $.trim(no), 'del': del,'import_list_id':import_list_id ,'notice_id':notice_id}, function (data){
if (data.success) {
window.location.href=data.url;
playCreatMuice();
} else {
PalyAudit();
setTimeout(function () {
alert(data.msg);
}, 1000);
$('#only_depot').val('');
}
}, "json");
// alert('请先扫描商品!');
}else {
var t = 0;
for (var x = 0; x < arrayObj.length; x++) {
if (arrayObj[x] == no) {
var t = 1;
break;
}
}
//t等于1说明未保存的商品列表存在该唯一码
if(t == 1){
//扫描数需要减1
i = i - 1;
//赋值到form表单扫描数中
$('#scannum').val(i);
$('#depot_table').find('td').parent().filter(":contains("+no+")").remove();
//找出唯一码在数组里的位置
$.inArray(no,arrayObj);
//删除数组中的唯一码
arrayObj.splice($.inArray(no,arrayObj),1);
//删除拼接字符集的唯一码
nos = nos.replace(','+no,'');
//重新赋值到form表单的隐藏域中
$('#nos').val(nos);
//请空输入框的内容方便下一次扫码
$('#only_depot').val('');
playCreatMuice();
}else
//说明未保存商品列表没有该唯一码信息,但需在保存后商品信息进行查询判断
{
//进行ajax后台判断唯一码是否保存在数据库,有的话删除该商品信息
$.post(url, {'no': $.trim(no),'del': del,'import_list_id':import_list_id,'notice_id':notice_id}, function (data){
if (data.success) {
playCreatMuice();
window.location.href=data.url;
} else {
PalyAudit();
setTimeout(function (){
alert(data.msg);
}, 1000);
$('#only_depot').val('');
}
}, "json");
}
}
}else
//否则,添加唯一码商品列表信息。
{
$.post(url, {'no': $.trim(no), 'del': del,'import_list_id':import_list_id,'notice_id':notice_id}, function (data) {
if (data.success) {
if (arrayObj.length == 0) {
arrayObj.push(data.data['no']);
i = i + 1;
var html = '';
html += "<tr>";
html += "<td>" + data.data['no'] + "</td>";
html += "<td>" + data['data']['supply_style_no'] + "</td>";
html += "<td>" + data['data']['name_zh'] + "</td>";
html += "<td>" + data['data']['color_name'] + "</td>";
html += "<td>" + data['data']['color'] + "</td>";
html += "<td>" + data['data']['size'] + "</td>";
html += "<td>" + data['data']['retail_price'] + "</td>";
html += "<td style='color: red'>数据未保存</td>";
html += "</tr>";
$('#depot_table').append(html);
$('#scannum').val(i);
nos += "," + data.data['no'];
$('#nos').val(nos);
$('#only_depot').val('');
playCreatMuice();
} else {
var t = 0;
for (var x = 0; x < arrayObj.length; x++){
if (arrayObj[x] == data.data['no']) {
var t = 1;
PalyAudit();
setTimeout(function () {
alert('唯一码' + data.data['no'] + '已添加,请勿重复');
}, 1000);
break;
}
}
if (t == 0) {
arrayObj.push(data.data['no']);
i = i + 1;
var html = '';
html += "<tr>";
html += "<td>" + data.data['no'] + "</td>";
html += "<td>" + data['data']['supply_style_no'] + "</td>";
html += "<td>" + data['data']['name_zh'] + "</td>";
html += "<td>" + data['data']['color_name'] + "</td>";
html += "<td>" + data['data']['color'] + "</td>";
html += "<td>" + data['data']['size'] + "</td>";
html += "<td>" + data['data']['retail_price'] + "</td>";
html += "<td style='color: red'>数据未保存</td>";
html += "</tr>";
$('#depot_table').append(html);
$('#scannum').val(i);
nos += "," + data.data['no'];
$('#nos').val(nos);
$('#only_depot').val('');
playCreatMuice();
} else {
$('#only_depot').val('');
}
}
} else {
PalyAudit();
setTimeout(function (){
alert(data.msg);
}, 1000);
$('#only_depot').val('');
}
}, "json");
}
}
});
});
~~~
**完整代码:**
~~~
//此函数调用发出警报的声音
function PalyAudit(){
$('#chatAudio').remove(); //解决声音不变的问题 2017-01-24 lanson
$('<audio id="chatAudio">' +
'<source src="/Public/base/mp3/Warning.ogg" type="audio/ogg">' +
' <source src="/Public/base/mp3/Warning.mp3" type="audio/mpeg">'+
' <source src="/Public/base/mp3/Warning.wav" type="audio/wav">'+
'</audio>').appendTo('body');
var waitTime = 150;
//时间不足,导致调用请求暂停问题解决 2017-01-24 lanson
setTimeout(function () {
var el = $('#chatAudio')[0];
if (el.paused) {
el.play(); //播放声音
}
}, waitTime);
}
//此函数调用发出成功的声音
function playCreatMuice(){
$('#chatAudio').remove(); //解决声音不变的问题 2017-01-24 lanson
$('<audio id="chatAudio">' +
'<source src="/Public/base/mp3/3434.ogg" type="audio/ogg">' +
' <source src="/Public/base/mp3/3434.mp3" type="audio/mpeg">'+
' <source src="/Public/base/mp3/3434.wav" type="audio/wav">'+
'</audio>').appendTo('body');
var waitTime = 150;
//时间不足,导致调用请求暂停问题解决 2017-01-24 lanson
setTimeout(function () {
var el = $('#chatAudio')[0];
if (el.paused) {
el.play(); //播放声音
}
}, waitTime);
}
~~~
- 模版
- 前言
- 项目架构
- 项目规范
- HTML
- CSS
- Javascript
- PHP
- MySQL
- 注意规范
- 开发版本管理
- 开发流程
- 系统配置
- 阿里云服务器配置
- 计划任务配置说明
- 开发示例
- Page分页
- Search_param搜索结果赋值
- Add新增
- Edit编辑
- Ajax表单验证
- Ajax二级联动
- Excel 导出数据首位不去0的方法
- POS总部控制
- 下载CSV格式的模板
- 订单唯一码表和订单SKU表实收金额生成
- 快捷日期选择
- JS函数
- ajax_send
- ajax_result
- createQrCodes
- createBarCodes
- printTpl
- JS插件
- BootstrapValidator表单验证插件
- Address省市区插件
- Bootstrap-datepicker日期插件
- Bootstrap-select多选框插件
- Toastr消息提示插件
- PalyAudit扫描声音提示插件
- WebUploader多图片上传插件
- Ueditor富文本编辑器插件
- Function
- alert
- object_to_array
- array_to_object
- get_address
- set_param_url
- get_shops_name
- get_user_name
- get_warehouse
- get_cheapest_sku
- print_attr(新)
- print_img(新)
- get_spu_no(新)
- get_type_name(新)
- get_brand_en(新)
- get_cat_name(新)
- get_attr_name(新)
- spu_cat_info(新)
- get_time_event_price
- get_vendors
- check_total_reduce
- check_total_discount
- get_inventory
- get_delivery
- get_sale_inventory
- get_customer_name
- phone_protection
- get_order_no
- get_event_name
- get_order_status
- get_item_status
- get_ditch_name
- get_card_no
- get_shop_sales
- get_pay_name
- get_season
- amt_format
- get_cat_parent
- print_attr_id
- round_bcadd
- round_bcsub
- round_bcmul
- round_bcdiv
- get_account_name
- Controller
- Common_BaseController
- check_membership_card
- get_menu_list
- importErrorMassage
- Wpos_IndexController
- get_customer_vip_card
- get_shops_id
- calculate_active_integral
- check_numbers_active
- check_goods_active
- Woms_IndexController
- Model
- View
- category
- cycle_date.html
- shop_select门店多选搜索框
- 品牌A-Z排序多选brand_mc.html
- 供应商代码A-Z排序vendor_no_mc.html
- Lib
- BuyerLib
- WarehouseLib
- EventLib
- getTimeEventPrice
- getVipType
- getEvent
- orderTotalEvent
- orderTimeEvent
- getTotalReduce
- getTotalDiscount
- SaleLib
- CustomerLib
- addCustomerService
- GiftcardLib
- WechatLib
- wxRefund
- OrdersLib
- orderLog
- calculatePayinAmount
- calculateSubtotal
- correctPayinAmount
- saveOrderAddress
- getOrderAddress
- setDeliveryNo
- SyncLib
- updateOuterStock
- UserLib
- createCommission
- FlowLib
- orderList
- addOrder
- addLog
- orderInfo
- checkSku
- orderSave
- orderStop
- orderExecute
- skuEdit
- orderPrinta
- scanGoods
- boxClose
- orderOut
- take
- bview
- check
- deliveryStatus
- checkGoods
- GoodsLib
- createGoodsNo
- createNewGoodsNo
- getSystemStyleNo
- getDim
- MallLib
- smsLog
- GoodsBaseLib
- getBrandInfo
- getBrandsInfo
- getAttrIdArray
- getPrintAttr
- getMustAttr
- getCatIdInfo
- valTypeId
- valsTypeId
- getCatNoInfo
- getCatInfo
- getAttrArr
- getAttrInfo
- getValInfo
- getAttrId
- getValId
- getAttrSeaon
- getValueId
- PointsLog
- pointsIn
- pointsUp
- EcGoodsLib
- getSkuInventory
- Tools
- CsvTools
- csvImport
- csvExport
- ExcelTools
- importExcel
- exportExcel
- exportHeadExcel
- MailTools
- SmsTools
- sendMessage
- UploadTools
- ExportTools
- exportData
- TaobaoTools
- getOnsaleItems
- getSkusItems
- PicturesTools
- uploadPicture
- Plugins
- WxBase
- Taobao
- 问题反馈