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

482 lines
8.9 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
  1. <template>
  2. <view class="page">
  3. <navbar />
  4. <!-- <view class="bg-color"></view> -->
  5. <view class="page-title">
  6. <!-- {{ configList.index_title }} -->
  7. <!-- <image src="/static/image/home/logo.png"
  8. style="width: 240rpx;"
  9. mode="widthFix"></image> -->
  10. <!-- <image :src="configList.index_img"
  11. style="width: 240rpx;"
  12. mode="widthFix"></image> -->
  13. </view>
  14. <view class="search">
  15. <uv-search
  16. placeholder="搜你喜欢的产品"
  17. bgColor="#fff"
  18. @custom="search"
  19. @search="search"
  20. v-model="keyword"></uv-search>
  21. </view>
  22. <view class="swipe">
  23. <uv-swiper
  24. :list="bannerList"
  25. indicator height="320rpx"
  26. keyName="image"></uv-swiper>
  27. </view>
  28. <!-- <view class="notice">
  29. <uv-notice-bar fontSize="32rpx"
  30. @click="$utils.navigateTo('/pages_order/home/notice')"
  31. :text="notice"></uv-notice-bar>
  32. </view> -->
  33. <view class="menu">
  34. <uv-grid :border="false" :col="4" >
  35. <uv-grid-item v-for="(item,index) in baseList" :key="index"
  36. @click="toUrl(item.url)">
  37. <image :src="item.image" mode="aspectFill"></image>
  38. <text class="menu-text">{{item.title}}</text>
  39. </uv-grid-item>
  40. </uv-grid>
  41. </view>
  42. <view class="map"
  43. v-if="configList.qd_image">
  44. <image :src="configList.qd_image" mode="widthFix" />
  45. </view>
  46. <view class="label">
  47. <text>推荐宝贝</text>
  48. </view>
  49. <view style="position: 20rpx;">
  50. <productList :list="list"/>
  51. </view>
  52. <PrivacyAgreementPoup />
  53. <customerServicePopup ref="customerServicePopup"/>
  54. <tabber select="home" />
  55. </view>
  56. </template>
  57. <script>
  58. import PrivacyAgreementPoup from '@/components/config/PrivacyAgreementPoup.vue'
  59. import Position from '@/utils/position.js'
  60. import tabber from '@/components/base/tabbar.vue'
  61. import { mapState } from 'vuex'
  62. import customerServicePopup from '@/components/config/customerServicePopup.vue'
  63. import productList from '@/components/user/productList.vue'
  64. import mixinsList from '@/mixins/list.js'
  65. export default {
  66. mixins : [mixinsList],
  67. components: {
  68. tabber,
  69. PrivacyAgreementPoup,
  70. customerServicePopup,
  71. productList,
  72. },
  73. data() {
  74. return {
  75. notice: '',
  76. bannerList: [],
  77. baseList: [
  78. ],
  79. productList: [],
  80. keyword: '',
  81. commonProductList : [],//常规产品
  82. riceProductList : [],//体验产品
  83. newList : [],//新闻列表
  84. mixinsListApi : 'getClassShopPageList',
  85. }
  86. },
  87. computed: {},
  88. onLoad(query) {
  89. if (query.shareId) {
  90. uni.setStorageSync('shareId', query.shareId)
  91. }
  92. },
  93. onShow() {
  94. this.getBanner()
  95. this.getRiceNoticeList()
  96. // this.getRiceCommonProductList()
  97. // this.getRiceProductList()
  98. // this.getRiceNewsList()
  99. this.getRiceIconList()
  100. },
  101. onPullDownRefresh() {
  102. this.getBanner()
  103. this.getRiceNoticeList()
  104. // this.getRiceCommonProductList()
  105. // this.getRiceProductList()
  106. // this.getRiceNewsList()
  107. },
  108. methods: {
  109. // 搜素
  110. search(){
  111. uni.navigateTo({
  112. url: '/pages/index/category?search=' + this.keyword
  113. })
  114. this.keyword = ''
  115. },
  116. // 获取轮播图
  117. getBanner(){
  118. this.$api('getRiceBanner', res => {
  119. if(res.code == 200){
  120. this.bannerList = res.result
  121. }
  122. })
  123. },
  124. // 获取公告
  125. getRiceNoticeList(){
  126. this.$api('getRiceNoticeList', res => {
  127. if(res.code == 200){
  128. this.notice = res.result.title
  129. }
  130. })
  131. },
  132. // 获取常规产品
  133. getRiceCommonProductList(){
  134. this.$api('getRiceCommonProductList', res => {
  135. uni.stopPullDownRefresh()
  136. if(res.code == 200){
  137. this.commonProductList = res.result
  138. }
  139. })
  140. },
  141. // 获取首页体验产品
  142. getRiceProductList(){
  143. this.$api('getRiceProductList', res => {
  144. if(res.code == 200){
  145. this.riceProductList = res.result
  146. }
  147. })
  148. },
  149. // 获取首页新闻列表
  150. getRiceNewsList(){
  151. this.$api('getRiceNewsList', res => {
  152. if(res.code == 200){
  153. this.newList = res.result.records
  154. }
  155. })
  156. },
  157. // 获取首页跳转图标
  158. getRiceIconList(){
  159. this.$api('getRiceIconList', res => {
  160. if(res.code == 200){
  161. this.baseList = res.result
  162. }
  163. })
  164. },
  165. toUrl(url){
  166. if(!url){
  167. uni.showToast({
  168. title: '功能暂未开放'
  169. })
  170. return
  171. }
  172. if(url == '::phone'){
  173. this.$refs.customerServicePopup.open()
  174. return
  175. }
  176. uni.navigateTo({
  177. url
  178. })
  179. },
  180. saveImage(image){
  181. /* 获取图片的信息 */
  182. uni.getImageInfo({
  183. src: image,
  184. success: function(image) {
  185. /* 保存图片到手机相册 */
  186. uni.saveImageToPhotosAlbum({
  187. filePath: image.path,
  188. success: function() {
  189. uni.showModal({
  190. title: '保存成功',
  191. content: '图片已成功保存到相册',
  192. showCancel: false
  193. });
  194. },
  195. complete(res) {
  196. console.log(res);
  197. }
  198. });
  199. }
  200. });
  201. },
  202. },
  203. }
  204. </script>
  205. <style scoped lang="scss">
  206. .page {
  207. position: relative;
  208. .bg-color {
  209. width: 100%;
  210. position: absolute;
  211. top: 0;
  212. left: 0;
  213. height: 550rpx;
  214. background: linear-gradient(to bottom, #E3441A, #E3441A, #fff);
  215. }
  216. .page-title {
  217. position: relative;
  218. margin-left: 30rpx;
  219. // margin-bottom: 30rpx;
  220. font-size: 34rpx;
  221. font-weight: 900;
  222. }
  223. .search {
  224. position: relative;
  225. background: #FFFFFF;
  226. margin: 20rpx;
  227. border-radius: 41rpx;
  228. padding: 10rpx 20rpx;
  229. display: flex;
  230. align-items: center;
  231. /deep/ .uv-search__action {
  232. background-color: $uni-color;
  233. color: #FFFFFF;
  234. padding: 10rpx 20rpx;
  235. border-radius: 30rpx;
  236. }
  237. }
  238. .swipe {
  239. position: relative;
  240. overflow: hidden;
  241. border-radius: 20rpx;
  242. margin: 20rpx;
  243. }
  244. .menu {
  245. margin: 20rpx;
  246. border-radius: 20rpx;
  247. padding: 20rpx;
  248. background-color: #fff;
  249. box-shadow: 0 0 10rpx 10rpx #00000009;
  250. image {
  251. width: 80rpx;
  252. height: 80rpx;
  253. margin-top: 10rpx;
  254. }
  255. .menu-text {
  256. font-size: 28rpx;
  257. margin-bottom: 10rpx;
  258. margin-top: 10rpx;
  259. }
  260. }
  261. .notice {
  262. margin: 0 20rpx;
  263. /deep/ .uv-notice-bar {
  264. background: linear-gradient(to right, #f9edc9, #dfedd6);
  265. border-radius: 16rpx;
  266. }
  267. /deep/ .uv-notice {
  268. padding: 14rpx 0;
  269. }
  270. /deep/ .uv-icon__icon {
  271. font-size: 36rpx !important;
  272. color: #000 !important;
  273. }
  274. }
  275. .map {
  276. margin: 20rpx;
  277. border-radius: 16rpx;
  278. image {
  279. width: 100%;
  280. }
  281. }
  282. .label{
  283. margin: 20rpx 0;
  284. padding: 30rpx;
  285. background-color: #fff;
  286. display: flex;
  287. justify-content: space-between;
  288. text{
  289. font-weight: 900;
  290. }
  291. .more{
  292. color: $uni-color;
  293. }
  294. }
  295. .commodity {
  296. display: flex;
  297. justify-content: center;
  298. align-items: center;
  299. margin: 20rpx;
  300. border-radius: 16rpx;
  301. background-color: #fff;
  302. .box {
  303. width: 100%;
  304. margin: 20rpx;
  305. .top {
  306. display: flex;
  307. border-left: 6rpx solid #A3D250;
  308. align-items: center;
  309. justify-content: space-between;
  310. .top-text {
  311. margin-left: 20rpx;
  312. view:nth-child(1) {
  313. font-size: 24rpx;
  314. color: #474747;
  315. }
  316. view:nth-child(2) {
  317. font-size: 32rpx;
  318. color: #A3D250;
  319. font-weight: 600;
  320. }
  321. }
  322. .top1 {
  323. font-size: 26rpx;
  324. color: #fff;
  325. padding: 10rpx 30rpx;
  326. background-color: #F6CD59;
  327. border-radius: 30rpx;
  328. }
  329. }
  330. }
  331. .centre {
  332. margin: 40rpx 20rpx;
  333. display: flex;
  334. flex-direction: column;
  335. align-items: center;
  336. justify-content: center;
  337. .boxs {
  338. display: flex;
  339. width: 100%;
  340. align-items: center;
  341. justify-content: center;
  342. margin-top: 20rpx;
  343. background-color: #f9f9f9;
  344. border-radius: 20rpx;
  345. padding: 20rpx;
  346. .images {
  347. width: 180rpx;
  348. height: 140rpx;
  349. flex-shrink: 0;
  350. border-radius: 8rpx;
  351. overflow: hidden;
  352. image {
  353. width: 100%;
  354. height: 100%;
  355. }
  356. }
  357. .box-fone {
  358. margin-left: 20rpx;
  359. flex: 1;
  360. view:nth-child(1) {
  361. font-size: 36rpx;
  362. color: #474747;
  363. }
  364. view:nth-child(2) {
  365. margin-top: 10rpx;
  366. font-size: 28rpx;
  367. color: #A2A2A2;
  368. }
  369. }
  370. .box-text,
  371. .box-img {
  372. flex: 1;
  373. }
  374. .box-img{
  375. height: 220rpx;
  376. image{
  377. width: 100%;
  378. height: 100%;
  379. }
  380. }
  381. .box-text {
  382. view:nth-child(1) {
  383. font-size: 32rpx;
  384. font-weight: 500;
  385. margin-top: 30rpx;
  386. }
  387. view:nth-child(2) {
  388. font-size: 28rpx;
  389. color: #CCCCCC;
  390. margin-bottom: 30rpx;
  391. }
  392. .text1 {
  393. color: #f40;
  394. font-size: 58rpx;
  395. }
  396. .text2 {
  397. font-size: 28rpx;
  398. color: #999;
  399. }
  400. .text3 {
  401. color: #f40;
  402. font-size: 28rpx;
  403. text{
  404. font-size: 30rpx;
  405. font-weight: 900;
  406. }
  407. }
  408. .text4 {
  409. font-size: 26rpx;
  410. color: #999;
  411. }
  412. }
  413. .box-img {
  414. image {
  415. height: 100%;
  416. width: 100%;
  417. }
  418. }
  419. }
  420. }
  421. }
  422. }
  423. </style>