语音功能优化,委托销售界面优化 ,支付成功界面显示问题处理,交易大厅bug处理

This commit is contained in:
jia 2023-08-17 17:58:28 +08:00
parent 5885261a60
commit 10e260bbcc
9 changed files with 535 additions and 569 deletions

73
App.vue
View File

@ -8,10 +8,10 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com> // | Author: CRMEB Team <admin@crmeb.com>
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// #ifdef APP-PLUS // #ifdef APP-PLUS
let jpushModule = uni.requireNativePlugin("JG-JPush"); let jpushModule = uni.requireNativePlugin("JG-JPush");
// #endif // #endif
import { import {
checkLogin checkLogin
} from "./libs/login"; } from "./libs/login";
import { import {
@ -22,8 +22,13 @@ import {
history history
} from '@/api/public.js' } from '@/api/public.js'
import Routine from './libs/routine.js'; import Routine from './libs/routine.js';
import voice from'./plugin/voice/voice.js'
export default { export default {
data() {
return {
audioTeam: []
}
},
globalData: { globalData: {
spid: 0, spid: 0,
code: 0, code: 0,
@ -121,9 +126,11 @@ import {
that.getConfigData() that.getConfigData()
//#ifdef APP-PLUS //#ifdef APP-PLUS
jpushModule.setLoggerEnable(true); jpushModule.setLoggerEnable(true);
jpushModule.initJPushService() jpushModule.initJPushService()
jpushModule.addConnectEventListener(result=>{ jpushModule.addConnectEventListener(result => {
let connectEnable = result.connectEnable let connectEnable = result.connectEnable
// console.log("jpush", connectEnable) // console.log("jpush", connectEnable)
}) })
@ -152,12 +159,15 @@ import {
let extras = result.extras let extras = result.extras
console.log("通知", result) console.log("通知", result)
// if(result.content==""){
// console.log("", '11111111') if (result.extras.type == 'ORDER_CREATE') {
// voice.init() if (this.audioTeam.length > 0) {
// } this.audioTeam.push(result.extras.type);
if(result.extras.type=='ORDER_CREATE'){ } else {
voice.init() this.audio()
this.audioTeam.push(result.extras.type);
}
} }
// //
@ -181,10 +191,6 @@ import {
}, },
onShow() { onShow() {
// console.log(voice.in)
// voice.connectSocketGlobal()
let that = this let that = this
// H5 // H5
if (this.$store.state.app.token) { if (this.$store.state.app.token) {
@ -213,11 +219,43 @@ import {
// #endif // #endif
}, },
methods: { methods: {
/**
* 语音播报
*
*
*/
async audio() {
const innerAudioContext = uni.createInnerAudioContext();
innerAudioContext.autoplay = true;
innerAudioContext.src = `/static/audio/order.mp3`;
innerAudioContext.onPlay(() => {
console.log('开始播放')
});
innerAudioContext.onEnded(() => {
console.log('语音播报结束')
innerAudioContext.destroy() //
if (this.audioTeam.length > 1) {
this.audioTeam.splice(0, 1);
console.log('队列中');
this.audio()
} else {
console.log('队列为零');
this.audioTeam = []
}
});
innerAudioContext.onError(() => {
console.log('语音播报失败')
innerAudioContext.destroy() //
});
},
// //
setOpenShare: function(data) { setOpenShare: function(data) {
let that = this; let that = this;
let href = location.href; let href = location.href;
href = href.indexOf("?") === -1 ? href + "?spid=" + this.globalData.uid : href + "&spid=" + this.globalData href = href.indexOf("?") === -1 ? href + "?spid=" + this.globalData.uid : href + "&spid=" + this
.globalData
.uid; .uid;
if (that.$wechat.isWeixin()) { if (that.$wechat.isWeixin()) {
let configAppMessage = { let configAppMessage = {
@ -226,7 +264,8 @@ import {
link: href, link: href,
imgUrl: data.share_pic imgUrl: data.share_pic
}; };
that.$wechat.wechatEvevt(["updateAppMessageShareData", "updateTimelineShareData"], configAppMessage); that.$wechat.wechatEvevt(["updateAppMessageShareData", "updateTimelineShareData"],
configAppMessage);
} }
}, },
// //

View File

@ -272,10 +272,9 @@
/*点击选中与否*/ /*点击选中与否*/
goodsCheck(item) { goodsCheck(item) {
this.$set(item, 'check', !item.check); this.$set(item, 'check', !item.check);
console.log( item.num)
if (item.check) { if (item.check) {
if (this.peicenumber > 0) { if (this.peicenumber == 0) {
item.num = this.peicenumber item.num = 1
} }
if (!item.product_attr_unique) { if (!item.product_attr_unique) {
@ -408,6 +407,11 @@
border-top: 2rpx solid #E7E6E4; border-top: 2rpx solid #E7E6E4;
.picTxt_one {
white-space: nowrap;
overflow: hidden;
}
.picTxt_one { .picTxt_one {
display: flex; display: flex;
margin-top: 20rpx; margin-top: 20rpx;

View File

@ -217,12 +217,15 @@
}) })
}, },
getGoods: function(item) { getGoods: function(item) {
// console.log(item);
graphicLstApi(this.where).then(res => { graphicLstApi(this.where).then(res => {
this.cateGoods.push(...res.data.list) this.cateGoods.push(...res.data.list)
if (res.data.list.length < this.where.limit) this.status = 'nomore' if (res.data.list.length < this.where.limit) this.status = 'nomore'
if (this.where.page == 1 && res.data.list.length <= 0) this.emptyShow = true if (this.where.page == 1 && res.data.list.length <= 0) this.emptyShow = true
if (item.index == 1) {
if(item){
if (item.index == 1 ) {
uni.navigateTo({ uni.navigateTo({
// #ifdef MP || H5 // #ifdef MP || H5
url: '/pages/short_video/nvueSwiper/index?id=' + this.cateGoods[0] url: '/pages/short_video/nvueSwiper/index?id=' + this.cateGoods[0]
@ -233,6 +236,8 @@
// #endif // #endif
}) })
} }
}
}) })
}, },
/*获取分类列表*/ /*获取分类列表*/

View File

@ -2,7 +2,7 @@
<view :style="viewColor"> <view :style="viewColor">
<view class='payment-status'> <view class='payment-status'>
<!--失败时 用icon-iconfontguanbi fail替换icon-duihao2 bg-color--> <!--失败时 用icon-iconfontguanbi fail替换icon-duihao2 bg-color-->
<view class='iconfont icon-duihao2 icon' v-if ="order_pay_info.paid !=0"></view> <view class='iconfont icon-duihao2 icon' v-if="order_pay_info.paid !=0"></view>
<view class='iconfont icon-iconfontguanbi icon' v-else></view> <view class='iconfont icon-iconfontguanbi icon' v-else></view>
<!-- 失败时订单支付失败 --> <!-- 失败时订单支付失败 -->
<view class='status'>{{order_pay_info.paid == 1 ?'支付成功':'订单未支付'}}</view> <view class='status'>{{order_pay_info.paid == 1 ?'支付成功':'订单未支付'}}</view>
@ -14,20 +14,24 @@
</view> </view>
<view class='item acea-row row-between-wrapper'> <view class='item acea-row row-between-wrapper'>
<view>支付方式</view> <view>支付方式</view>
<view v-if="order_pay_info.pay_type==1 || order_pay_info.pay_type==2 || order_pay_info.pay_type==3" class='itemCom'>微信</view> <view v-if="order_pay_info.pay_type==1 || order_pay_info.pay_type==2 || order_pay_info.pay_type==3"
<view v-else-if="order_pay_info.pay_type==4 || order_pay_info.pay_type==5" class='itemCom'>支付宝</view> class='itemCom'>微信</view>
<view v-else-if="order_pay_info.pay_type==4 || order_pay_info.pay_type==5" class='itemCom'>支付宝
</view>
<view v-else class='itemCom'>余额</view> <view v-else class='itemCom'>余额</view>
</view> </view>
<view class='item acea-row row-between-wrapper'> <view class='item acea-row row-between-wrapper'>
<view>支付金额</view> <view>支付金额</view>
<view class='itemCom'>{{order_pay_info.pay_price}}</view> <view class='itemCom'>{{order_pay_info.pay_price}}</view>
</view> </view>
<view v-if="order_pay_info.give_integral > 0 && order_pay_info.paid" class='item acea-row row-between-wrapper'> <view v-if="order_pay_info.give_integral > 0 && order_pay_info.paid"
class='item acea-row row-between-wrapper'>
<view>赠送积分</view> <view>赠送积分</view>
<view class='itemCom t-color'>{{order_pay_info.give_integral}}</view> <view class='itemCom t-color'>{{order_pay_info.give_integral}}</view>
</view> </view>
<!--失败时加上这个 --> <!--失败时加上这个 -->
<view class='item acea-row row-between-wrapper' v-if="order_pay_info.paid==0 && order_pay_info.pay_type != 'offline' && msg != 'success'"> <view class='item acea-row row-between-wrapper'
v-if="order_pay_info.paid==0 && order_pay_info.pay_type != 'offline' && msg != 'success'">
<view>失败原因</view> <view>失败原因</view>
<view class='itemCom'>{{order_pay_info.pay_type==0 ? '余额不足':msg}}</view> <view class='itemCom'>{{order_pay_info.pay_type==0 ? '余额不足':msg}}</view>
</view> </view>
@ -42,8 +46,10 @@
<!-- <view @tap="goOrderDetails" v-if="order_pay_info.paid==0 && status==2"> <!-- <view @tap="goOrderDetails" v-if="order_pay_info.paid==0 && status==2">
<button class='returnBnt bg-color' hover-class='none'>重新支付</button> <button class='returnBnt bg-color' hover-class='none'>重新支付</button>
</view> --> </view> -->
<button @click="goPink(order_pay_info.activity_id)" class='returnBnt s-Color' formType="submit" hover-class='none' v-if="order_pay_info.activity_type == 4 && order_pay_info.paid">邀请好友参团</button> <button @click="goPink(order_pay_info.activity_id)" class='returnBnt s-Color' formType="submit"
<button v-if="!order_pay_info.paid || order_pay_info.activity_type != 4" @click="goIndex" class='returnBnt s-Color' formType="submit" hover-class='none'>返回首页</button> hover-class='none' v-if="order_pay_info.activity_type == 4 && order_pay_info.paid">邀请好友参团</button>
<button v-if="!order_pay_info.paid || order_pay_info.activity_type != 4" @click="goIndex"
class='returnBnt s-Color' formType="submit" hover-class='none'>返回首页</button>
<view class="coupon-wrapper" v-if="couponList.length>0 && order_pay_info.paid"> <view class="coupon-wrapper" v-if="couponList.length>0 && order_pay_info.paid">
<view class="hd"> <view class="hd">
<view class="line"></view> <view class="line"></view>
@ -53,12 +59,16 @@
<view class="coupon-box" :class="{on:isOpen}"> <view class="coupon-box" :class="{on:isOpen}">
<block v-for="(item,index) in couponList" :key="index"> <block v-for="(item,index) in couponList" :key="index">
<view class="coupon-item flex"> <view class="coupon-item flex">
<view class="left-bg" :style="{ 'background-image': `url(${domain}/static/diy/couponBg${keyColor}.png)` }"><text></text>{{item.coupon_price}}</view> <view class="left-bg"
:style="{ 'background-image': `url(${domain}/static/diy/couponBg${keyColor}.png)` }">
<text></text>{{item.coupon_price}}
</view>
<view class="info"> <view class="info">
<view class="title">{{item.title}}</view> <view class="title">{{item.title}}</view>
<view class="des">{{item.use_min_price}}元可用</view> <view class="des">{{item.use_min_price}}元可用</view>
<block v-if="item.coupon_type == 1"> <block v-if="item.coupon_type == 1">
<view class="des">有效期:{{ item.use_start_time |timeYMD }}-{{ item.use_end_time |timeYMD}}</view> <view class="des">
有效期:{{ item.use_start_time |timeYMD }}-{{ item.use_end_time |timeYMD}}</view>
</block> </block>
<block v-if="item.coupon_type == 0"> <block v-if="item.coupon_type == 0">
<view class="des">领取后{{ item.coupon_time}}天内可用</view> <view class="des">领取后{{ item.coupon_time}}天内可用</view>
@ -88,19 +98,27 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com> // | Author: CRMEB Team <admin@crmeb.com>
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
import {getPayOrder} from '@/api/order.js'; import {
import {openOrderSubscribe} from '@/utils/SubscribeMessage.js'; getPayOrder
import {mapGetters} from "vuex"; } from '@/api/order.js';
import {
openOrderSubscribe
} from '@/utils/SubscribeMessage.js';
import {
mapGetters
} from "vuex";
import authorize from '@/components/Authorize'; import authorize from '@/components/Authorize';
import { HTTP_REQUEST_URL } from '@/config/app'; import {
HTTP_REQUEST_URL
} from '@/config/app';
export default { export default {
components: { components: {
authorize, authorize,
}, },
filters: { filters: {
timeYMD: function (value) { timeYMD: function(value) {
if(value){ if (value) {
var newDate=/\d{4}-\d{1,2}-\d{1,2}/g.exec(value) var newDate = /\d{4}-\d{1,2}-\d{1,2}/g.exec(value)
return newDate[0] return newDate[0]
} }
} }
@ -115,15 +133,16 @@
isShowAuth: false, // isShowAuth: false, //
status: 0, status: 0,
msg: '', msg: '',
couponList:[], // couponList: [], //
isOpen:false ,// isOpen: false, //
moneyBg: '/static/images/couponBg', moneyBg: '/static/images/couponBg',
text: '展开更多', text: '展开更多',
timer: null, timer: null,
product_type:'', product_type: '',
}; };
}, },
computed: mapGetters(['isLogin','viewColor','keyColor']), computed: mapGetters(['isLogin', 'viewColor', 'keyColor']),
onLoad: function(options) { onLoad: function(options) {
if (!options.order_id) return this.$util.Tips({ if (!options.order_id) return this.$util.Tips({
title: '缺少参数无法查看订单支付状态' title: '缺少参数无法查看订单支付状态'
@ -135,7 +154,7 @@
this.order_type = options.order_type; this.order_type = options.order_type;
this.status = options.status || 0; this.status = options.status || 0;
this.msg = options.msg || ''; this.msg = options.msg || '';
this.product_type=options.product_type this.product_type = options.product_type
if (this.isLogin) { if (this.isLogin) {
this.refreshData(); this.refreshData();
} else { } else {
@ -145,13 +164,12 @@
console.log(options); console.log(options);
}, },
methods: { methods: {
refreshData(){ refreshData() {
this.timer = setInterval(()=>{
this.getOrderPayInfo(); this.getOrderPayInfo();
},1000)
}, },
// //
bindMore(){ bindMore() {
this.isOpen = !this.isOpen this.isOpen = !this.isOpen
this.text = this.text == '展开更多' ? '收起' : '展开更多'; this.text = this.text == '展开更多' ? '收起' : '展开更多';
}, },
@ -176,7 +194,7 @@
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: res.data.paid == 1 ? '支付成功' : '支付失败' title: res.data.paid == 1 ? '支付成功' : '支付失败'
}); });
if(res.data.paid == 1){ if (res.data.paid == 1) {
clearInterval(this.timer); clearInterval(this.timer);
this.timer = null; this.timer = null;
} }
@ -203,11 +221,10 @@
* 去订单详情页面 * 去订单详情页面
*/ */
goOrderDetails: function(e) { goOrderDetails: function(e) {
console.log(this.product_type);
let that = this; let that = this;
if (this.product_type == 98) { if (this.product_type == 98) {
uni.navigateTo({ uni.navigateTo({
url: `/pages/users/order_list/index?status=1&product_type=${this.product_type}` url: `/pages/users/order_list/indexCopy?status=1&product_type=${this.product_type}`
}) })
} else { } else {
uni.navigateTo({ uni.navigateTo({
@ -235,6 +252,7 @@
border-radius: 10rpx; border-radius: 10rpx;
padding: 1rpx 0 28rpx 0; padding: 1rpx 0 28rpx 0;
} }
.payment-status .icon { .payment-status .icon {
font-size: 70rpx; font-size: 70rpx;
width: 140rpx; width: 140rpx;
@ -246,19 +264,23 @@
border: 6rpx solid #f5f5f5; border: 6rpx solid #f5f5f5;
margin: -76rpx auto 0 auto; margin: -76rpx auto 0 auto;
background-color: #999; background-color: #999;
&.icon-duihao2{
&.icon-duihao2 {
background-color: var(--view-theme); background-color: var(--view-theme);
} }
} }
.payment-status .icon.fail { .payment-status .icon.fail {
text-shadow: 0px 4px 0px #7a7a7a; text-shadow: 0px 4px 0px #7a7a7a;
} }
.payment-status .status { .payment-status .status {
font-size: 32rpx; font-size: 32rpx;
font-weight: bold; font-weight: bold;
text-align: center; text-align: center;
margin: 25rpx 0 37rpx 0; margin: 25rpx 0 37rpx 0;
} }
.payment-status .wrapper { .payment-status .wrapper {
border: 1px solid #eee; border: 1px solid #eee;
margin: 0 30rpx 47rpx 30rpx; margin: 0 30rpx 47rpx 30rpx;
@ -266,16 +288,20 @@
border-left: 0; border-left: 0;
border-right: 0; border-right: 0;
} }
.payment-status .wrapper .item { .payment-status .wrapper .item {
font-size: 28rpx; font-size: 28rpx;
color: #282828; color: #282828;
} }
.payment-status .wrapper .item~.item { .payment-status .wrapper .item~.item {
margin-top: 20rpx; margin-top: 20rpx;
} }
.payment-status .wrapper .item .itemCom { .payment-status .wrapper .item .itemCom {
color: #666; color: #666;
} }
.payment-status .returnBnt { .payment-status .returnBnt {
width: 630rpx; width: 630rpx;
height: 86rpx; height: 86rpx;
@ -285,46 +311,56 @@
text-align: center; text-align: center;
line-height: 86rpx; line-height: 86rpx;
margin: 0 auto 20rpx auto; margin: 0 auto 20rpx auto;
&.gColor{
&.gColor {
background-color: var(--view-theme); background-color: var(--view-theme);
} }
&.s-Color{
&.s-Color {
color: var(--view-theme); color: var(--view-theme);
border: 1px solid var(--view-theme); border: 1px solid var(--view-theme);
} }
} }
.t-color { .t-color {
color: var(--view-theme)!important; color: var(--view-theme) !important;
} }
.coupon-wrapper{
.hd{ .coupon-wrapper {
.hd {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
margin: 30rpx 0; margin: 30rpx 0;
color: #999999; color: #999999;
font-size: 24rpx; font-size: 24rpx;
.line{
.line {
width: 70rpx; width: 70rpx;
height: 1px; height: 1px;
background: #DCDCDC; background: #DCDCDC;
} }
.txt{
.txt {
margin: 0 20rpx; margin: 0 20rpx;
} }
} }
.coupon-box{
.coupon-box {
height: 356rpx; height: 356rpx;
padding: 0 20rpx; padding: 0 20rpx;
overflow: hidden; overflow: hidden;
&.on{
&.on {
height: auto; height: auto;
} }
.coupon-item{
.coupon-item {
width: 100%; width: 100%;
margin-bottom: 20rpx; margin-bottom: 20rpx;
box-shadow:0px 2px 10px 0px rgba(0, 0, 0, 0.06); box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.06);
.left-bg{
.left-bg {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
@ -332,36 +368,42 @@
height: 160rpx; height: 160rpx;
color: #fff; color: #fff;
font-size: 64rpx; font-size: 64rpx;
text{
text {
margin-top: 26rpx; margin-top: 26rpx;
font-size: 36rpx; font-size: 36rpx;
} }
} }
.info{
.info {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: space-between; justify-content: space-between;
margin-left: 20rpx; margin-left: 20rpx;
padding: 20rpx 0; padding: 20rpx 0;
.title{
.title {
color: #282828; color: #282828;
font-size: 30rpx; font-size: 30rpx;
} }
.des{
.des {
font-size: 24rpx; font-size: 24rpx;
color: #999999; color: #999999;
} }
} }
} }
} }
.more{
.more {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
padding-top: 24rpx; padding-top: 24rpx;
font-size: 24rpx; font-size: 24rpx;
color: #999999; color: #999999;
.iconfont{
.iconfont {
margin-top: 6rpx; margin-top: 6rpx;
margin-left: 10rpx; margin-left: 10rpx;
font-size: 20rpx; font-size: 20rpx;

View File

@ -72,7 +72,7 @@
<view class="content_enter-one"> <view class="content_enter-one">
类型 类型
</view> </view>
<view class="content_enter-two" v-if="listobj.is_type==3"> <view class="content_enter-two" v-if="listobj.resale_type==1">
调货 调货
</view> </view>
<view class="content_enter-two" v-else> <view class="content_enter-two" v-else>
@ -83,7 +83,7 @@
</view> </view>
<view class="content_bootm" v-if='listobj.resale'> <view class="content_bootm" v-if='listobj.resale'>
<view class="content_bootm_txt"> <view class="content_bootm_txt" v-if='listobj.resale.length>0'>
查看TA提到的宝贝({{listobj.resale.length}}) 查看TA提到的宝贝({{listobj.resale.length}})
</view> </view>

View File

@ -582,8 +582,9 @@
/*获取选中的宝贝*/ /*获取选中的宝贝*/
getProduct(data) { getProduct(data) {
this.productList=[] this.productList=[]
this.price = 0 this.price = 0;
if (data.length > 0) { if (data.length > 0) {
this.productList = data; this.productList = data;
for (let i in data) { for (let i in data) {
console.log(Number(data[i].num) , Number(data[i].price),(Number(data[i].num) * Number(data[i].price))) console.log(Number(data[i].num) , Number(data[i].price),(Number(data[i].num) * Number(data[i].price)))

View File

@ -1027,7 +1027,7 @@
use_integral: that.use_integral use_integral: that.use_integral
}).then(res => { }).then(res => {
// //
console.log(res); that.product_type=res.data.order_type
that.is_take = false that.is_take = false
res.data.order.forEach(el => { res.data.order.forEach(el => {
if (el.order.isTake == 1) that.is_take = true if (el.order.isTake == 1) that.is_take = true

View File

@ -1,125 +0,0 @@
/**
* Notes: APP语音播报
* @author WJD
* @version 1.0.0
* @Date 2022-01-26
*/
// 是否播放中
let isPlaying = false;
// 播放列表
let currentAudio = ['/static/audio/order.mp3'];
// 播放顺序
let playIndex = 0
// 播放器
let audioPlayer = null;
// 平台
let platform = 'iOS';
// 定时器
let timer = null;
const voice = {
// 创建播放器
init: () => {
platform = plus.os.name;
if (platform == 'Android') {
let MediaPlayer = plus.android.importClass("android.media.MediaPlayer");
audioPlayer = new MediaPlayer()
}
if (platform == "iOS") {
let AVAudioPlayer = plus.ios.importClass("AVAudioPlayer");
audioPlayer = new AVAudioPlayer();
}
console.log('创建播放器成功');
voice.playAudio();
},
// 重置播放列表
resetPlayList: () => {
playIndex = 0;
currentAudio = ['/static/audio/order.mp3'];
},
clearTimer: () => {
if (timer) {
clearInterval(timer);
timer = null;
}
},
// 播放音频
playAudio: () => {
if (isPlaying) {
console.log('播放中,请等待...')
return false;
}
if (audioPlayer == null) {
console.log('未启动音频播放器');
return false;
}
let audioList = currentAudio;
// voice.resetPlayList();
// if (currentAudio.length == 0) {
// const keys = Object.keys(audioList)
// console.log(audioList)
// if (keys.length) {
// currentAudio = Object.values(audioList)[0]
// delete audioList[keys[0]]
// playIndex = 0
// } else {
// voice.resetPlayList();
// }
// }
console.log('正在播报:', currentAudio[playIndex]);
let path = plus.io.convertLocalFileSystemURL(currentAudio[playIndex]);
let currentTime = 0; // 当前流媒体的播放的位置,单位是秒
let currentDuration = 0; // 当前文件时长
if (platform == 'iOS') {
let NSData = plus.ios.importClass("NSData");
let AVAudioPlayer = plus.ios.importClass("AVAudioPlayer");
let pathFileData = NSData.dataWithContentsOfFile(path);
audioPlayer.initWithDataerror(pathFileData, null);
// audioPlayer.setNumberOfLoops(-1); //-1无限循环
audioPlayer.prepareToPlay(); //初始化播放器
audioPlayer.play();
isPlaying = audioPlayer.isPlaying();
// 当前播放进度 currentTime 秒
} else {
let MediaPlayer = plus.android.importClass("android.media.MediaPlayer");
audioPlayer.setDataSource(path); //指定音频文件路径
// audioPlayer.setLooping(true); //设置为循环播放
audioPlayer.prepare(); //初始化播放器MediaPlayer
audioPlayer.start();
isPlaying = audioPlayer.isPlaying();
// 获取音乐的总时长
console.log(isPlaying, audioPlayer.getDuration());
// 当前播放进度 getCurrentPosition 毫秒
}
timer = setInterval(function() {
currentTime = platform == 'iOS' ? audioPlayer.currentTime() : audioPlayer
.getCurrentPosition() / 1000;
currentDuration = platform == 'iOS' ? audioPlayer.duration() : audioPlayer
.getDuration() / 1000;
// console.log(currentTime, currentDuration)
if (currentTime == currentDuration || currentTime == 0) {
isPlaying = false;
voice.clearTimer();
if (playIndex < currentAudio.length - 1) {
playIndex++
} else {
currentAudio = [];
playIndex = 0;
}
if (Object.keys(audioList).length == 0 && currentAudio.length == 0) {
voice.resetPlayList();
}
// voice.playAudio();
}
}, 200);
}
}
export default voice

Binary file not shown.