customItemType.js 1.5 KB

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