index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <template>
  2. <home-frame @toPath="toPath">
  3. <view class="main">
  4. <view class="one">
  5. <view class="list" v-for="(item,index) in typeList" :key="index" @tap="typeChange(item,index)">
  6. <span :style="{background:tActive==index?'var(--rgbfa4)':''}" class="textOver">{{item.title}}</span>
  7. </view>
  8. </view>
  9. <view class="two">
  10. <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
  11. <view class="list-scroll-view">
  12. <view class="two_1">
  13. 推荐
  14. </view>
  15. <view class="two_2">
  16. <view class="list" v-for="(item,index) in recomList" :key="index"
  17. @tap="toCommon('pagesVideo/more/index',item)">
  18. <image class="image"
  19. :src="item.img_url&&item.img_url.length>0?item.img_url[0].url:'../../static/error.jpg'"
  20. mode="">
  21. </image>
  22. <span class="name" v-if="item.title">{{item.title}}</span>
  23. </view>
  24. </view>
  25. <view class="two_1">
  26. 全部
  27. </view>
  28. <view class="two_2">
  29. <view class="list" v-for="(item,index) in list" :key="index"
  30. @tap="toCommon('pagesVideo/more/index',item)">
  31. <image class="image"
  32. :src="item.img_url&&item.img_url.length>0?item.img_url[0].url:'../../static/error.jpg'"
  33. mode="">
  34. </image>
  35. <span class="name" v-if="item.title">{{item.title}}</span>
  36. </view>
  37. </view>
  38. </view>
  39. </scroll-view>
  40. </view>
  41. </view>
  42. </home-frame>
  43. </template>
  44. <script>
  45. import homeFrame from "../components/home-frame.vue";
  46. export default {
  47. components: {
  48. homeFrame
  49. },
  50. data() {
  51. return {
  52. typeList: [],
  53. tActive: 0,
  54. type_id: '',
  55. recomList: [],
  56. list: [],
  57. total: 0,
  58. page: 0,
  59. skip: 0,
  60. limit: 20,
  61. // 数据是否触底
  62. is_bottom: false,
  63. scrollTop: 0
  64. };
  65. },
  66. onLoad() {
  67. },
  68. onShow() {
  69. const that = this;
  70. that.search()
  71. },
  72. onHide() {
  73. const that = this;
  74. that.clearPage()
  75. },
  76. methods: {
  77. async search() {
  78. const that = this;
  79. let res = await that.$api('scenetype', 'GET', {
  80. is_use: '0'
  81. })
  82. if (res.errcode == '0') {
  83. that.$set(that, `typeList`, res.data);
  84. if (res.total > 0) {
  85. that.$set(that, `type_id`, res.data[0]._id);
  86. that.searchScene()
  87. that.searchData()
  88. }
  89. }
  90. },
  91. // 类型选择
  92. typeChange(e, index) {
  93. const that = this;
  94. that.$set(that, `tActive`, index);
  95. that.$set(that, `type_id`, e._id);
  96. that.clearPage();
  97. that.searchScene();
  98. that.searchData();
  99. },
  100. // 查询推荐
  101. async searchScene() {
  102. const that = this;
  103. let res = await that.$api('scenedata', 'GET', {
  104. skip: 0,
  105. limit: 6,
  106. type_id: that.type_id,
  107. is_scene: '1',
  108. is_use: '0',
  109. })
  110. if (res.errcode == '0') {
  111. that.$set(that, `recomList`, res.data);
  112. }
  113. },
  114. // 查询数据
  115. async searchData() {
  116. const that = this;
  117. let res = await that.$api('scenedata', 'GET', {
  118. skip: that.skip,
  119. limit: that.limit,
  120. type_id: that.type_id,
  121. is_use: '0',
  122. })
  123. if (res.errcode == '0') {
  124. let list = [...that.list, ...res.data]
  125. that.$set(that, `list`, list);
  126. that.$set(that, `total`, res.total);
  127. }
  128. },
  129. toPage() {
  130. const that = this;
  131. let list = that.list;
  132. let limit = that.limit;
  133. if (that.total > list.length) {
  134. uni.showLoading({
  135. title: '加载中',
  136. mask: true
  137. })
  138. let page = that.page + 1;
  139. that.$set(that, `page`, page)
  140. let skip = page * limit;
  141. that.$set(that, `skip`, skip)
  142. that.searchData();
  143. uni.hideLoading();
  144. } else that.$set(that, `is_bottom`, true)
  145. },
  146. toScroll(e) {
  147. const that = this;
  148. let up = that.scrollTop;
  149. that.$set(that, `scrollTop`, e.detail.scrollTop);
  150. let num = Math.sign(up - e.detail.scrollTop);
  151. if (num == 1) that.$set(that, `is_bottom`, false);
  152. },
  153. async toCommon(route, e) {
  154. const that = this;
  155. let res;
  156. let firm_id = '';
  157. let type_id = '';
  158. let place_id = '';
  159. let year = '';
  160. let head_actor = '';
  161. res = await that.$api(`scenetype/${e.type_id}`, 'GET', {});
  162. if (res.errcode == '0') {
  163. if (res.data && res.data.title == "厂商") {
  164. firm_id = e.id;
  165. } else if (res.data && res.data.title == "类型") {
  166. type_id = e.id;
  167. } else if (res.data && res.data.title == "产地") {
  168. place_id = e.id;
  169. } else if (res.data && res.data.title == "年份") {
  170. year = e.id;
  171. } else if (res.data && res.data.title == "演员") {
  172. head_actor = e.id;
  173. }
  174. }
  175. let query = firm_id ? `firm_id=${firm_id}` : type_id ? `type_id=${type_id}` : place_id ?
  176. `place_id=${place_id}` : year ? `year=${year}` : head_actor ? `head_actor=${head_actor}` : '';
  177. uni.navigateTo({
  178. url: `/${route}?${query}`
  179. })
  180. },
  181. // 清空列表
  182. clearPage() {
  183. const that = this;
  184. that.$set(that, `list`, [])
  185. that.$set(that, `skip`, 0)
  186. that.$set(that, `limit`, 20)
  187. that.$set(that, `page`, 0)
  188. },
  189. // 跳转页面
  190. toPath(e) {
  191. let url = `/${e.route}`;
  192. if (e.type == '0') uni.navigateTo({
  193. url
  194. })
  195. else if (e.type == '1') uni.redirectTo({
  196. url
  197. })
  198. else if (e.type == '2') uni.reLaunch({
  199. url
  200. })
  201. else if (e.type == '3') uni.switchTab({
  202. url
  203. })
  204. }
  205. },
  206. };
  207. </script>
  208. <style lang="scss">
  209. .main {
  210. background-color: var(--rgb111);
  211. display: flex;
  212. flex-direction: row;
  213. width: 96vw;
  214. height: 92vh;
  215. padding: 0 2vw;
  216. .one {
  217. width: 24vw;
  218. color: var(--rgbfff);
  219. margin: 0 10px 0 0;
  220. background-color: var(--rgb000);
  221. overflow-y: auto;
  222. .list {
  223. span {
  224. display: inline-block;
  225. width: 100%;
  226. height: 40px;
  227. line-height: 40px;
  228. text-align: center;
  229. font-size: 14px;
  230. }
  231. }
  232. }
  233. .two {
  234. flex-grow: 1;
  235. color: var(--rgbfff);
  236. background-color: var(--rgb000);
  237. padding: 0 2vw;
  238. overflow-y: auto;
  239. position: relative;
  240. .two_1 {
  241. padding: 1vw 0;
  242. }
  243. .two_2 {
  244. display: flex;
  245. // justify-content: space-around;
  246. flex-wrap: wrap;
  247. position: relative;
  248. .list {
  249. width: 30%;
  250. height: 70px;
  251. overflow: hidden;
  252. position: relative;
  253. margin: 0 10px 10px 0;
  254. box-shadow: 0 0 5px var(--rgbf1f);
  255. border-radius: 5px;
  256. .image {
  257. width: 100%;
  258. height: 100%;
  259. border-radius: 5px;
  260. }
  261. .name {
  262. position: absolute;
  263. bottom: 10px;
  264. width: 100%;
  265. text-align: center;
  266. left: 0;
  267. color: var(--rgbfff);
  268. font-size: 12px;
  269. font-family: monospace;
  270. }
  271. }
  272. .list:nth-child(3n) {
  273. margin: 0 0 10px 0;
  274. }
  275. }
  276. }
  277. }
  278. .scroll-view {
  279. position: absolute;
  280. top: 0;
  281. left: 0;
  282. right: 0;
  283. bottom: 0;
  284. .list-scroll-view {
  285. display: flex;
  286. flex-direction: column;
  287. padding: 0 2vw;
  288. }
  289. }
  290. .is_bottom {
  291. text-align: center;
  292. text {
  293. padding: 2vw 0;
  294. display: inline-block;
  295. color: #858585;
  296. font-size: 14px;
  297. }
  298. }
  299. </style>