request.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. function customSQL(sql, type) {
  2. let promise = new Promise((res, rej) => {
  3. wx.request({
  4. url: "https://server.fmode.cn/api/novaql/select",
  5. data: {
  6. sql: sql,
  7. },
  8. method: "POST",
  9. success(success) {
  10. res(success.data.data);
  11. },
  12. fail(err) {
  13. rej(err);
  14. },
  15. });
  16. });
  17. return promise;
  18. }
  19. function getPhone(code) {
  20. return new Promise((res) => {
  21. wx.request({
  22. url: 'https://server.fmode.cn/api/wxapp/decrypt_phone',
  23. data: {
  24. code: code,
  25. companyId: getApp().globalData.company
  26. },
  27. header: {
  28. 'content-type': 'application/json'
  29. },
  30. method: 'GET',
  31. success: (result) => {
  32. if (result.data.code == 0 && result.data.data && result.data.data.phoneNumber) {
  33. console.log(result.data.data.phoneNumber)
  34. res(result.data.data.phoneNumber)
  35. } else {
  36. wx.showToast({
  37. title: '手机号获取失败',
  38. icon: 'error',
  39. image: '',
  40. duration: 1500,
  41. mask: false,
  42. });
  43. res()
  44. }
  45. },
  46. fail: () => {
  47. wx.showToast({
  48. title: '手机号获取失败',
  49. icon: 'error',
  50. image: '',
  51. duration: 1500,
  52. mask: false,
  53. });
  54. res()
  55. },
  56. complete: () => {
  57. }
  58. });
  59. })
  60. }
  61. module.exports = {
  62. customSQL,
  63. getPhone
  64. };