index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <template>
  2. <view class="container">
  3. <view style="background-color: rgba(255, 255, 255, 0.2);width: 750rpx;height: 72px;">
  4. <image src="../../static/touxiang.png" class="touxiang"></image>
  5. <view class="username">{{name}}</view>
  6. <text class="phone">{{phone}}</text>
  7. <image src="../../static/share.png" class="share" @click="share"></image>
  8. <image src="../../static/loginout.png" class="loginout" @click="loginout"></image>
  9. </view>
  10. <!-- 项目列表 -->
  11. <view class="list-item" v-for="(item,index) in list" :key="index">
  12. <view class="list-title">体适能</view>
  13. <view class="list-icon"></view>
  14. <view class="list-title2">学习视频</view>
  15. <!-- 视频 -->
  16. <view style="margin-left: 40px;height: 104px;margin-top: 10px;">
  17. <image class="video" @click="playVideo(item)" :src="item.pictureUrl"></image>
  18. <view class="jieshao">{{item.videoName}}</view>
  19. <view class="xiang">{{item.videoDescription}}</view>
  20. </view>
  21. <view class="list-icon"></view>
  22. <view class="list-title2">学习资料</view>
  23. <!-- 资料 -->
  24. <view style="width: 690rpx;margin-left: 40px;margin-top: 10px;" v-for="(item,index) in item.videoElseList" :key="index">
  25. <view class="ziliao">{{item.videoElesName}}</view>
  26. <image src="../../static/xiazai.png" class="xiazai" @click="download(item)"></image>
  27. </view>
  28. <view style="height:20px"></view>
  29. <!-- <view style="width: 690rpx;margin-left: 40px;margin-top: 10px;">
  30. <view class="ziliao">资料2</view>
  31. <image src="../../static/xiazai.png" class="xiazai"></image>
  32. </view> -->
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. export default {
  38. data() {
  39. return {
  40. name:'xxx',//用户名
  41. phone:'xxxxxxxxxxx',//手机号
  42. fileUrl:'https://chuanghai-tech.com/video/txt.pdf',//下载链接
  43. list:[],//当前页面数组数据
  44. list2:[],//下载的东西2
  45. token:'',//缓存token
  46. resultDecodeN:'',//解密后数据
  47. }
  48. },
  49. onShow() {
  50. if(wx.getStorageSync('userName')!='' || wx.getStorageSync('telPhone')!=''){
  51. this.name=wx.getStorageSync('userName')
  52. this.phone=wx.getStorageSync('telPhone')
  53. }
  54. this.token=wx.getStorageSync('token')
  55. this.getList()
  56. if(wx.getStorageSync('token')==''){
  57. uni.navigateTo({
  58. url:'/pages/login/login'
  59. })
  60. }
  61. },
  62. onLoad() {
  63. },
  64. methods: {
  65. //列表
  66. getList(){
  67. this.list=[]
  68. this.resultDecodeN=''
  69. this.$axios.get('/videos/api/video/video',
  70. {
  71. headers:{
  72. 'token':wx.getStorageSync('token')
  73. }
  74. }
  75. ).then(res => {
  76. if(res.data.message=='token已过期'){
  77. uni.navigateTo({
  78. url:'/pages/login/login'
  79. })
  80. }
  81. if (res.data.success) {
  82. var shu=res.data.data
  83. var length=Object.values(res.data.data).length
  84. // console.log(Object.values(res.data.data).length)
  85. // 开始解密
  86. for(var i=0;i<length;i++){
  87. this.resultDecodeN =this.resultDecodeN+this.$fns.rsaDecode(shu[i])
  88. }
  89. // 开始解密
  90. // this.resultDecodeN = this.$fns.rsaDecode(shu[0])+
  91. // this.$fns.rsaDecode(shu[1])+this.$fns.rsaDecode(shu[2])+
  92. // this.$fns.rsaDecode(shu[3])+this.$fns.rsaDecode(shu[4])+
  93. // this.$fns.rsaDecode(shu[5])+this.$fns.rsaDecode(shu[6])+
  94. // this.$fns.rsaDecode(shu[7])+this.$fns.rsaDecode(shu[8])+
  95. // this.$fns.rsaDecode(shu[9])
  96. //解析
  97. console.log(this.resultDecodeN);
  98. console.log(JSON.parse(this.resultDecodeN));
  99. //获取数组
  100. JSON.parse(this.resultDecodeN).forEach(data => {
  101. this.list.push(data)
  102. // this.list2.push(data.videoElseList)
  103. })
  104. } else {
  105. uni.showToast({ title: res.data.message, icon: 'none' });
  106. }
  107. }).catch(res =>{
  108. });
  109. },
  110. //跳转播放视频
  111. playVideo(item){
  112. uni.navigateTo({
  113. url:'/pages/video/video?id='+item.id
  114. })
  115. },
  116. //下载文件
  117. download(item) {
  118. if(this.isIos()){
  119. uni.navigateTo({
  120. url:'/pages/IOSDownLoad/IOSDownLoad?url='+item.videoElesUrl
  121. })
  122. }else{
  123. //直接在浏览器中打开
  124. window.location.href = 'http://139.199.2.142:8081//img'+item.videoElesUrl;
  125. }
  126. },
  127. //判断是否ios
  128. isIos() {
  129. let u = navigator.userAgent
  130. let isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)
  131. if (isIOS) {
  132. return true
  133. } else {
  134. return false
  135. }
  136. },
  137. //分享链接
  138. share(){
  139. wx.setClipboardData({
  140. data: uni.getStorageSync('url'),
  141. success: function(res) {
  142. wx.showToast({
  143. title: '复制'+uni.getStorageSync('url')+'成功',
  144. icon: "none",
  145. mask: "true"
  146. })
  147. }
  148. })
  149. },
  150. //退出登录
  151. loginout(){
  152. uni.navigateTo({
  153. url:'/pages/login/login'
  154. })
  155. }
  156. }
  157. }
  158. </script>
  159. <style>
  160. .container {
  161. padding: 10px 20px 20px 0px;
  162. font-size: 16px;
  163. line-height: 24px;
  164. background-image: url('../../static/indexbg.png');
  165. background-size: 100%;
  166. width: 750rpx;
  167. height: 1334rpx;
  168. }
  169. .touxiang{
  170. width: 100rpx;
  171. height: 100rpx;
  172. padding: 10px 10px 10px 10px;
  173. }
  174. .username{
  175. margin-left: 70px;
  176. margin-top: -65px;
  177. color: #FFFFFF;
  178. }
  179. .phone{
  180. margin-left: 70px;
  181. font-size: 14px;
  182. color: #FFFFFF;
  183. }
  184. .share{
  185. width: 50rpx;
  186. height: 50rpx;
  187. /* position: absolute; */
  188. margin-left: 160px;
  189. margin-top: -15px;
  190. background-size: 100%;
  191. }
  192. .loginout{
  193. width: 50rpx;
  194. height: 50rpx;
  195. /* position: absolute; */
  196. margin-left: 10px;
  197. margin-top: -15px;
  198. background-size: 100%;
  199. }
  200. /* 项目列表 */
  201. .list-item{
  202. margin-top: 10px;
  203. width: 750rpx;
  204. height: auto;
  205. border-radius: 15rpx;
  206. background-color: rgba(255, 255, 255, 0.2);
  207. }
  208. .list-title{
  209. padding-top: 20px;
  210. font-size: 27px;
  211. text-align: center;
  212. color: #FFFFFF;
  213. }
  214. .list-icon{
  215. margin-left: 20px;
  216. margin-top: 20rpx;
  217. width: 8rpx;
  218. height: 32rpx;
  219. opacity: 1;
  220. border-radius: 33rpx;
  221. background: #1E7DFB;
  222. }
  223. .list-title2{
  224. margin-top: -20px;
  225. margin-left: 30px;
  226. color: #FFFFFF;
  227. }
  228. /* 视频 */
  229. .video{
  230. width: 394rpx;
  231. height: 200rpx;
  232. background-color: antiquewhite;
  233. /* float: left; */
  234. }
  235. .jieshao{
  236. margin-top: -100px;
  237. margin-left: 220px;
  238. color: #FFFFFF;
  239. }
  240. .xiang{
  241. margin-left: 220px;
  242. margin-top: 10px;
  243. color: #FFFFFF;
  244. }
  245. /* 资料 */
  246. .ziliao{
  247. width: 200px;
  248. line-height: 40rpx;
  249. font-size: 32rpx;
  250. float: left;
  251. color: #FFFFFF;
  252. }
  253. .xiazai{
  254. width: 40rpx;
  255. height: 40rpx;
  256. margin-left: 120px;
  257. background-size: 100%;
  258. /* float: right; */
  259. }
  260. </style>