helper.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import * as config from '../config'
  2. const ossUploadUrl = 'https://taohaoliang.oss-cn-beijing.aliyuncs.com/';
  3. const contactCustomerService = (item) => {
  4. console.log(item)
  5. if (!item) {
  6. item = '110'
  7. }
  8. console.log("联系客服")
  9. uni.makePhoneCall({
  10. phoneNumber: item,
  11. success: (res) => {
  12. console.log('调用成功!')
  13. },
  14. // 失败回调
  15. fail: (res) => {
  16. console.log('调用失败!')
  17. contactCustomerService(item)
  18. }
  19. });
  20. }
  21. const logout = () => {
  22. uni.removeStorage({
  23. key: 'userInfo'
  24. })
  25. }
  26. const formatLocation = (str) => {
  27. let area = {}
  28. let index11 = 0
  29. let index1 = str.indexOf("省")
  30. if (index1 == -1) {
  31. index11 = str.indexOf("自治区")
  32. if (index11 != -1) {
  33. area.Province = str.substring(0, index11 + 3)
  34. } else {
  35. area.Province = str.substring(0, 0)
  36. }
  37. } else {
  38. area.Province = str.substring(0, index1 + 1)
  39. }
  40. let index2 = str.indexOf("市")
  41. if (index11 == -1) {
  42. area.City = str.substring(index11 + 1, index2 + 1)
  43. } else {
  44. if (index11 == 0) {
  45. area.City = str.substring(index1 + 1, index2 + 1)
  46. } else {
  47. area.City = str.substring(index11 + 3, index2 + 1)
  48. }
  49. }
  50. let index3 = str.indexOf("区")
  51. if (index3 == -1) {
  52. index3 = str.indexOf("县")
  53. if (index3 == -1) {
  54. index3 = str.lastIndexOf("市")
  55. if (index3 == -1) {
  56. index3 = str.indexOf("镇")
  57. if (index3 == -1) {
  58. } else {
  59. area.Country = str.substring(index2 + 1, index3 + 1)
  60. }
  61. } else {
  62. area.Country = str.substring(index2 + 1, index3 + 1)
  63. }
  64. } else {
  65. area.Country = str.substring(index2 + 1, index3 + 1)
  66. }
  67. } else {
  68. area.Country = str.substring(index2 + 1, index3 + 1)
  69. }
  70. area.Village = str.substring(index3 + 1, str.length)
  71. return area;
  72. }
  73. export default {
  74. logout,
  75. contactCustomerService,
  76. formatLocation
  77. }