api.js 38 KB

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