敢为人鲜小程序前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

414 lines
8.1 KiB

5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
  1. <template>
  2. <view class="home">
  3. <view style="background-color: white;">
  4. <!-- 导航栏 -->
  5. <navbar />
  6. <!-- 搜索栏 -->
  7. <view class="search">
  8. <uv-search placeholder="搜你喜欢的产品" bgColor="#fff" @custom="search" @search="search"
  9. v-model="keyword"></uv-search>
  10. </view>
  11. <!-- 轮播图 -->
  12. <view class="swipe">
  13. <uv-swiper :list="bannerList" indicator height="320rpx" keyName="image"></uv-swiper>
  14. </view>
  15. <!-- 首页-分类菜单 -->
  16. <view class="home-menu">
  17. <uv-grid :border="false" :col="5">
  18. <uv-grid-item v-for="(item,index) in baseList" :key="index" @click="toUrl(item.url)">
  19. <image :src="item.image" mode="aspectFill"></image>
  20. <text class="menu-text">{{item.title}}</text>
  21. </uv-grid-item>
  22. </uv-grid>
  23. </view>
  24. </view>
  25. <!-- 新人专享 -->
  26. <view class="new-people">
  27. <view class="new-perple-top">
  28. <view class="new-perple-top-left">
  29. <view class="title">
  30. 新人专享
  31. </view>
  32. <view class="descript">
  33. 领199元大礼包
  34. </view>
  35. </view>
  36. <view class="new-perple-top-right">
  37. <image src="@/static/image/home/view-more.png" mode="widthFix"></image>
  38. </view>
  39. </view>
  40. <view class="new-perple-main">
  41. <view class="red-packet">
  42. <image src="@/static/image/home/red-packet.png" mode="widthFix"></image>
  43. </view>
  44. <view v-for="item in 4" :key="item" class="activity">
  45. <image src="@/static/image/home/necklace.png" mode="widthFix"></image>
  46. <image src="@/static/image/home/exclusive.png" mode="widthFix"></image>
  47. <view class="product-price">
  48. 100
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. <!-- 视频 -->
  54. <view class="video-line">
  55. <view class="line"></view>
  56. 视频
  57. </view>
  58. <view class="video-list">
  59. <scroll-view class="scroll-view_H" scroll-x="true" @scroll="scroll">
  60. <view v-for="item in 10" class="video-item">
  61. <video src="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/2minute-demo.mp4"
  62. @error="videoErrorCallback" :danmu-list="danmuList" controls class="product-video"></video>
  63. </view>
  64. </scroll-view>
  65. </view>
  66. <!-- 推荐 -->
  67. <view class="recommend">
  68. <view class="recommend-title">推荐宝贝</view>
  69. <view class="recommend-more">更多</view>
  70. </view>
  71. <!-- 商品列表 -->
  72. <view style="position: 20rpx;">
  73. <productList :list="commonProductList" />
  74. </view>
  75. <!-- 全局弹框 -->
  76. <PrivacyAgreementPoup />
  77. <!-- 隐私政策用户协议弹框 -->
  78. <customerServicePopup ref="customerServicePopup" />
  79. <!-- tabbar -->
  80. <tabber select="home" />
  81. <!-- 优惠券弹窗 -->
  82. <couponPopup v-model="showCouponPopup"></couponPopup>
  83. </view>
  84. </template>
  85. <script>
  86. import PrivacyAgreementPoup from '@/components/config/PrivacyAgreementPoup.vue'
  87. import Position from '@/utils/position.js'
  88. import tabber from '@/components/base/tabbar.vue'
  89. import couponPopup from "@/components/couponPopup/couponPopup.vue"
  90. import {
  91. mapState
  92. } from 'vuex'
  93. import customerServicePopup from '@/components/config/customerServicePopup.vue'
  94. import productList from '@/components/user/productList.vue'
  95. import mixinsList from '@/mixins/list.js'
  96. export default {
  97. mixins: [mixinsList],
  98. components: {
  99. tabber,
  100. PrivacyAgreementPoup,
  101. customerServicePopup,
  102. productList,
  103. couponPopup
  104. },
  105. data() {
  106. return {
  107. notice: '',
  108. bannerList: [],
  109. baseList: [],
  110. productList: [],
  111. keyword: '',
  112. commonProductList: [], //常规产品
  113. riceProductList: [], //体验产品
  114. newList: [], //新闻列表
  115. mixinsListApi: 'getClassShophomeList',
  116. showCouponPopup : true
  117. }
  118. },
  119. computed: {},
  120. onLoad(query) {
  121. if (query.shareId) {
  122. uni.setStorageSync('shareId', query.shareId)
  123. }
  124. },
  125. onShow() {
  126. this.getBanner()
  127. this.getRiceNoticeList()
  128. this.getRiceIconList()
  129. this.getRiceCommonProductList()
  130. },
  131. onPullDownRefresh() {
  132. this.getBanner()
  133. this.getRiceNoticeList()
  134. },
  135. methods: {
  136. // 搜素
  137. search() {
  138. uni.navigateTo({
  139. url: '/homes/index/category?search=' + this.keyword
  140. })
  141. this.keyword = ''
  142. },
  143. // 获取轮播图
  144. getBanner() {
  145. this.$api('getRiceBanner', res => {
  146. if (res.code == 200) {
  147. this.bannerList = res.result
  148. }
  149. })
  150. },
  151. // 获取公告
  152. getRiceNoticeList() {
  153. this.$api('getRiceNoticeList', res => {
  154. if (res.code == 200) {
  155. this.notice = res.result.title
  156. }
  157. })
  158. },
  159. // 获取常规产品
  160. getRiceCommonProductList() {
  161. this.$api('getRiceCommonProductList', res => {
  162. uni.stopPullDownRefresh()
  163. if (res.code == 200) {
  164. this.commonProductList = res.result
  165. }
  166. })
  167. },
  168. // 获取首页体验产品
  169. getRiceProductList() {
  170. this.$api('getRiceProductList', res => {
  171. if (res.code == 200) {
  172. this.riceProductList = res.result
  173. }
  174. })
  175. },
  176. // 获取首页新闻列表
  177. getRiceNewsList() {
  178. this.$api('getRiceNewsList', res => {
  179. if (res.code == 200) {
  180. this.newList = res.result.records
  181. }
  182. })
  183. },
  184. // 获取首页菜单图标
  185. getRiceIconList() {
  186. this.$api('getRiceIconList', res => {
  187. if (res.code == 200) {
  188. this.baseList = res.result.slice(0, 5)
  189. }
  190. })
  191. },
  192. //跳转
  193. toUrl(url) {
  194. if (!url) {
  195. uni.showToast({
  196. title: '功能暂未开放'
  197. })
  198. return
  199. }
  200. if (url == '::phone') {
  201. this.$refs.customerServicePopup.open()
  202. return
  203. }
  204. uni.navigateTo({
  205. url
  206. })
  207. },
  208. //视频播放错误
  209. videoErrorCallback: function(e) {
  210. uni.showModal({
  211. content: e.target.errMsg,
  212. showCancel: false
  213. })
  214. },
  215. //左右滚动视频
  216. scroll: function(e) {
  217. },
  218. },
  219. }
  220. </script>
  221. <style scoped lang="scss">
  222. .home {
  223. // 搜索栏
  224. .search {
  225. border: 1px solid #F0F0F0;
  226. margin: 20rpx;
  227. border-radius: 41rpx;
  228. padding: 10rpx 0rpx;
  229. display: flex;
  230. align-items: center;
  231. /deep/ .uv-search__action {
  232. background-color: $uni-color;
  233. color: #FFFFFF;
  234. padding: 10rpx 20rpx;
  235. border-radius: 30rpx;
  236. }
  237. }
  238. // 轮播图
  239. .swipe {
  240. overflow: hidden;
  241. border-radius: 20rpx;
  242. margin: 20rpx;
  243. }
  244. // 首页-分类菜单
  245. .home-menu {
  246. margin: 20rpx;
  247. border-radius: 20rpx;
  248. padding: 20rpx 0rpx;
  249. background-color: #fff;
  250. image {
  251. width: 80rpx;
  252. height: 80rpx;
  253. margin-top: 10rpx;
  254. }
  255. .menu-text {
  256. font-size: 28rpx;
  257. margin: 10rpx 0rpx;
  258. }
  259. }
  260. // 新人专享
  261. .new-people {
  262. background: white;
  263. padding: 20rpx;
  264. margin-bottom: 20rpx;
  265. .new-perple-top {
  266. display: flex;
  267. align-items: center;
  268. justify-content: space-between;
  269. margin-bottom: 20rpx;
  270. .new-perple-top-left {
  271. display: flex;
  272. align-items: center;
  273. color: #E7474C;
  274. .title {
  275. font-size: 40rpx;
  276. font-weight: bold;
  277. }
  278. .descript {
  279. margin-left: 10rpx;
  280. }
  281. }
  282. .new-perple-top-right {
  283. image {
  284. width: 80px;
  285. }
  286. }
  287. }
  288. .new-perple-main {
  289. display: flex;
  290. .red-packet {
  291. display: flex;
  292. align-items: center;
  293. justify-content: center;
  294. width: 20%;
  295. image {
  296. width: 80%;
  297. }
  298. }
  299. .activity {
  300. display: flex;
  301. flex-direction: column;
  302. align-items: center;
  303. justify-content: center;
  304. width: 20%;
  305. background: white;
  306. border-radius: 10px;
  307. image {
  308. width: 80%;
  309. }
  310. .product-price {
  311. color: $uni-color;
  312. }
  313. }
  314. }
  315. }
  316. // 视频
  317. .video-line {
  318. display: flex;
  319. align-items: center;
  320. padding: 20rpx;
  321. background: white;
  322. font-size: 34rpx;
  323. .line {
  324. height: 40rpx;
  325. width: 10rpx;
  326. background: $uni-color;
  327. border-radius: 5rpx;
  328. margin-right: 10rpx;
  329. }
  330. }
  331. .video-list {
  332. .scroll-view_H {
  333. white-space: nowrap;
  334. width: 750rpx;
  335. .video-item {
  336. display: inline-block;
  337. width: 35%;
  338. border: 1px solid #ccc;
  339. .product-video {
  340. width: 100%;
  341. height: 70px;
  342. }
  343. }
  344. }
  345. }
  346. // 推荐
  347. .recommend {
  348. display: flex;
  349. align-items: center;
  350. justify-content: space-between;
  351. background: white;
  352. margin: 20rpx 0rpx;
  353. padding: 20rpx;
  354. .recommend-title {
  355. font-size: 36rpx;
  356. }
  357. .recommend-more {
  358. color: $uni-color;
  359. }
  360. }
  361. }
  362. </style>