敢为人鲜小程序前端代码仓库
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.

437 lines
8.6 KiB

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