applist.vue 9.3 KB

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