forked from gzzfw/frontEnd/gzDyh

liuwh
2024-09-09 2e4d56e2ed95cb0f336522216fedc37167fb446d
gz-wxparty/utils/util.js
@@ -5,7 +5,7 @@
const url = api.url;
// 是否是开发环境
const isDebug = true;
const isDebug = false;
const baseUrl = isDebug ? api.url.debug : api.url.web;
@@ -22,6 +22,7 @@
    submitData,
    service,
    v1,
  ai,
    noToken
}) => {
    const app = getApp();
@@ -50,7 +51,7 @@
    let baseUrl = isDebug ? api.url.debug : api.url.web;
    let visitUrl = `${baseUrl}${api.url[service] || ''}/api/${v1 ? 'v1' : 'wechat'}/${url}`;
  let visitUrl = `${baseUrl}${api.url[service] || ''}/api/${v1 ? 'v1' :ai ? 'ai' : 'wechat'}/${url}`;
    return new Promise((resolve, reject) => {
        wx.request({
@@ -191,6 +192,18 @@
            success && success(res);
        },
    });
};
const ellipsis = ({
  value,
  len
}) => {
  if (!value) return '';
  if (value.length > len) {
    return value.slice(0, len) + '...';
  }
  return value;
};
//api错误modal框消息提示
@@ -348,15 +361,7 @@
const getLocationIndex = (data, currentData) => {
    let selectOption = JSON.parse(JSON.stringify(data));
    let submitData = currentData;
    let arr = [0, 0, 0, 0];
    if (submitData.prov) {
        forEach: for (let i = 0; i < selectOption.length; i++) {
            if (selectOption[i].value === submitData.prov) {
                arr[0] = i;
                break forEach;
            }
        }
    }
  let arr = [0, 0, 0];
    if (submitData.city) {
        forEach: for (let i = 0; i < selectOption[arr[0]].children.length; i++) {
            if (selectOption[arr[0]].children[i].value === submitData.city) {
@@ -373,14 +378,14 @@
            }
        }
    }
    if (submitData.road) {
        forEach: for (let i = 0; i < selectOption[arr[0]].children[arr[1]].children[arr[2]].children.length; i++) {
            if (selectOption[arr[0]].children[arr[1]].children[arr[2]].children[i].value === submitData.road) {
                arr[3] = i;
                break forEach;
            }
        }
    }
  // if (submitData.road) {
  //   forEach: for (let i = 0; i < selectOption[arr[0]].children[arr[1]].children[arr[2]].children.length; i++) {
  //     if (selectOption[arr[0]].children[arr[1]].children[arr[2]].children[i].value === submitData.road) {
  //       arr[3] = i;
  //       break forEach;
  //     }
  //   }
  // }
    return arr;
};
@@ -478,6 +483,7 @@
    showToast,
    errorModal,
    showModal,
  ellipsis,
    showLoading,
    hideLoading,
    timeFormat,