123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- <template>
- <view class="box">
- <view v-if="flag == 2" class="boxlist">
- <view @click="nextTo(item)" class="bb vidLi dfsb" v-for="(item, ind) in list" :key="ind">
- <image class="imgbox" src="/static/img/pro/wodimg.png" mode=""></image>
- <view class="dffd flex1">
- <view class="title elli">{{ item.title }}</view>
- <view class="textgrey fontsm">{{ item.is_buy == 1 ? '已购买' : '未购买' }}</view>
- </view>
- <image v-if="flag == 2" class="down" src="../../../static/img/pro/navdown.png" mode=""></image>
- </view>
- </view>
- <view v-if="flag == 1" class="boxlist">
- <view @click="nextTo(item, 1)" class="bb vidLi dfsb" v-for="(item, ind) in list" :key="ind">
- <image class="imgbox" src="/static/img/pro/wodimg.png" mode=""></image>
- <view class="dffd flex1">
- <view class="title elli">{{ item.title }}</view>
- <view class="textgrey fontsm">已购买</view>
- </view>
- <image class="down" src="../../../static/img/pro/navdown.png" mode=""></image>
- </view>
- </view>
- <view v-if="flag == 4" class="boxlist">
- <view @click="nextTo(item, 1)" class="bb vidLi dfsb" v-for="(item, ind) in list" :key="ind">
- <image class="imgbox" src="/static/img/pro/wodimg.png" mode=""></image>
- <view class="dffd flex1">
- <view class="title elli">{{ item.title }}</view>
- <!-- <view class="textgrey fontsm">已购买</view> -->
- </view>
- <image class="down" src="../../../static/img/pro/navdown.png" mode=""></image>
- </view>
- </view><view v-if="flag == 5" class="boxlist">
- <view @click="nextTo(item, 1)" class="bb vidLi dfsb" v-for="(item, ind) in list" :key="ind">
- <!-- <image class="imgbox" src="/static/img/pro/wodimg.png" mode=""></image> -->
- <view class="dffd flex1">
- <view class="title elli">{{ item.title }}</view>
- <!-- <view class="textgrey fontsm">已购买</view> -->
- </view>
- <image class="down" src="../../../static/img/pro/navdown.png" mode=""></image>
- </view>
- </view>
- <view v-if="flag == 3" class="boxlist">
- <view v-if="item.is_buy == 0" class="bb vidLi dfsb" v-for="(item, ind) in list" :key="ind">
- <image class="imgbox" src="/static/img/pro/wodimg.png" mode=""></image>
- <view class="dffd flex1">
- <view class="title elli">{{ item.title }}</view>
-
- <text v-if="selType == 1&&item.price>0" class="priceDan">{{ item.price }}</text>
- <text v-if="selType == 1&&item.price==0" class="fontsm prosecond">免费</text>
- <view v-if="selType == 2" class="textgrey fontsm">{{ item.bean==0?'免费':item.bean+'学豆' }}</view>
- <!-- <view v-if="selType == 1" class="textgrey fontsm">{{ item.bean==0?'免费':item.bean+'学豆' }}</view>
- <text v-if="selType == 2&&item.price>0" class="priceDan">{{ item.price }}</text>
- <text v-if="selType == 2&&item.price==0" class="fontsm prosecond">免费</text> -->
- </view>
- <image @click.stop="hhh(item, ind)" v-if="!item.sel" class="down" src="/static/img/pro/wxz.png" mode=""></image>
- <image @click.stop="hhh(item, ind)" v-if="item.sel" class="down" src="/static/img/pro/chenggong.png" mode=""></image>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- path: ''
- };
- },
- props: {
- list: {
- type: Array,
- default: []
- },
- flag: {
- type: [String, Number],
- default: 1
- },
- selType: {
- type: [String, Number],
- default: 2
- }
- },
- methods: {
- hhh(item, ind) {
- console.log('hhh: ',item);
- // if(item.sel)
- item.sel = !item.sel;
- // console.log(111, item.sel);
- this.$emit('getItem', item.sel, ind);
- },
- nextTo(item, val) {
- let that = this;
- if ((that.flag == 2 && item.is_buy == 1) || val == 1) {
- // that.$api.toast('点击下载');
- let url = item.files;
- // 下载
- uni.downloadFile({
- url: url, //仅为示例,并非真实的资源
- success: res => {
- if (res.statusCode === 200) {
- that.$api.toast('下载成功');
- that.path = res.tempFilePath;
- console.log(res, that.path);
- //保存到本地
- uni.saveFile({
- tempFilePath: that.path,
- success: res1 => {
- //res.savedFilePath文件的保存路径
- //保存成功并打开文件
- uni.openDocument({
- filePath: res1.savedFilePath,
- showMenu:true,
- success: res2 => {
- that.$api.toast('打开成功');
- }
- });
- },
- fail: res3 => {
- console.log(res3);
- that.$api.toast('保存失败');
- }
- });
- } else {
- that.$api.toast('下载失败');
- }
- },
- complete: res12 => {
- console.log(res12);
- that.$api.toast(res12);
- },
- fail: res11 => {
- console.log(res11);
- that.$api.toast(res11);
- }
- });
- } else {
- that.$api.toast('请先购买');
- }
- }
- }
- };
- </script>
- <style scoped lang="scss">
- .boxlist {
- .vidLi {
- width: 100%;
- padding: 27rpx 0;
- background-color: #fff;
- &:nth-of-type(2n) {
- margin-right: 0;
- }
- .imgbox {
- width: 146rpx;
- height: 146rpx;
- margin-right: 18rpx;
- }
- .title {
- font-size: 28rpx;
- line-height: 40rpx;
- margin-bottom: 12rpx;
- }
- .auth {
- margin-top: 15rpx;
- width: 100%;
- }
- .down {
- width: 40rpx;
- height: 40rpx;
- margin-right: 30rpx;
- }
- }
- }
- </style>
|