product.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. const _Http = getApp().globalData.http,
  2. currency = require("../../utils/currency"),
  3. CNY = (value, symbol = "¥", precision = 2) => currency(value, {
  4. symbol,
  5. precision
  6. }).format();
  7. Component({
  8. options: {
  9. addGlobalClass: true
  10. },
  11. lifetimes: {
  12. attached: function () {
  13. getApp().globalData.Language.getLanguagePackage(this)
  14. this.setData({
  15. siteid: wx.getStorageSync('userMsg').siteid
  16. })
  17. }
  18. },
  19. properties: {
  20. },
  21. data: {
  22. showList: false,
  23. showList1: false,
  24. list: [],
  25. "content": {
  26. "nocache": true,
  27. "pageNumber": 1,
  28. "pageTotal": 1,
  29. "total": null,
  30. "where": {
  31. begdate: "",
  32. enddate: "",
  33. }
  34. }
  35. },
  36. methods: {
  37. getList(id, init) {
  38. let content = this.data.content;
  39. content.sa_projectid = id;
  40. if (init) {
  41. content.pageNumber = 1;
  42. content.total = null;
  43. }
  44. if (!this.data.showList && content.total != null) return;
  45. if (content.pageNumber > content.pageTotal) return;
  46. _Http.basic({
  47. "id": 20230715112104,
  48. content
  49. }).then(res => {
  50. console.log("产品配置明细", res)
  51. if (res.code != '1') return wx.showToast({
  52. title: res.data,
  53. icon: "none"
  54. })
  55. content.pageNumber = res.pageNumber + 1;
  56. content.pageSize = res.pageSize;
  57. content.pageTotal = res.pageTotal;
  58. content.total = res.total;
  59. res.data = res.data.map(v => {
  60. if (v.itemsClassAmount) v.itemsClassAmount = v.itemsClassAmount.map(item => {
  61. item.itemclassAmount = CNY(item.itemclassAmount)
  62. return item
  63. })
  64. v.itemSumAmount = CNY(v.itemSumAmount / (wx.getStorageSync('languagecode') == 'ZH' ? 10000 : 1000))
  65. v.marketprice = CNY(v.marketprice)
  66. v.price = CNY(v.price)
  67. v.amount = CNY(v.amount)
  68. return v
  69. })
  70. this.setData({
  71. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  72. content,
  73. id: id,
  74. });
  75. })
  76. },
  77. shrinkChange({
  78. detail
  79. }) {
  80. this.setData({
  81. showList: detail
  82. })
  83. },
  84. shrinkChange1({
  85. detail
  86. }) {
  87. this.setData({
  88. showList1: detail
  89. })
  90. }
  91. }
  92. })