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

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