Browse Source

no message

xiaoxin 2 years ago
parent
commit
47ab5c624d
4 changed files with 88 additions and 33 deletions
  1. 3 1
      main.js
  2. 1 1
      pages/home/home.vue
  3. 28 28
      pages/home3/home3.vue
  4. 56 3
      util/api.js

+ 3 - 1
main.js

@@ -5,10 +5,12 @@ import Vue from 'vue'
 import './uni.promisify.adaptor'
 
 import {
-	myRequest
+	myRequest,
+	myRequest_shop
 } from "./util/api"
 
 Vue.prototype.$myRequest = myRequest
+Vue.prototype.$myRequest_shop = myRequest_shop
 
 Vue.config.productionTip = false
 App.mpType = 'app'

+ 1 - 1
pages/home/home.vue

@@ -133,7 +133,7 @@ export default {
 		}
 	},
 	onLoad(options) {
-		console.log(options)
+		// console.log(options)
 		this.keywords = options.keywords
 		if (!options.level || options.level === '白金') {
 			this.current = 0

+ 28 - 28
pages/home3/home3.vue

@@ -164,7 +164,7 @@
 				<view class="body_list">
 					<!-- 每一个特产区域 -->
 					<view class="item_goods" v-for="item in goodsList" :key="item.id">
-						<img class="goods_img" mode="acpectFill" :src="item.imgUrl" />
+						<img class="goods_img" mode="acpectFill" :src="item.imgs.split(',')[0]" />
 						<view class="goods_name">{{ item.name }}</view>
 
 						<view class="goods_detail">
@@ -311,33 +311,10 @@ export default {
 				border: 'none',
 				selectedBorder: 'none'
 			},
+			// 招商资讯轮播图当前索引值
 			current: 0,
-			goodsList: [
-				{
-					id: 1,
-					imgUrl: 'https://img0.baidu.com/it/u=598641720,3978772869&fm=253&fmt=auto&app=138&f=JPEG?w=600&h=447',
-					name: '靖安白茶',
-					price: 180
-				},
-				{
-					id: 2,
-					imgUrl: 'https://img0.baidu.com/it/u=598641720,3978772869&fm=253&fmt=auto&app=138&f=JPEG?w=600&h=447',
-					name: '靖安白茶',
-					price: 180
-				},
-				{
-					id: 3,
-					imgUrl: 'https://img0.baidu.com/it/u=598641720,3978772869&fm=253&fmt=auto&app=138&f=JPEG?w=600&h=447',
-					name: '靖安白茶',
-					price: 180
-				},
-				{
-					id: 4,
-					imgUrl: 'https://img0.baidu.com/it/u=598641720,3978772869&fm=253&fmt=auto&app=138&f=JPEG?w=600&h=447',
-					name: '靖安白茶',
-					price: 180
-				}
-			]
+			// 特产甄选列表
+			goodsList: []
 		}
 	},
 	created() {
@@ -382,6 +359,9 @@ export default {
 		this.page = 1
 		this.getLocation()
 		this.getResidueCount()
+		this.getBestNews()
+		this.getNews()
+		this.getGoodsList()
 		setTimeout(() => {
 			uni.stopPullDownRefresh()
 		}, 1000)
@@ -393,6 +373,8 @@ export default {
 		this.getBestNews()
 		// 获取招商资讯列表
 		this.getNews()
+		// 获取特产列表
+		this.getGoodsList()
 		// 获取定位
 		this.getLocation()
 	},
@@ -422,6 +404,20 @@ export default {
 				})
 			}
 		},
+		async getGoodsList() {
+			const res = await this.$myRequest_shop({
+				url: '/cloud-mall/goods/open/page',
+				data: {
+					curPage: 1,
+					pageSize: 4,
+					hot: 1
+				}
+			})
+			// console.log(res)
+			if (res.code === '1') {
+				this.goodsList = res.data.list
+			}
+		},
 		// 获取用户当前位置
 		getLocation() {
 			uni.getSetting({
@@ -1081,12 +1077,16 @@ export default {
 					.goods_img {
 						width: 335rpx;
 						height: 223rpx;
+						border-bottom: 1rpx solid #eee;
 					}
 
 					.goods_name {
-						margin: 18rpx 0 18rpx 30rpx;
+						margin: 18rpx 5rpx 18rpx 30rpx;
 						font-size: 28rpx;
 						font-weight: bold;
+						overflow: hidden;
+						white-space: nowrap;
+						text-overflow: ellipsis;
 					}
 
 					.goods_detail {

+ 56 - 3
util/api.js

@@ -1,7 +1,9 @@
-// const BASE_URL = "https://chtech.ncjti.edu.cn/hotelReservation"
-// const BASE_URL = "http://101.42.162.31:8088"
+// 民宿接口前缀
 const BASE_URL = "https://chtech.ncjti.edu.cn/homestay"
-// const BASE_URL = "http://192.168.161.224:8088"
+
+// 商城接口前缀
+const BASE_URL_SHOP = "https://www.daweilinli.com"
+
 export const myRequest = (options) => {
 	uni.showLoading({
 		title: "加载中",
@@ -51,4 +53,55 @@ export const myRequest = (options) => {
 			}
 		})
 	})
+}
+
+export const myRequest_shop = (options) => {
+	uni.showLoading({
+		title: "加载中",
+		mask: true,
+	});
+	return new Promise((resolve, reject) => {
+		uni.request({
+			url: BASE_URL_SHOP + options.url,
+			method: options.method || "GET",
+			// header: options.header || {
+			// 	'userId': uni.getStorageSync('userInfo').id
+			// },
+			data: options.data || {},
+			timeout: 10000,
+			success: (res) => {
+				if (res.data.code === '1') {
+					resolve(res.data)
+				} else {
+
+				}
+			},
+			fail: (err) => {
+				uni.showToast({
+					title: "请求发送失败",
+					icon: "none",
+					mask: true
+				})
+				reject(err)
+			},
+			complete: (res) => {
+				// console.log(res);
+				uni.hideLoading({
+					complete: (hide) => {
+						// console.log(hide);
+						if (res.data.code === '1') {
+
+						} else {
+							uni.showToast({
+								title: res.data.message ? res.data.message :
+									'报错',
+								icon: "none",
+								mask: true
+							})
+						}
+					}
+				});
+			}
+		})
+	})
 }