customItemType.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. function getLabelList() {
  2. let siteCustomLabel = {
  3. "default": {
  4. length: "长",
  5. width: "宽",
  6. height: "厚度",
  7. cheek: "边框",
  8. color: "颜色",
  9. material: "基材",
  10. spec: "尺寸",
  11. custom: "定制"
  12. },
  13. "DLB": {
  14. length: "长",
  15. width: "宽",
  16. height: "厚度",
  17. cheek: "工艺",
  18. color: "颜色",
  19. material: "选项",
  20. spec: "尺寸",
  21. custom: "定制"
  22. }
  23. };
  24. return siteCustomLabel[wx.getStorageSync('siteP').siteid] || siteCustomLabel.default
  25. }
  26. function getCustomItems(data, prefix = '') {
  27. const _Http = getApp().globalData.http;
  28. let labelList = getLabelList(),
  29. httpList = [];
  30. for (const key in labelList) {
  31. const name = key + 'schemeid';
  32. if (data[name]) httpList.push({
  33. sa_sizecustomizedschemeid: data[name],
  34. date: Date.now() + 1,
  35. label: labelList[key],
  36. value: data[prefix + key] || "",
  37. key: prefix + key,
  38. name
  39. })
  40. };
  41. return new Promise((resolve, reject) => {
  42. if (!httpList.length) return resolve([]);
  43. Promise.all(httpList.map(v => _Http.basic({
  44. "id": "20230707091603",
  45. "version": 1,
  46. content: v
  47. }))).then(res => resolve(res.map((v, i) => {
  48. v.data = Object.assign(v.data, httpList[i])
  49. return v
  50. }).filter(v => v.msg == '成功').map(v => v.data)))
  51. })
  52. }
  53. function getCustomText(data, prefix = '') {
  54. let labelList = getLabelList(),
  55. customText = [];
  56. for (const key in labelList) {
  57. const name = key + 'schemeid';
  58. if (data[name]) customText.push(`${labelList[key]}:${data[prefix+key]||'定制'}`)
  59. };
  60. return customText
  61. }
  62. module.exports = {
  63. getLabelList,
  64. getCustomItems,
  65. getCustomText
  66. }