index.vue 9.0 KB

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