getData.js 10.4 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
updata  
maguohua 已提交
13 14 15
/**
 * 获取首页默认地址
 */
M
update  
maguohua 已提交
16 17 18 19 20

// export const cityGuess = () => fetch('GET', '/v1/cities', {
// 	type: 'guess'
// });

M
maguohua 已提交
21

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

// export const hotcity = () => fetch('GET', '/v1/cities', {
// 	type: 'hot'
// });

M
maguohua 已提交
30

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

// export const groupcity = () => fetch('GET', '/v1/cities', {
// 	type: 'group'
// });

M
maguohua 已提交
39

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

// export const currentcity = number => fetch('GET', '/v1/cities/' + number, {});

M
maguohua 已提交
46

M
maguohua 已提交
47
/**
M
updata  
maguohua 已提交
48 49
 * 获取搜索地址
 */
M
update  
maguohua 已提交
50 51 52 53 54 55 56

// export const searchplace = (cityid, value) => fetch('GET', '/v1/pois', {
// 	type: 'search',
// 	city_id: cityid,
// 	keyword: value
// });

M
maguohua 已提交
57

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

// export const msiteAdress = geohash => fetch('GET', '/v2/pois/' + geohash, {});

M
maguohua 已提交
64

M
maguohua 已提交
65 66 67
/**
 * 获取msite页面食品分类列表
 */
M
update  
maguohua 已提交
68 69 70 71 72 73 74

// export const msiteFoodTypes = geohash => fetch('GET', '/v2/index_entry', {
// 	geohash,
// 	group_type: '1',
// 	'flags[]': 'F'
// });

M
maguohua 已提交
75

M
maguohua 已提交
76 77 78
/**
 * 获取msite商铺列表
 */
M
update  
maguohua 已提交
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101

// 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
maguohua 已提交
102

M
updata  
maguohua 已提交
103
/**
M
maguohua 已提交
104
 * 获取search页面搜索结果
M
updata  
maguohua 已提交
105
 */
M
update  
maguohua 已提交
106 107 108 109 110 111 112 113

// export const searchRestaurant = (geohash, keyword) => fetch('GET', '/v4/restaurants', {
// 	'extras[]': 'restaurant_activity',
// 	geohash,
// 	keyword,
// 	type: 'search'
// });

M
maguohua 已提交
114

M
updata  
maguohua 已提交
115 116 117
/**
 * 获取food页面的 category 种类列表
 */
M
update  
maguohua 已提交
118 119 120 121 122 123

// export const foodCategory = (latitude, longitude) => fetch('GET', '/shopping/v2/restaurant/category', {
// 	latitude,
// 	longitude
// });

M
maguohua 已提交
124

M
maguohua 已提交
125 126 127
/**
 * 获取food页面的配送方式
 */
M
update  
maguohua 已提交
128 129 130 131 132 133 134

// export const foodDelivery = (latitude, longitude) => fetch('GET', '/shopping/v1/restaurants/delivery_modes', {
// 	latitude,
// 	longitude,
// 	kw: ''
// });

M
maguohua 已提交
135

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

// export const foodActivity = (latitude, longitude) => fetch('GET', '/shopping/v1/restaurants/activity_attributes', {
// 	latitude,
// 	longitude,
// 	kw: ''
// });

M
maguohua 已提交
146

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

M
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 157



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

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


M
maguohua 已提交
167 168 169
/**
 * 获取商铺评价列表
 */
M
update  
maguohua 已提交
170 171 172 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
maguohua 已提交
179 180 181
/**
 * 获取商铺评价分数
 */
M
update  
maguohua 已提交
182 183 184 185

// export const ratingScores = shopid => fetch('GET', '/ugc/v2/restaurants/' + shopid + '/ratings/scores', {});


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

// export const ratingTags = shopid => fetch('GET', '/ugc/v2/restaurants/' + shopid + '/ratings/tags', {});


M
maguohua 已提交
193 194 195
/**
 * 获取短信验证码
 */
M
update  
maguohua 已提交
196 197 198 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
/**
M
maguohua 已提交
205
 * 手机号登陆
M
maguohua 已提交
206
 */
M
update  
maguohua 已提交
207

M
confrim  
maguohua 已提交
208 209 210 211 212
// export const sendLogin = (code, mobile, validate_token) => fetch('POST', '/v1/login/app_mobile', {
// 	code,
// 	mobile,
// 	validate_token
// });
M
maguohua 已提交
213 214 215 216 217 218 219 220 221 222 223



/**
 * 获取用户信息
 */

// export const getUser = () => fetch('GET', '/v1/user', {});



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

// export const getcaptchas = () => fetch('POST', '/v1/captchas', {});


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

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


M
maguohua 已提交
238 239 240
/**
 * 检测帐号是否存在
 */
M
maguohua 已提交
241 242 243 244 245 246

// export const checkExsis = (checkNumber, type) => fetch('GET', '/v1/users/exists', {
// 	[type]: checkNumber,
// 	type
// });

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

M
maguohua 已提交
251 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
update  
maguohua 已提交
260

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

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

M
update  
maguohua 已提交
271

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

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


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

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


M
confrim  
maguohua 已提交
290 291 292
/**
 * 搜索地址
 */
M
maguohua 已提交
293

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


M
confrim  
maguohua 已提交
300 301 302
/**
 * 添加地址
 */
M
maguohua 已提交
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381

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


/**
 * 下订单
 */

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


/**
 * 重新发送订单验证码
 */

// export const rePostVerify = (cart_id, sig, type) => fetch('POST', '/v1/carts/' + cart_id + '/verify_code', {
// 	sig,
// 	type,
// });

/**
 * 下订单
 */

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


/**
 * 重新发送订单验证码
 */

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

M
updata  
maguohua 已提交
383

M
maguohua 已提交
384 385 386 387 388 389 390 391
/**
 * 获取订单列表
 */

// export const getOrderList = (user_id, offset) => fetch('GET', '/bos/v2/users/' + user_id + '/orders', {
// 	limit: 10,
// 	offset,
// });
M
maguohua 已提交
392 393 394 395 396
/**
 * 获取订单详情
 */

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


M
updata  
maguohua 已提交
399

M
maguohua 已提交
400 401 402
/**
 * 以下是临时数据
 */
M
maguohua 已提交
403 404 405 406 407
const setpromise = data => {
	return new Promise((resolve, reject) => {
		resolve(data)
	})
}
M
udpata  
maguohua 已提交
408

M
update  
maguohua 已提交
409 410 411 412 413 414 415 416 417 418 419 420
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);
M
maguohua 已提交
421 422
export const shopDetails = (shopid, latitude, longitude) => setpromise(shop.shopDetails);
export const foodMenu = restaurant_id => setpromise(shop.shopMenu);
M
update  
maguohua 已提交
423 424 425 426
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);
M
maguohua 已提交
427
export const sendLogin = (code, mobile, validate_token) => setpromise(login.userInfo);
M
maguohua 已提交
428
export const accountLogin = (username, password, captcha_code) => setpromise(login.userInfo);
M
maguohua 已提交
429
export const checkExsis = (checkNumber, type) => setpromise(login.checkExsis);
M
maguohua 已提交
430
export const sendMobile = (sendData, captcha_code, type, password) => setpromise(login.send);
M
maguohua 已提交
431
export const checkout = (geohash, entities) => setpromise(confirm.checkout);
M
confrim  
maguohua 已提交
432 433 434
export const getRemark = (id, sig) => setpromise(confirm.remark);
export const getAddress = (id, sig) => setpromise(confirm.addressList);
export const getUser = () => setpromise(login.userInfo);
M
update  
maguohua 已提交
435
export const getcaptchas = () => setpromise(login.cpatchs);
M
confrim  
maguohua 已提交
436
export const searchNearby = keyword => setpromise(confirm.searchAddress);
M
maguohua 已提交
437 438 439 440 441 442 443 444 445 446 447 448 449 450
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);
M
maguohua 已提交
451
export const payRequest = (merchantOrderNo, userId) => setpromise(confirm.payDetail);
M
maguohua 已提交
452 453
export const getOrderList = (user_id, offset) => setpromise(order.orderList);
export const getOrderDetail = (user_id, orderid) => setpromise(order.orderDetail);