1
0

guestclues.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. // mycustomer/pages/guestclues/guestclues.js
  2. const app=getApp();
  3. var utils=require("../../../utils/http");
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. imgUrl:app.globalData.imgUrl,
  10. recordshow:false,
  11. lineght:'100%',
  12. recordshow:false,
  13. sourceflag:false,
  14. phoneflag:false,
  15. stateflag:false,
  16. customerList:[],
  17. sourcetext:'来源',
  18. phonetext:'手机号',
  19. statetext:'状态',
  20. sourcetype:'',
  21. page:1,
  22. phonetype:'',
  23. statetype:'',
  24. datashow:false,
  25. alertflag:false,
  26. weburl:''
  27. },
  28. /**
  29. * 生命周期函数--监听页面加载
  30. */
  31. onLoad: function (options) {
  32. // 访问记录 案例添加 已预约,列表中,显示预约次数
  33. this.setData({
  34. weburl:app.globalData.webUrl + 'applet.html#/guestclues?token=' + app.globalData.token + '&client_type=' + app.globalData.clientype+'&type=1' + "&platform="+app.globalData.platform,
  35. })
  36. },
  37. sourcetap:function(){
  38. this.setData({
  39. sourceflag:true,
  40. alertflag:true
  41. })
  42. },
  43. setalertap:function(){
  44. let that=this;
  45. that.setData({
  46. sourceflag:false,
  47. phoneflag:false,
  48. stateflag:false,
  49. alertflag:false
  50. })
  51. },
  52. setsourcetap:function(e){
  53. wx.showLoading({
  54. title: '加载中...',
  55. })
  56. this.setData({
  57. sourceflag:false,
  58. sourcetype:e.currentTarget.dataset.text,
  59. sourcetext:e.currentTarget.dataset.type,
  60. alertflag:false,
  61. })
  62. this.goodsData();
  63. },
  64. phonetap:function(){
  65. this.setData({
  66. phoneflag:true,
  67. alertflag:true
  68. })
  69. },
  70. setphonetap:function(e){
  71. wx.showLoading({
  72. title: '加载中...',
  73. })
  74. this.setData({
  75. phoneflag:false,
  76. phonetype:e.currentTarget.dataset.text,
  77. phonetext:e.currentTarget.dataset.type,
  78. alertflag:false
  79. })
  80. this.goodsData();
  81. },
  82. statetap:function(){
  83. this.setData({
  84. stateflag:true,
  85. alertflag:true
  86. })
  87. },
  88. setstatetap:function(e){
  89. wx.showLoading({
  90. title: '加载中...',
  91. })
  92. this.setData({
  93. stateflag:false,
  94. statetype:e.currentTarget.dataset.text,
  95. statetext:e.currentTarget.dataset.type,
  96. alertflag:false
  97. })
  98. this.goodsData();
  99. },
  100. goodsData:function(){
  101. let that=this;
  102. let means='';
  103. if(that.data.sourcetype==''){
  104. means="11,12,13,14,15,21,22,23,112,141";
  105. }else{
  106. means=that.data.sourcetype;
  107. }
  108. that.setData({
  109. page:1
  110. })
  111. utils.$post({
  112. url: app.globalData.webUrl + 'api/profile/customernew',
  113. header: {
  114. 'Authorization':'bearer '+app.globalData.token
  115. },
  116. data:{
  117. page:1,
  118. limit:10,
  119. means:means, //11是文章,12视频,13活动,14 案例,15口碑见证,21 => '装修报价算一算',22 => '装修风格测一测',23 => '老房翻新测一测',112 => '微网',141 => '名片',
  120. state:that.data.statetype,
  121. phone:that.data.phonetype
  122. },
  123. success: function (res) {
  124. if(res.data.code=='0'){
  125. for(let i=0;i<res.data.user.length;i++){
  126. res.data.user[i]=that.setdate(res.data.user[i]);
  127. res.data.user[i].statelook=0;
  128. }
  129. that.setData({
  130. customerList:res.data.user,
  131. datashow:true
  132. })
  133. }
  134. setTimeout(function(){
  135. wx.hideLoading()
  136. },1000)
  137. },
  138. fail(){
  139. wx.hideLoading()
  140. }
  141. })
  142. },
  143. setnametap:function(e){
  144. wx.setClipboardData({
  145. data: e.currentTarget.dataset.name,
  146. success (res) {
  147. }
  148. })
  149. },
  150. callphonetap:function(e){
  151. wx.makePhoneCall({
  152. phoneNumber: e.currentTarget.dataset.phone //仅为示例,并非真实的电话号码
  153. })
  154. },
  155. setdate:function(obj){
  156. obj.nowdate=obj.addtime.split(' ')[0];
  157. return obj
  158. },
  159. closerecordtap:function(e){
  160. this.setData({
  161. recordshow:false
  162. })
  163. },
  164. dothis:function(){},
  165. recordtap:function(e){
  166. this.setData({
  167. recordshow:true,
  168. visitList:[]
  169. })
  170. this.visitlog(e.currentTarget.dataset.cid);
  171. },
  172. visitlog:function(num){
  173. let that=this;
  174. utils.$post({
  175. url: app.globalData.webUrl + 'api/profile/customervisitlog',
  176. header: {
  177. 'Authorization':'bearer '+app.globalData.token
  178. },
  179. data:{
  180. id:num
  181. },
  182. success: function (res) {
  183. if(res.data.code=='0'){
  184. var t=0;
  185. for(let i=0;i<res.data.data.length;i++){
  186. res.data.data[i]=that.setdate(res.data.data[i]);
  187. if(i==0){
  188. t=t+1;
  189. }else if(res.data.data[i].nowdate!=res.data.data[i-1].nowdate){
  190. t=t+1;
  191. }
  192. }
  193. that.setData({
  194. lineght: (20+12+16+12)*t+(12+16+24+16+12)*(res.data.data.length-t) +(12+16+24+20)*(t-1) +12+'rpx',
  195. visitList:res.data.data
  196. })
  197. }
  198. }
  199. })
  200. },
  201. topdatanum:function(){
  202. let that=this;
  203. utils.$post({
  204. url: app.globalData.webUrl + 'api/profile/getCustomerCount',
  205. header: {
  206. 'Authorization':'bearer '+app.globalData.token
  207. },
  208. data:{
  209. user_id:app.globalData.personMsg.id
  210. },
  211. success: function (res) {
  212. if(res.data.code=='0'){
  213. that.setData({
  214. topnumobj:res.data
  215. })
  216. }
  217. }
  218. })
  219. },
  220. seteverystatetap:function(e){
  221. let that=this;
  222. if(e.currentTarget.dataset.type==0){
  223. var customerList=that.data.customerList;
  224. if(customerList[e.currentTarget.dataset.idx].statelook==1){
  225. customerList[e.currentTarget.dataset.idx].statelook=0;
  226. }else{
  227. customerList[e.currentTarget.dataset.idx].statelook=1;
  228. }
  229. that.setData({
  230. customerList:customerList
  231. })
  232. }
  233. },
  234. setjiandangtap:function(e){
  235. let that=this;
  236. wx.showModal({
  237. title: '线索状态修改',
  238. content: '您确定要修改这个客户的状态吗',
  239. success (res) {
  240. if (res.confirm) {
  241. var customerList=that.data.customerList;
  242. customerList[e.currentTarget.dataset.idx].statelook=0;
  243. customerList[e.currentTarget.dataset.idx].state=1;
  244. that.setData({
  245. customerList:customerList
  246. })
  247. var phone=!!e.currentTarget.dataset.phone?e.currentTarget.dataset.phone:''
  248. wx.navigateTo({
  249. url: '/mycustomer/pages/addcustomerData/addcustomerData?type=0&cid='+e.currentTarget.dataset.cid+"&phone="+phone
  250. })
  251. }
  252. }
  253. })
  254. },
  255. setinvalidtap:function(e){
  256. let that=this;
  257. wx.showModal({
  258. title: '线索状态修改',
  259. content: '您确定要修改这个客户的状态吗',
  260. success (res) {
  261. if (res.confirm) {
  262. utils.$post({
  263. url: app.globalData.webUrl + 'api/profile/invalidClue',
  264. header: {
  265. 'Authorization':'bearer '+app.globalData.token
  266. },
  267. data:{
  268. id:e.currentTarget.dataset.cid,
  269. state:2
  270. },
  271. success: function (res) {
  272. if(res.data.code=='0'){
  273. var customerList=that.data.customerList;
  274. customerList[e.currentTarget.dataset.idx].statelook=0;
  275. customerList[e.currentTarget.dataset.idx].state=2;
  276. that.setData({
  277. customerList:customerList
  278. })
  279. wx.showToast({
  280. title:res.data.msg,
  281. icon: 'none',
  282. duration: 2000
  283. })
  284. }
  285. }
  286. })
  287. }
  288. }
  289. })
  290. },
  291. /**
  292. * 生命周期函数--监听页面初次渲染完成
  293. */
  294. onReady: function () {
  295. },
  296. /**
  297. * 生命周期函数--监听页面显示
  298. */
  299. onShow: function () {
  300. },
  301. /**
  302. * 生命周期函数--监听页面隐藏
  303. */
  304. onHide: function () {
  305. },
  306. /**
  307. * 生命周期函数--监听页面卸载
  308. */
  309. onUnload: function () {
  310. },
  311. /**
  312. * 页面相关事件处理函数--监听用户下拉动作
  313. */
  314. onPullDownRefresh: function () {
  315. let that=this;
  316. let means='';
  317. if(that.data.sourcetype==''){
  318. means="11,12,13,14,15,21,22,23,112,141";
  319. }
  320. that.setData({
  321. page:1
  322. })
  323. utils.$post({
  324. url: app.globalData.webUrl + 'api/profile/customernew',
  325. header: {
  326. 'Authorization':'bearer '+app.globalData.token
  327. },
  328. data:{
  329. page:1,
  330. limit:10,
  331. means:means, //11是文章,12视频,13活动,14 案例,15口碑见证,21 => '装修报价算一算',22 => '装修风格测一测',23 => '老房翻新测一测',112 => '微网',141 => '名片',
  332. state:that.data.statetype,
  333. phone:that.data.phonetype
  334. },
  335. success: function (res) {
  336. wx.stopPullDownRefresh();
  337. if(res.data.code=='0'){
  338. for(let i=0;i<res.data.user.length;i++){
  339. res.data.user[i]=that.setdate(res.data.user[i]);
  340. res.data.user[i].statelook=0;
  341. }
  342. that.setData({
  343. customerList:res.data.user,
  344. })
  345. }
  346. }
  347. })
  348. },
  349. /**
  350. * 页面上拉触底事件的处理函数
  351. */
  352. onReachBottom: function () {
  353. let that=this;
  354. let means='';
  355. if(that.data.sourcetype==''){
  356. means="11,12,13,14,15,21,22,23,112,141";
  357. }
  358. let page=that.data.page;
  359. page=page*1+1;
  360. that.setData({
  361. page:page
  362. })
  363. utils.$post({
  364. url: app.globalData.webUrl + 'api/profile/customernew',
  365. header: {
  366. 'Authorization':'bearer '+app.globalData.token
  367. },
  368. data:{
  369. page:page,
  370. limit:10,
  371. means:means, //11是文章,12视频,13活动,14 案例,15口碑见证,21 => '装修报价算一算',22 => '装修风格测一测',23 => '老房翻新测一测',112 => '微网',141 => '名片',
  372. state:that.data.statetype,
  373. phone:that.data.phonetype
  374. },
  375. success: function (res) {
  376. if(res.data.code=='0'){
  377. for(let i=0;i<res.data.user.length;i++){
  378. res.data.user[i]=that.setdate(res.data.user[i]);
  379. res.data.user[i].statelook=0;
  380. }
  381. let customerList=that.data.customerList;
  382. customerList=customerList.concat(res.data.user)
  383. that.setData({
  384. customerList:customerList,
  385. })
  386. }
  387. }
  388. })
  389. },
  390. /**
  391. * 用户点击右上角分享
  392. */
  393. // onShareAppMessage: function () {
  394. // }
  395. })