wordlist.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <view class="box">
  3. <view v-if="flag == 2" class="boxlist">
  4. <view @click="nextTo(item)" class="bb vidLi dfsb" v-for="(item, ind) in list" :key="ind">
  5. <image class="imgbox" src="/static/img/pro/wodimg.png" mode=""></image>
  6. <view class="dffd flex1">
  7. <view class="title elli">{{ item.title }}</view>
  8. <view class="textgrey fontsm">{{ item.is_buy == 1 ? '已购买' : '未购买' }}</view>
  9. </view>
  10. <image v-if="flag == 2" class="down" src="../../../static/img/pro/navdown.png" mode=""></image>
  11. </view>
  12. </view>
  13. <view v-if="flag == 1" class="boxlist">
  14. <view @click="nextTo(item, 1)" class="bb vidLi dfsb" v-for="(item, ind) in list" :key="ind">
  15. <image class="imgbox" src="/static/img/pro/wodimg.png" mode=""></image>
  16. <view class="dffd flex1">
  17. <view class="title elli">{{ item.title }}</view>
  18. <view class="textgrey fontsm">已购买</view>
  19. </view>
  20. <image class="down" src="../../../static/img/pro/navdown.png" mode=""></image>
  21. </view>
  22. </view>
  23. <view v-if="flag == 4" class="boxlist">
  24. <view @click="nextTo(item, 1)" class="bb vidLi dfsb" v-for="(item, ind) in list" :key="ind">
  25. <image class="imgbox" src="/static/img/pro/wodimg.png" mode=""></image>
  26. <view class="dffd flex1">
  27. <view class="title elli">{{ item.title }}</view>
  28. <!-- <view class="textgrey fontsm">已购买</view> -->
  29. </view>
  30. <image class="down" src="../../../static/img/pro/navdown.png" mode=""></image>
  31. </view>
  32. </view><view v-if="flag == 5" class="boxlist">
  33. <view @click="nextTo(item, 1)" class="bb vidLi dfsb" v-for="(item, ind) in list" :key="ind">
  34. <!-- <image class="imgbox" src="/static/img/pro/wodimg.png" mode=""></image> -->
  35. <view class="dffd flex1">
  36. <view class="title elli">{{ item.title }}</view>
  37. <!-- <view class="textgrey fontsm">已购买</view> -->
  38. </view>
  39. <image class="down" src="../../../static/img/pro/navdown.png" mode=""></image>
  40. </view>
  41. </view>
  42. <view v-if="flag == 3" class="boxlist">
  43. <view v-if="item.is_buy == 0" class="bb vidLi dfsb" v-for="(item, ind) in list" :key="ind">
  44. <image class="imgbox" src="/static/img/pro/wodimg.png" mode=""></image>
  45. <view class="dffd flex1">
  46. <view class="title elli">{{ item.title }}</view>
  47. <text v-if="selType == 1&&item.price>0" class="priceDan">{{ item.price }}</text>
  48. <text v-if="selType == 1&&item.price==0" class="fontsm prosecond">免费</text>
  49. <view v-if="selType == 2" class="textgrey fontsm">{{ item.bean==0?'免费':item.bean+'学豆' }}</view>
  50. <!-- <view v-if="selType == 1" class="textgrey fontsm">{{ item.bean==0?'免费':item.bean+'学豆' }}</view>
  51. <text v-if="selType == 2&&item.price>0" class="priceDan">{{ item.price }}</text>
  52. <text v-if="selType == 2&&item.price==0" class="fontsm prosecond">免费</text> -->
  53. </view>
  54. <image @click.stop="hhh(item, ind)" v-if="!item.sel" class="down" src="/static/img/pro/wxz.png" mode=""></image>
  55. <image @click.stop="hhh(item, ind)" v-if="item.sel" class="down" src="/static/img/pro/chenggong.png" mode=""></image>
  56. </view>
  57. </view>
  58. </view>
  59. </template>
  60. <script>
  61. export default {
  62. data() {
  63. return {
  64. path: ''
  65. };
  66. },
  67. props: {
  68. list: {
  69. type: Array,
  70. default: []
  71. },
  72. flag: {
  73. type: [String, Number],
  74. default: 1
  75. },
  76. selType: {
  77. type: [String, Number],
  78. default: 2
  79. }
  80. },
  81. methods: {
  82. hhh(item, ind) {
  83. console.log('hhh: ',item);
  84. // if(item.sel)
  85. item.sel = !item.sel;
  86. // console.log(111, item.sel);
  87. this.$emit('getItem', item.sel, ind);
  88. },
  89. nextTo(item, val) {
  90. let that = this;
  91. if ((that.flag == 2 && item.is_buy == 1) || val == 1) {
  92. // that.$api.toast('点击下载');
  93. let url = item.files;
  94. // 下载
  95. uni.downloadFile({
  96. url: url, //仅为示例,并非真实的资源
  97. success: res => {
  98. if (res.statusCode === 200) {
  99. that.$api.toast('下载成功');
  100. that.path = res.tempFilePath;
  101. console.log(res, that.path);
  102. //保存到本地
  103. uni.saveFile({
  104. tempFilePath: that.path,
  105. success: res1 => {
  106. //res.savedFilePath文件的保存路径
  107. //保存成功并打开文件
  108. uni.openDocument({
  109. filePath: res1.savedFilePath,
  110. showMenu:true,
  111. success: res2 => {
  112. that.$api.toast('打开成功');
  113. }
  114. });
  115. },
  116. fail: res3 => {
  117. console.log(res3);
  118. that.$api.toast('保存失败');
  119. }
  120. });
  121. } else {
  122. that.$api.toast('下载失败');
  123. }
  124. },
  125. complete: res12 => {
  126. console.log(res12);
  127. that.$api.toast(res12);
  128. },
  129. fail: res11 => {
  130. console.log(res11);
  131. that.$api.toast(res11);
  132. }
  133. });
  134. } else {
  135. that.$api.toast('请先购买');
  136. }
  137. }
  138. }
  139. };
  140. </script>
  141. <style scoped lang="scss">
  142. .boxlist {
  143. .vidLi {
  144. width: 100%;
  145. padding: 27rpx 0;
  146. background-color: #fff;
  147. &:nth-of-type(2n) {
  148. margin-right: 0;
  149. }
  150. .imgbox {
  151. width: 146rpx;
  152. height: 146rpx;
  153. margin-right: 18rpx;
  154. }
  155. .title {
  156. font-size: 28rpx;
  157. line-height: 40rpx;
  158. margin-bottom: 12rpx;
  159. }
  160. .auth {
  161. margin-top: 15rpx;
  162. width: 100%;
  163. }
  164. .down {
  165. width: 40rpx;
  166. height: 40rpx;
  167. margin-right: 30rpx;
  168. }
  169. }
  170. }
  171. </style>