praiselist.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. const app=getApp();
  2. var utils=require("../../../utils/http"),page=1;
  3. const util = require("../../../utils/util");
  4. let time = 0,timer = null;
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. evidencetype:[],
  11. nowtype:'',
  12. evidencelist:[],
  13. leftevidencelist:[],
  14. rightevidencelist:[],
  15. datashow:false,
  16. imgUrl:app.globalData.imgUrl,
  17. loginFlag:false,
  18. canIUseGetUserProfile: false,
  19. shareobj:{},
  20. employeeflag:false,//false是用户,true是员工
  21. top:app.globalData.statusBarHeight,
  22. hgt:app.globalData.titleBarHeight,
  23. companyobj:{},
  24. },
  25. /**
  26. * 生命周期函数--监听页面加载
  27. */
  28. onLoad: function (options) {
  29. wx.showLoading({
  30. title: '加载中...',
  31. })
  32. time = 0;
  33. this.setData({
  34. top:app.globalData.statusBarHeight,
  35. hgt:app.globalData.titleBarHeight,
  36. })
  37. if (wx.getUserProfile) {
  38. this.setData({
  39. canIUseGetUserProfile: true
  40. })
  41. }
  42. if(!!options.scene){
  43. options=unescape(options.scene);
  44. let arr=options.split('&');
  45. let obj={};
  46. for(let i=0;i<arr.length;i++){
  47. let arr1=arr[i].split('=');
  48. obj[arr1[0]]=arr1[1];
  49. }
  50. app.globalData.shareuserid=obj.uid;
  51. app.globalData.clientype=obj.ctp;
  52. }else{
  53. app.globalData.clientype=options.ctp;
  54. app.globalData.shareuserid=options.uid;
  55. }
  56. this.login();
  57. },
  58. sharecompany:function (){
  59. const that=this;
  60. utils.$post({
  61. url: app.globalData.webUrl + 'client/index/content_belong_company',
  62. header: {
  63. 'Authorization':'bearer '+app.globalData.token
  64. },
  65. data:{
  66. client_type:app.globalData.clientype,
  67. uid: app.globalData.shareuserid
  68. },
  69. success: function (res) {
  70. if(res.data.code=='0'){
  71. app.globalData.companyobj=res.data.data;
  72. that.setData({
  73. companyobj:res.data.data
  74. })
  75. }
  76. },
  77. complete(res) {
  78. wx.hideLoading()
  79. }
  80. })
  81. },
  82. login:function(){
  83. var that=this;
  84. wx.login({
  85. success: function (data) {
  86. if (data.errMsg == 'login:ok') {
  87. utils.$post({
  88. url: app.globalData.webUrl + 'api/users/code2session',
  89. data: {
  90. code:data.code,
  91. share: app.globalData.shareuserid,
  92. client_type:app.globalData.clientype
  93. },
  94. success: function (r) {
  95. if (r.data.code == '0') {
  96. app.globalData.sharepersonobj = r.data.share;
  97. app.globalData.token = r.data.token;
  98. that.setData({
  99. shareobj:app.globalData.sharepersonobj,
  100. })
  101. util.toolfun(3);
  102. that.sharecompany();
  103. that.praisetit();
  104. if (r.data.user != null&&(!!r.data.user.headimgurl&&r.data.user.headimgurl!=""||!!r.data.user.nickname&&r.data.user.nickname!=""&&r.data.user.nickname!='游客')) {
  105. that.setData({
  106. loginFlag: false,
  107. employeeflag:(!!r.data.user.binded&&r.data.user.binded.state=='在职')?true:false
  108. })
  109. app.globalData.personMsg = r.data.user;
  110. app.globalData.userflag = false; //有个人信息
  111. var nickname = r.data.user.nickname;
  112. var phone = r.data.user.phone;
  113. app.globalData.phone = false; //没有手机号
  114. if (r.data.user.phone == '') {
  115. wx.hideLoading();
  116. app.globalData.phone = false; //没有手机号
  117. } else {
  118. app.globalData.phone = true; //有手机号
  119. }
  120. } else {
  121. wx.hideLoading();
  122. that.setData({
  123. loginFlag: true
  124. })
  125. }
  126. that.evidencelistfun();
  127. } else {
  128. setTimeout(function () {
  129. wx.hideLoading()
  130. }, 500)
  131. }
  132. }
  133. })
  134. }
  135. }
  136. })
  137. },
  138. prelooktap(){
  139. if(!app.globalData.sharepersonobj.qrcode){
  140. wx.showToast({
  141. title: "当前专属客服的二维码为空!",
  142. icon: 'none',
  143. duration: 2000
  144. })
  145. return false;
  146. }
  147. wx.previewImage({
  148. current: app.globalData.imgUrl+app.globalData.sharepersonobj.qrcode, // 当前显示图片的http链接
  149. urls: [app.globalData.imgUrl+app.globalData.sharepersonobj.qrcode]// 需要预览的图片http链接列表
  150. })
  151. },
  152. callphonetap:function(){
  153. console.log()
  154. wx.makePhoneCall({
  155. phoneNumber: app.globalData.sharepersonobj.phone //仅为示例,并非真实的电话号码
  156. })
  157. },
  158. praisetit:function(){
  159. var that=this;
  160. utils.$get({
  161. url: app.globalData.webUrl + 'api/evidencecate',
  162. header: {
  163. 'Authorization':'bearer '+app.globalData.token
  164. },
  165. data:{},
  166. success: function (res) {
  167. that.setData({
  168. evidencetype:res.data.data
  169. })
  170. }
  171. })
  172. },
  173. firsttap:function(e){
  174. this.setData({
  175. nowtype:e.currentTarget.dataset.text
  176. })
  177. this.evidencelistfun();
  178. },
  179. evidencelistfun:function(e){
  180. var that=this;
  181. page=1;
  182. utils.$get({
  183. url: app.globalData.webUrl + 'client/material/evidencelist',
  184. header: {
  185. 'Authorization':'bearer '+app.globalData.token
  186. },
  187. data:{
  188. uid:app.globalData.personMsg.id,
  189. page:1,
  190. cate:that.data.nowtype,
  191. keyword:''
  192. },
  193. success: function (res) {
  194. setTimeout(function(){
  195. wx.hideLoading()
  196. },1000)
  197. if(res.data.code=='0'){
  198. that.setData({
  199. evidencelist:res.data.data,
  200. leftevidencelist:[],
  201. rightevidencelist:[],
  202. datashow:true
  203. })
  204. that.imgload();
  205. }
  206. },
  207. fail(){
  208. wx.hideLoading()
  209. }
  210. })
  211. },
  212. imgload:function(){
  213. var that=this;
  214. var leftlist=that.data.leftevidencelist;
  215. var rightlist=that.data.rightevidencelist;
  216. var indexlist=that.data.evidencelist;
  217. if(indexlist.length==0){
  218. return false;
  219. }
  220. if(leftlist.length==0){
  221. leftlist.push(indexlist[0]);
  222. indexlist.shift();
  223. that.setData({
  224. evidencelist:indexlist,
  225. leftevidencelist:leftlist,
  226. rightevidencelist:rightlist
  227. })
  228. }else{
  229. var leftheight,rightheight;
  230. const query = wx.createSelectorQuery()
  231. query.select('.leftpublicpraisebox').boundingClientRect();
  232. query.exec(function(res){
  233. leftheight=res[0].height;
  234. const queryright = wx.createSelectorQuery()
  235. queryright.select('.rightpublicpraisebox').boundingClientRect();
  236. queryright.exec(function(rs){
  237. leftlist=that.data.leftevidencelist;
  238. rightlist=that.data.rightevidencelist;
  239. indexlist=that.data.evidencelist;
  240. rightheight=rs[0].height;
  241. if(leftheight<=rightheight){
  242. leftlist.push(indexlist[0]);
  243. indexlist.shift();
  244. }else{
  245. rightlist.push(indexlist[0]);
  246. indexlist.shift();
  247. }
  248. that.setData({
  249. evidencelist:indexlist,
  250. leftevidencelist:leftlist,
  251. rightevidencelist:rightlist
  252. })
  253. })
  254. })
  255. }
  256. },
  257. publictap:function(e){
  258. wx.navigateTo({
  259. url: '/share/pages/publicpraisemsg/publicpraisemsg?type=3&eid='+e.currentTarget.dataset.eid+"&uid="+app.globalData.shareuserid+'&ctp='+app.globalData.clientype
  260. })
  261. },
  262. /**
  263. * 生命周期函数--监听页面初次渲染完成
  264. */
  265. onReady: function () {
  266. },
  267. golastap:function(){
  268. wx.navigateBack()
  269. },
  270. goindextap:function(){
  271. wx.reLaunch({
  272. url: '/pages/index/index?state=1',
  273. })
  274. },
  275. /**
  276. * 生命周期函数--监听页面显示
  277. */
  278. onShow: function () {
  279. this.setData({
  280. top:app.globalData.statusBarHeight,
  281. hgt:app.globalData.titleBarHeight,
  282. })
  283. timer = setInterval(function () {
  284. time = time * 1 + 1;
  285. }, 1000)
  286. },
  287. setimetap(){
  288. const that = this;
  289. utils.$post({
  290. url: app.globalData.webUrl + 'client/index/visit_due_time',
  291. header: {
  292. 'Authorization': 'bearer ' + app.globalData.token
  293. },
  294. data: {
  295. id: that.data.companyobj.employee_id,
  296. pipe_type: 'toolAll',
  297. time: time,
  298. },
  299. success: function (res) {
  300. }
  301. })
  302. },
  303. /**
  304. * 生命周期函数--监听页面隐藏
  305. */
  306. onHide: function () {
  307. if (timer) {
  308. clearInterval(timer)
  309. }
  310. this.setimetap();
  311. },
  312. /**
  313. * 生命周期函数--监听页面卸载
  314. */
  315. onUnload: function () {
  316. this.setimetap();
  317. },
  318. /**
  319. * 页面相关事件处理函数--监听用户下拉动作
  320. */
  321. onPullDownRefresh: function () {
  322. var that=this;
  323. page=1;
  324. utils.$get({
  325. url: app.globalData.webUrl + 'client/material/evidencelist',
  326. header: {
  327. 'Authorization':'bearer '+app.globalData.token
  328. },
  329. data:{
  330. uid:app.globalData.personMsg.id,
  331. page:1,
  332. cate:that.data.nowtype,
  333. keyword:''
  334. },
  335. success: function (res) {
  336. wx.stopPullDownRefresh();
  337. if(res.data.code=='0'){
  338. that.setData({
  339. evidencelist:res.data.data,
  340. leftevidencelist:[],
  341. rightevidencelist:[],
  342. datashow:true
  343. })
  344. that.imgload();
  345. }
  346. }
  347. })
  348. },
  349. /**
  350. * 页面上拉触底事件的处理函数
  351. */
  352. onReachBottom: function () {
  353. var that=this;
  354. page=page*1+1;
  355. utils.$get({
  356. url: app.globalData.webUrl + 'client/material/evidencelist',
  357. header: {
  358. 'Authorization':'bearer '+app.globalData.token
  359. },
  360. data:{
  361. uid:app.globalData.personMsg.id,
  362. page:page,
  363. cate:that.data.nowtype,
  364. keyword:''
  365. },
  366. success: function (res) {
  367. wx.stopPullDownRefresh();
  368. if(res.data.code=='0'){
  369. let evidencelist=that.data.evidencelist;
  370. var arrflag=false
  371. if(evidencelist.length!=0){
  372. arrflag=true;
  373. }
  374. for(let i=0;i<res.data.data.length;i++){
  375. evidencelist.push(res.data.data[i])
  376. }
  377. that.setData({
  378. evidencelist:evidencelist
  379. })
  380. if(!arrflag){
  381. that.imgload();
  382. }
  383. }
  384. }
  385. })
  386. },
  387. addsharetap: function (type) {
  388. let that = this;
  389. utils.$post({
  390. url: app.globalData.webUrl + 'api/share/addlog',
  391. header: {
  392. 'Authorization': 'bearer ' + app.globalData.token
  393. },
  394. data: {
  395. id: '0',
  396. type: type,
  397. },
  398. success: function (r) {}
  399. })
  400. },
  401. /**
  402. * 用户点击右上角分享
  403. */
  404. onShareAppMessage: function () {
  405. let that=this;
  406. that.addsharetap('toolAll');
  407. return {
  408. title: "客户好评-"+this.data.companyobj.company_name,
  409. imageUrl:app.globalData.imgUrl+"xcx/praiseimg.jpg",
  410. path: '/share/pages/praiselist/praiselist?uid='+app.globalData.shareuserid+'&cate='+this.data.nowtype+'&ctp='+app.globalData.clientype
  411. }
  412. }
  413. })