find.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <view>
  3. <view class="flex">
  4. <view class="list-item add-btn" >
  5. <uni-icons type="plus-filled" size="30" color="#333" @click="addVideo"></uni-icons>
  6. </view>
  7. <swiper class="swiper-container" :autoplay="false" :duration="1000" display-multiple-items="5">
  8. <swiper-item v-for="(item,index) in cate_list" :key="index" @click="changeItem(item,index)">
  9. <view class="list-item">
  10. <text :class="{active:active_index == index}">{{item.name}}</text>
  11. </view>
  12. </swiper-item>
  13. </swiper>
  14. </view>
  15. <scroll-view class="video-list" :style="{height:scrollHeight+'px',width:sys.windowWidth+'px'}" scroll-x="false" scroll-y="true" @scrolltolower="getVideoList">
  16. <view class="video-item" v-for="(item,index) in videoList" :key="index" @click="toDetail(item.id)">
  17. <image :src="static_url+item.gif" mode="aspectFill"></image>
  18. <view class="cover">
  19. <view class="flex align-center">
  20. <image @click.stop="handleUser(item.user_id)" :src="static_photo+item.user_info.face" class="avatar" alt="头像">
  21. <text class="text-white margin-left-sm name">{{item.user_info.username}}</text>
  22. </view>
  23. <view class="flex align-center" @click.stop="handleLike(item)">
  24. <text :class="{ 'text-red': item.is_fabulous == 1 }"
  25. class="icon text-xxl">&#xe635;</text>
  26. <text class="text-white margin-left-xs text-min">{{ item.fabulous }}</text>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="nomore" v-if="videoList.length == 0">
  31. <image src="../../static/theme/default/nomore.png" mode="widthFix"></image>
  32. <text>没有更多了。。</text>
  33. </view>
  34. </scroll-view>
  35. </view>
  36. </template>
  37. <script>
  38. import _mixins from '@/common/_mixins';
  39. import _data from "@/common/_data";
  40. import uniIcons from '@/components/uni-icons/uni-icons.vue'
  41. import uniLoadMore from '@/components/uni-ui/uni-load-more/uni-load-more.vue'
  42. import uniStatusBar from '@/components/uni-ui/uni-status-bar/uni-status-bar.vue'
  43. export default{
  44. data(){
  45. return{
  46. cate_list:[],
  47. active_index:0,
  48. videoList:[],//视频列表
  49. current_page:1,
  50. scrollHeight:'',
  51. sys:{},//系统高度
  52. static_url:'',
  53. static_photo:'',
  54. }
  55. },
  56. components:{
  57. uniIcons,
  58. uniLoadMore,
  59. uniStatusBar
  60. },
  61. mounted() {
  62. const sys = uni.getSystemInfoSync();
  63. this.sys = {
  64. windowWidth: sys.windowWidth,
  65. windowHeight: sys.windowHeight,
  66. status:sys.statusBarHeight
  67. };
  68. console.log("this.sys",this.sys);
  69. this.scrollHeight = this.sys.windowHeight - 50;
  70. this.static_url = getApp().globalData.static_url;
  71. console.log(this.static_url,'this.static_url');
  72. this.static_photo = _data.staticPhoto();
  73. this.getCate();
  74. },
  75. methods:{
  76. // 获取分类
  77. getCate(){
  78. this.$httpSend({
  79. path: '/im/video.Share/category',
  80. success: (data) => {
  81. console.log("data", data);
  82. this.cate_list = data;
  83. this.getVideoList();
  84. }
  85. })
  86. },
  87. addVideo(){
  88. uni.navigateTo({
  89. url:'./add?type=video',
  90. });
  91. },
  92. toDetail(id) {
  93. uni.navigateTo({
  94. url: './detail?id=' + id,
  95. })
  96. },
  97. handleUser(user_no) {
  98. uni.navigateTo({
  99. url: `/pages/video/user?id=${user_no}`,
  100. });
  101. },
  102. async handleLike(item) {
  103. _mixins.methods.$httpSend({
  104. path: "/im/video.Share/fabulous",
  105. data: {
  106. id: item.id,
  107. },
  108. success: (data) => {
  109. if (data.code == 0) {
  110. item.is_fabulous = !item.is_fabulous;
  111. if (item.is_fabulous) {
  112. item.fabulous++;
  113. } else {
  114. item.fabulous--;
  115. }
  116. } else {
  117. uni.showToast({
  118. icon: "none",
  119. title: data.msg,
  120. });
  121. }
  122. },
  123. });
  124. },
  125. changeItem(e,index){
  126. this.active_index = index;
  127. this.current_page = 1;
  128. this.videoList = [];
  129. this.getVideoList();
  130. },
  131. getVideoList(){
  132. _mixins.methods.$httpSend({
  133. path: "/im/video.Share/video_lists",
  134. data: {
  135. type: this.cate_list[this.active_index]?this.cate_list[this.active_index].id:'',
  136. page:this.current_page
  137. },
  138. success: (data) => {
  139. this.last_page = data.last_page;
  140. if (this.current_page <= data.last_page) {
  141. this.current_page++;
  142. this.videoList = this.videoList.concat(data.data);
  143. }
  144. // console.log("this.videoList", this.videoList);
  145. },
  146. fail: (err) => {
  147. console.log("err", err);
  148. }
  149. });
  150. }
  151. }
  152. }
  153. </script>
  154. <style lang="scss" scoped>
  155. @import '@/static/css/common.css';
  156. .nomore{
  157. width: 200rpx;
  158. margin: 100rpx auto;
  159. image{
  160. width: 100%;
  161. height: auto;
  162. }
  163. }
  164. .swiper-container{
  165. height: 100rpx;
  166. background: #ffffff;
  167. flex: 1;
  168. }
  169. .scroll{
  170. white-space: nowrap;
  171. background: #ffffff;
  172. }
  173. .list-item{
  174. display: inline-block;
  175. width: 160rpx;
  176. height: 100rpx;
  177. line-height: 100rpx;
  178. text-align: center;
  179. text{
  180. color: #213547;
  181. }
  182. }
  183. .list-item .active{
  184. font-weight: bold;
  185. }
  186. .add-btn{
  187. display: inline-block;
  188. width: 100rpx;
  189. height: 100rpx;
  190. line-height: 100rpx;
  191. text-align: center;
  192. background: #fff;
  193. }
  194. .video-list{
  195. }
  196. .video-item{
  197. display: inline-block;
  198. width: 48%;
  199. height: 500rpx;
  200. border-radius: 10rpx;
  201. overflow: hidden;
  202. margin: 1%;
  203. position: relative;
  204. image{
  205. width: 100%;
  206. height: 100%;
  207. background-color: grey;
  208. }
  209. .cover{
  210. bottom: 0;
  211. height: 120rpx;
  212. position: absolute;
  213. left:0;
  214. width: 100%;
  215. display: flex;
  216. justify-content: space-between;
  217. align-items: center;
  218. box-sizing: border-box;
  219. padding: 10rpx;
  220. .avatar{
  221. width: 80rpx;
  222. height: 80rpx;
  223. border-radius: 50%;
  224. }
  225. .name{
  226. width:100rpx;//固定宽度
  227. overflow:hidden;
  228. text-overflow:ellipsis;
  229. white-space:nowrap;
  230. }
  231. }
  232. }
  233. </style>