getData.js 11.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
update  
maguohua 已提交
11 12
import * as service from './tempdata/service'

M
maguohua 已提交
13

M
update  
maguohua 已提交
14

M
udpate  
maguohua 已提交
15 16 17
// /**
//  * 获取首页默认地址
//  */
M
maguohua 已提交
18

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


M
udpate  
maguohua 已提交
24 25 26
// /**
//  * 获取首页热门城市
//  */
M
update  
maguohua 已提交
27

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

M
update  
maguohua 已提交
32

M
udpate  
maguohua 已提交
33 34 35
// /**
//  * 获取首页所有城市
//  */
M
update  
maguohua 已提交
36

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

M
update  
maguohua 已提交
41

M
udpate  
maguohua 已提交
42 43 44
// /**
//  * 获取当前所在城市
//  */
M
update  
maguohua 已提交
45

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

M
update  
maguohua 已提交
48

M
udpate  
maguohua 已提交
49 50 51
// /**
//  * 获取搜索地址
//  */
M
update  
maguohua 已提交
52

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

M
update  
maguohua 已提交
59

M
udpate  
maguohua 已提交
60 61 62
// /**
//  * 获取msite页面地址信息
//  */
M
update  
maguohua 已提交
63

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

M
update  
maguohua 已提交
66

M
udpate  
maguohua 已提交
67 68 69
// /**
//  * 获取msite页面食品分类列表
//  */
M
maguohua 已提交
70

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

M
maguohua 已提交
77

M
udpate  
maguohua 已提交
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
// /**
//  * 获取msite商铺列表
//  */

// 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);
// };


// /**
//  * 获取search页面搜索结果
//  */

// export const searchRestaurant = (geohash, keyword) => fetch('GET', '/v4/restaurants', {
// 	'extras[]': 'restaurant_activity',
// 	geohash,
// 	keyword,
// 	type: 'search'
// });
M
update  
maguohua 已提交
115 116


M
udpate  
maguohua 已提交
117 118 119
// /**
//  * 获取food页面的 category 种类列表
//  */
M
maguohua 已提交
120

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


M
udpate  
maguohua 已提交
127 128 129
// /**
//  * 获取food页面的配送方式
//  */
M
maguohua 已提交
130

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


M
udpate  
maguohua 已提交
138 139 140
// /**
//  * 获取food页面的商家属性活动列表
//  */
M
maguohua 已提交
141

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


M
udpate  
maguohua 已提交
149 150 151
// /**
//  * 获取shop页面商铺详情
//  */
M
maguohua 已提交
152

M
udpate  
maguohua 已提交
153 154 155 156
// 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 已提交
157 158 159



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

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


M
udpate  
maguohua 已提交
169 170 171
// /**
//  * 获取商铺评价列表
//  */
M
update  
maguohua 已提交
172

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


M
udpate  
maguohua 已提交
181 182 183
// /**
//  * 获取商铺评价分数
//  */
M
update  
maguohua 已提交
184

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


M
udpate  
maguohua 已提交
188 189 190
// /**
//  * 获取商铺评价分类
//  */
M
update  
maguohua 已提交
191

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


M
udpate  
maguohua 已提交
195 196 197
// /**
//  * 获取短信验证码
//  */
M
maguohua 已提交
198

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


M
udpate  
maguohua 已提交
206 207 208
// /**
//  * 手机号登陆
//  */
M
update  
maguohua 已提交
209

M
udpate  
maguohua 已提交
210 211 212 213 214
// // export const sendLogin = (code, mobile, validate_token) => fetch('POST', '/v1/login/app_mobile', {
// // 	code,
// // 	mobile,
// // 	validate_token
// // });
M
update  
maguohua 已提交
215 216 217



M
udpate  
maguohua 已提交
218 219 220
// /**
//  * 获取用户信息
//  */
M
maguohua 已提交
221

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



M
udpate  
maguohua 已提交
226 227 228
// /**
//  * 获取图片验证码
//  */
M
update  
maguohua 已提交
229

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


M
udpate  
maguohua 已提交
233 234 235
// /**
//  * 账号密码登陆
//  */
M
update  
maguohua 已提交
236

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


M
udpate  
maguohua 已提交
240 241 242
// /**
//  * 检测帐号是否存在
//  */
M
maguohua 已提交
243

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

M
maguohua 已提交
249

M
udpate  
maguohua 已提交
250 251 252
// /**
//  * 发送帐号
//  */
M
update  
maguohua 已提交
253

M
udpate  
maguohua 已提交
254 255 256 257 258 259 260 261
// 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 已提交
262

M
update  
maguohua 已提交
263

M
udpate  
maguohua 已提交
264 265 266
// /**
//  * 确认订单
//  */
M
maguohua 已提交
267

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

M
update  
maguohua 已提交
274

M
udpate  
maguohua 已提交
275 276 277
// /**
//  * 获取快速备注列表
//  */
M
maguohua 已提交
278

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


M
udpate  
maguohua 已提交
284 285 286
// /**
//  * 获取地址列表
//  */
M
maguohua 已提交
287

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


M
udpate  
maguohua 已提交
293 294 295
// /**
//  * 搜索地址
//  */
M
maguohua 已提交
296

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


M
udpate  
maguohua 已提交
303 304 305
// /**
//  * 添加地址
//  */
M
maguohua 已提交
306

M
udpate  
maguohua 已提交
307 308 309 310 311 312 313 314 315 316 317 318
// 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 已提交
319 320


M
udpate  
maguohua 已提交
321 322 323
// /**
//  * 下订单
//  */
M
maguohua 已提交
324

M
udpate  
maguohua 已提交
325 326 327 328 329 330 331 332 333 334
// 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 已提交
335 336


M
udpate  
maguohua 已提交
337 338 339
// /**
//  * 重新发送订单验证码
//  */
M
maguohua 已提交
340

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


M
maguohua 已提交
347

M
udpate  
maguohua 已提交
348 349 350
// /**
//  * 下订单
//  */
M
maguohua 已提交
351

M
udpate  
maguohua 已提交
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373
// 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 已提交
374 375


M
udpate  
maguohua 已提交
376 377 378
// /**
//  * 重新发送订单验证码
//  */
M
maguohua 已提交
379

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

M
updata  
maguohua 已提交
388

M
update  
maguohua 已提交
389 390 391 392 393 394 395 396 397 398 399 400 401 402 403

// /**
//  * 获取服务中心信息
//  */

// export const getService = () => fetch('GET', '/m.ele.me@json/profile/explain', {});









M
udpate  
maguohua 已提交
404 405 406
// /**
//  * 获取订单列表
//  */
M
maguohua 已提交
407

M
udpate  
maguohua 已提交
408 409 410 411
// // export const getOrderList = (user_id, offset) => fetch('GET', '/bos/v2/users/' + user_id + '/orders', {
// // 	limit: 10,
// // 	offset,
// // });
M
maguohua 已提交
412

M
udate  
maguohua 已提交
413

M
udpate  
maguohua 已提交
414 415 416
// /**
//  * 获取订单详情
//  */
M
maguohua 已提交
417

M
udpate  
maguohua 已提交
418
// // export const getOrderDetail = (user_id, orderid) => fetch('GET', '/bos/v1/users/' + user_id + '/orders/' + orderid + '/snapshot', {});
M
maguohua 已提交
419 420


M
updata  
maguohua 已提交
421

M
update  
maguohua 已提交
422 423 424



M
maguohua 已提交
425 426 427
/**
 * 以下是临时数据
 */
M
maguohua 已提交
428 429 430 431 432
const setpromise = data => {
	return new Promise((resolve, reject) => {
		resolve(data)
	})
}
M
udpata  
maguohua 已提交
433

M
udpate  
maguohua 已提交
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474
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 已提交
475 476 477
export const getService = () => setpromise(service.serviceData);


M
update  
maguohua 已提交
478 479 480



M
update  
maguohua 已提交
481
export const getUser = () => setpromise(login.userInfo);
M
update  
maguohua 已提交
482
export const sendLogin = (code, mobile, validate_token) => setpromise(login.userInfo);
M
update  
maguohua 已提交
483 484
export const getOrderList = (user_id, offset) => setpromise(order.orderList);
export const getOrderDetail = (user_id, orderid) => setpromise(order.orderDetail);
M
update  
maguohua 已提交
485 486 487 488

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