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