getData.js 10.1 KB
Newer Older
M
updata  
maguohua 已提交
1
import fetch from '../config/fetch'
M
updata  
maguohua 已提交
2
import * as home from './tempdata/home'
M
updata  
maguohua 已提交
3
import * as city from './tempdata/city'
M
maguohua 已提交
4
import * as msite from './tempdata/msite'
M
updata  
maguohua 已提交
5
import * as search from './tempdata/search'
M
maguohua 已提交
6
import * as food from './tempdata/food'
M
maguohua 已提交
7
import * as shop from './tempdata/shop'
M
maguohua 已提交
8
import * as login from './tempdata/login'
M
maguohua 已提交
9
import * as confirm from './tempdata/confirm'
M
maguohua 已提交
10
import * as order from './tempdata/order'
M
maguohua 已提交
11

M
update  
maguohua 已提交
12

M
update  
maguohua 已提交
13 14 15
/**
 * 获取首页默认地址
 */
M
update  
maguohua 已提交
16

M
update  
maguohua 已提交
17 18 19
export const cityGuess = () => fetch('GET', '/v1/cities', {
	type: 'guess'
});
M
maguohua 已提交
20

M
update  
maguohua 已提交
21

M
update  
maguohua 已提交
22 23 24
/**
 * 获取首页热门城市
 */
M
maguohua 已提交
25

M
update  
maguohua 已提交
26 27 28
export const hotcity = () => fetch('GET', '/v1/cities', {
	type: 'hot'
});
M
update  
maguohua 已提交
29 30


M
update  
maguohua 已提交
31 32 33
/**
 * 获取首页所有城市
 */
M
maguohua 已提交
34

M
update  
maguohua 已提交
35 36 37
export const groupcity = () => fetch('GET', '/v1/cities', {
	type: 'group'
});
M
update  
maguohua 已提交
38 39


M
update  
maguohua 已提交
40 41 42
/**
 * 获取当前所在城市
 */
M
maguohua 已提交
43

M
update  
maguohua 已提交
44
export const currentcity = number => fetch('GET', '/v1/cities/' + number, {});
M
update  
maguohua 已提交
45 46


M
update  
maguohua 已提交
47 48 49
/**
 * 获取搜索地址
 */
M
maguohua 已提交
50

M
update  
maguohua 已提交
51 52 53 54 55
export const searchplace = (cityid, value) => fetch('GET', '/v1/pois', {
	type: 'search',
	city_id: cityid,
	keyword: value
});
M
update  
maguohua 已提交
56 57


M
update  
maguohua 已提交
58 59 60
/**
 * 获取msite页面地址信息
 */
M
maguohua 已提交
61

M
update  
maguohua 已提交
62
export const msiteAdress = geohash => fetch('GET', '/v2/pois/' + geohash, {});
M
update  
maguohua 已提交
63 64


M
update  
maguohua 已提交
65 66 67
/**
 * 获取msite页面食品分类列表
 */
M
maguohua 已提交
68

M
update  
maguohua 已提交
69 70 71 72 73
export const msiteFoodTypes = geohash => fetch('GET', '/v2/index_entry', {
	geohash,
	group_type: '1',
	'flags[]': 'F'
});
M
update  
maguohua 已提交
74

M
maguohua 已提交
75

M
update  
maguohua 已提交
76 77 78
/**
 * 获取msite商铺列表
 */
M
update  
maguohua 已提交
79

M
update  
maguohua 已提交
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
export const shopList = (latitude, longitude, offset, restaurant_category_id = '', restaurant_category_ids = '', order_by = '', delivery_mode = '', support_ids = []) => {
	let supportStr = '';
	support_ids.forEach(item => {
		if (item.status) {
			supportStr += '&support_ids[]=' + item.id;
		}
	});
	let data = {
		latitude,
		longitude,
		offset,
		limit: '20',
		'extras[]': 'activities',
		keyword: '',
		restaurant_category_id,
		'restaurant_category_ids[]': restaurant_category_ids,
		order_by,
		'delivery_mode[]': delivery_mode + supportStr
	};
	return fetch('GET', '/shopping/restaurants', data);
};
M
update  
maguohua 已提交
101

M
maguohua 已提交
102

M
update  
maguohua 已提交
103 104 105
/**
 * 获取search页面搜索结果
 */
M
update  
maguohua 已提交
106

M
update  
maguohua 已提交
107 108 109 110 111 112
export const searchRestaurant = (geohash, keyword) => fetch('GET', '/v4/restaurants', {
	'extras[]': 'restaurant_activity',
	geohash,
	keyword,
	type: 'search'
});
M
update  
maguohua 已提交
113

M
maguohua 已提交
114

M
update  
maguohua 已提交
115 116 117
/**
 * 获取food页面的 category 种类列表
 */
M
update  
maguohua 已提交
118

M
update  
maguohua 已提交
119 120 121 122
export const foodCategory = (latitude, longitude) => fetch('GET', '/shopping/v2/restaurant/category', {
	latitude,
	longitude
});
M
update  
maguohua 已提交
123

M
maguohua 已提交
124

M
update  
maguohua 已提交
125 126 127
/**
 * 获取food页面的配送方式
 */
M
update  
maguohua 已提交
128

M
update  
maguohua 已提交
129 130 131 132 133
export const foodDelivery = (latitude, longitude) => fetch('GET', '/shopping/v1/restaurants/delivery_modes', {
	latitude,
	longitude,
	kw: ''
});
M
update  
maguohua 已提交
134

M
maguohua 已提交
135

M
update  
maguohua 已提交
136 137 138
/**
 * 获取food页面的商家属性活动列表
 */
M
maguohua 已提交
139

M
update  
maguohua 已提交
140 141 142 143 144
export const foodActivity = (latitude, longitude) => fetch('GET', '/shopping/v1/restaurants/activity_attributes', {
	latitude,
	longitude,
	kw: ''
});
M
maguohua 已提交
145 146


M
update  
maguohua 已提交
147 148 149
/**
 * 获取shop页面商铺详情
 */
M
maguohua 已提交
150

M
update  
maguohua 已提交
151 152 153 154
export const shopDetails = (shopid, latitude, longitude) => fetch('GET', '/shopping/restaurant/' + shopid, {
	latitude,
	longitude: longitude + '&extras[]=activities&extras[]=album&extras[]=license&extras[]=identification&extras[]=statistics'
});
M
maguohua 已提交
155 156


M
update  
maguohua 已提交
157

M
update  
maguohua 已提交
158 159 160
/**
 * 获取food页面的商家属性活动列表
 */
M
update  
maguohua 已提交
161

M
update  
maguohua 已提交
162 163 164
export const foodMenu = restaurant_id => fetch('GET', '/shopping/v2/menu', {
	restaurant_id
});
M
update  
maguohua 已提交
165 166


M
update  
maguohua 已提交
167 168 169
/**
 * 获取商铺评价列表
 */
M
update  
maguohua 已提交
170

M
update  
maguohua 已提交
171 172 173 174 175 176
export const getRatingList = (offset, tag_name = '') => fetch('GET', '/ugc/v2/restaurants/834828/ratings', {
	has_content: true,
	offset,
	limit: 10,
	tag_name
});
M
update  
maguohua 已提交
177 178


M
update  
maguohua 已提交
179 180 181
/**
 * 获取商铺评价分数
 */
M
update  
maguohua 已提交
182

M
update  
maguohua 已提交
183
export const ratingScores = shopid => fetch('GET', '/ugc/v2/restaurants/' + shopid + '/ratings/scores', {});
M
update  
maguohua 已提交
184 185


M
update  
maguohua 已提交
186 187 188
/**
 * 获取商铺评价分类
 */
M
update  
maguohua 已提交
189

M
update  
maguohua 已提交
190
export const ratingTags = shopid => fetch('GET', '/ugc/v2/restaurants/' + shopid + '/ratings/tags', {});
M
update  
maguohua 已提交
191 192


M
update  
maguohua 已提交
193 194 195
/**
 * 获取短信验证码
 */
M
maguohua 已提交
196

M
update  
maguohua 已提交
197 198 199 200 201
export const mobileCode = phone => fetch('POST', '/v4/mobile/verify_code/send', {
	mobile: phone,
	scene: 'login',
	type: 'sms'
});
M
maguohua 已提交
202 203


M
update  
maguohua 已提交
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
/**
 * 手机号登陆
 */

// export const sendLogin = (code, mobile, validate_token) => fetch('POST', '/v1/login/app_mobile', {
// 	code,
// 	mobile,
// 	validate_token
// });



/**
 * 获取用户信息
 */
M
maguohua 已提交
219

M
update  
maguohua 已提交
220
// export const getUser = () => fetch('GET', '/v1/user', {});
M
maguohua 已提交
221 222 223



M
update  
maguohua 已提交
224 225 226
/**
 * 获取图片验证码
 */
M
update  
maguohua 已提交
227

M
update  
maguohua 已提交
228
export const getcaptchas = () => fetch('POST', '/v1/captchas', {});
M
update  
maguohua 已提交
229 230


M
update  
maguohua 已提交
231 232 233
/**
 * 账号密码登陆
 */
M
update  
maguohua 已提交
234

M
update  
maguohua 已提交
235
export const accountLogin = (username, password, captcha_code) => fetch('POST', '/v2/login', {username, password, captcha_code});
M
update  
maguohua 已提交
236 237


M
update  
maguohua 已提交
238 239 240
/**
 * 检测帐号是否存在
 */
M
maguohua 已提交
241

M
update  
maguohua 已提交
242 243 244 245
export const checkExsis = (checkNumber, type) => fetch('GET', '/v1/users/exists', {
	[type]: checkNumber,
	type
});
M
udate  
maguohua 已提交
246

M
maguohua 已提交
247

M
update  
maguohua 已提交
248 249 250
/**
 * 发送帐号
 */
M
update  
maguohua 已提交
251

M
update  
maguohua 已提交
252 253 254 255 256 257 258 259
export const sendMobile = (sendData, captcha_code, type, password) => fetch('POST', '/v1/mobile/verify_code/send', {
	action: "send",
	captcha_code,
	[type]: sendData,
	type: "sms",
	way: type,
	password,
});
M
maguohua 已提交
260

M
update  
maguohua 已提交
261

M
update  
maguohua 已提交
262 263 264
/**
 * 确认订单
 */
M
maguohua 已提交
265

M
update  
maguohua 已提交
266 267 268 269 270
export const checkout = (geohash, entities) => fetch('POST', '/v1/carts/checkout', {
	come_from: "web",
	geohash,
	entities,
});
M
maguohua 已提交
271

M
update  
maguohua 已提交
272

M
update  
maguohua 已提交
273 274 275
/**
 * 获取快速备注列表
 */
M
maguohua 已提交
276

M
update  
maguohua 已提交
277 278 279
export const getRemark = (id, sig) => fetch('GET', '/v1/carts/' + id + '/remarks', {
	sig
});
M
maguohua 已提交
280 281


M
update  
maguohua 已提交
282 283 284
/**
 * 获取地址列表
 */
M
maguohua 已提交
285

M
update  
maguohua 已提交
286 287 288
export const getAddress = (id, sig) => fetch('GET', '/v1/carts/' + id + '/addresses', {
	sig
});
M
maguohua 已提交
289 290


M
update  
maguohua 已提交
291 292 293
/**
 * 搜索地址
 */
M
maguohua 已提交
294

M
update  
maguohua 已提交
295 296 297 298
export const searchNearby = keyword => fetch('GET', '/v1/pois', {
	type: 'nearby',
	keyword
});
M
maguohua 已提交
299 300


M
update  
maguohua 已提交
301 302 303
/**
 * 添加地址
 */
M
maguohua 已提交
304

M
update  
maguohua 已提交
305 306 307 308 309 310 311 312 313 314 315 316
export const postAddAddress = (userId, address, address_detail, geohash, name, phone, phone_bk, poi_type, sex, tag, tag_type) => fetch('POST', '/v1/users/' + userId + '/addresses', {
	address,
	address_detail,
	geohash,
	name,
	phone,
	phone_bk,
	poi_type,
	sex,
	tag,
	tag_type,
});
M
maguohua 已提交
317 318


M
update  
maguohua 已提交
319 320 321
/**
 * 下订单
 */
M
maguohua 已提交
322

M
update  
maguohua 已提交
323 324 325 326 327 328 329 330 331 332
export const placeOrders = (user_id, cart_id, address_id, description, entities, geohash, sig) => fetch('POST', '/v1/users/' + user_id + '/carts/' + cart_id + '/orders', {
	address_id,
	come_from: "mobile_web",
	deliver_time: "",
	description,
	entities,
	geohash,
	paymethod_id: 1,
	sig,
});
M
maguohua 已提交
333 334


M
update  
maguohua 已提交
335 336 337
/**
 * 重新发送订单验证码
 */
M
maguohua 已提交
338

M
update  
maguohua 已提交
339 340 341 342
export const rePostVerify = (cart_id, sig, type) => fetch('POST', '/v1/carts/' + cart_id + '/verify_code', {
	sig,
	type,
});
M
udate  
maguohua 已提交
343 344


M
maguohua 已提交
345

M
update  
maguohua 已提交
346 347 348
/**
 * 下订单
 */
M
maguohua 已提交
349

M
update  
maguohua 已提交
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371
export const validateOrders = ({
	user_id,
	cart_id,
	address_id,
	description,
	entities,
	geohash,
	sig,
	validation_code,
	validation_token
}) => fetch('POST', '/v1/users/' + user_id + '/carts/' + cart_id + '/orders', {
	address_id,
	come_from: "mobile_web",
	deliver_time: "",
	description,
	entities,
	geohash,
	paymethod_id: 1,
	sig,
	validation_code,
	validation_token,
});
M
maguohua 已提交
372 373


M
update  
maguohua 已提交
374 375 376
/**
 * 重新发送订单验证码
 */
M
maguohua 已提交
377

M
update  
maguohua 已提交
378 379 380 381 382 383 384
export const payRequest = (merchantOrderNo, userId) => fetch('GET', '/payapi/payment/queryOrder', {
	merchantId: 5,
	merchantOrderNo,
	source: 'MOBILE_WAP',
	userId,
	version: '1.0.0',
});
M
maguohua 已提交
385

M
updata  
maguohua 已提交
386

M
update  
maguohua 已提交
387 388 389
/**
 * 获取订单列表
 */
M
maguohua 已提交
390

M
update  
maguohua 已提交
391 392 393 394
// export const getOrderList = (user_id, offset) => fetch('GET', '/bos/v2/users/' + user_id + '/orders', {
// 	limit: 10,
// 	offset,
// });
M
maguohua 已提交
395

M
udate  
maguohua 已提交
396

M
update  
maguohua 已提交
397 398 399
/**
 * 获取订单详情
 */
M
maguohua 已提交
400

M
update  
maguohua 已提交
401
// export const getOrderDetail = (user_id, orderid) => fetch('GET', '/bos/v1/users/' + user_id + '/orders/' + orderid + '/snapshot', {});
M
maguohua 已提交
402 403


M
updata  
maguohua 已提交
404

M
maguohua 已提交
405 406 407
/**
 * 以下是临时数据
 */
M
maguohua 已提交
408 409 410 411 412
const setpromise = data => {
	return new Promise((resolve, reject) => {
		resolve(data)
	})
}
M
udpata  
maguohua 已提交
413

M
update  
maguohua 已提交
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457
// export const cityGuess = () => setpromise(home.guesscity);
// export const hotcity = () => setpromise(home.hotcity);
// export const groupcity = () => setpromise(home.groupcity);
// export const currentcity = number => setpromise(city.currentcity);
// export const searchplace = (cityid, value) => setpromise(city.searchdata);
// export const msiteAdress = geohash => setpromise(msite.msiteAdress);
// export const msiteFoodTypes = geohash => setpromise(msite.foodTypes);
// export const shopList = (latitude, longitude, offset) => setpromise(msite.shopList);
// export const searchRestaurant = (geohash, keyword) => setpromise(search.searchData);
// export const foodCategory = (latitude, longitude) => setpromise(food.category);
// export const foodDelivery = (latitude, longitude) => setpromise(food.delivery);
// export const foodActivity = (latitude, longitude) => setpromise(food.activity);
// export const shopDetails = (shopid, latitude, longitude) => setpromise(shop.shopDetails);
// export const foodMenu = restaurant_id => setpromise(shop.shopMenu);
// export const getRatingList = (offset, tag_name = '') => setpromise(shop.ratingList);
// export const ratingScores = shopid => setpromise(shop.scores);
// export const ratingTags = shopid => setpromise(shop.tage);
// export const mobileCode = phone => setpromise(login.validate_token);
// export const accountLogin = (username, password, captcha_code) => setpromise(login.userInfo);
// export const checkExsis = (checkNumber, type) => setpromise(login.checkExsis);
// export const sendMobile = (sendData, captcha_code, type, password) => setpromise(login.send);
// export const checkout = (geohash, entities) => setpromise(confirm.checkout);
// export const getRemark = (id, sig) => setpromise(confirm.remark);
// export const getAddress = (id, sig) => setpromise(confirm.addressList);
// export const getcaptchas = () => setpromise(login.cpatchs);
// export const searchNearby = keyword => setpromise(confirm.searchAddress);
// export const postAddAddress = (userId, address, address_detail, geohash, name, phone, phone_bk, poi_type, sex, tag, tag_type) => setpromise(confirm.addAddress);
// export const placeOrders = (user_id, cart_id, address_id, description, entities, geohash, sig) => setpromise(confirm.palceOrder);
// export const rePostVerify = (cart_id, sig, type) => setpromise(confirm.verfiyCode);
// export const validateOrders = ({
// 	user_id,
// 	cart_id,
// 	address_id,
// 	description,
// 	entities,
// 	geohash,
// 	sig,
// 	validation_code,
// 	validation_token
// }) => setpromise(confirm.orderSuccess);
// export const payRequest = (merchantOrderNo, userId) => setpromise(confirm.payDetail);



M
update  
maguohua 已提交
458
export const getUser = () => setpromise(login.userInfo);
M
update  
maguohua 已提交
459
export const sendLogin = (code, mobile, validate_token) => setpromise(login.userInfo);
M
update  
maguohua 已提交
460 461
export const getOrderList = (user_id, offset) => setpromise(order.orderList);
export const getOrderDetail = (user_id, orderid) => setpromise(order.orderDetail);
M
update  
maguohua 已提交
462 463 464 465

//获取地址
export const getAddressList = (user_id) => fetch('GET', '/v1/users/'+user_id+'/addresses')