123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418 |
- // mycustomer/pages/guestclues/guestclues.js
- const app=getApp();
- var utils=require("../../../utils/http");
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- imgUrl:app.globalData.imgUrl,
- recordshow:false,
- lineght:'100%',
- recordshow:false,
- sourceflag:false,
- phoneflag:false,
- stateflag:false,
- customerList:[],
- sourcetext:'来源',
- phonetext:'手机号',
- statetext:'状态',
- sourcetype:'',
- page:1,
- phonetype:'',
- statetype:'',
- datashow:false,
- alertflag:false,
- weburl:''
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- // 访问记录 案例添加 已预约,列表中,显示预约次数
- this.setData({
- weburl:app.globalData.webUrl + 'applet.html#/guestclues?token=' + app.globalData.token + '&client_type=' + app.globalData.clientype,
- })
- },
- sourcetap:function(){
- this.setData({
- sourceflag:true,
- alertflag:true
- })
- },
- setalertap:function(){
- let that=this;
- that.setData({
- sourceflag:false,
- phoneflag:false,
- stateflag:false,
- alertflag:false
- })
- },
- setsourcetap:function(e){
- wx.showLoading({
- title: '加载中...',
- })
- this.setData({
- sourceflag:false,
- sourcetype:e.currentTarget.dataset.text,
- sourcetext:e.currentTarget.dataset.type,
- alertflag:false,
- })
- this.goodsData();
- },
- phonetap:function(){
- this.setData({
- phoneflag:true,
- alertflag:true
- })
- },
- setphonetap:function(e){
- wx.showLoading({
- title: '加载中...',
- })
- this.setData({
- phoneflag:false,
- phonetype:e.currentTarget.dataset.text,
- phonetext:e.currentTarget.dataset.type,
- alertflag:false
- })
- this.goodsData();
- },
- statetap:function(){
- this.setData({
- stateflag:true,
- alertflag:true
- })
- },
- setstatetap:function(e){
- wx.showLoading({
- title: '加载中...',
- })
- this.setData({
- stateflag:false,
- statetype:e.currentTarget.dataset.text,
- statetext:e.currentTarget.dataset.type,
- alertflag:false
- })
- this.goodsData();
- },
- goodsData:function(){
- let that=this;
- let means='';
- if(that.data.sourcetype==''){
- means="11,12,13,14,15,21,22,23,112,141";
- }else{
- means=that.data.sourcetype;
- }
- that.setData({
- page:1
- })
- utils.$post({
- url: app.globalData.webUrl + 'api/profile/customernew',
- header: {
- 'Authorization':'bearer '+app.globalData.token
- },
- data:{
- page:1,
- limit:10,
- means:means, //11是文章,12视频,13活动,14 案例,15口碑见证,21 => '装修报价算一算',22 => '装修风格测一测',23 => '老房翻新测一测',112 => '微网',141 => '名片',
- state:that.data.statetype,
- phone:that.data.phonetype
- },
- success: function (res) {
-
- if(res.data.code=='0'){
- for(let i=0;i<res.data.user.length;i++){
- res.data.user[i]=that.setdate(res.data.user[i]);
- res.data.user[i].statelook=0;
- }
- that.setData({
- customerList:res.data.user,
- datashow:true
- })
- }
- setTimeout(function(){
- wx.hideLoading()
- },1000)
- },
- fail(){
- wx.hideLoading()
- }
- })
- },
- setnametap:function(e){
- wx.setClipboardData({
- data: e.currentTarget.dataset.name,
- success (res) {
-
- }
- })
- },
- callphonetap:function(e){
- wx.makePhoneCall({
- phoneNumber: e.currentTarget.dataset.phone //仅为示例,并非真实的电话号码
- })
- },
- setdate:function(obj){
- obj.nowdate=obj.addtime.split(' ')[0];
- return obj
- },
- closerecordtap:function(e){
- this.setData({
- recordshow:false
- })
- },
- dothis:function(){},
- recordtap:function(e){
- this.setData({
- recordshow:true,
- visitList:[]
- })
- this.visitlog(e.currentTarget.dataset.cid);
- },
- visitlog:function(num){
- let that=this;
- utils.$post({
- url: app.globalData.webUrl + 'api/profile/customervisitlog',
- header: {
- 'Authorization':'bearer '+app.globalData.token
- },
- data:{
- id:num
- },
- success: function (res) {
-
- if(res.data.code=='0'){
- var t=0;
- for(let i=0;i<res.data.data.length;i++){
- res.data.data[i]=that.setdate(res.data.data[i]);
- if(i==0){
- t=t+1;
- }else if(res.data.data[i].nowdate!=res.data.data[i-1].nowdate){
- t=t+1;
- }
-
- }
- that.setData({
- lineght: (20+12+16+12)*t+(12+16+24+16+12)*(res.data.data.length-t) +(12+16+24+20)*(t-1) +12+'rpx',
- visitList:res.data.data
- })
- }
- }
- })
- },
- topdatanum:function(){
- let that=this;
- utils.$post({
- url: app.globalData.webUrl + 'api/profile/getCustomerCount',
- header: {
- 'Authorization':'bearer '+app.globalData.token
- },
- data:{
- user_id:app.globalData.personMsg.id
- },
- success: function (res) {
-
- if(res.data.code=='0'){
- that.setData({
- topnumobj:res.data
- })
- }
- }
- })
- },
- seteverystatetap:function(e){
- let that=this;
-
- if(e.currentTarget.dataset.type==0){
- var customerList=that.data.customerList;
- if(customerList[e.currentTarget.dataset.idx].statelook==1){
- customerList[e.currentTarget.dataset.idx].statelook=0;
- }else{
- customerList[e.currentTarget.dataset.idx].statelook=1;
- }
- that.setData({
- customerList:customerList
- })
- }
-
- },
- setjiandangtap:function(e){
- let that=this;
- wx.showModal({
- title: '线索状态修改',
- content: '您确定要修改这个客户的状态吗',
- success (res) {
- if (res.confirm) {
- var customerList=that.data.customerList;
- customerList[e.currentTarget.dataset.idx].statelook=0;
- customerList[e.currentTarget.dataset.idx].state=1;
- that.setData({
- customerList:customerList
- })
- var phone=!!e.currentTarget.dataset.phone?e.currentTarget.dataset.phone:''
- wx.navigateTo({
- url: '/mycustomer/pages/addcustomerData/addcustomerData?type=0&cid='+e.currentTarget.dataset.cid+"&phone="+phone
- })
- }
- }
- })
- },
- setinvalidtap:function(e){
- let that=this;
- wx.showModal({
- title: '线索状态修改',
- content: '您确定要修改这个客户的状态吗',
- success (res) {
- if (res.confirm) {
- utils.$post({
- url: app.globalData.webUrl + 'api/profile/invalidClue',
- header: {
- 'Authorization':'bearer '+app.globalData.token
- },
- data:{
- id:e.currentTarget.dataset.cid,
- state:2
- },
- success: function (res) {
-
- if(res.data.code=='0'){
- var customerList=that.data.customerList;
- customerList[e.currentTarget.dataset.idx].statelook=0;
- customerList[e.currentTarget.dataset.idx].state=2;
- that.setData({
- customerList:customerList
- })
-
- wx.showToast({
- title:res.data.msg,
- icon: 'none',
- duration: 2000
- })
- }
- }
- })
- }
- }
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- let that=this;
- let means='';
- if(that.data.sourcetype==''){
- means="11,12,13,14,15,21,22,23,112,141";
- }
- that.setData({
- page:1
- })
- utils.$post({
- url: app.globalData.webUrl + 'api/profile/customernew',
- header: {
- 'Authorization':'bearer '+app.globalData.token
- },
- data:{
- page:1,
- limit:10,
- means:means, //11是文章,12视频,13活动,14 案例,15口碑见证,21 => '装修报价算一算',22 => '装修风格测一测',23 => '老房翻新测一测',112 => '微网',141 => '名片',
- state:that.data.statetype,
- phone:that.data.phonetype
- },
- success: function (res) {
- wx.stopPullDownRefresh();
- if(res.data.code=='0'){
- for(let i=0;i<res.data.user.length;i++){
- res.data.user[i]=that.setdate(res.data.user[i]);
- res.data.user[i].statelook=0;
- }
- that.setData({
- customerList:res.data.user,
- })
- }
- }
- })
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- let that=this;
- let means='';
- if(that.data.sourcetype==''){
- means="11,12,13,14,15,21,22,23,112,141";
- }
- let page=that.data.page;
- page=page*1+1;
- that.setData({
- page:page
- })
- utils.$post({
- url: app.globalData.webUrl + 'api/profile/customernew',
- header: {
- 'Authorization':'bearer '+app.globalData.token
- },
- data:{
- page:page,
- limit:10,
- means:means, //11是文章,12视频,13活动,14 案例,15口碑见证,21 => '装修报价算一算',22 => '装修风格测一测',23 => '老房翻新测一测',112 => '微网',141 => '名片',
- state:that.data.statetype,
- phone:that.data.phonetype
- },
- success: function (res) {
- if(res.data.code=='0'){
- for(let i=0;i<res.data.user.length;i++){
- res.data.user[i]=that.setdate(res.data.user[i]);
- res.data.user[i].statelook=0;
- }
- let customerList=that.data.customerList;
- customerList=customerList.concat(res.data.user)
- that.setData({
- customerList:customerList,
- })
- }
- }
- })
- },
- /**
- * 用户点击右上角分享
- */
- // onShareAppMessage: function () {
- // }
- })
|