index.vue 8.3 KB

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