api.js 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188
  1. import Vue from 'vue'
  2. import __config from 'config/env';
  3. import util from 'utils/util';
  4. import { validatenull } from './validate';
  5. const request = (url, method, data, showLoading) => {
  6. let _url = url;
  7. //#ifndef H5
  8. _url = __config.basePath + url
  9. //#endif
  10. _url = __config.basePath + url
  11. let tokenName = uni.getStorageSync(__config.tokenNameKey)
  12. let tokenValue = uni.getStorageSync(__config.tokenValueKey)
  13. let shopId = uni.getStorageSync(__config.shopIdSessionKey)
  14. let switchToken = uni.getStorageSync(__config.switchTokenKey)
  15. let deviceId = uni.getStorageSync(__config.deviceIdSessionKey)
  16. if(!deviceId){
  17. deviceId = getApp().globalData.deviceId
  18. }
  19. let headerTokenObj = {}
  20. if (tokenName && tokenValue) {
  21. headerTokenObj[tokenName ? tokenName : 'rs-auth-token'] = tokenValue ? tokenValue : ''
  22. }
  23. // 拼接 header 所有参数
  24. let headerOptions = Object.assign({
  25. 'tenant-id': __config.tenantId, //租户ID
  26. //#ifdef H5
  27. // 'app-id': getApp().globalData.appId ? getApp().globalData.appId : '', //微信h5有appId
  28. // 'switch-token' : getApp().globalData.isEnableSwitchToken ? switchToken : '', //临时用户身份凭证
  29. // 'client-type': validatenull(shopId) ? 'OM-HALL' : 'OM-SHOP', //点餐机类型 大厅的/门店内
  30. // 'device-id': "1f82c7ab30405ebf", //点餐机-唯一设备编号
  31. "client-type": "OM-SHOP",
  32. "device-id": "0369E2FE48919344005E364491A7D614",
  33. "switch-token": "",
  34. "shop-id": "1631454886708219906",
  35. //#endif
  36. //#ifdef MP-WEIXIN
  37. 'client-type': 'MA', //客户端类型小程序
  38. 'app-id': uni.getAccountInfoSync().miniProgram.appId, //小程序appId
  39. 'shop-id': "1658295766983700481", //店铺ID
  40. //#endif
  41. //#ifdef APP-PLUS
  42. /* 点餐机模式 */
  43. 'client-type': validatenull(shopId) ? 'OM-HALL' : 'OM-SHOP', //点餐机类型 大厅的/门店内
  44. 'device-id': deviceId, //点餐机-唯一设备编号
  45. 'switch-token' : getApp().globalData.isEnableSwitchToken ? switchToken : '', //临时用户身份凭证
  46. 'shop-id': shopId, //店铺ID
  47. //#endif
  48. }, headerTokenObj)
  49. //#ifdef APP-PLUS
  50. console.log('\n APP模式 ===============>>>>>>>>>>>>>>>>>>>> \nAPI 请求 Header参数: \n' + JSON.stringify(headerOptions, null, '\t') + '\nAPI 请求URL: ' + _url + '\nAPI 请求Request参数: ' + JSON.stringify(data, null, '\t') + '\n')
  51. //#endif
  52. //#ifdef H5
  53. console.log('\n H5模拟APP模式 ===============>>>>>>>>>>>>>>>>>>>> \nAPI 请求 Header参数: \n' + JSON.stringify(headerOptions, null, '\t') + '\nAPI 请求URL: ' + _url + '\nAPI 请求Request参数: ' + JSON.stringify(data, null, '\t') + '\n')
  54. //#endif
  55. //#ifdef MP-WEIXIN
  56. console.log('WX小程序模式 => API 请求 Header参数: \n' + JSON.stringify(headerOptions, null, '\t'))
  57. //#endif
  58. return new Promise((resolve, reject) => {
  59. if (showLoading) {
  60. // uni.showLoading({
  61. // title: '加载中···'
  62. // });
  63. // uni.hideLoading();
  64. }
  65. // console.log(getApp().globalData.isEnableSwitchToken,"isEnableSwitchToken")
  66. // console.log(switchToken, "switchToken")
  67. uni.request({
  68. url: _url,
  69. method: method,
  70. data: data,
  71. withCredentials: true,
  72. header: headerOptions,
  73. success(res) {
  74. if (res.statusCode == 200) {
  75. if (res.data.code != 200) {
  76. if (res.data.code == 60001 || res.data.code == 406) {
  77. if (!getApp().globalData.logining) {
  78. getApp().globalData.logining = true //防止同时多个接口触发登录
  79. if (util.isMiniPg() || (getApp().globalData.appId && util
  80. .isWeiXinBrowser())) {
  81. //小程序或公众号H5,删除wx_token_name|wx_token_value重新登录
  82. uni.removeStorageSync(__config.tokenNameKey);
  83. uni.removeStorageSync(__config.tokenValueKey);
  84. getApp().doLogin().then(res => {
  85. var pages = getCurrentPages(); // 获取页面栈
  86. var currPage = pages[pages.length - 1]; // 当前页面
  87. currPage.onLoad(currPage.options)
  88. currPage.onShow()
  89. });
  90. } else {
  91. util.backLoginPage()
  92. }
  93. setTimeout(function() {
  94. getApp().globalData.logining = false;
  95. }, 2000);
  96. }
  97. reject("session过期重新登录");
  98. } else if (res.data.code == 60003) {
  99. if (!getApp().globalData.logining2) {
  100. getApp().globalData.logining2 = true //防止同时多个接口触发登录
  101. util.backLoginPage()
  102. setTimeout(function() {
  103. getApp().globalData.logining2 = false;
  104. }, 2000);
  105. }
  106. reject("请先登录系统");
  107. } else {
  108. let code = ["80050"]
  109. for (var i = 0; i < code.length; i++) {
  110. if(code[i] = res.data.code){
  111. reject(res.data)
  112. }else{
  113. uni.showModal({
  114. title: '提示',
  115. content: res.data.msg + '',
  116. success() {},
  117. complete() {
  118. }
  119. });
  120. }
  121. }
  122. // reject(res.data.msg);
  123. }
  124. }
  125. resolve(res.data);
  126. } else if (res.statusCode == 404) {
  127. uni.showModal({
  128. title: '提示',
  129. content: '接口请求出错,请检查手机网络',
  130. success(res) {}
  131. });
  132. reject();
  133. } else if (res.statusCode == 502) {
  134. console.log(502)
  135. uni.showModal({
  136. title: '提示',
  137. content: '服务器维护中,请稍后再来',
  138. success(res) {}
  139. });
  140. reject();
  141. } else if (res.statusCode == 503) {
  142. console.log(503)
  143. uni.showModal({
  144. title: '提示',
  145. content: '503错误,服务未启动',
  146. success(res) {}
  147. });
  148. reject();
  149. } else {
  150. console.error(`API请求=>接口地址: ${_url} \n错误信息: ${res.data.msg}`);
  151. // uni.showModal({
  152. // title: '提示',
  153. // content: '错误:' + res.data.msg,
  154. // success(res) {}
  155. // });
  156. reject();
  157. }
  158. },
  159. fail(error) {
  160. console.error(`[fail].API请求=>接口地址: ${_url} \n错误信息: ${JSON.stringify(error, null, '\t')}`);
  161. uni.showModal({
  162. title: '提示',
  163. content: '接口请求出错:' + error.errMsg,
  164. success(res) {}
  165. });
  166. reject(error);
  167. },
  168. complete(res) {
  169. uni.hideLoading();
  170. }
  171. });
  172. });
  173. };
  174. // 登录成功后需要进行的统一操作
  175. const loginSuccess = (request) => {
  176. return new Promise((resolve, reject) => {
  177. request.then((res) => {
  178. if (res && res.data.id) { // 登录成功
  179. console.log("************登录成功************");
  180. let userInfo = res.data;
  181. uni.setStorageSync('third_session', userInfo.thirdSession);
  182. uni.setStorageSync('user_info', userInfo);
  183. getApp().userOnlineHeartbeat()
  184. }
  185. resolve(res)
  186. }).catch((err) => {
  187. reject(err)
  188. })
  189. })
  190. }
  191. // 退出登录后需要进行的统一操作
  192. const logoutSuccess = (request) => {
  193. return new Promise((resolve, reject) => {
  194. request.then((res) => {
  195. //退出登录成功
  196. console.log("************退出登录成功************");
  197. getApp().userOnlineHeartbeat(true)
  198. resolve(res)
  199. }).catch((err) => {
  200. reject(err)
  201. })
  202. })
  203. }
  204. module.exports = {
  205. request,
  206. doGet: function(url, params, isShowLoading = true) {
  207. return request(url, 'get', params, isShowLoading);
  208. },
  209. doPost: function(url, params, isShowLoading = true) {
  210. return request(url, 'post', params, isShowLoading);
  211. },
  212. doPut: function(url, params, isShowLoading = true) {
  213. return request(url, 'put', params, isShowLoading);
  214. },
  215. doDelete: function(url, params, isShowLoading = true) {
  216. return request(url, 'delete', params, isShowLoading);
  217. },
  218. deviceReport: (data) => {
  219. // 点餐机设备信息上报
  220. return new Promise((resolve, reject) => {
  221. request('/mallapi/deviceReport/add', 'post', data, false).then(res => {
  222. resolve(res)
  223. }).catch(error => {
  224. reject(error)
  225. })
  226. })
  227. },
  228. userInfoGet: () => {
  229. //查询点餐平台用户信息
  230. //小程序获取当前登录用户信息
  231. return new Promise((resolve, reject) => {
  232. request('/openapi/ma/common/getCurrentUser', 'get', null, false).then(res => {
  233. /**
  234. * 缓存用户信息
  235. */
  236. let wxMemberInfo = util.parseUser(res.data)
  237. uni.setStorageSync(__config.loginWxUserInfoKey, wxMemberInfo)
  238. res.data = wxMemberInfo
  239. resolve(res)
  240. }).catch(error => {
  241. console.error('小程序获取当前登录用户信息出错: ' + error)
  242. reject(error)
  243. })
  244. })
  245. },
  246. getCurrentUserSync: (data) => {
  247. //小程序获取当前登录用户信息
  248. return new Promise((resolve, reject) => {
  249. request('/openapi/ma/common/getCurrentUser', 'get', data, false).then(res => {
  250. /**
  251. * 缓存用户信息
  252. */
  253. let wxMemberInfo = util.parseUser(res.data)
  254. uni.setStorageSync(__config.loginWxUserInfoKey, wxMemberInfo)
  255. res.data = wxMemberInfo
  256. resolve(res)
  257. }).catch(error => {
  258. console.error('小程序获取当前登录用户信息出错: ' + error)
  259. reject(error)
  260. })
  261. })
  262. },
  263. /* 小程序文件上传方法 */
  264. uploadFile: (params, filePath) => {
  265. uni.showLoading({
  266. title: '文件上传中...'
  267. });
  268. let tokenName = uni.getStorageSync(__config.tokenNameKey)
  269. let tokenValue = uni.getStorageSync(__config.tokenValueKey)
  270. let headerTokenObj = {}
  271. if (tokenName && tokenValue) {
  272. headerTokenObj[tokenName ? tokenName : 'rs-auth-token'] = tokenValue ? tokenValue : ''
  273. }
  274. headerTokenObj = Object.assign({
  275. "Content-Type": "multipart/form-data"
  276. }, headerTokenObj)
  277. if (!params) {
  278. params = {
  279. dir: '/uploads/',
  280. }
  281. }
  282. //小程序上传文件
  283. return new Promise((resolve, reject) => {
  284. uni.uploadFile({
  285. url: __config.basePath + '/openapi/storage/upload?dir=' + params.dir,
  286. filePath: filePath,
  287. name: 'file',
  288. header: headerTokenObj,
  289. //formData: params,
  290. success: (res) => {
  291. resolve(JSON.parse(res.data))
  292. },
  293. fail: (err) => {
  294. reject(err)
  295. },
  296. complete(res) {
  297. uni.hideLoading();
  298. }
  299. })
  300. })
  301. },
  302. getSingleConfig: key => {
  303. //根据配置Key获取单个配置值(返回单个值)
  304. return request('/openapi/common/getSingleConfig/' + key, 'get', null, false);
  305. },
  306. getMultipleConfig: keys => {
  307. //根据配置Keys获取多个配置值(返回对象)
  308. return request('/openapi/common/getMultipleConfig/' + keys, 'get', null, false);
  309. },
  310. getMultipleConfigByMasterKey: masterKey => {
  311. //根据配置主表Key获取多个配置值(返回对象)
  312. return request('/openapi/common/getMultipleConfig/masterKey/' + masterKey, 'get', null, false);
  313. },
  314. getGroupDataList: groupKey => {
  315. //根据组Key获取数据集合(不分页)
  316. return request('/openapi/common/getGroupDataList/' + groupKey, 'get', null, false);
  317. },
  318. getGroupDataPageList: groupKey => {
  319. //根据组Key获取数据集合(不分页)
  320. return request('/openapi/common/getGroupDataPageList/' + groupKey, 'get', null, false);
  321. },
  322. getDictByKey: data => {
  323. //获取字典信息(根据字典编码)
  324. return request('/openapi/common/getDictByKey/' + data, 'get', null, false);
  325. },
  326. getConfigByKey: data => {
  327. //获取字典信息(根据字典编码)
  328. return request('/openapi/common/getConfigByKey/' + data, 'get', null, false);
  329. },
  330. getAssetsByKey: data => {
  331. //获取资产信息(根据资产编码)
  332. return request('/openapi/assets/info/' + data, 'get', null, false);
  333. },
  334. getAssetsJsonByKey: (key) => {
  335. //获取当前项目配置信息
  336. return new Promise((resolve, reject) => {
  337. request('/openapi/assets/info/' + key, 'get', null, false).then(res => {
  338. try {
  339. if(res.data.length > 0){
  340. resolve(JSON.parse(res.data[0].itemValue))
  341. }else{
  342. resolve(undefined)
  343. }
  344. } catch (err) {
  345. console.error(err)
  346. resolve(undefined)
  347. }
  348. }).catch(error => {
  349. console.error('小程序获取静态资源配置信息出错: ' + error)
  350. resolve(undefined)
  351. })
  352. })
  353. },
  354. unifiedOrder: data => {
  355. //聚合支付下单接口
  356. /* {
  357. "orderId":"1519237400780607571",
  358. "payType":"PAY_TYPE_WX_MA"
  359. }*/
  360. return request('/openapi/payment/unifiedOrder', 'post', data, null, true);
  361. },
  362. loginWxMa: data => {
  363. //如果有分享人则带上分享人的user_code
  364. data = util.dataAddSharerUserCode(data)
  365. //微信小程序登录接口
  366. // return request('/mallapi/wxuser/loginma', 'post', data, false);
  367. return loginSuccess(request('/mallapi/wxuser/loginma', 'post', data, false));
  368. },
  369. loginWxMp: data => {
  370. //如果有分享人则带上分享人的user_code
  371. data = util.dataAddSharerUserCode(data)
  372. //微信公众号登录接口
  373. return loginSuccess(request('/mallapi/wxuser/loginmp', 'post', data, false));
  374. },
  375. loginByPhoneMa: data => {
  376. //如果有分享人则带上分享人的user_code
  377. data = util.dataAddSharerUserCode(data)
  378. //点餐平台通过小程序授权手机号一键登录点餐平台
  379. return loginSuccess(request('/mallapi/userinfo/ma/phone/login', 'post', data, true));
  380. },
  381. loginByPhone: data => {
  382. //如果有分享人则带上分享人的user_code
  383. data = util.dataAddSharerUserCode(data)
  384. //点餐平台手机验证码登录点餐平台
  385. return loginSuccess(request('/mallapi/userinfo/phone/login', 'post', data, true));
  386. },
  387. login: data => {
  388. //如果有分享人则带上分享人的user_code
  389. data = util.dataAddSharerUserCode(data)
  390. //点餐平台账号登录
  391. return loginSuccess(request('/mallapi/userinfo/login', 'post', data, true));
  392. },
  393. logout: data => {
  394. //点餐平台退出登录
  395. return logoutSuccess(request('/mallapi/userinfo/logout', 'post', data, true));
  396. },
  397. getPhoneCode: data => {
  398. //获取手机验证码
  399. return request('/mallapi/phone/code', 'get', data, true);
  400. },
  401. register: data => {
  402. //如果有分享人则带上分享人的user_code
  403. data = util.dataAddSharerUserCode(data)
  404. //账号注册
  405. return request('/mallapi/userinfo/register', 'post', data, true);
  406. },
  407. updateUserPhone: data => {
  408. //修改点餐平台用户手机号
  409. return request('/mallapi/userinfo/phone', 'post', data, true);
  410. },
  411. getJsSdkConfig: data => {
  412. //获取jssdk config参数
  413. return request('/mallapi/wxjssdk/config', 'post', data, false);
  414. },
  415. themeMobileGet: () => {
  416. //获取点餐平台主题装修配置
  417. return new Promise((resolve, reject) => {
  418. resolve({})
  419. });
  420. },
  421. getShopNameArr: () => {
  422. //店铺列表
  423. return request('/mallapi/shopinfo/getShopNameArr', 'get', null, false);
  424. },
  425. shopInfoPage: data => {
  426. //店铺列表
  427. return request('/mallapi/shopinfo/page', 'get', data, false);
  428. },
  429. shopInfoPageWithSpu: data => {
  430. //店铺列表带菜品
  431. return request('/mallapi/shopinfo/pagewithspu', 'get', data, false);
  432. },
  433. shopInfoGet: id => {
  434. //店铺查询
  435. return request('/mallapi/shopinfo/' + id, 'get', null, false);
  436. },
  437. userInfoUpdateByMa: data => {
  438. //通过微信小程序更新用户信息
  439. return request('/mallapi/userinfo/ma', 'put', data, true);
  440. },
  441. userInfoUpdateByMp: data => {
  442. //通过微信公众号网页授权更新用户信息
  443. return request('/mallapi/userinfo/mp', 'put', data, true);
  444. },
  445. getSpuPriceGoodsCoupon: data => {
  446. //订单菜品单独计算商品兑换券
  447. return request('/mallapi/orderCountPrice/computeGoodsCoupon', 'post', data, true);
  448. },
  449. goodsCategoryTree: data => {
  450. //点餐平台菜品分类tree查询
  451. return request('/mallapi/goodscategory/tree', 'get', data, false);
  452. },
  453. goodsCategoryShopTree: data => {
  454. //店铺菜品分类tree查询
  455. return request('/mallapi/goodscategoryshop/tree', 'get', data, true);
  456. },
  457. goodsPage: data => {
  458. //菜品列表
  459. return request('/mallapi/goodsspu/page', 'get', data, false);
  460. },
  461. goodsGet: id => {
  462. //菜品查询
  463. return request('/mallapi/goodsspu/' + id, 'get', null, false);
  464. },
  465. goodsSpecGet: data => {
  466. //菜品规格查询
  467. return request('/mallapi/goodsspuspec/tree', 'get', data, true);
  468. },
  469. shoppingCartPage: data => {
  470. //购物车列表
  471. return request('/mallapi/shoppingcart/page', 'get', data, false);
  472. },
  473. shoppingCartEmpty: data => {
  474. //清空购物车列表
  475. return request('/mallapi/shoppingcart', 'delete', data, false);
  476. },
  477. shoppingCartAdd: data => {
  478. //购物车新增
  479. return request('/mallapi/shoppingcart', 'post', data, true);
  480. },
  481. shoppingCartUpdate: data => {
  482. //购物车修改
  483. return request('/mallapi/shoppingcart', 'put', data, true);
  484. },
  485. shoppingCartDel: data => {
  486. //购物车删除
  487. return request('/mallapi/shoppingcart/del', 'post', data, false);
  488. },
  489. shoppingCartCount: data => {
  490. //购物车数量
  491. return request('/mallapi/shoppingcart/count', 'get', data, false);
  492. },
  493. shoppingToOrder: data => {
  494. //购物车数量
  495. return request('/mallapi/shoppingcart/toOrder', 'post', data, false);
  496. },
  497. orderSub: data => {
  498. //订单提交
  499. return request('/mallapi/orderinfo', 'post', data, true);
  500. },
  501. queryMicroOrder: data => {
  502. //付款码支付查询订单交易状态
  503. return request('/mallapi/orderinfo/queryMicroOrder/' + data.orderId, 'post', data , false);
  504. },
  505. getIndexStatus: tenantId => {
  506. //判断租户是否要显示首页(堂食还是外卖页)
  507. return request('/mallapi/orderinfo/getIndexStatus/' + tenantId, 'get', null , false);
  508. },
  509. getSendFloor: tenantId => {
  510. //获取餐厅配送楼层信息
  511. return request('/mallapi/orderinfo/getSendFloor/' + tenantId, 'get', null , false);
  512. },
  513. getRoomNo: tenantId => {
  514. //获取餐厅是显示楼层信息还是房间号信息
  515. return request('/mallapi/orderinfo/getRoomNo/' + tenantId, 'get', null , false);
  516. },
  517. orderPage: data => {
  518. //订单列表
  519. return request('/mallapi/orderinfo/page', 'get', data, false);
  520. },
  521. orderGet: id => {
  522. //订单详情查询
  523. return request('/mallapi/orderinfo/' + id, 'get', null, false);
  524. },
  525. orderAgain: data => {
  526. //再来一单
  527. return request('/mallapi/orderinfo/anotherOrder', 'get', data, false);
  528. },
  529. orderCancel: id => {
  530. //订单确认取消
  531. return request('/mallapi/orderinfo/cancel/' + id, 'put', null, true);
  532. },
  533. orderReceive: id => {
  534. //订单确认收货
  535. return request('/mallapi/orderinfo/receive/' + id, 'put', null, true);
  536. },
  537. orderDel: id => {
  538. //订单删除
  539. return request('/mallapi/orderinfo/' + id, 'delete', null, false);
  540. },
  541. orderCountAll: data => {
  542. //订单计数
  543. return request('/mallapi/orderinfo/countAll', 'get', data, false);
  544. },
  545. orderLogisticsGet: logisticsId => {
  546. //订单物流查询
  547. return request('/mallapi/orderinfo/orderlogistics/' + logisticsId, 'get', null, false);
  548. },
  549. unifiedOrder: data => {
  550. //下单接口
  551. return request('/mallapi/orderinfo/unifiedOrder', 'post', data, true);
  552. },
  553. userAddressPage: data => {
  554. //用户收货地址列表
  555. return request('/mallapi/useraddress/page', 'get', data, false);
  556. },
  557. userAddressSave: data => {
  558. //用户收货地址新增
  559. return request('/mallapi/useraddress', 'post', data, true);
  560. },
  561. userAddressDel: id => {
  562. //用户收货地址删除
  563. return request('/mallapi/useraddress/' + id, 'delete', null, false);
  564. },
  565. userCollectAdd: data => {
  566. //用户收藏新增
  567. return request('/mallapi/usercollect', 'post', data, true);
  568. },
  569. userCollectDel: id => {
  570. //用户收藏删除
  571. return request('/mallapi/usercollect/' + id, 'delete', null, false);
  572. },
  573. userCollectPage: data => {
  574. //用户收藏列表
  575. return request('/mallapi/usercollect/page', 'get', data, false);
  576. },
  577. userFootprintPage: data => {
  578. //用户足迹列表
  579. return request('/mallapi/userfootprint/page', 'get', data, false);
  580. },
  581. goodsAppraisesAdd: data => {
  582. //菜品评价新增
  583. return request('/mallapi/goodsappraises', 'post', data, true);
  584. },
  585. getSpuPriceTwo: data => {
  586. //订单菜品单独计算优惠信息
  587. return request('/mallapi/orderCountPrice/computeTwo', 'post', data, true);
  588. },
  589. orderPriceSub: data => {
  590. //订单提交(新版 2023-08-22)
  591. return request('/mallapi/orderinfo/orderPriceSub', 'post', data, true);
  592. },
  593. goodsAppraisesPage: data => {
  594. //菜品评价列表
  595. return request('/mallapi/goodsappraises/page', 'get', data, false);
  596. },
  597. qrCodeUnlimited: data => {
  598. //获取小程序二维码
  599. return request('/mallapi/wxqrcode/unlimited', 'post', data, true);
  600. },
  601. orderItemGet: id => {
  602. //查询订单详情
  603. return request('/mallapi/orderitem/' + id, 'get', null, false);
  604. },
  605. orderRefundsSave: data => {
  606. //发起退款
  607. return request('/mallapi/orderrefunds', 'post', data, true);
  608. },
  609. userInfoUpdate: (data) => {
  610. //修改点餐平台用户
  611. return request('/mallapi/userinfo', 'put', data, true);
  612. },
  613. pointsRecordPage: data => {
  614. //查询积分记录
  615. return request('/mallapi/pointsrecord/page', 'get', data, false);
  616. },
  617. pointsConfigGet: () => {
  618. //查询积分配置
  619. return request('/mallapi/pointsconfig', 'get', null, false);
  620. },
  621. couponUserSave: data => {
  622. //电子券用户领取
  623. return request('/mallapi/couponuser', 'post', data, true);
  624. },
  625. couponUserInfo: data => {
  626. //优惠卷详情
  627. return request('/mallapi/couponuser/' + data.id, 'get', false);
  628. },
  629. addCouponAndSendToUser: data => {
  630. //根据优惠券规则ID生成商品券并分给当前用户
  631. return request('/mallapi/coupon/addCouponAndSendToUser', 'get' , data , false);
  632. },
  633. getBookingDate: data => {
  634. //获取预约可选时间
  635. return request('/mallapi/orderinfo/getBookingDate', 'get', data, false);
  636. },
  637. getSaleTime: ()=>{
  638. //获取餐厅菜品销售时间
  639. return request('/mallapi/orderinfo/getSaleTimeType', 'get', null, false);
  640. },
  641. getSendTime: data=>{
  642. //获取可配送时间
  643. return request('/mallapi/orderinfo/getSendTime', 'get', data, false);
  644. },
  645. getSubscribeOrderCouponAmount: data => {
  646. //获取预约订单优惠规则及金额
  647. return request('/mallapi/settlementCoupon/getSubscribeOrderCouponAmount', 'post', data, false);
  648. },
  649. couponUserPage: (data,pageParam) => {
  650. pageParam = pageParam||{}
  651. //电子券用户列表
  652. return request(`/mallapi/couponuser/page?pageNum=${pageParam.pageNum}&pageSize=${pageParam.pageSize}`, 'post', data, true);
  653. },
  654. goodCouponPage: (data,pageParam) => {
  655. pageParam = pageParam||{}
  656. //商品券用户列表
  657. return request(`/mallapi/couponuser/goodCouponPage?pageNum=${pageParam.pageNum}&pageSize=${pageParam.pageSize}`, 'post', data, true);
  658. },
  659. receiveGoodCoupon: data => {
  660. //用户扫码绑定优惠券
  661. return request('/mallapi/couponuser/receiveGoodCoupon', 'get', data, false);
  662. },
  663. couponInfoPage: data => {
  664. //电子券列表
  665. return request('/mallapi/couponinfo/page', 'get', data, false);
  666. },
  667. bargainInfoPage: data => {
  668. //砍价列表
  669. return request('/mallapi/bargaininfo/page', 'get', data, false);
  670. },
  671. bargainInfoGet: data => {
  672. //砍价详情
  673. return request('/mallapi/bargaininfo', 'get', data, true);
  674. },
  675. bargainUserSave: data => {
  676. //发起砍价
  677. return request('/mallapi/bargainuser', 'post', data, true);
  678. },
  679. bargainCutPage: data => {
  680. //帮砍记录
  681. return request('/mallapi/bargaincut/page', 'get', data, true);
  682. },
  683. bargainUserGet: id => {
  684. //砍价记录详情
  685. return request('/mallapi/bargainuser/' + id, 'get', null, false);
  686. },
  687. bargainUserPage: data => {
  688. //砍价记录列表
  689. return request('/mallapi/bargainuser/page', 'get', data, true);
  690. },
  691. bargainCutSave: data => {
  692. //砍一刀
  693. return request('/mallapi/bargaincut', 'post', data, true);
  694. },
  695. listEnsureBySpuId: data => {
  696. //通过spuID,查询菜品保障
  697. return request('/mallapi/ensuregoods/listEnsureBySpuId', 'get', data, true);
  698. },
  699. grouponInfoPage: data => {
  700. //拼团列表
  701. return request('/mallapi/grouponinfo/page', 'get', data, false);
  702. },
  703. grouponInfoGet: id => {
  704. //拼团详情
  705. return request('/mallapi/grouponinfo/' + id, 'get', null, true);
  706. },
  707. grouponUserPageGrouponing: data => {
  708. //拼团中分页列表
  709. return request('/mallapi/grouponuser/page/grouponing', 'get', data, true);
  710. },
  711. grouponUserPage: data => {
  712. //拼团记录列表
  713. return request('/mallapi/grouponuser/page', 'get', data, true);
  714. },
  715. grouponUserGet: id => {
  716. //拼团记录详情
  717. return request('/mallapi/grouponuser/' + id, 'get', null, false);
  718. },
  719. seckillhallList: date => {
  720. //秒杀会场时间列表
  721. return request('/mallapi/seckillhall/list?hallDate=' + date, 'get', null, false);
  722. },
  723. seckillinfoPage: data => {
  724. //秒杀列表
  725. return request('/mallapi/seckillinfo/page', 'get', data, false);
  726. },
  727. seckillInfoGet: (seckillHallInfoId) => {
  728. //秒杀详情
  729. return request('/mallapi/seckillinfo/' + seckillHallInfoId, 'get', null, true);
  730. },
  731. wxTemplateMsgList: data => {
  732. //订阅消息列表
  733. return request('/mallapi/wxtemplatemsg/list', 'post', data, false);
  734. },
  735. liveRoomInfoList: data => {
  736. //获取直播房间列表
  737. return request('/mallapi/wxmalive/roominfo/list', 'get', data, true);
  738. },
  739. customerServiceList: shopId => {
  740. //客服列表
  741. return request('/mallapi/customerservice/list/' + shopId, 'get', null, false);
  742. },
  743. pagedevise: pageType => {
  744. //首页组件配置
  745. return new Promise((resolve, reject) => {
  746. resolve({code: 200, data: {}})
  747. });
  748. },
  749. pagedeviseShop: shopId => {
  750. // 店铺组件配置
  751. return request('/mallapi/pagedevise?pageType=2&shopId=' + shopId, 'get', null, false);
  752. },
  753. getJiguangConfig: data => {
  754. //获取极光参数
  755. return request('/mallapi/jiguang/config', 'get', data, false);
  756. },
  757. getJiguangMessages: data => {
  758. //获取极光消息
  759. return request('/mallapi/jiguang/messages?userName=' + data.userName + '&beginTime=' + data.beginTime +
  760. '&endTime=' + data.endTime, 'get', null, false);
  761. },
  762. articlePage: data => {
  763. //文章列表
  764. return request('/mallapi/articleinfo/page', 'get', data, false);
  765. },
  766. articleGet: id => {
  767. //文章详情
  768. return request('/mallapi/articleinfo/' + id, 'get', null, false);
  769. },
  770. articleCategoryPage: data => {
  771. //文章分类列表
  772. return request('/mallapi/articlecategory/page', 'get', data, false);
  773. },
  774. userSign: data => {
  775. //积分签到
  776. return request('/mallapi/signrecord/user', 'post', data, false);
  777. },
  778. getSignRecord: data => {
  779. //签到记录查询
  780. return request('/mallapi/signrecord/user', 'get', data, false);
  781. },
  782. signConfigPage: data => {
  783. //获取签到积分记录
  784. return request('/mallapi/signconfig/page', 'get', data, false);
  785. },
  786. distributionConfig: () => {
  787. //分销设置查询
  788. return request('/mallapi/distributionconfig', 'get');
  789. },
  790. distributionuser: () => {
  791. //分销员查询
  792. return request('/mallapi/distributionuser', 'get');
  793. },
  794. distributionuserPage: (data) => {
  795. //分销员查询
  796. return request('/mallapi/distributionuser/page', 'get', data);
  797. },
  798. distributionorderPage: data => {
  799. //分销订单分页
  800. return request('/mallapi/distributionorder/page', 'get', data);
  801. },
  802. distributionorderFrozenAmount: data => {
  803. //获取当前分销员的冻结金额
  804. return request('/mallapi/distributionorder/frozenAmount', 'get', data);
  805. },
  806. distributionPromotionPage: data => {
  807. //分销 推广人统计
  808. return request('/mallapi/userinfo/page', 'get', data);
  809. },
  810. userwithdrawRecordSave: data => {
  811. //分销 申请提现
  812. return request('/mallapi/userwithdrawrecord', 'post', data, true);
  813. },
  814. userwithdrawRecordUpdate: data => {
  815. //分销 提现申请修改
  816. return request('/mallapi/userwithdrawrecord', 'put', data, true);
  817. },
  818. userwithdrawRecordPage: data => {
  819. //分销 提现记录
  820. return request('/mallapi/userwithdrawrecord/page', 'get', data);
  821. },
  822. userwithdrawRecord: id => {
  823. //分销 提现记录详情
  824. return request('/mallapi/userwithdrawrecord/' + id, 'get', null);
  825. },
  826. userRecord: () => {
  827. //分销 用户消费总额记录
  828. return request('/mallapi/userrecord', 'get', null);
  829. },
  830. wxAppConfig: id => {
  831. //获取wx一件授权的component_appid
  832. return request('/mallapi/wxapp/' + id, 'get', null);
  833. },
  834. userAppraisesPage: data => {
  835. //我的评价
  836. return request('/mallapi/goodsappraises/page/user', 'get', data);
  837. },
  838. goodsSpuListByIds: data => {
  839. //根据id集合菜品查询
  840. if (data && data.length > 0) {
  841. return request('/mallapi/goodsspu/listbyids', 'post', data, false);
  842. } else {
  843. return new Promise((resolve, reject) => {
  844. resolve({
  845. data: []
  846. })
  847. })
  848. }
  849. },
  850. userOnlineHeartbeat: data => {
  851. // 接收点餐平台用户心跳
  852. return request('/mallapi/useronline/heartbeat', 'get', data);
  853. },
  854. orderingMachineActivityList: data => {
  855. //点餐机活动列表
  856. return request('/mallapi/activity/orderingMachineActivityList', 'get', data);
  857. },
  858. appActivityList: data => {
  859. //小程序活动列表
  860. return request('/mallapi/activity/appActivityList', 'get', data, true);
  861. },
  862. goodscategoryshop: data => {
  863. // 分页查询店铺分类列表
  864. return request('/mallapi/goodscategoryshop/page', 'get', data, true);
  865. },
  866. goodscategory: data => {
  867. // 分页查询菜品分类列表
  868. return request('/mallapi/goodscategory/page', 'get', data);
  869. },
  870. goodscategorytoshop: data => {
  871. // 分页查询菜品分类列表
  872. return request('/mallapi/goodscategory/pageOne', 'get', data);
  873. },
  874. shopinfo: data => {
  875. // 分页查询店铺列表
  876. return request('/mallapi/shopinfo/page', 'get', data);
  877. },
  878. goodsspu: data => {
  879. // 分页查询菜品列表
  880. return request('/mallapi/goodsspu/page', 'post', data, true);
  881. },
  882. getGoodsSpu: data => {
  883. // 根据菜品ID查询此菜品的SKU
  884. return request('/mallapi/goodsspu/' + data.spuId, 'get', null);
  885. },
  886. goodsspuspec: data => {
  887. // 根据菜品ID查询此菜品的SKU
  888. return request('/mallapi/goodsspuspec/tree' + data.spuId, 'get', null);
  889. },
  890. goodCouponSpecTree: data => {
  891. //获取菜品规格(商品礼券结算用)
  892. return request('/mallapi/goodsspuspec/goodCouponSpecTree' ,'get', data, false);
  893. },
  894. invoiceHeaderPage: data => {
  895. // 发票抬头分页查询
  896. return request('/mallapi/invoiceHeader/page', 'get', data,true);
  897. },
  898. invoiceHeaderSave: data => {
  899. // 发票抬头新增
  900. return request('/mallapi/invoiceHeader/save', 'post', data,true);
  901. },
  902. invoiceHeaderDetail: data => {
  903. // 发票抬头详情
  904. return request('/mallapi/invoiceHeader/selectDetails/' + data.id, 'get',true );
  905. },
  906. invoiceHeaderUpdate: data => {
  907. // 发票抬头修改
  908. return request('/mallapi/invoiceHeader/update', 'post', data,true);
  909. },
  910. invoiceHeaderDelete: data => {
  911. // 发票抬头删除
  912. return request('/mallapi/invoiceHeader/delete/' + data.id, 'delete',true );
  913. },
  914. couldInvoicedOrder: data => {
  915. // 当前用户未可开票的订单
  916. return request('/mallapi/invoiceHistory/couldInvoicedOrder', 'get', data,true);
  917. },
  918. getInvoiceHeader: data => {
  919. // 申请开票时的发票抬头列表,默认选中第一个
  920. return request('/mallapi/invoiceHistory/getInvoiceHeader', 'get',true)
  921. },
  922. apply: data => {
  923. // 确认申请开票
  924. return request('/mallapi/invoiceHistory/apply', 'post', data,true)
  925. },
  926. selectDetails: data => {
  927. // 开票记录详情
  928. return request('/mallapi/invoiceHistory/selectDetails/' + data.id, 'get',true);
  929. },
  930. selectList: data => {
  931. // 分页查询开票记录
  932. return request('/mallapi/invoiceHistory/invoiceHistoryPage', 'get' , data,true);
  933. },
  934. takeAwayMachineTemplate: orderId => {
  935. // 获取点餐机支付成功打印模板数据
  936. return request('/mallapi/orderinfo/takeAwayMachineStr/' + orderId, 'get' , null, false);
  937. },
  938. takeAwayMachineTemplates: orderId => {
  939. // 获取点餐机支付失败打印模板数据
  940. return request('/mallapi/orderinfo/takeAwayMachineStrError/' + orderId, 'get' , null, false);
  941. },
  942. getSwitchToken: data =>{
  943. // 获取点餐机临时token
  944. return request('/openapi/ma/common/getSwitchToken', 'get' , data);
  945. },
  946. setSwitchToken: data =>{
  947. // 存储点餐机临时token
  948. return request('/openapi/ma/common/setSwitchToken', 'get' , data);
  949. },
  950. getCouponList: data =>{
  951. // 获取用户优惠券列表(订单结算页用)
  952. return request('/mallapi/settlementCoupon/getCouponList', 'get' , data);
  953. },
  954. companyList: data => {
  955. // 公司列表
  956. return request('/mallapi/userInfo/companyList', 'post', data)
  957. },
  958. updateUserInfo: data => {
  959. // 修改个人信息
  960. return request('/mallapi/userInfo/updateUserInfo', 'post', data)
  961. },
  962. verifyGoodCoupon: data =>{
  963. // 验证商品券是否可用
  964. return request('/mallapi/coupon/verifyGoodCoupon', 'get' , data);
  965. },
  966. fullGoodCoupon: data =>{
  967. // 验证商品券是否可用
  968. return request('/mallapi/coupon/fullGoodCoupon', 'get' , data);
  969. },
  970. newFullGoodCoupon: data =>{
  971. // 验证商品券是否可用(2023-05-08新版)
  972. return request('/mallapi/coupon/newFullGoodCoupon', 'get' , data);
  973. },
  974. getCouponSpuList: data =>{
  975. // 根据商品ID集合查询商品列表(返回购物车接口格式的数据)
  976. return request('/mallapi/coupon/getCouponSpuList', 'get' , data);
  977. },
  978. getMallOpenTime: data =>{
  979. // 获取当前时间、餐厅营业时间
  980. return request('/mallapi/sysMallSettingConfig/getMallOpenTime', 'get' , data);
  981. },
  982. getHalfPriceSpuIdList: data =>{
  983. // 第二份半价
  984. return request('/mallapi/settlementCoupon/getHalfPriceSpuIdList', 'post' , data, true);
  985. },
  986. originRefundOrderItem: data =>{
  987. // 获取已经退款的子单ID集合
  988. return request('/mallapi/orderinfo/originRefundOrderItem', 'get' , data, true);
  989. },
  990. refundOrderInfo: data =>{
  991. // 获取退款详情
  992. return request('/mallapi/orderinfo/refundOrderInfo', 'get' , data, true);
  993. },
  994. cancelRefundApply: data =>{
  995. // 撤销退款申请
  996. return request('/mallapi/orderinfo/cancelRefundApply', 'get' , data, true);
  997. },
  998. sendNotice: data =>{
  999. // 发送帮助
  1000. return request('/mallapi/help/sendNotice', 'get' , data, true);
  1001. },
  1002. getByOrderNo: data =>{
  1003. // 获取订单详情(根据订单编号)
  1004. return request('/mallapi/orderinfo/getByOrderNo', 'get' , data, true);
  1005. },
  1006. publishReceptionPrint: data =>{
  1007. // 执行前台打印机打印
  1008. return request('/mallapi/orderinfo/publishReceptionPrint', 'get' , data, true);
  1009. },
  1010. getMaTemplateIdList: data => {
  1011. // 获取微信小程序模板消息接口
  1012. return request('/mallapi/sysMallSettingConfig/getMaTemplateIdList', 'get', data, false);
  1013. },
  1014. getCompanyInfo: data => {
  1015. // 查询微信授权手机号是否在企业管理员名单中
  1016. return request('/openapi/ma/common/getCompanyInfo', 'get', data, false);
  1017. },
  1018. getWorkingMealInfo: data => {
  1019. // 查询中午订餐记录
  1020. return request('/mallapi/company/getWorkingMealInfo', 'get', data, false);
  1021. },
  1022. getGoodSendRecordInfo: data => {
  1023. // 古野查询订餐记录(代金券)
  1024. return request('/mallapi/company/getGoodSendRecordInfo', 'get', data, false);
  1025. },
  1026. getGoodInfo: data => {
  1027. // 查询该小程序绑定得手机号绑定得公司绑定得优惠券
  1028. return request('/mallapi/company/getGoodInfo', 'get', data, false);
  1029. },
  1030. saveWorkingMealInfo: data => {
  1031. //
  1032. return request('/mallapi/company/save', 'post', data, false);
  1033. },
  1034. saveSendInfo: data => {
  1035. //
  1036. return request('/mallapi/company/saveSendInfo', 'post', data, false);
  1037. },
  1038. getOtherData: data => {
  1039. // 查询剩余金额
  1040. return request('/mallapi/company/getOtherData', 'get', data, false);
  1041. },
  1042. getUrlQRCode:() => {
  1043. return request('/mallapi/company/generate', 'get');
  1044. },
  1045. getRecordsInfo: data => {
  1046. return request('/mallapi/company/getRecordsInfo', 'get', data, false);
  1047. },
  1048. machineAddUpdate: data => {
  1049. // 点餐机新增或更新店铺数据
  1050. return request('/mallapi/deviceReport/addUpdate', 'post', data, false);
  1051. },
  1052. IPAD_fetchShopCateogry: data => {
  1053. // 获取店铺下分类tree
  1054. return request('/magic-api/openapi/ipad/shop/category/tree', 'get', data, false);
  1055. },
  1056. IPAD_getShoppingCart: data => {
  1057. // 获取购物车-预览报表接口
  1058. return request('/magic-api/openapi/ipad/cart/preview/statistics', 'get', data, false);
  1059. },
  1060. IPAD_getTableInfoStatus: (tableId) => {
  1061. // 获取餐桌状态
  1062. return request(`/magic-api/openapi/ipad/floor/table/status?tableId=${tableId}`, 'get', {}, false)
  1063. },
  1064. IPAD_updateShopTablePeople: (data) => {
  1065. // 修改就餐人数
  1066. return request(`/mallapi/ipad/updateDiningPeople`, 'post', data, false)
  1067. },
  1068. PHONE_getFloorList : (data) => {
  1069. // 获取楼层列表
  1070. return request(`/magic-api/openapi/phone/floor/list`, 'get', data, false)
  1071. },
  1072. PHONE_getFloorTableList : (data) => {
  1073. // 获取楼层对应的餐桌列表
  1074. return request(`/magic-api/openapi/phone/floor/tableList`, 'get', data, false)
  1075. },
  1076. PHONE_updateDiningPeople : (data) => {
  1077. // 根据桌号修改就餐人数、入店时间
  1078. return request(`/mallapi/phone/updateDiningPeople`, 'post', data, false)
  1079. },
  1080. PHONE_getTableStatus : (tableId) => {
  1081. // 获取餐桌当前状态
  1082. return request(`/magic-api/openapi/phone/floor/table/tableStatusPhone?tableId=${tableId}`, 'get', {}, false)
  1083. },
  1084. PHONE_fetchShopCategory: data => {
  1085. // 获取店铺下分类tree
  1086. return request('/magic-api/openapi/phone/shop/category/treePhone', 'get', data, false);
  1087. },
  1088. };