index.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. loading: true,
  5. "content": {
  6. "version": 1,
  7. nocache: true,
  8. "pageNumber": 1,
  9. "pageTotal": 1,
  10. "where": {
  11. "condition": ""
  12. },
  13. sort: []
  14. }
  15. },
  16. onLoad(options) {
  17. this.getList()
  18. },
  19. getList(init = false) {
  20. if (init.detail != undefined) init = init.detail;
  21. let content = this.data.content;
  22. if (init) content.pageNumber = 1;
  23. if (content.pageNumber > content.pageTotal) return;
  24. _Http.basic({
  25. "id": 20220103140003,
  26. content
  27. }).then(res => {
  28. console.log("活动列表", res)
  29. this.selectComponent('#ListBox').RefreshToComplete();
  30. let list = res.data.map(v => {
  31. v.surplus = Date.parse(new Date(v.enddate)) - Date.parse(new Date())
  32. return v
  33. });
  34. this.setData({
  35. list: res.pageNumber == 1 ? list : this.data.list.concat(list),
  36. "content.pageNumber": res.pageNumber + 1,
  37. "content.pageTotal": res.pageTotal,
  38. "content.sort": res.sort,
  39. loading: false
  40. })
  41. })
  42. },
  43. onClick({
  44. detail
  45. }) {
  46. console.log(detail)
  47. if (detail.type == '套餐活动') {
  48. wx.navigateTo({
  49. url: '/packageA/activity/bindingProduct/index?params=' + JSON.stringify({
  50. "id": 20230116094803,
  51. "version": 1,
  52. "content": {
  53. nocache: true,
  54. sa_brandid: detail.sa_brandid,
  55. sa_promotionid: detail.sa_promotionid,
  56. packagetype: detail.packagetype,
  57. "where": {
  58. "condition": "",
  59. packagetypemx: '',
  60. }
  61. }
  62. }),
  63. });
  64. getApp().globalData.handleSelect = function ({
  65. list
  66. }) {
  67. return handleSubmit(list)
  68. }.bind(this);
  69. } else {
  70. wx.navigateTo({
  71. url: '/packageA/activity/selectProduct/index?params=' + JSON.stringify({
  72. "id": 20230116094803,
  73. "version": 1,
  74. "content": {
  75. nocache: true,
  76. sa_brandid: detail.sa_brandid,
  77. sa_promotionid: detail.sa_promotionid,
  78. "where": {
  79. "condition": ""
  80. }
  81. }
  82. }),
  83. });
  84. getApp().globalData.handleSelect = function ({
  85. list
  86. }) {
  87. wx.showModal({
  88. title: '提示',
  89. content: '是否确定创建促销订单?',
  90. complete: ({
  91. confirm
  92. }) => {
  93. if (confirm) handleSubmit(list)
  94. }
  95. })
  96. }.bind(this);
  97. }
  98. function handleSubmit(list) {
  99. return new Promise((resolve) => {
  100. wx.showLoading({
  101. title: '生成中...',
  102. mask: true
  103. })
  104. _Http.basic({
  105. "id": 20221128183202,
  106. "content": {
  107. istool: 0,
  108. type: "促销订单",
  109. sa_orderid: 0,
  110. sa_accountclassid: detail.sa_accountclassid,
  111. rec_contactsid: 0,
  112. pay_enterpriseid: 0,
  113. sa_contractid: 0,
  114. sa_projectid: 0,
  115. sa_promotionid: detail.sa_promotionid,
  116. sa_brandid: detail.sa_brandid, //品牌ID
  117. type: "促销订单", //订单类型
  118. tradefield: detail.tradefield.join(','), //必选
  119. items: list.map(v => {
  120. return {
  121. sa_orderitemsid: 0,
  122. itemid: v.itemid,
  123. itemno: v.itemno,
  124. qty: v.qty,
  125. price: v.price,
  126. length: v.length,
  127. width: v.width,
  128. sa_promotion_itemsid: v.sa_promotion_itemsid,
  129. cheek: v.cheek,
  130. color: v.color,
  131. material: v.material,
  132. spec: v.spec,
  133. custom: v.custom
  134. }
  135. })
  136. }
  137. }).then(res => {
  138. wx.hideLoading()
  139. console.log("转化促销订单", res)
  140. resolve(res.msg == '成功')
  141. wx.showToast({
  142. title: res.msg != '成功' ? res.msg : '创建成功',
  143. icon: "none",
  144. mask: res.msg == '成功'
  145. });
  146. if (res.msg == '成功') setTimeout(() => {
  147. wx.redirectTo({
  148. url: '/packageA/orderForm/detail?id=' + res.data.sa_orderid,
  149. });
  150. delete getApp().globalData.handleSelect
  151. }, 500)
  152. })
  153. })
  154. }
  155. },
  156. onSearch({
  157. detail
  158. }) {
  159. this.setData({
  160. "content.where.condition": detail
  161. });
  162. this.getList(true)
  163. },
  164. onReady() {
  165. this.setListHeight()
  166. },
  167. /* 设置页面高度 */
  168. setListHeight() {
  169. this.selectComponent("#ListBox").setHeight(".division", this);
  170. },
  171. })