index.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. options: {
  4. addGlobalClass: true
  5. },
  6. data: {
  7. sheetTitle: "",
  8. showWhere: "所有日期",
  9. timeRangeShow: false,
  10. sat_orderclueid: 0,
  11. detailsData: null,
  12. followList: null,
  13. isdesc: 1,
  14. whereType: {
  15. value: "start",
  16. list: {
  17. "start": "",
  18. "end": ""
  19. }
  20. },
  21. where: {
  22. "start": "",
  23. "end": ""
  24. },
  25. teamList: [],
  26. isEdit: false, //退出时是否重新获取列表
  27. },
  28. /**
  29. * 生命周期函数--监听页面加载
  30. */
  31. onLoad(options) {
  32. let auth = [];
  33. options.auth ? auth = options.auth.split(",") : getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['营销工具'], ['销售线索'])[0].apps[0].meta.auth.forEach(v => auth.push(v.optionname));
  34. this.setData({
  35. sat_orderclueid: options.id,
  36. tagColor: options.color,
  37. auth
  38. })
  39. this.selectDetail();
  40. this.getFollowList();
  41. this.query_teamList();
  42. },
  43. /* 团队成员 */
  44. query_teamList(i = 0) {
  45. if (i == 5) return;
  46. _Http.basic({
  47. "classname": "sale.team.team",
  48. "method": "query_teamList",
  49. "content": {
  50. "pageNumber": 1,
  51. "pageSize": 99999,
  52. "where": {
  53. "condition": ""
  54. }
  55. }
  56. }).then(res => {
  57. if (res.msg != '成功') return this.selectDetail(i + 1);
  58. this.setData({
  59. teamList: res.data
  60. })
  61. })
  62. },
  63. /* 查询详情 */
  64. selectDetail(i = 0) {
  65. if (i == 5) return wx.showToast({
  66. title: '详情信息查询失败!',
  67. icon: "none"
  68. })
  69. _Http.basic({
  70. "classname": "saletool.orderclue.web.orderclue",
  71. "method": "selectDetail",
  72. "content": {
  73. "sat_orderclueid": this.data.sat_orderclueid
  74. }
  75. }).then(res => {
  76. if (res.msg != '成功') return this.selectDetail(i + 1);
  77. let data = res.data;
  78. for (let i in data) {
  79. if (data[i] == '') data[i] = '-';
  80. }
  81. this.setData({
  82. detailsData: data
  83. })
  84. })
  85. },
  86. /* 跟进列表 */
  87. getFollowList(i = 0) {
  88. if (i == 5) return wx.showToast({
  89. title: '跟进记录查询失败!',
  90. icon: "none"
  91. })
  92. _Http.basic({
  93. "classname": "saletool.orderclue.web.orderclue",
  94. "method": "getFollowList",
  95. "content": {
  96. "sat_orderclueid": this.data.sat_orderclueid,
  97. "isdesc": this.data.isdesc,
  98. where: this.data.where
  99. }
  100. }).then(res => {
  101. console.log("跟进", res)
  102. if (res.msg != '成功') return this.getFollowList(i + 1);
  103. this.setData({
  104. followList: res.data
  105. })
  106. })
  107. },
  108. /* 打开弹出 */
  109. openPoput(e) {
  110. const {
  111. name
  112. } = e.currentTarget.dataset;
  113. if (name == '线索编辑') this.selectComponent("#edit").initData();
  114. if (name == '跟进计划') this.selectComponent("#follow").updateTime();
  115. this.setData({
  116. sheetTitle: name
  117. })
  118. },
  119. /* 结束编辑 */
  120. endEdit() {
  121. this.setData({
  122. sheetTitle: "",
  123. isEdit: true
  124. })
  125. this.selectDetail();
  126. },
  127. /* 结束跟进 */
  128. endFollow() {
  129. this.endEdit();
  130. this.getFollowList();
  131. },
  132. /* 修改排序方式 */
  133. changeIsdesc() {
  134. this.setData({
  135. isdesc: this.data.isdesc == 1 ? 0 : 1
  136. });
  137. this.getFollowList();
  138. },
  139. /* 打开选择时间 */
  140. openSelectDate() {
  141. this.setData({
  142. timeRangeShow: true
  143. })
  144. },
  145. /* 查看所有日期 */
  146. toSeeAll() {
  147. this.setData({
  148. showWhere: "所有日期"
  149. })
  150. this.timeRangeClose();
  151. this.getFollowList();
  152. },
  153. /* 关闭时间范围选择 */
  154. timeRangeClose() {
  155. this.setData({
  156. timeRangeShow: false,
  157. "where": {
  158. "start": "",
  159. "end": ""
  160. }
  161. })
  162. },
  163. /* 选择日期类型 */
  164. selectDateType(e) {
  165. const {
  166. name
  167. } = e.target.dataset;
  168. this.setData({
  169. "whereType.value": name
  170. })
  171. },
  172. /* 得到选择时间 */
  173. getDate({
  174. detail
  175. }) {
  176. let obj = this.data.whereType;
  177. obj.list[obj.value] = detail;
  178. this.setData({
  179. whereType: obj
  180. })
  181. },
  182. /* 确定时间范围 */
  183. determineScope() {
  184. const {
  185. list
  186. } = this.data.whereType;
  187. this.setData({
  188. "where": list,
  189. showWhere: list.start + '~' + list.end,
  190. timeRangeShow: false
  191. });
  192. this.getFollowList();
  193. },
  194. callOut(e) {
  195. wx.makePhoneCall({
  196. phoneNumber: e.currentTarget.dataset.phonenumber
  197. })
  198. },
  199. onUnload() {
  200. if (this.data.isEdit) {
  201. let pages = getCurrentPages();
  202. pages[pages.length - 2].getList(true)
  203. }
  204. },
  205. })