addFollow.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. const deleteMark = require("../../utils/deleteMark"),
  2. getTime = require("../../utils/getTime"),
  3. _Http = getApp().globalData.http,
  4. QQMapWX = require('../../utils/qqmap-wx-jssdk.min'),
  5. qqmapsdk = new QQMapWX({
  6. key: 'QF6BZ-4IQC5-SN2IH-QL5BW-U4IJO-R3BY4' // 必填
  7. });
  8. Page({
  9. data: {
  10. sat_orderclueid: null,
  11. deleteItem: false,
  12. actionShow: false,
  13. date1: getTime.formatTime(new Date(), '-').split(' ')[0],
  14. time: getTime.formatTime(new Date(), '-').split(' ')[1],
  15. actions: [],
  16. disabled: true,
  17. loading: false,
  18. },
  19. onLoad(options) {
  20. if (options.sat_orderclueid) this.setData({
  21. sat_orderclueid: options.sat_orderclueid
  22. })
  23. this.getFollowType()
  24. this.init();
  25. },
  26. bindDateChange: function (e) {
  27. this.setData({
  28. date1: e.detail.value
  29. })
  30. },
  31. bindTimeChange(e) {
  32. this.setData({
  33. time: e.detail.value+":00"
  34. })
  35. },
  36. /* 跟进初始化 */
  37. init() {
  38. let that = this;
  39. _Http.basic({
  40. id: "20221208100602",
  41. "content": {
  42. sat_orderclueid: this.data.sat_orderclueid,
  43. sat_ordercluefollowuplogid: 0,
  44. "content": "",
  45. "followupmode": "",
  46. "logtype": "",
  47. "competitor": "",
  48. latitude: "", //经度
  49. longitude: "", //纬度
  50. address: "", //逆解析位置
  51. }
  52. }).then(res => {
  53. console.log("初始化", res)
  54. if (res.msg != '成功') {
  55. wx.showToast({
  56. title: '初始化失败!请稍后再试',
  57. icon: "none"
  58. });
  59. setTimeout(() => {
  60. wx.navigateBack()
  61. }, 300)
  62. return
  63. } else {
  64. that.setData({
  65. content: res.data,
  66. deleteItem: true,
  67. });
  68. wx.getLocation({
  69. type: 'wgs84',
  70. altitude: true,
  71. isHighAccuracy: true,
  72. highAccuracyExpireTime: 5000,
  73. success({
  74. latitude,
  75. longitude
  76. }) {
  77. that.setData({
  78. "content.latitude": latitude,
  79. "content.longitude": longitude
  80. })
  81. qqmapsdk.reverseGeocoder({
  82. location: {
  83. latitude,
  84. longitude
  85. },
  86. success(s) {
  87. console.log("逆解析", s)
  88. that.setData({
  89. "content.address": s.result.address,
  90. })
  91. }
  92. })
  93. },
  94. fail(err) {
  95. console.log(err)
  96. }
  97. })
  98. }
  99. })
  100. },
  101. submit() {
  102. if (this.data.loading) return;
  103. let content = this.data.content;
  104. content.createdate = this.data.date1 + " " + this.data.time
  105. this.setData({
  106. loading: true
  107. })
  108. content.logtype = '跟进';
  109. _Http.basic({
  110. id: "20221208100602",
  111. content
  112. }).then(res => {
  113. this.setData({
  114. loading: false
  115. })
  116. if (res.msg != '成功') return wx.showToast({
  117. title: res.msg,
  118. icon: "none"
  119. });
  120. this.setData({
  121. deleteItem: false
  122. })
  123. wx.showToast({
  124. title: '保存成功!',
  125. })
  126. setTimeout(() => {
  127. let page = getCurrentPages().find(v => v.__route__ == 'packageA/saleClue/detail');
  128. page.selectComponent("#follow").getList(page.data.sat_orderclueid, true);
  129. page.getDetail();
  130. wx.navigateBack();
  131. }, 300)
  132. })
  133. },
  134. /* 绑定媒体 */
  135. insertImgEdit({
  136. detail
  137. }) {
  138. _Http.basic({
  139. "classname": "system.attachment.Attachment",
  140. "method": "createFileLink",
  141. "content": {
  142. "ownertable": "sat_ordercluefollowuplog",
  143. "ownerid": this.data.content.sat_ordercluefollowuplogid,
  144. "usetype": "default",
  145. "attachmentids": detail
  146. }
  147. }).then(res => {
  148. console.log('跟进记录绑定附件', res)
  149. if (res.msg != '成功') return wx.showToast({
  150. title: res.msg,
  151. icon: "none"
  152. })
  153. this.selectComponent("#Yl_Files").handleFiles(res.data)
  154. })
  155. },
  156. /* 获取跟进方式 */
  157. async getFollowType() {
  158. let res = await _Http.basic({
  159. "classname": "sysmanage.develop.optiontype.optiontype",
  160. "method": "optiontypeselect",
  161. "content": {
  162. "typename": 'followupmode'
  163. }
  164. })
  165. let Arr = res.data.map(item => {
  166. return {
  167. name: item.value
  168. }
  169. })
  170. this.setData({
  171. actions: Arr
  172. })
  173. },
  174. /* 打开选择跟进方式 */
  175. selectWay() {
  176. this.setData({
  177. actionShow: !this.data.actionShow
  178. })
  179. },
  180. /* 选择方式 */
  181. onSelect(e) {
  182. this.setData({
  183. "content.followupmode": e.detail.name
  184. })
  185. this.isDisabled();
  186. },
  187. /* 选择结果 */
  188. changeType(e) {
  189. if (e.target.dataset.name) this.setData({
  190. 'content.logtype': e.target.dataset.name
  191. })
  192. this.isDisabled();
  193. },
  194. /* 输入框输入内容 */
  195. inputChange(e) {
  196. let text = e.type == 'input' ? e.detail.value : e.detail;
  197. this.setData({
  198. "content.content": deleteMark.queryStr(text)
  199. })
  200. this.isDisabled();
  201. },
  202. isDisabled() {
  203. let data = this.data.content;
  204. this.setData({
  205. disabled: (data.followupmode != '' && data.content != '') ? false : true
  206. })
  207. },
  208. onUnload() {
  209. if (this.data.deleteItem) _Http.basic({
  210. "id": 20221208112002,
  211. "content": {
  212. "sat_ordercluefollowuplogid": this.data.content.sat_ordercluefollowuplogid
  213. }
  214. }).then(res => {
  215. console.log("删除未提交", res)
  216. })
  217. }
  218. })