Commit bf4400a5 authored by qipeng's avatar qipeng

新增VLOG收费

parent 1af0e48f
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
<view class=""> <view class="">
<button v-if="item.shareNumber===0" :data-productUrl="item.productUrl" :data-productId="item.productId" class="btnn" <button v-if="item.shareNumber===0" :data-productUrl="item.productUrl" :data-productId="item.productId" class="btnn"
open-type="share">分享下载</button> open-type="share">分享下载</button>
<button v-else class="btnn" @click="handleDownload(item.productUrl)">下载视频</button> <button v-else class="btnn" @click="handPayment(item.productUrl,item.isPay,item.sellingPrice)">下载视频</button>
<text class="price">¥<text>0</text></text> <text class="price">¥<text>{{item.sellingPrice}}</text></text>
</view> </view>
<view style="clear: both;"></view> <view style="clear: both;"></view>
</view> </view>
...@@ -17,151 +17,224 @@ ...@@ -17,151 +17,224 @@
</template> </template>
<script> <script>
export default { export default {
data() { data() {
return { return {
myVlogList: [], //我的视频列表 openid:'',
merchantId: '', //景区id myVlogList: [], //我的视频列表
} merchantId: '', //景区id
}, merchantIdOrder:'',//下单用merchantId
onLoad(options) { merchantMessage:[],//景区基础参数
this.merchantId = options.merchantId }
this.getMyVlogList() },
}, onLoad(options) {
onShow() { this.merchantId = options.merchantId
this.merchantIdOrder=options.merchantIdOrder||'z0015605022691a5945bbe463141668c'
this.openid = uni.getStorageSync('openid') //获取openid
this.getMyVlogList()
this.mearchLoadList()//调用参数
},
onShow() {
}, },
onUnload() { //退出页面 onUnload() { //退出页面
}, },
onHide() {}, onHide() {},
onReady() {}, onReady() {},
onShareAppMessage(res) { //分享 onShareAppMessage(res) { //分享
let productId = res.target.dataset.productid let productId = res.target.dataset.productid
let productUrl= res.target.dataset.producturl let productUrl= res.target.dataset.producturl
if (res.from === 'button') { if (res.from === 'button') {
this.$request('wechatUser/myPage/updateVlogRecord', { this.$request('wechatUser/myPage/updateVlogRecord', {
productId, productId,
openid: uni.getStorageSync('openid') openid: uni.getStorageSync('openid')
}).then(res => { }).then(res => {
if (res.code === '00') { if (res.code === '00') {
this.getMyVlogList() this.getMyVlogList()
} }
}) })
return { return {
title: '胖丁旅行', title: '胖丁旅行',
type: 4, type: 4,
path: '/pages/vlog/share/share?url='+productUrl, path: '/pages/vlog/share/share?url='+productUrl,
} }
}else{ }else{
return { return {
title: '胖丁旅行', title: '胖丁旅行',
type: 4, type: 4,
path: '/pages/vlog/vlogIndex/vlogIndex', path: '/pages/vlog/vlogIndex/vlogIndex',
} }
} }
}, },
methods: { methods: {
getMyVlogList() { //获取景区vlog列表 getMyVlogList() { //获取景区vlog列表
this.$request('wechatUser/myPage/getVlogRecord', { this.$request('wechatUser/myPage/getVlogRecord', {
openid: uni.getStorageSync('openid'), openid: uni.getStorageSync('openid'),
productType:0 productType:0
}).then(res => { }).then(res => {
if (res.code === '00') { if (res.code === '00') {
res.data.forEach(item => { //获取当前景区视频列表 res.data.forEach(item => { //获取当前景区视频列表
if (this.merchantId === item.merchantId) { if (this.merchantId === item.merchantId) {
this.myVlogList = item.vlogList this.myVlogList = item.vlogList
} }
}) })
} }
}) })
}, },
playing(e) { //控制只播放当前video playing(e) { //控制只播放当前video
this.myVlogList.forEach((item, index) => { this.myVlogList.forEach((item, index) => {
if (e !== index) { if (e !== index) {
uni.createVideoContext(index.toString()).pause() uni.createVideoContext(index.toString()).pause()
} }
}) })
}, },
handleDownload(url) { // 下载功能 handPayment(productUrl,isPay,sellingPrice){//当前视频是否需要支付下载费用
uni.showLoading({ //isPay 0为未支付 1为已支付
title: '下载中', if(isPay==0){//originalPrice 原价 sellingPrice售价 settlementPrice结算价
mask: true this.upLoad(sellingPrice)
}) }else{
let fileName = new Date().valueOf() //获取时间戳 handleDownload(productUrl)
uni.downloadFile({ //下载文件资源到本地 }
url, },
filePath: wx.env.USER_DATA_PATH + '/' + fileName + '.mp4', //filePath指定文件下载后存储的路径,wx.env.USER_DATA_PATH,时间戳为文件名 upLoad(sellingPrice){//下单
success: res => { //下载到本地成功 var data = {
let filePath = res.filePath companyId:this.merchantMessage[0].companyId||'',//公司ID
uni.saveVideoToPhotosAlbum({ //保存视频到系统相册。 orderMoney:sellingPrice,//订单总价
filePath, userId:this.openid,
success: file => { //保存成功 orderProductVo:{},//下单信息
//删除本地缓存 orderType:11,//相册TYPE值
let fileMgr = uni.getFileSystemManager() orderProductList:[],//景区下单信息
fileMgr.unlink({ }
filePath: wx.env.USER_DATA_PATH + '/' + fileName + '.mp4', var orderProductListData = {
}) buyNum:1,//购买数量
uni.showToast({ merchantId:this.merchantMessage[0].merchantId||'',
title: '下载成功', orderType:11,//11相册
icon: 'success', productId:this.merchantMessage[0].merchantExtendProjectId||'',
mask: true productName:this.merchantMessage[0].merchantExtendProjectName||'',
}) extendContent:'',
}, unitPrice:sellingPrice,//产品单价
fail: err => { orderImgList:[],////订单图片
uni.hideLoading() couponList:[],//券信息
//拒绝授权时显示 }
if (err.errMsg === 'saveVideoToPhotosAlbum:fail auth deny') {
uni.showModal({ var extendContentData={
title: '提示', openid:this.openid,
content: '需要您授权保存相册', projectAddress:this.merchantMessage[0].projectAddress||'',
showCancel: false, projectPhone:this.merchantMessage[0].projectPhone||'',
success: data => { }
//打开权限设置 orderProductListData.extendContent = JSON.stringify(extendContentData)
uni.openSetting({ data.orderProductList.push(orderProductListData)
success: setting => { //data.orderProductVo = orderProductVo
if (setting.authSetting['scope.writePhotosAlbum']) { this.$request('orderc/photo/photoCreateOrder',data).then((res)=>{
uni.showModal({ if(res.code=='00'){
title: '提示', uni.navigateTo({
content: '获取权限成功,再次点击下载即可保存', url:'../../payment/orderPayment/orderPayment?orderId='+res.data.id+'&albumOrderdetail=1'
showCancel: false, })
}) }else{
} else { uni.showToast({
uni.showModal({ title: res.message,
title: '提示', icon: 'none'
ontent: '获取权限失败,将无法保存到相册哦', })
showCancel: false }
}) })
} },
}, mearchLoadList(){//调用参数
}) var merchantIds = []
} merchantIds.push(this.merchantIdOrder)
}) this.$request('scenic/merchantExtendProject/loadList',{
} merchantIds:merchantIds,
} merchantExtendProjectName:'vlog'
}) }).then((res)=>{
}, if(res.code=='00'){
fail: err => { //下载失败 this.merchantMessage = res.data
uni.hideLoading() }else{
if (err.errMsg == 'downloadFile:fail createDownloadTask:fail url not in domain list') { uni.showToast({
uni.showToast({ title: res.message,
title: '服务器错误,请联系相关管理员', icon: 'none'
icon: 'none', })
mask: true }
}) })
} },
} handleDownload(url) { // 下载功能
}) uni.showLoading({
}, title: '下载中',
error(e) { //视频播放出错触发函数 mask: true
uni.showModal({ })
content: e.target.errMsg, let fileName = new Date().valueOf() //获取时间戳
showCancel: false uni.downloadFile({ //下载文件资源到本地
}) url,
}, filePath: wx.env.USER_DATA_PATH + '/' + fileName + '.mp4', //filePath指定文件下载后存储的路径,wx.env.USER_DATA_PATH,时间戳为文件名
} success: res => { //下载到本地成功
} let filePath = res.filePath
uni.saveVideoToPhotosAlbum({ //保存视频到系统相册。
filePath,
success: file => { //保存成功
//删除本地缓存
let fileMgr = uni.getFileSystemManager()
fileMgr.unlink({
filePath: wx.env.USER_DATA_PATH + '/' + fileName + '.mp4',
})
uni.showToast({
title: '下载成功',
icon: 'success',
mask: true
})
},
fail: err => {
uni.hideLoading()
//拒绝授权时显示
if (err.errMsg === 'saveVideoToPhotosAlbum:fail auth deny') {
uni.showModal({
title: '提示',
content: '需要您授权保存相册',
showCancel: false,
success: data => {
//打开权限设置
uni.openSetting({
success: setting => {
if (setting.authSetting['scope.writePhotosAlbum']) {
uni.showModal({
title: '提示',
content: '获取权限成功,再次点击下载即可保存',
showCancel: false,
})
} else {
uni.showModal({
title: '提示',
ontent: '获取权限失败,将无法保存到相册哦',
showCancel: false
})
}
},
})
}
})
}
}
})
},
fail: err => { //下载失败
uni.hideLoading()
if (err.errMsg == 'downloadFile:fail createDownloadTask:fail url not in domain list') {
uni.showToast({
title: '服务器错误,请联系相关管理员',
icon: 'none',
mask: true
})
}
}
})
},
error(e) { //视频播放出错触发函数
uni.showModal({
content: e.target.errMsg,
showCancel: false
})
},
}
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment