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

443 lines
8.8 KiB

3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 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 categoryList"
  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.name}}</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. categoryList : [],
  120. }
  121. },
  122. computed: {
  123. ...mapState(['riceInfo', 'category'])
  124. },
  125. onLoad(query) {
  126. if (query.shareId) {
  127. uni.setStorageSync('shareId', query.shareId)
  128. }
  129. },
  130. onShow() {
  131. this.getBanner()
  132. this.getRiceNoticeList()
  133. this.getRiceIconList()
  134. this.getCategoryList()
  135. this.getRiceAdList()
  136. if(uni.getStorageSync('token')){
  137. this.$store.commit('getRiceInfo')
  138. this.$store.commit('getUserInfo')
  139. }
  140. },
  141. onPullDownRefresh() {
  142. this.getBanner()
  143. this.getRiceNoticeList()
  144. },
  145. methods: {
  146. // 搜素
  147. search() {
  148. uni.navigateTo({
  149. url: '/pages/index/category?search=' + this.keyword
  150. })
  151. this.keyword = ''
  152. },
  153. // 查询分类接口
  154. getCategoryList() {
  155. this.$api('getPidList', res => {
  156. if (res.code == 200) {
  157. this.categoryList = res.result
  158. }
  159. })
  160. },
  161. // 获取轮播图
  162. getBanner() {
  163. this.$api('getRiceBanner', res => {
  164. if (res.code == 200) {
  165. this.bannerList = res.result
  166. }
  167. })
  168. },
  169. // 获取公告
  170. getRiceNoticeList() {
  171. this.$api('getRiceNoticeList', res => {
  172. if (res.code == 200) {
  173. this.notice = res.result.title
  174. }
  175. })
  176. },
  177. // 获取首页新闻列表
  178. getRiceNewsList() {
  179. this.$api('getRiceNewsList', res => {
  180. if (res.code == 200) {
  181. this.newList = res.result.records
  182. }
  183. })
  184. },
  185. // 获取首页菜单图标
  186. getRiceIconList() {
  187. this.$api('getRiceIconList', res => {
  188. if (res.code == 200) {
  189. this.baseList = res.result
  190. }
  191. })
  192. },
  193. //获取首页广告
  194. getRiceAdList() {
  195. this.$api('getRiceProductList', {
  196. pageNo: 1,
  197. pageSize: 4,
  198. }, res => {
  199. if (res.code == 200) {
  200. this.adList = res.result.records
  201. }
  202. })
  203. },
  204. //跳转
  205. toUrl(url) {
  206. if (!url) {
  207. uni.showToast({
  208. title: '功能暂未开放',
  209. icon: 'none'
  210. })
  211. return
  212. }
  213. if (url == '::phone') {
  214. this.$refs.customerServicePopup.open()
  215. return
  216. }
  217. uni.navigateTo({
  218. url
  219. })
  220. },
  221. //视频播放错误
  222. videoErrorCallback: function(e) {
  223. uni.showModal({
  224. content: e.target.errMsg,
  225. showCancel: false
  226. })
  227. },
  228. //左右滚动视频
  229. scroll: function(e) {
  230. },
  231. },
  232. }
  233. </script>
  234. <style scoped lang="scss">
  235. .home {
  236. // 搜索栏
  237. .search {
  238. border: 1px solid #F0F0F0;
  239. margin: 20rpx;
  240. border-radius: 41rpx;
  241. padding: 10rpx 0rpx;
  242. display: flex;
  243. align-items: center;
  244. /deep/ .uv-search__action {
  245. background-color: $uni-color;
  246. color: #FFFFFF;
  247. padding: 10rpx 20rpx;
  248. border-radius: 30rpx;
  249. }
  250. }
  251. // 轮播图
  252. .swipe {
  253. overflow: hidden;
  254. border-radius: 20rpx;
  255. margin: 20rpx;
  256. }
  257. // 首页-分类菜单
  258. .home-menu {
  259. margin: 20rpx;
  260. border-radius: 20rpx;
  261. padding: 20rpx 0rpx;
  262. background-color: #fff;
  263. image {
  264. width: 80rpx;
  265. height: 80rpx;
  266. margin-top: 10rpx;
  267. }
  268. .menu-text {
  269. font-size: 28rpx;
  270. margin: 10rpx 0rpx;
  271. }
  272. }
  273. // 新人专享
  274. .new-people {
  275. background: white;
  276. padding: 20rpx;
  277. margin-bottom: 20rpx;
  278. .new-perple-top {
  279. display: flex;
  280. align-items: center;
  281. justify-content: space-between;
  282. margin-bottom: 20rpx;
  283. .new-perple-top-left {
  284. display: flex;
  285. align-items: center;
  286. color: #E7474C;
  287. .title {
  288. font-size: 40rpx;
  289. font-weight: bold;
  290. }
  291. .descript {
  292. margin-left: 10rpx;
  293. }
  294. }
  295. .new-perple-top-right {
  296. image {
  297. width: 80px;
  298. height: 40rpx;
  299. }
  300. }
  301. }
  302. .new-perple-main {
  303. display: flex;
  304. .red-packet {
  305. display: flex;
  306. align-items: center;
  307. justify-content: center;
  308. width: 20%;
  309. image {
  310. width: 120rpx;
  311. height: 120rpx;
  312. }
  313. }
  314. .activity {
  315. display: flex;
  316. flex-direction: column;
  317. align-items: center;
  318. justify-content: center;
  319. width: 25%;
  320. background: white;
  321. border-radius: 10px;
  322. image {
  323. width: 140rpx;
  324. height: 140rpx;
  325. border-radius: 10rpx;
  326. }
  327. .title {
  328. background: $uni-color;
  329. color: white;
  330. border-radius: 20rpx;
  331. font-size: 24rpx;
  332. padding: 5rpx 10rpx;
  333. margin: 10rpx 0rpx;
  334. width: 90%;
  335. white-space: nowrap;
  336. overflow: hidden;
  337. text-overflow: ellipsis;
  338. box-sizing: border-box;
  339. text-align: center;
  340. }
  341. .product-price {
  342. color: $uni-color;
  343. font-size: 24rpx;
  344. }
  345. }
  346. }
  347. }
  348. // 视频
  349. .video-line {
  350. display: flex;
  351. align-items: center;
  352. padding: 20rpx;
  353. background: white;
  354. font-size: 34rpx;
  355. .line {
  356. height: 40rpx;
  357. width: 10rpx;
  358. background: $uni-color;
  359. border-radius: 5rpx;
  360. margin-right: 10rpx;
  361. }
  362. }
  363. .video-item {
  364. display: flex;
  365. justify-content: center;
  366. align-items: center;
  367. margin: 20rpx 0rpx;
  368. .product-video {
  369. border-radius: 20rpx;
  370. width: calc(710rpx);
  371. }
  372. }
  373. // 推荐
  374. .recommend {
  375. display: flex;
  376. align-items: center;
  377. justify-content: space-between;
  378. background: white;
  379. margin: 20rpx 0rpx;
  380. padding: 20rpx;
  381. .recommend-title {
  382. font-size: 36rpx;
  383. }
  384. .recommend-more {
  385. color: $uni-color;
  386. }
  387. }
  388. }
  389. </style>