signIn.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. const _Http = getApp().globalData.http;
  2. const QQMapWX = require('../../utils/qqmap-wx-jssdk.min'),
  3. qqmapsdk = new QQMapWX({
  4. key: 'QF6BZ-4IQC5-SN2IH-QL5BW-U4IJO-R3BY4' // 必填
  5. });
  6. import {
  7. formatTime
  8. } from "../../utils/getTime";
  9. let timing = null;
  10. Page({
  11. data: {
  12. markers: [],
  13. content: {},
  14. time: formatTime(new Date(), '-'),
  15. form: null,
  16. continue1: null,
  17. },
  18. onLoad(options) {
  19. this.getLocation();
  20. timing = setInterval(() => {
  21. this.setData({
  22. time: formatTime(new Date(), '-')
  23. })
  24. }, 1000);
  25. this.rander();
  26. },
  27. submit() {
  28. let data = this.selectComponent("#Form").submit(),
  29. content = this.data.content,
  30. continue1 = this.data.continue1,
  31. that = this;
  32. content.remarks = data.remarks;
  33. if (continue1 == null) {
  34. wx.showModal({
  35. title: '提示',
  36. content: '是否确认本次签到',
  37. complete: (res) => {
  38. if (res.confirm) that.onConfirm(content);
  39. }
  40. })
  41. } else {
  42. content.ownertable = data[continue1] == '' ? continue1 == 'sa_project' ? 'sys_enterprise' : 'sa_project' : continue1;
  43. content.ownerid = data[content.ownertable][1][0];
  44. wx.showModal({
  45. title: '提示',
  46. content: `本次签到将跟进${content.ownertable=='sa_project'?'项目':'客户'}“${data[content.ownertable][0]}”`,
  47. complete: (res) => {
  48. if (res.confirm) that.onConfirm(content);
  49. }
  50. })
  51. }
  52. },
  53. onConfirm(content) {
  54. _Http.basic({
  55. id: 20221229145901,
  56. content
  57. }).then(res => {
  58. console.log("签到", res)
  59. wx.showToast({
  60. title: res.msg == '成功' ? '签到成功' : res.msg,
  61. icon: "none"
  62. })
  63. if (res.msg == '成功') setTimeout(() => {
  64. getCurrentPages()[getCurrentPages().length - 2].toDate(this.data.time.split(" ")[0]);
  65. wx.navigateBack();
  66. }, 500)
  67. })
  68. },
  69. rander() {
  70. this.setData({
  71. form: [{
  72. label: "客户",
  73. error: false,
  74. errMsg: "",
  75. type: "route",
  76. url: "/packageA/select/setclient/select",
  77. radio: true,
  78. value: "",
  79. params: {
  80. "id": 20221012164402,
  81. content: {
  82. nocache: true,
  83. "type": 0,
  84. "pageNumber": 1,
  85. "pageSize": 20,
  86. "isExport": 0,
  87. "where": {
  88. "condition": "",
  89. },
  90. "sort": [{
  91. sortname: "默认",
  92. sorted: 1,
  93. sortid: 67,
  94. reversed: 0
  95. }]
  96. },
  97. },
  98. placeholder: "选择客户",
  99. valueName: "sys_enterprise",
  100. checking: "base",
  101. required: false
  102. }, {
  103. label: "项目",
  104. error: false,
  105. errMsg: "",
  106. type: "route",
  107. url: "/packageA/select/project/select",
  108. radio: true,
  109. value: "",
  110. params: {
  111. "id": 20221020143502,
  112. content: {
  113. nocache: true,
  114. "type": 0,
  115. "pageNumber": 1,
  116. "pageSize": 20,
  117. "where": {
  118. "condition": "", //模糊搜索
  119. },
  120. },
  121. },
  122. placeholder: "选择项目",
  123. valueName: "sa_project",
  124. checking: "base",
  125. required: false
  126. }, {
  127. label: "说明",
  128. error: false,
  129. errMsg: "",
  130. type: "textarea",
  131. value: "",
  132. placeholder: "请填写",
  133. valueName: "remarks",
  134. required: false, //必填
  135. }],
  136. continue1: null
  137. })
  138. },
  139. /* 打断处理form */
  140. interrupt(e) {
  141. let {
  142. data,
  143. form
  144. } = e.detail,
  145. that = this;
  146. console.log("处理", data, form)
  147. if (this.data.continue1 == null) {
  148. wx.showModal({
  149. title: '提示',
  150. cancelText: "继续选择",
  151. confirmText: `跟进${data.label}`,
  152. content: `继续选择"${data.value[0]}"相关${data.label=='客户'?"项目":"客户"},还是跟进当前选择${data.label}?`,
  153. complete: (res) => {
  154. if (data.label == '客户') {
  155. if (res.confirm) {
  156. form.splice(1, 1);
  157. that.setData({
  158. form,
  159. continue1: "sys_enterprise"
  160. })
  161. }
  162. if (res.cancel) {
  163. form[1].label = '客户关联项目'
  164. form[1].params = {
  165. "id": "20221018102003",
  166. "content": {
  167. "nocache": true,
  168. "pageNumber": 1,
  169. "pageTotal": 1,
  170. sys_enterpriseid: data.value[1][0],
  171. "total": null,
  172. "type": 1,
  173. "where": {
  174. "condition": ""
  175. }
  176. }
  177. }
  178. that.setData({
  179. form,
  180. continue1: "sa_project"
  181. })
  182. }
  183. } else {
  184. if (res.confirm) {
  185. form.splice(0, 1);
  186. that.setData({
  187. form,
  188. continue1: "sa_project"
  189. })
  190. }
  191. if (res.cancel) {
  192. form.splice(0, 1);
  193. form.splice(1, 0, {
  194. label: "项目关联客户",
  195. error: false,
  196. errMsg: "",
  197. type: "route",
  198. url: "/packageA/select/setclient/select",
  199. radio: true,
  200. value: "",
  201. params: {
  202. "id": "20221027143702",
  203. content: {
  204. nocache: true,
  205. sa_projectid: data.value[1][0],
  206. pageNumber: 1,
  207. pageTotal: 1,
  208. pageSize: 10,
  209. total: null,
  210. where: {
  211. condition: "",
  212. }
  213. },
  214. },
  215. placeholder: "选择客户",
  216. valueName: "sys_enterprise",
  217. checking: "base",
  218. required: false
  219. });
  220. that.setData({
  221. form,
  222. continue1: "sys_enterprise"
  223. })
  224. }
  225. }
  226. }
  227. })
  228. } else {
  229. if (data.valueName != this.data.continue1 && form.length == 3) {
  230. form[1].params.sa_projectid = data.value[1][0];
  231. form[1].params.sys_enterpriseid = data.value[1][0];
  232. form[1].value = "";
  233. }
  234. this.setData({
  235. form
  236. })
  237. }
  238. },
  239. /* 获取定位 */
  240. getLocation() {
  241. let that = this;
  242. wx.showLoading({
  243. title: '定位中...',
  244. });
  245. wx.getLocation({
  246. type: 'gcj02',
  247. isHighAccuracy: true,
  248. highAccuracyExpireTime: 8000,
  249. success({
  250. latitude,
  251. longitude
  252. }) {
  253. wx.hideLoading();
  254. that.setData({
  255. 'markers[0]': {
  256. id: 1,
  257. latitude,
  258. longitude,
  259. }
  260. });
  261. qqmapsdk.reverseGeocoder({
  262. location: {
  263. latitude,
  264. longitude
  265. },
  266. success(s) {
  267. console.log("逆解析", s)
  268. that.setData({
  269. content: {
  270. province: s.result.address_component.province,
  271. city: s.result.address_component.city,
  272. county: s.result.address_component.district,
  273. address: s.result.address,
  274. longitude,
  275. latitude,
  276. remarks: "",
  277. ownertable: "",
  278. ownerid: ""
  279. }
  280. })
  281. },
  282. fail(err) {
  283. console.log(err)
  284. wx.showToast({
  285. title: '定位失败',
  286. icon: "none"
  287. })
  288. }
  289. })
  290. },
  291. fail(err) {
  292. console.log(err)
  293. wx.showToast({
  294. title: '定位失败',
  295. icon: "none"
  296. })
  297. }
  298. })
  299. },
  300. onUnload() {
  301. clearInterval(timing)
  302. },
  303. onReady() {
  304. },
  305. })