珠宝小程序前端代码
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.

452 lines
8.9 KiB

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