index.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. const _Http = getApp().globalData.http;
  2. Component({
  3. properties: {
  4. disabled: {
  5. type: Boolean,
  6. value: false
  7. }
  8. },
  9. options: {
  10. addGlobalClass: true
  11. },
  12. data: {
  13. sa_trialid: 0,
  14. content: {
  15. nocache: true,
  16. pageNumber: 1,
  17. pageSize: 10,
  18. pageTotal: 1,
  19. total: null,
  20. where: {
  21. condition: ""
  22. }
  23. },
  24. list: [],
  25. showSearch: false,
  26. focus: false,
  27. condition: ""
  28. },
  29. methods: {
  30. getList(id, init = false) {
  31. let content = {
  32. ...this.data.content,
  33. sa_trialid: id || this.data.sa_trialid
  34. };
  35. if (init) {
  36. content.pageNumber = 1
  37. content.pageTotal = 1
  38. }
  39. _Http.basic({
  40. "id": 2025110715410702,
  41. content
  42. }).then(res => {
  43. console.log("科室推荐产品", res)
  44. if (res.code != '1') return wx.showToast({
  45. title: res.data,
  46. icon: "none"
  47. });
  48. let list = res.data.map(v => {
  49. try {
  50. v.cover = v.attinfos.length ? _Http.getSpecifiedImage(v.attinfos[0]) : ''
  51. } catch (error) {
  52. }
  53. return v
  54. })
  55. this.setData({
  56. "content.pageNumber": res.pageNumber + 1,
  57. "content.pageTotal": res.pageTotal,
  58. "content.total": res.total,
  59. list: res.pageNumber == 1 ? list : this.data.list.concat(list),
  60. sa_trialid: content.sa_trialid
  61. })
  62. })
  63. },
  64. /* 去添加产品 */
  65. addProduct() {
  66. let page = getCurrentPages().find(v => v.__route__ == 'prsx/tryOut/detail').data,
  67. detail = page.detail,
  68. query = "&newprice=contractprice"; /* marketprice */
  69. wx.navigateTo({
  70. url: `/prsx/select/product/index?params=${JSON.stringify({
  71. "id":2025110715184302,
  72. "content": {
  73. nocache:true,
  74. sa_trialid:detail.sa_trialid, //订单ID
  75. "total": 0,
  76. "where": {
  77. "condition": ""
  78. }
  79. }
  80. })+query}`
  81. });
  82. this.setData({
  83. type: detail.type
  84. })
  85. _Http.handleSelect = this.handleSelect.bind(this);
  86. },
  87. /* 处理新增产品 */
  88. handleSelect(detail) {
  89. console.log(detail)
  90. let that = this;
  91. wx.showModal({
  92. cancelText: getApp().globalData.Language.getMapText('取消'),
  93. confirmText: getApp().globalData.Language.getMapText('确定'),
  94. title: getApp().globalData.Language.getMapText('提示'),
  95. content: getApp().globalData.Language.joint([{
  96. v: '是否确认添加',
  97. t: 1
  98. }, {
  99. v: detail.result.length,
  100. t: 1,
  101. r: ' ',
  102. f: " "
  103. }, {
  104. v: '件商品',
  105. t: 1,
  106. r: '?',
  107. }]),
  108. complete: (res) => {
  109. if (res.confirm) _Http.basic({
  110. "id": 2025110715293102,
  111. "content": {
  112. ...that.data.base,
  113. sa_trialid:this.data.sa_trialid,
  114. "items": detail.list.map(v => {
  115. return {
  116. sa_trialitemsid: 0,
  117. "itemid": v.itemid, //商品ID
  118. "qty": 1, //数量
  119. remarks: v.remarks
  120. }
  121. })
  122. }
  123. }).then(s => {
  124. console.log('新增产品', s)
  125. wx.showToast({
  126. title: s.code == '1' ? getApp().globalData.Language.getMapText('添加成功') : s.msg,
  127. icon: "none"
  128. });
  129. if (s.code == '1') setTimeout(() => {
  130. that.getList('', true);
  131. wx.navigateBack();
  132. that.updateThePrice();
  133. }, 300)
  134. })
  135. }
  136. });
  137. },
  138. deleteItem(e) {
  139. const {
  140. item
  141. } = e.currentTarget.dataset,
  142. that = this;
  143. wx.showModal({
  144. content: `是否确定删除该试用明细下的产品`,
  145. complete: ({
  146. confirm
  147. }) => {
  148. if (confirm) _Http.basic({
  149. "id": "2025110715414702",
  150. "content": {
  151. sa_trialid: this.data.sa_trialid,
  152. sa_trialitemsids: [item.sa_trialitemsid]
  153. },
  154. }).then(res => {
  155. wx.showToast({
  156. title: res.code == 1 ? '删除成功' : res.msg,
  157. icon: "none"
  158. })
  159. if (res.code == 1) {
  160. that.getList('', true)
  161. }
  162. })
  163. }
  164. })
  165. },
  166. toSearch() {
  167. if (this.data.showSearch && this.data.content.where.condition) {
  168. this.data.content.where.condition = '';
  169. this.getList("", true);
  170. } else if (this.data.condition) {
  171. this.data.content.where.condition = this.data.condition;
  172. this.setData({
  173. condition: this.data.condition
  174. })
  175. this.getList("", true);
  176. }
  177. this.setData({
  178. showSearch: !this.data.showSearch
  179. })
  180. setTimeout(() => {
  181. this.setData({
  182. focus: this.data.showSearch
  183. })
  184. }, 300)
  185. },
  186. changeQty(e) {
  187. let value = e.detail.value,
  188. index = e.currentTarget.dataset.index;
  189. this.data.list[index].qty = value;
  190. _Http.basic({
  191. "id": 2025110715293102,
  192. "content": {
  193. "sa_trialid": this.data.sa_trialid,
  194. items: this.data.list
  195. }
  196. }).then(res => {
  197. console.log("修改数量", res)
  198. wx.showToast({
  199. title: res.code == 1 ? '修改成功' : res.msg,
  200. icon: "none"
  201. })
  202. // if (res.code == 1) getCurrentPages().find(v => v.__route__ == 'prsx/tyrOut/detail').getDetail()
  203. })
  204. },
  205. onChange({
  206. detail
  207. }) {
  208. this.data.condition = detail;
  209. },
  210. onSearch({
  211. detail
  212. }) {
  213. this.data.content.where.condition = detail;
  214. this.getList("", true)
  215. },
  216. }
  217. })