diff --git a/components/release/release.vue b/components/release/release.vue index 2265738..eb7e02f 100644 --- a/components/release/release.vue +++ b/components/release/release.vue @@ -121,7 +121,7 @@ .release_content_left { display: flex; - + } .release_content_right { @@ -135,7 +135,7 @@ height: 96rpx; margin-top: 21rpx; margin-right: 19rpx; - margin-left: -15rpx; + image { width: 111rpx; @@ -144,11 +144,12 @@ } .release_imga { + width: 76rpx; height: 113rpx; - margin-left: 21rpx; + margin-top: 5rpx; - margin-right: 19rpx; + margin-right: 50rpx; image { width: 76rpx; diff --git a/components/shoppinglist/shoppinglist.vue b/components/shoppinglist/shoppinglist.vue index 7a29516..258289d 100644 --- a/components/shoppinglist/shoppinglist.vue +++ b/components/shoppinglist/shoppinglist.vue @@ -31,34 +31,39 @@ {{item.store_name}} - - - - {{item.attrValue[index].sku}} - - + + + {{item.attrValue[index].sku}} + - 库存:{{item.stock}} + 库存:{{item.attrValue[index].stock}} - + + + + 出售价格 - + 出售数量 - - + + + @@ -140,8 +145,8 @@ IfProductId: 0, }], index: 0, - pickerData: '请选择' - + pickerData: '请选择', + itstock: '', }; }, @@ -157,16 +162,13 @@ mounted() { this.checkedArr = this.checkedObj this.getBounht(); - - }, methods: { // picker修改事件 - bindPickerChange: function(e, storage) { - console.log(e) - console.log(storage) - // this.index = e.target.value + bindPickerChange: function(e, storage, num) { + this.bought[num].attrValue[this.index].stock=storage[e.detail.value].stock + this.bought[num].product_attr_unique=storage[e.detail.value].unique this.pickerData = storage[this.index] // 这里就是选中的对象 }, @@ -174,8 +176,10 @@ close() { this.$emit('close'); }, - numberChange(data) { + numberChange(data,i) { this.peicenumber = data.number; + this.bought[i].num=data.number + }, tabs(index) { this.isActive = index @@ -203,7 +207,7 @@ }, searchBut() { this.whereb.page = this.wherec.page = this.wheres.page = - this.bought = [] + this.bought = [] this.isActive == 0 ? this.getBounht() : '' }, getBounht() { @@ -213,7 +217,6 @@ getCommunitygetOrderList(that.whereb).then( res => { - that.loadingb = false; that.loadedb = res.data.list.length < that.whereb.limit; that.bought.push.apply(that.bought, res.data.list); @@ -237,9 +240,14 @@ that.checkedArr.forEach((val, i) => { if (item.product_id == val.product_id) { that.$set(item, 'check', true); + that.$set(item, 'num', val.num); + + }else{ + that.$set(item, 'num', 0); } }) }) + }, /*已选中的商品打钩*/ getCheckedGoods() { @@ -250,10 +258,19 @@ }, /*点击选中与否*/ goodsCheck(item) { - this.$set(item, 'check', !item.check); - console.log(item, 'check', !item.check) + this.$set(item, 'check', !item.check); if (item.check) { + if(this.peicenumber>0){ + item.num=this.peicenumber + }else{ + item.num=1 + } + + if(!item.product_attr_unique){ + item.product_attr_unique=item.attrValue[0].unique + } this.checkedArr.push(item) + } else { this.checkedArr.splice(this.checkedArr.findIndex(itemn => ((itemn.spu_id == item.spu_id) || (item .spu_id == ( @@ -263,8 +280,9 @@ }, /*确定提交*/ submit() { + this.$emit('getProduct', this.checkedArr); - console.log(this.checkedArr) + }, } } @@ -408,7 +426,7 @@ .price { display: flex; - margin-right: 15rpx; + margin-right: 15rpx; input { width: 210rpx; @@ -419,9 +437,9 @@ font-size: 28rpx; font-family: PingFang SC-Regular, PingFang SC; font-weight: 400; - + margin-left: 20rpx; - + } } diff --git a/pages/commissionedSales/initiateDelegation/index.vue b/pages/commissionedSales/initiateDelegation/index.vue index e38eac1..ce2d100 100644 --- a/pages/commissionedSales/initiateDelegation/index.vue +++ b/pages/commissionedSales/initiateDelegation/index.vue @@ -6,7 +6,7 @@ - + @@ -43,12 +43,12 @@ - + 已接受 - + 结束委托 @@ -60,7 +60,7 @@ - + 已拒绝 @@ -94,7 +94,7 @@ - - + + - - + + + @@ -211,17 +210,16 @@ 利息比例: 0.05% - + 拒绝原因: - - + @@ -96,8 +95,10 @@ - 价格:¥{{price}} - + + 价格:¥{{price}} + @@ -136,13 +137,7 @@ - + @@ -154,7 +149,7 @@ import authorize from '@/components/Authorize'; import avatar from "@/components/yq-avatar/yq-avatar.vue"; import associated from '@/components/shoppinglist/shoppinglist.vue'; - + import { TOKENNAME, HTTP_REQUEST_URL @@ -173,6 +168,9 @@ import { configMap } from '@/utils'; + import { + getCommunitycreate + } from '@/api/trading-floor.js' import store from '@/store'; export default { components: { @@ -187,11 +185,13 @@ formData: { image: [], content: "", - topic_id: "", - spu_id: [], - video_link: '' + topic_id: 0, + category_id: 0, + video_link: '', + is_type: 3, + product_info: [] }, - price:0, + price: 0, imageSrc: '', productList: [], topicName: {}, @@ -222,7 +222,9 @@ video_link: "", showVideo: false, videoplay: false, - videoContext: '' + videoContext: '', + + }; }, computed: { @@ -251,8 +253,7 @@ onLoad(options) { // uni.hideTabBar() this.id = options.id; - this.order_id = options.order_id; - // console.log("options.order_id", options.order_id) + this.tabActive = options.type || 1; if (this.community_app_switch.length == 1) { this.tabActive = this.community_app_switch[0] @@ -261,16 +262,8 @@ this.isAuto = true; this.isShowAuth = true } else { - if (this.id) { - this.getDetail() - } else { - // const data = getStorage('addPlant'); - // if(data){ - // this.formData.content = data.content || ''; - // this.formData.image = data.image || []; - // } - } - if (this.order_id) this.getOrderGoods() + + } this.videoContext = uni.createVideoContext("myvideo", this); }, @@ -279,7 +272,8 @@ this.formData.content = '' this.formData.image = [] this.formData.topic_id = '' - this.formData.spu_id = '' + + this.formData.video_link = '' this.productList = [] this.topicName = {} @@ -293,31 +287,7 @@ authColse: function(e) { this.isShowAuth = e; }, - /*获取图文详情*/ - getDetail() { - let that = this - plantDetailApi(that.id).then(res => { - that.formData = res.data - that.productList = res.data.relevance || [] - that.topicName = res.data.topic || {} - }).catch(err => { - return that.$util.Tips({ - title: err - }); - }) - }, - /*获取关联订单商品*/ - getOrderGoods() { - let that = this - orderAssociatePlantApi(that.order_id).then(res => { - that.productList = res.data || [] - that.formData.spu_id = res.data.map(val => val.spu_id) - }).catch(err => { - return that.$util.Tips({ - title: err - }); - }) - }, + /*点击输入价格*/ addprice() { this.isshow = true @@ -485,7 +455,7 @@ close() { this.$refs.associated.close(); - + }, /*查看视频*/ videoshow() { @@ -508,8 +478,23 @@ }, /*获取选中的宝贝*/ getProduct(data) { - this.productList = data; - this.formData.spu_id = data.map(val => val.spu_id) + if (data.length > 0) { +this.productList = data; + for (let i in data) { + this.price = Number(this.price) + (Number(data[i].num) * Number(data[i].price)) + this.formData.product_info.push({ + product_attr_unique: data[i].product_attr_unique, + number: Number(data[i].num), + price: data[i].price + }) + } + } else { + this.price = 0 + } + + + + this.$refs.associated.close(); }, @@ -517,128 +502,62 @@ * 提交数据 */ formSubmit: function(e) { + console.log(this.id) let that = this, value = that.formData; if (value.image.length == 0) return that.$util.Tips({ - title: '请添加话题图片' + title: '请添加图文图片' + }); + if (value.product_info.length == 0) return that.$util.Tips({ + title: '请选择产品' }); if (!value.content) return that.$util.Tips({ - title: '请分享使用心得和体会' + title: '请添加商品描述' }); if (that.tabActive == 2 && !value.video_link) { return that.$util.Tips({ title: '请添加话题视频' }); } - if (!value.category_id || !value.topic_id) { - return that.$util.Tips({ - title: '请选择话题' - }) - } - if (that.id) { - if (value.relevance.length) { - value.spu_id = value.relevance.map(val => (val.spu && val.spu.spu_id) || val.spu_id) - } - } - value.order_id = that.order_id - value.is_type = that.tabActive + uni.showLoading({ title: '保存中', mask: true }) - that.id ? updatePlantApi(that.id, value).then(res => { - uni.hideLoading() - that.$util.Tips({ - title: res.messge, - icon: 'success' - }); - - setTimeout(function() { - if (that.tabActive == 2) { - uni.navigateTo({ - //#ifdef APP - url: '/pages/short_video/appSwiper/index?id=' + res.data - .community_id + '&user=1&uid=' + - that.uid - //#endif - //#ifndef APP - url: '/pages/short_video/nvueSwiper/index?id=' + res.data - .community_id + '&user=1&uid=' + - that.uid - //#endif - }); - } else { - uni.navigateTo({ - url: '/pages/plantGrass/plant_detail/index?id=' + res.data - .community_id + '&type=' + that - .tabActive - }) - } - /** - * 将对象所有值为空 - * */ - /** - * 将对象所有值为空 - * */ + getCommunitycreate(value).then(res => { + if (res.status == '200') { + uni.hideLoading() + that.$util.Tips({ + title: '发布成功', + icon: 'success' + }); that.formData = { image: [], content: "", - topic_id: "", - spu_id: [], - video_link: "", - } - that.topicName = {} - }, 1000); - }).catch(err => { - return that.$util.Tips({ - title: err - }); - }) : createPlantApi(value).then(res => { - uni.hideLoading() - that.$util.Tips({ - title: res.messge, - icon: 'success' - }); - setStorage('addPlant', ''); - setTimeout(function() { - if (that.tabActive == 2) { - uni.navigateTo({ - //#ifdef APP - url: '/pages/short_video/appSwiper/index?id=' + res.data - .community_id + '&user=1&uid=' + - that.uid - //#endif - //#ifndef APP - url: '/pages/short_video/nvueSwiper/index?id=' + res.data - .community_id + '&user=1&uid=' + - that.uid - //#endif - }); - } else { - uni.navigateTo({ - url: '/pages/plantGrass/plant_detail/index?id=' + res.data - .community_id + '&type=' + that - .tabActive - }) - } - /** - * 将对象所有值为空 - * */ - that.formData = { - image: [], - content: "", - topic_id: "", - spu_id: [], - video_link: "", + topic_id: 0, + category_id: 0, + video_link: '', + is_type: 3, + product_info: [] } + uni.navigateTo({ + url: '/pages/releaseManagement/index?key=' + 2 + }) - }, 1000); + } else { + that.$util.Tips({ + title: res.messge, + icon: 'success' + }); + } }).catch(err => { - // console.log('aaa', value) + return that.$util.Tips({ title: err }); }) + + } } } diff --git a/pages/users/order_list/index.vue b/pages/users/order_list/index.vue index 432146b..0afdb64 100644 --- a/pages/users/order_list/index.vue +++ b/pages/users/order_list/index.vue @@ -21,7 +21,7 @@ 全部 - {{orderData.all || 0}} + {{orderData.orderCount || 0}} 待付款 @@ -493,7 +493,7 @@ */ getOrderData: function() { let that = this; - orderData().then(res => { + orderData({product_type:0}).then(res => { that.$set(that, 'orderData', res.data); }) }, diff --git a/pages/users/order_list/indexCopy.vue b/pages/users/order_list/indexCopy.vue index 03d3f7f..d563918 100644 --- a/pages/users/order_list/indexCopy.vue +++ b/pages/users/order_list/indexCopy.vue @@ -21,7 +21,7 @@ 全部 - {{orderData.all || 0}} + {{orderData.orderCount || 0}} 待付款 @@ -493,8 +493,10 @@ */ getOrderData: function() { let that = this; - orderData().then(res => { - console.log(res.data) + orderData({ + product_type:98 + }).then(res => { + // console.log(res.data) that.$set(that, 'orderData', res.data); }) }, diff --git a/pages/users/trading_hall/index.vue b/pages/users/trading_hall/index.vue index 3f8a4e1..3c7f6c1 100644 --- a/pages/users/trading_hall/index.vue +++ b/pages/users/trading_hall/index.vue @@ -17,8 +17,10 @@ - - {{this.recomname}} + + + {{this.recomname}} + @@ -41,16 +43,16 @@ 调货 委托销售 - {{item.name}} + {{item.title}} {{item.total_price}} - + - {{item.author.nickname}} + {{item.mer_name}} @@ -164,7 +166,7 @@ }, getlist(index) { - console.log(this.num) + if (this.num == 0) { this.where = { page: 1, @@ -222,8 +224,10 @@ this.visible = false }, menuAction(action, rowId) { - console.log(action); + // console.log(action); // 忽略初始化时的传入的空操作 + this.num=action + this.getlist(action) if (action === '') { this.recomname = this.options[0].text } else { @@ -305,7 +309,7 @@ font-size: 32rpx; font-family: 'PingFang SC'; font-weight: 400; - color: #F84221; + .recom_sym { width: 28rpx; @@ -361,10 +365,11 @@ } .list { - width: 100%; + width: 694.74rpx; + margin: 0 auto; display: flex; - justify-content: flex-start; + justify-content: space-between; align-items: center; flex-wrap: wrap; @@ -374,7 +379,7 @@ height: 561rpx; background-color: #fff; margin-top: 21rpx; - margin-left: 25rpx; + border-radius: 14rpx 14rpx 0 0; .shopimg { @@ -403,6 +408,7 @@ font-weight: 400; color: #FFFFFF; font-size: 25rpx; + margin-right: 15rpx; } } diff --git a/plugin/voice/voice.js b/plugin/voice/voice.js new file mode 100644 index 0000000..eba91a9 --- /dev/null +++ b/plugin/voice/voice.js @@ -0,0 +1,269 @@ +/** + * Notes: APP语音播报 + * @author WJD + * @version 1.0.0 + * @Date 2022-01-26 + */ + +// import store from '../store' + +// 是否播放中 +let isPlaying = false; +// 播放列表 +let currentAudio = ['/static/audio/order.mp3']; +// 播放顺序 +let playIndex = 0 +// 播放器 +let audioPlayer = null; +// 平台 +let platform = 'iOS'; +// 定时器 +let timer = null; +// socket地址 +const socketUrl = "wss://gateworker.yngod.cn:8686"; + +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(); + }, + // 连接socket + connectSocketGlobal: () => { + uni.connectSocket({ + url: socketUrl, + success: (res) => { + console.log('连接成功'); + } + }) + + uni.onSocketOpen((success) => { + console.log('WebSocket连接已打开!'); + let storeIds = store.state.storeIds; + if (storeIds.length > 0) { + storeIds.forEach(sid => { + uni.sendSocketMessage({ + data: sid.toString(), + success: (s) => { + console.log('成功'); + } + }); + }) + } + store.commit('setData', { + key: 'socketIsOpen', + val: true + }); + }) + + uni.onSocketError(function(error) { + console.log('WebSocket连接打开失败,请检查!'); + }); + + uni.onSocketMessage((res) => { + console.log('接收播报数据', res) + //按接收的内容播放信息 + try { + if (typeof res == 'string') { + res = JSON.parse(res); + } + if (typeof res.data == 'string') { + res.data = JSON.parse(res.data); + } + if(res.data?.Hearbeat) { + uni.sendSocketMessage({ + data: "hearbeat", + success: (s) => { + console.log('成功'); + } + }); + return ; + } + if (res.data.needPlay) { + try { + // var parseStr = voice.parseAudioData(res.data); + } catch (e) { + // console.log('解析出错', e) + } + // console.log('解析数据', parseStr) + // voice.addAudioQueue(parseStr); + } + } catch (e) {} + }) + }, + //解析服务器数据 + parseAudioData: function(serverData) { + let audio = []; + //头部 + //处理中间数字 + serverData.data = parseFloat(serverData.data).toString(); + //如果当前数字中没有小数点,则用.00补足 + if (serverData.data.indexOf('.') == -1) serverData.data += '.00'; + let dot = serverData.data.indexOf('.'); + let l = serverData.data.length; + for (let n = 0; n < l; n++) { + //如果上一位是0则不加入 + if (audio[audio.length - 1] != 0 || serverData.data.substr(n, 1) != '0') { + audio.push(serverData.data.substr(n, 1)); + //根据当前数字的位置与dot的位置决定后缀并且当前不是小数点 + if (serverData.data.substr(n, 1) != '.' && serverData.data.substr(n, 1) != '0') { + if (dot - n == 2) { + audio.push('ten'); + } else if (dot - n == 3) { + audio.push('hundred'); + } else if (dot - n == 4) { + audio.push('thousand'); + } else if (dot - n == 5) { + audio.push('ten_thousand'); + } + } + } + } + //如果出现1shi则去掉1 + let _audio = audio.join('&'); + if (audio[0] == 1) { + _audio = _audio.replace('1&shi', 'shi'); //应对一十元问题 + } + if (audio[0] != 0) { + _audio = _audio.replace('0&.', '.'); //应对一十点问题 + } + if (_audio.indexOf('.&0') == _audio.length - 2 - 1) { //应对末尾是.0 + _audio = _audio.substr(0, _audio.length - 2 - 2); + } + //加入前缀 + if (_audio) { + _audio = 'header_' + serverData.header.toString() + '&' + _audio; + } else { + _audio = 'header_' + serverData.header.toString(); + } + audio = _audio.split("&"); + //如果有金额 + if (l) { + audio.push('yuan'); + } + //底部 + if (serverData.footer) { + audio.push('footer'); + } + let result = []; + audio.map(item => { + if (item != '.') + result.push(`/static/audio/tts_${item}.mp3`); + else + result.push(`/static/audio/tts_dot.mp3`); + }) + return result; + }, + // 随机数 + getRandomKey: () => { + var max = 99999; + var min = 1; + return (Date.parse(new Date()) + '' + parseInt(Math.random() * (max - min + 1) + min, 10)).toString(); + }, + + // 语言播报语音数据 加入到队列里面 + addAudioQueue: (parseStr) => { + let audioList = store.state.audioList; + audioList[voice.getRandomKey()] = parseStr; + store.commit('setData', { + key: 'audioList', + val: audioList + }); + }, + // 重置播放列表 + 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; + if (currentAudio.length == 0) { + const keys = Object.keys(audioList) + if (keys.length) { + currentAudio = Object.values(audioList)[0] + delete audioList[keys[0]] + playIndex = 0 + // store.commit('setData', { + // key: 'audioList', + // val: audioList + // }); + } 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(audioPlayer.getDuration()); + // 当前播放进度 getCurrentPosition 毫秒 + } + timer = setInterval(function() { + currentTime = platform == 'iOS' ? audioPlayer.currentTime() : audioPlayer + .getCurrentPosition() / 1000; + currentDuration = platform == 'iOS' ? audioPlayer.duration() : audioPlayer + .getDuration() / 1000; + 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 diff --git a/static/audio/order.mp3 b/static/audio/order.mp3 new file mode 100644 index 0000000..3bec7be Binary files /dev/null and b/static/audio/order.mp3 differ