ss.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. <template>
  2. <view>
  3. <!-- <sub-tabnav :tabs="tabs" @change="changeIndex" :selectIndex="selectIndex" :scrollTop="scrollTop"></sub-tabnav> -->
  4. <!-- #ifdef MP-WEIXIN -->
  5. <view class="" style="background: #ffffff;">
  6. <uni-search-bar @confirm="search" :focus="false" placeholder="请输入搜索内容" v-model="searchValue" @blur="blur" @focus="focus" @input="input"
  7. @cancel="cancel" @clear="clear">
  8. </uni-search-bar>
  9. </view>
  10. <!-- #endif -->
  11. <view style="margin:10upx 30upx 0 30upx;box-shadow: 0px 4px 20px 0px rgba(0,0,0,0.04);">
  12. <home-banner :banners="banners"></home-banner>
  13. </view>
  14. <view class="flex space" style="display:flex; flex-wrap:wrap; padding: 30upx 30upx 0px 30upx;">
  15. <block v-for="(value,key) in listData" :key="key">
  16. <view class="box pb10 mb15" style="width:31%; border-radius:20rpx;" @click="detail(value.id,0)">
  17. <!-- <view class="btn-mini" style="position: absolute; top: 20upx; right: 20upx; border-radius: 10upx;font-size: 18upx;width: 60upx; height: 36upx; z-index: 1;" :style="getBtnStyle">{{value.lxname}}</view> -->
  18. <image class="integral-mall-goods" mode="aspectFill" :src="value.img"></image>
  19. <view class="mt8 plr10 ft14 ftw400 text-center text-over cl-main">{{value.name}}</view>
  20. </view>
  21. </block>
  22. <!-- <uni-pagination title="" @change="onPageChange" v-if="total>pageSize" show-icon="true" :pageSize="pageSize" :total="total" current="1"></uni-pagination> -->
  23. </view>
  24. <uni-load-more :status="status" :content-text="contentText" />
  25. <view style="width: 100%; height: 30upx;"></view>
  26. <!-- <dialog-login v-if="showLogin" @loginYes="loginYes" @closed="showLogin = false"></dialog-login> -->
  27. <!-- <com-footer model="tuan"></com-footer> -->
  28. </view>
  29. </template>
  30. <script>
  31. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  32. export default {
  33. components: {
  34. uniLoadMore
  35. },
  36. data(){
  37. return {
  38. banners:[],
  39. vipLevel:0,
  40. isLogin:true,
  41. showLogin:false,
  42. datasa:[],
  43. dataconfig:[],
  44. searchValue:'',
  45. total:0,
  46. pageSize:10,
  47. tabs:[
  48. {name:'全部'},
  49. {name:'视频'},
  50. {name:'音频'},
  51. {name:'小说'},
  52. {name:'壁纸'},
  53. ],
  54. selectIndex:0,
  55. scrollTop:0,
  56. type2tab:[],
  57. selecttype2:0,
  58. type2id:'',
  59. type3tab:[],
  60. selecttype3:0,
  61. type3id:'',
  62. type4tab:[],
  63. selecttype4:0,
  64. type4id:'',
  65. typetab:[],
  66. selecttype:0,
  67. typeid:'',
  68. addddtab:[],
  69. selectadddd:0,
  70. addddid:'',
  71. yeartab:[],
  72. selectyear:0,
  73. yearid:'',
  74. type:'',
  75. keytext:'',
  76. listData: [],
  77. last_id: 0,
  78. reload: true,
  79. status: 'more',
  80. contentText: {
  81. contentdown: '上拉加载更多',
  82. contentrefresh: '加载中',
  83. contentnomore: '没有数据了'
  84. }
  85. }
  86. },
  87. onLoad(e){
  88. //console.log(111)
  89. if(e.selectIndex){
  90. this.selectIndex=e.selectIndex*1
  91. }
  92. this.status = 'more';
  93. this.getList();
  94. this.banners=uni.getStorageSync("config").banner
  95. },
  96. onPageScroll(e){
  97. this.scrollTop = e.scrollTop;
  98. },
  99. onReachBottom() {
  100. this.status = 'more';
  101. this.getList();
  102. },
  103. //监听搜索框文本变化
  104. onNavigationBarSearchInputChanged(e) {
  105. let text = e.text;
  106. if(text){
  107. this.keytext=text;
  108. }
  109. console.log(text)
  110. },
  111. //监听点击搜索按钮事件
  112. onNavigationBarSearchInputConfirmed(e) {
  113. // #ifdef APP-PLUS
  114. plus.key.hideSoftKeybord();
  115. // #endif
  116. var this_=this
  117. let text = e.text;
  118. if (!text) {
  119. uni.showModal({
  120. title: '',
  121. content:"请输入搜索内容",
  122. showCancel: false,
  123. confirmText: "确定",
  124. confirmColor:"#e19503",
  125. success: function (res) {
  126. this_.keytext='';
  127. this_.getList(0)
  128. }
  129. });
  130. return;
  131. } else {
  132. this.keytext=text;
  133. this.listData=[];
  134. this.last_id=0;
  135. this.type='';
  136. this.getList(0)
  137. }
  138. },
  139. methods:{
  140. detail(vid,mid){
  141. var fxpid=1
  142. if(uni.getStorageSync("userinfo")){
  143. fxpid=uni.getStorageSync("userinfo").id
  144. }
  145. uni.navigateTo({
  146. url:'/pages/video/index?vid='+vid+'&mid='+mid+'&fxpid='+fxpid
  147. })
  148. },
  149. onPageChange(e) {
  150. this.last_id=0
  151. this.reload=true
  152. this.getList()
  153. uni.pageScrollTo({
  154. scrollTop: 0,
  155. duration: 100
  156. });
  157. },
  158. getList() {
  159. let data = {
  160. //column: 'id,post_id,title,author_name,cover,published_at' //需要的字段名
  161. };
  162. var limit=10;
  163. if (this.last_id>0) {
  164. //说明已有数据,目前处于上拉加载
  165. this.status = 'loading';
  166. data.offset = this.last_id*limit;
  167. data._ = new Date().getTime() + '';
  168. }
  169. data.limit=limit
  170. if(this.selectIndex){
  171. data.lx=this.selectIndex
  172. }
  173. if(this.typeid && this.selectIndex==1){
  174. data.typeid=this.typeid
  175. }
  176. if(this.addddid && this.selectIndex==1){
  177. data.addddid=this.addddid
  178. }
  179. if(this.yearid && this.selectIndex==1){
  180. data.yearid=this.yearid
  181. }
  182. if(this.type2id && this.selectIndex==2){
  183. data.typeid=this.type2id
  184. }
  185. if(this.type3id && this.selectIndex==3){
  186. data.typeid=this.type3id
  187. }
  188. if(this.type4id && this.selectIndex==4){
  189. data.typeid=this.type4id
  190. }
  191. if(this.keytext){
  192. data.keytext=this.keytext
  193. }
  194. uni.request({
  195. url: this.configs.webUrl+'/api/video/lists',
  196. data: data,
  197. success: data => {
  198. //console.log(data.data)
  199. this.yeartab=data.data.typedata.year
  200. this.addddtab=data.data.typedata.adddd
  201. this.typetab=data.data.typedata.type
  202. this.type2tab=data.data.typedata.type2
  203. this.type3tab=data.data.typedata.type3
  204. this.type4tab=data.data.typedata.type4
  205. if (data.data.total>0) {
  206. let list = data.data.rows;
  207. this.listData = this.reload ? list : this.listData.concat(list);
  208. this.reload = false;
  209. this.last_id = this.last_id+1;
  210. if(data.data.total<this.last_id*limit){
  211. this.status = '';
  212. }
  213. }else{
  214. this.listData=[];
  215. this.contentText.contentdown='没有数据'
  216. this.status=''
  217. }
  218. },
  219. fail: (data, code) => {
  220. //console.log('fail' + JSON.stringify(data));
  221. }
  222. });
  223. },
  224. changeIndex(index){
  225. this.selectIndex = index;
  226. this.type=this.tabs[index].name
  227. this.getdata()
  228. },
  229. changetype(index){
  230. this.selecttype = index;
  231. this.typeid=this.typetab[index].id
  232. this.getdata()
  233. },
  234. changeadddd(index){
  235. this.selectadddd = index;
  236. this.addddid=this.addddtab[index].id
  237. this.getdata()
  238. },
  239. changeyear(index){
  240. this.selectyear = index;
  241. this.yearid=this.yeartab[index].id
  242. this.getdata()
  243. },
  244. changetype2(index){
  245. this.selecttype2 = index;
  246. this.type2id=this.type2tab[index].id
  247. this.getdata()
  248. },
  249. changetype3(index){
  250. this.selecttype3 = index;
  251. this.type3id=this.type3tab[index].id
  252. this.getdata()
  253. },
  254. changetype4(index){
  255. this.selecttype4 = index;
  256. this.type4id=this.type4tab[index].id
  257. this.getdata()
  258. },
  259. getdata(){
  260. this.last_id=0
  261. this.reload=true
  262. this.getList()
  263. },
  264. loginYes(){
  265. },
  266. mlinkTo(e){
  267. if(this.isLogin == true){
  268. let link = e.currentTarget.dataset.link;
  269. }else{
  270. this.showLogin = true;
  271. }
  272. },
  273. search(res) {
  274. this.listData=[];
  275. this.last_id=0;
  276. this.keytext=res.value;
  277. this.type='';
  278. this.getList(0)
  279. },
  280. clear(res) {
  281. },
  282. input(res) {
  283. console.log('----input:', res)
  284. },
  285. blur(res) {
  286. // this.listData=[];
  287. // this.last_id=0;
  288. // this.keytext=res.value;
  289. // this.type='';
  290. // this.getList(0)
  291. //res.value
  292. },
  293. focus(e) {
  294. },
  295. cancel(res) {
  296. this.keytext='';
  297. this.type='';
  298. this.getList(0)
  299. }
  300. }
  301. }
  302. </script>
  303. <style>
  304. .integral-mall-goods{
  305. width: 100%;
  306. height: 280rpx;
  307. background: #F2F2F2;
  308. border-radius: 16upx;
  309. }
  310. .user-not-vip{
  311. width: 100%;
  312. height: 80rpx;
  313. background: #FDF6EC;
  314. border-radius: 40rpx;
  315. border: 2rpx solid #EFC381;
  316. text-align: center;
  317. line-height: 76rpx;
  318. font-size: 24rpx;
  319. color:#000000;
  320. font-weight: bold;
  321. }
  322. .tuan-product-l{
  323. width: 320rpx;
  324. height: 240rpx;
  325. border-radius: 16rpx;
  326. background: #F2F2F2;
  327. }
  328. .tuan-product-r{
  329. width: calc(100% - 320rpx);
  330. }
  331. .search-result {
  332. padding-top: 10px;
  333. padding-bottom: 20px;
  334. text-align: center;
  335. }
  336. .search-result-text {
  337. text-align: center;
  338. font-size: 14px;
  339. color:#666;
  340. }
  341. .example-body {
  342. /* #ifndef APP-NVUE */
  343. display: block;
  344. /* #endif */
  345. padding: 0px;
  346. }
  347. .uni-mt-10 {
  348. margin-top: 10px;
  349. }
  350. </style>