applist.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. <template>
  2. <scroll-view scroll-y class="content" @scrolltolower='onBottom'>
  3. <topbar />
  4. <view class="back">
  5. <view class="sticky">
  6. <van-search class='top-search' shape="round" background="#fff" placeholder="请输入搜索关键词" @search="onSearch" @change='onSearchChange' />
  7. <view class="grid">
  8. <view class="grid-item" :class="{border:listType==0}" @click="listType=0">
  9. <van-icon name="/static/imgs/jx.png" size="30px" />
  10. <text class="text">精选</text>
  11. </view>
  12. <view class="grid-item" :class="{border:listType==item.id}" @click="listType=item.id" v-for="(item,index) in typeList"
  13. :key='index'>
  14. <van-icon :name="item.fileUrl || '/static/imgs/wxtb.png'" size="30px" />
  15. <text class="text">{{item.productName}}</text>
  16. </view>
  17. <view class="grid-item" :class="{border:listType==5}" @click="moreShow=!moreShow,typeMore()">
  18. <van-icon v-if='moreShow' name="/static/imgs/sq.png" size="30px" />
  19. <van-icon v-else name="/static/imgs/gd.png" size="30px" />
  20. <text class="text">{{moreShow?'收起':'更多'}}</text>
  21. </view>
  22. </view>
  23. </view>
  24. <loadSke :loading='loading' :list='applist'>
  25. <view class='list-item' v-for="(item, index) in applist" :key="index" @click="clickJumpType(item)">
  26. <image class="avatar" mode="aspectFit" :src="item.appletLogoFileUrl || '/static/imgs/shmr.png'" />
  27. <view class="top">
  28. <van-icon class="icon" v-if="item.collectionStatus=='0'" @tap.stop='addSc(index)' name="star-o" color='#999999' />
  29. <van-icon class="icon" v-else @tap.stop='delSc(index)' name="star" color='#dfdf00' />
  30. <van-icon class="icon" name="ellipsis" size='20' color='#999999' @tap.stop='showShare=true' />
  31. </view>
  32. <view class="item-right">
  33. <view class="bottom">
  34. <text class="title">{{item.corporateName}}</text>
  35. <text class="type">{{itemType(item)}}</text>
  36. <view class="right" v-if="false">
  37. <view class="flex">
  38. <van-icon class="icon" name="/static/imgs/评论.png" size='15' />
  39. <text>54</text>
  40. </view>
  41. <view class="flex">
  42. <van-icon class="icon" name="/static/imgs/好评率.png" size='15' />
  43. <text>99%</text>
  44. </view>
  45. </view>
  46. </view>
  47. <view class="center" v-if="item.appletIntroduce">
  48. <text class="details">{{item.appletIntroduce || `Appid: ${item.appletAddress}`}}</text>
  49. </view>
  50. </view>
  51. </view>
  52. <view v-if="bottomLoading" class="bottom-loading">
  53. 正在加载中...
  54. </view>
  55. <view class="ad-box list-item">
  56. <ad unit-id="adunit-d8c1548cc9663765"></ad>
  57. </view>
  58. <view class="ad-box list-item">
  59. <ad-custom unit-id="adunit-66504f2e91ee7be4"></ad-custom>
  60. </view>
  61. </loadSke>
  62. </view>
  63. <van-share-sheet :show="showShare" :options="options" @select="onSelect" @close='shareClose' />
  64. </scroll-view>
  65. </template>
  66. <script>
  67. import {
  68. debounce
  69. } from '@/utils/utils.js'
  70. import {
  71. typeList,
  72. getTypeAppList,
  73. addFavorites,
  74. delFavorites,
  75. BrowseRecordAdd,
  76. getCarouselChartList
  77. } from '@/api/applist.js'
  78. export default {
  79. data() {
  80. return {
  81. comname: 'xueche',
  82. active: 0,
  83. tabActive: 0,
  84. info: [{
  85. "id": 12,
  86. "pictureName": "山泉心品",
  87. "fileId": "77",
  88. "fileUrl": "http://image.jppt.com.cn/zzjs/2021-04-09/others/1617954376809.jpg",
  89. "jumpUrl": "{\"appId\":\"wxb47185e82704dda8\"}",
  90. "jumpUrlType": "goMiniApp",
  91. "status": 0
  92. }],
  93. current: 0,
  94. mode: 'round',
  95. applist: [],
  96. typeList: {},
  97. listType: 0,
  98. loading: true,
  99. showShare: false,
  100. moreShow: false,
  101. options: [{
  102. name: '微信',
  103. icon: 'wechat',
  104. openType: 'share'
  105. }],
  106. pageNum: 1,
  107. pageSize: 10,
  108. total: 1,
  109. customerName: '',
  110. bottomLoading: false
  111. }
  112. },
  113. mounted() {
  114. this.initAppList()
  115. },
  116. watch: {
  117. listType(val) {
  118. this.customerName = ''
  119. this.pageNum = 1
  120. this.loading = true
  121. getTypeAppList(val, {
  122. pageNum: this.pageNum,
  123. pageSize: this.pageSize
  124. }).then(res => {
  125. this.applist = res.rows
  126. this.total = res.total
  127. this.$nextTick(() => {
  128. this.loading = false
  129. })
  130. })
  131. }
  132. },
  133. methods: {
  134. itemType(item) {
  135. if (item.jumpUrlType == 'goMiniApp') {
  136. return '小程序'
  137. }
  138. if (item.jumpUrlType == 'goPage') {
  139. return '子页面'
  140. }
  141. if (item.jumpUrlType == 'goWebView') {
  142. return 'WEB'
  143. }
  144. },
  145. onSearchChange(e) {
  146. this.customerName = e.detail
  147. },
  148. onSearch(e) {
  149. this.pageNum = 1
  150. this.loading = true
  151. getTypeAppList(this.listType, {
  152. pageNum: this.pageNum,
  153. pageSize: this.pageSize,
  154. customerName: e.detail
  155. }).then(res => {
  156. this.applist = res.rows
  157. this.total = res.total
  158. this.$nextTick(() => {
  159. this.loading = false
  160. })
  161. })
  162. },
  163. initAppList() {
  164. typeList({
  165. pid: 0
  166. }).then(res => {
  167. this.typeList = res.rows.slice(0, 8)
  168. })
  169. getTypeAppList(0, {
  170. pageNum: 1,
  171. pageSize: 10
  172. }).then(res => {
  173. this.applist = res.rows
  174. this.total = res.total
  175. this.$nextTick(() => {
  176. this.loading = false
  177. })
  178. })
  179. },
  180. onBottom() {
  181. if(this.bottomLoading) return
  182. if (this.total - this.pageNum * this.pageSize <= 0) {
  183. return
  184. }
  185. this.bottomLoading=true
  186. this.pageNum++
  187. getTypeAppList(this.listType, {
  188. pageNum: this.pageNum,
  189. pageSize: this.pageSize,
  190. customerName: this.customerName
  191. }).then(res => {
  192. this.applist = this.applist.concat(res.rows)
  193. this.$nextTick(()=>{
  194. this.bottomLoading=false
  195. })
  196. })
  197. },
  198. typeMore() {
  199. if (this.moreShow) {
  200. typeList({
  201. pid: 0
  202. }).then(res => {
  203. this.typeList = res.rows
  204. })
  205. } else {
  206. this.typeList = this.typeList.slice(0, 8)
  207. }
  208. },
  209. addSc(index) {
  210. addFavorites(this.applist[index].id).then(res => {
  211. if (res.code == 200) {
  212. this.$set(this.applist[index], 'collectionStatus', '1')
  213. this.Toast('收藏成功!');
  214. }
  215. })
  216. },
  217. delSc(index) {
  218. delFavorites(this.applist[index].id).then(res => {
  219. if (res.code == 200) {
  220. this.$set(this.applist[index], 'collectionStatus', '0')
  221. this.Toast('取消收藏成功!');
  222. }
  223. })
  224. },
  225. shareClose() {
  226. this.showShare = false;
  227. },
  228. onSelect(event) {
  229. this.Toast(event.detail.name);
  230. this.onClose();
  231. },
  232. getAppList() {
  233. featuredAppList({
  234. pageNum: 1,
  235. pageSize: 10
  236. }).then(res => {
  237. console.log(res)
  238. this.applist = res.rows
  239. this.$nextTick(() => {
  240. this.loading = false
  241. })
  242. })
  243. }
  244. }
  245. }
  246. </script>
  247. <style lang="scss" scoped>
  248. .bottom-loading {
  249. text-align: center;
  250. padding: 10rpx;
  251. }
  252. .ad-box {
  253. margin: 40rpx;
  254. box-sizing: border-box;
  255. display: flex;
  256. justify-content: center !important;
  257. align-items: center;
  258. }
  259. .content {
  260. padding-bottom: 1rpx;
  261. height: 100%;
  262. }
  263. .swiper-box {
  264. width: 100vw;
  265. height: 56.25vw;
  266. .image {
  267. width: 100%;
  268. height: 100%;
  269. }
  270. }
  271. .sticky {
  272. position: sticky;
  273. top: 0rpx;
  274. left: 0;
  275. background-color: #fff;
  276. z-index: 9;
  277. margin-bottom: 20rpx;
  278. .grid {
  279. display: flex;
  280. flex-wrap: wrap;
  281. justify-content: flex-start;
  282. overflow: auto;
  283. .grid-item {
  284. flex-shrink: 0;
  285. width: 20%;
  286. height: 130rpx;
  287. display: flex;
  288. justify-content: center;
  289. flex-direction: column;
  290. align-items: center;
  291. text-align: center;
  292. font-size: 34rpx;
  293. padding: 10rpx;
  294. box-sizing: border-box;
  295. position: relative;
  296. .text {
  297. font-size: .8em;
  298. margin-top: 5rpx;
  299. color: #999999;
  300. font-weight: 400;
  301. }
  302. }
  303. .border::after {
  304. content: '';
  305. position: absolute;
  306. bottom: 5rpx;
  307. width: 30rpx;
  308. height: 5rpx;
  309. background-color: red;
  310. }
  311. }
  312. }
  313. .list-item {
  314. display: flex;
  315. align-items: center;
  316. justify-content: space-between;
  317. background-color: #FFFFFF;
  318. padding: 20rpx;
  319. margin: 2rpx 0rpx;
  320. position: relative;
  321. .avatar {
  322. flex-shrink: 0;
  323. width: 100rpx;
  324. height: 100rpx;
  325. border-radius: 50%;
  326. border: 1px solid #1989FA;
  327. margin-right: 16rpx;
  328. }
  329. .top {
  330. display: flex;
  331. justify-content: flex-end;
  332. position: absolute;
  333. top: 10rpx;
  334. right: 0;
  335. .icon {
  336. margin-top: -20rpx;
  337. padding: 20rpx;
  338. }
  339. }
  340. .item-right {
  341. flex: 1;
  342. display: flex;
  343. flex-direction: column;
  344. justify-content: space-between;
  345. // height: 200rpx;
  346. .center {
  347. align-self: flex-start;
  348. .details {
  349. width: 436rpx;
  350. // height: 70rpx;
  351. font-size: 26rpx;
  352. font-family: PingFang SC;
  353. font-weight: 400;
  354. color: #999999;
  355. display: -webkit-box;
  356. margin-bottom: 20rpx;
  357. overflow: hidden;
  358. text-overflow: ellipsis;
  359. word-wrap: break-word;
  360. white-space: normal !important;
  361. -webkit-line-clamp: 2;
  362. -webkit-box-orient: vertical;
  363. }
  364. }
  365. .bottom {
  366. display: flex;
  367. justify-content: flex-start;
  368. align-items: center;
  369. margin: 20rpx 0;
  370. .title {
  371. max-width: 300rpx;
  372. white-space: nowrap;
  373. text-overflow: ellipsis;
  374. overflow: hidden;
  375. word-break: break-all;
  376. font-family: PingFang SC;
  377. font-weight: 400;
  378. }
  379. .type {
  380. margin-left: 10rpx;
  381. padding: 3rpx 12rpx;
  382. height: 30rpx;
  383. border: 2rpx solid #999999;
  384. border-radius: 20rpx;
  385. font-size: 20rpx;
  386. color: #999999;
  387. line-height: 20rpx;
  388. display: flex;
  389. justify-content: center;
  390. align-items: center;
  391. }
  392. .right {
  393. width: 170rpx;
  394. display: flex;
  395. justify-content: space-between;
  396. align-items: center;
  397. font-size: 22rpx;
  398. font-family: PingFang SC;
  399. font-weight: 400;
  400. color: #999999;
  401. line-height: 35rpx;
  402. .flex {
  403. display: flex;
  404. justify-content: center;
  405. .icon {
  406. margin-right: 5rpx;
  407. }
  408. }
  409. }
  410. }
  411. }
  412. }
  413. </style>