publicpraisemsg.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  1. const app = getApp();
  2. var utils = require("../../../utils/http")
  3. const util = require("../../../utils/util");
  4. let videoContext = null;
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. imgUrl: app.globalData.imgUrl,
  11. eid: '',
  12. evidencemsg: {},
  13. lastId: '',
  14. nextId: '',
  15. bType: "",
  16. pType: "",
  17. wshareshow: false,
  18. showTask: true,
  19. datashow: false,
  20. personMsg: app.globalData.personMsg,
  21. companyobj: app.globalData.companyobj,
  22. priceflag: false,
  23. showDsc: false,
  24. ltype: '',//不为空是从名片中点击进去
  25. playflag: 2,//1是播放中,2是暂停
  26. showCutImage: false,
  27. loading: false,
  28. showApproval: false,
  29. remark: "",
  30. trackimgarr: [],
  31. nowimagearr: [],
  32. shareApprovallist: []
  33. },
  34. /**
  35. * 生命周期函数--监听页面加载
  36. */
  37. onLoad: function (options) {
  38. var that = this;
  39. wx.showLoading({
  40. title: '加载中...',
  41. })
  42. that.setData({
  43. eid: options.eid,
  44. ltype: options.ltype ? options.ltype : ''
  45. })
  46. if (!!options.ty) {
  47. this.setData({
  48. bType: options.ty,
  49. showTask: false
  50. })
  51. }
  52. if (!!options.tp) {
  53. this.setData({
  54. pType: options.tp
  55. })
  56. }
  57. that.evidencefun();
  58. },
  59. handShowUpload: function () {
  60. this.setData({
  61. trackimgarr: [],
  62. nowimagearr: [],
  63. remark: "",
  64. showCutImage: true
  65. })
  66. },
  67. handleShowApproval() {
  68. if (this.data.evidencemsg.difference==1) {
  69. videoContext.pause();
  70. }
  71. this.setData({
  72. showApproval: true
  73. })
  74. wx.showLoading({
  75. title: '加载中...',
  76. })
  77. this.getBrokerApprovallist();
  78. },
  79. //获取审核列表
  80. getBrokerApprovallist() {
  81. const that = this;
  82. utils.$post({
  83. url: app.globalData.webUrl + 'api/agentEmp/share_list',
  84. header: {
  85. 'Authorization': 'bearer ' + app.globalData.token
  86. },
  87. data: {
  88. id: that.data.eid,
  89. type: "MaterialEvidence"
  90. },
  91. success: function (res) {
  92. wx.hideLoading();
  93. if (res.data.code == 0) {
  94. that.setData({
  95. shareApprovallist: res.data.data,
  96. datashow: true
  97. })
  98. }
  99. }
  100. })
  101. },
  102. previewImageEvent(e) {
  103. let index = parseInt(e.currentTarget.dataset.index);
  104. let idx = parseInt(e.currentTarget.dataset.idx);
  105. wx.previewImage({
  106. urls: this.data.shareApprovallist[index].img,
  107. current: this.data.shareApprovallist[index].img[idx]
  108. })
  109. },
  110. closeDialog: function () {
  111. this.setData({
  112. showCutImage: false,
  113. showApproval: false
  114. })
  115. },
  116. getTextarea(e) {
  117. this.setData({
  118. remark: e.detail.value
  119. })
  120. },
  121. //审核通过
  122. confirmApproval(e) {
  123. let id = e.currentTarget.dataset.id;
  124. const that = this;
  125. wx.showModal({
  126. title: '审核提醒',
  127. content: '您确认通过审核吗?',
  128. complete: (res) => {
  129. if (res.confirm) {
  130. utils.$post({
  131. url: app.globalData.webUrl + 'api/agentEmp/validate_share',
  132. header: {
  133. 'Authorization': 'bearer ' + app.globalData.token
  134. },
  135. data: {
  136. share_id: id,
  137. status: 1
  138. },
  139. success: function (res) {
  140. if (res.data.code == 0) {
  141. wx.showToast({
  142. title: '已通过审核',
  143. icon: "none",
  144. duration: 1500,
  145. success: function() {
  146. setTimeout(() => {
  147. that.getBrokerApprovallist();
  148. },1000)
  149. }
  150. })
  151. }
  152. }
  153. })
  154. }
  155. }
  156. })
  157. },
  158. //审核拒绝
  159. rejectApproval(e) {
  160. let id = e.currentTarget.dataset.id;
  161. const that = this;
  162. wx.showModal({
  163. title: '审核提醒',
  164. content: '您确认驳回审核吗?',
  165. complete: (res) => {
  166. if (res.confirm) {
  167. utils.$post({
  168. url: app.globalData.webUrl + 'api/agentEmp/validate_share',
  169. header: {
  170. 'Authorization': 'bearer ' + app.globalData.token
  171. },
  172. data: {
  173. share_id: id,
  174. status: 2
  175. },
  176. success: function (res) {
  177. if (res.data.code == 0) {
  178. wx.showToast({
  179. title: '已驳回审核',
  180. icon: "none",
  181. duration: 1500,
  182. success: function() {
  183. setTimeout(() => {
  184. that.getBrokerApprovallist();
  185. },1000)
  186. }
  187. })
  188. }
  189. }
  190. })
  191. }
  192. }
  193. })
  194. },
  195. //上传分享截图
  196. submitData() {
  197. if (!this.data.trackimgarr.length) {
  198. wx.showToast({
  199. title: '请上传分享截图!',
  200. icon: "none",
  201. duration: 1500,
  202. })
  203. return false;
  204. }
  205. this.setData({
  206. loading: true
  207. })
  208. this.ossuploadimg();
  209. },
  210. uploadImage() {
  211. let _this = this;
  212. wx.chooseMedia({
  213. count: 9,
  214. mediaType: ["image"],
  215. sourceType: ["album", "camera"],
  216. sizeType: ['original', 'compressed'],
  217. success: function (res) {
  218. if (res.errMsg == "chooseMedia:ok") {
  219. _this.createImagePayment(res.tempFiles);
  220. }
  221. }
  222. })
  223. },
  224. imageDel(e) {
  225. let index = e.currentTarget.dataset.index;
  226. this.data.trackimgarr.splice(index, 1);
  227. this.setData({
  228. trackimgarr: this.data.trackimgarr
  229. })
  230. },
  231. createImagePayment: function (imgUrl) {
  232. var that = this;
  233. if (imgUrl.length == 0) return;
  234. var lent = that.data.trackimgarr.length + imgUrl.length;
  235. if (lent > 9) {
  236. lent = 9
  237. } else {
  238. lent = lent;
  239. }
  240. let trackimgarr = that.data.trackimgarr;
  241. let len = imgUrl.length;
  242. if ((trackimgarr.length + len) > 9) {
  243. for (let j = 0; j < len; j++) {
  244. if (trackimgarr.length < 9) {
  245. trackimgarr.push(imgUrl[j]);
  246. }
  247. }
  248. } else {
  249. trackimgarr = trackimgarr.concat(imgUrl);
  250. }
  251. that.setData({
  252. trackimgarr: trackimgarr
  253. })
  254. },
  255. ossuploadimg: function (e) {
  256. let that = this;
  257. let trackimgarr = that.data.trackimgarr;
  258. var arr = [];
  259. for (let i = 0; i < trackimgarr.length; i++) {
  260. //获取文件后缀
  261. // 随机生成文件名称
  262. let rstr = trackimgarr[i].tempFilePath.split('.');
  263. var fileRandName = Date.now() + "" + parseInt(Math.random() * 10000) + i;
  264. var imgName = fileRandName + '.' + 'png';
  265. // var fileName = that.data.;
  266. var date = new Date();
  267. var time = date.getFullYear() + '' + (date.getMonth() * 1 + 1) + '' + date.getDate();
  268. var imgstr = 'broker/' + time + '/' + imgName;
  269. var nowimagearr = that.data.nowimagearr;
  270. nowimagearr.push(imgstr);
  271. that.setData({
  272. nowimagearr: nowimagearr
  273. })
  274. wx.uploadFile({
  275. url: 'https://wzh-zqxg.oss-cn-hangzhou.aliyuncs.com',
  276. filePath: trackimgarr[i].tempFilePath,
  277. name: 'file',
  278. formData: {
  279. // name: that.data.imgSrc[0],
  280. key: 'broker/' + time + '/' + imgName,
  281. policy: "eyJleHBpcmF0aW9uIjoiMjA0MC0wMS0wMVQxMjowMDowMC4wMDBaIiwiY29uZGl0aW9ucyI6W1siY29udGVudC1sZW5ndGgtcmFuZ2UiLDAsMTA0ODU3NjAwMF1dfQ==",
  282. OSSAccessKeyId: "LTAI5tHjWupJSCAycy2yVbQZ",
  283. success_action_status: "200",
  284. signature: "GPu5wBYVzdhICS/hdJH6rKG0kos=",
  285. },
  286. header: {
  287. "Content-Type": "multipart/form-data",
  288. 'accept': 'application/json',
  289. },
  290. success: function (rs) {
  291. if (rs.errMsg == 'uploadFile:ok') {
  292. arr.push('0');
  293. if (arr.length == trackimgarr.length) {
  294. that.requestUploadImageApi();
  295. }
  296. }
  297. },
  298. fail(res) {
  299. wx.hideLoading()
  300. }
  301. })
  302. }
  303. },
  304. requestUploadImageApi() {
  305. let that = this;
  306. let imgs = that.data.nowimagearr.map(v => {
  307. return { serverId: "", img: v, };
  308. })
  309. utils.$post({
  310. url: app.globalData.webUrl + 'api/agentsWork/upload_share_log',
  311. header: {
  312. 'Authorization': 'bearer ' + app.globalData.token
  313. },
  314. data: {
  315. article_id: that.data.eid,
  316. file_media_id: imgs,
  317. remarks: that.data.remark,
  318. type: "MaterialEvidence"
  319. },
  320. success: function (res) {
  321. that.setData({
  322. loading: false
  323. })
  324. if (res.data.code == '0') {
  325. wx.showToast({
  326. title: '上传成功',
  327. icon: "success",
  328. duration: 1500
  329. })
  330. that.setData({
  331. showCutImage: false
  332. })
  333. }
  334. }
  335. })
  336. },
  337. showDscTextFunc: function () {
  338. if (this.data.evidencemsg.desc.length > 29) {
  339. this.data.showDsc = !this.data.showDsc;
  340. this.setData({
  341. showDsc: this.data.showDsc
  342. })
  343. }
  344. },
  345. priceshowtap() {
  346. videoContext.pause();
  347. this.setData({
  348. priceflag: true
  349. })
  350. },
  351. videotap() {
  352. videoContext.play();
  353. wx.showLoading()
  354. },
  355. bindprogress() {
  356. wx.hideLoading();
  357. this.setData({
  358. playflag: 1
  359. })
  360. },
  361. closepricetap() {
  362. this.setData({
  363. priceflag: false
  364. })
  365. },
  366. /**
  367. * 生命周期函数--监听页面初次渲染完成
  368. */
  369. onReady: function () {
  370. },
  371. setpostertap: function () {
  372. if (this.data.bType == 'b') {
  373. wx.navigateTo({
  374. url: '/index/pages/setposter/setposter?type=materialEvidence&aid=' + this.data.eid + "&ty=b&listshare=",
  375. })
  376. } else {
  377. wx.navigateTo({
  378. url: '/index/pages/setposter/setposter?type=materialEvidence&aid=' + this.data.eid + "&listshare=",
  379. })
  380. }
  381. },
  382. sharetap: function () {
  383. this.setData({
  384. wshareshow: true
  385. })
  386. },
  387. evidencefun: function () {
  388. var that = this;
  389. utils.$get({
  390. url: app.globalData.webUrl + 'api/evidencedetail',
  391. header: {
  392. 'Authorization': 'bearer ' + app.globalData.token
  393. },
  394. data: {
  395. id: that.data.eid,
  396. uid: app.globalData.personMsg.id,
  397. },
  398. success: function (res) {
  399. wx.hideLoading()
  400. if (res.data.code == '0') {
  401. res.data.data.desc = res.data.data.title + '#' + res.data.data.desc + '#';
  402. that.setData({
  403. evidencemsg: res.data.data,
  404. lastId: res.data.lastId,
  405. nextId: res.data.nextId,
  406. })
  407. wx.setNavigationBarTitle({
  408. title: res.data.data.title
  409. })
  410. if (res.data.data.difference == 1) {
  411. videoContext = that.selectComponent('#myVideo');
  412. videoContext.play();
  413. }
  414. }
  415. }
  416. })
  417. },
  418. collectap: function () {
  419. var that = this;
  420. var list = that.data.evidencemsg;
  421. utils.$post({
  422. url: app.globalData.webUrl + 'api/collect',
  423. header: {
  424. 'Authorization': 'bearer ' + app.globalData.token
  425. },
  426. data: {
  427. user_id: app.globalData.personMsg.id,
  428. content_type: "materialEvidence",
  429. content_id: that.data.eid
  430. },
  431. success: function (res) {
  432. if (res.data.code == '0') {
  433. wx.showToast({
  434. title: res.data.msg,
  435. icon: 'none',
  436. duration: 2000
  437. })
  438. list.collected = !list.collected;
  439. that.setData({
  440. evidencemsg: list
  441. })
  442. }
  443. }
  444. })
  445. },
  446. shareurltap: function () {
  447. wx.showLoading({
  448. title: '加载中...',
  449. })
  450. if (this.data.bType == 'b') {
  451. util.schemefun('/share/pages/publicpraisemsg/publicpraisemsg', 'eid=' + this.data.eid + '&uid=' + app.globalData.agentEmployeEid + '&ctp=' + app.globalData.clientype + '&agid=' + app.globalData.brokeruserId, this.data.eid, 'materialEvidence', '');
  452. } else {
  453. util.schemefun('/share/pages/publicpraisemsg/publicpraisemsg', 'eid=' + this.data.eid + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype, this.data.eid, 'materialEvidence', '');
  454. }
  455. this.evidencesharetap();
  456. },
  457. sendfriendtap() {
  458. this.evidencesharetap();
  459. },
  460. evidencesharetap: function () {
  461. var that = this;
  462. utils.$post({
  463. url: app.globalData.webUrl + 'api/share/addlog',
  464. header: {
  465. 'Authorization': 'bearer ' + app.globalData.token
  466. },
  467. data: {
  468. id: that.data.eid,
  469. type: 'materialEvidence'
  470. },
  471. success: function (r) { }
  472. })
  473. },
  474. pretap: function () {
  475. if (!this.data.lastId) {
  476. wx.showToast({
  477. title: '已经第一篇了!',
  478. icon: 'none',
  479. duration: 2000
  480. })
  481. return false
  482. }
  483. wx.redirectTo({
  484. url: '/index/pages/publicpraisemsg/publicpraisemsg?eid=' + this.data.lastId,
  485. })
  486. },
  487. nextap: function () {
  488. if (!this.data.nextId) {
  489. wx.showToast({
  490. title: '已经最后一篇了!',
  491. icon: 'none',
  492. duration: 2000
  493. })
  494. return false
  495. }
  496. wx.redirectTo({
  497. url: '/index/pages/publicpraisemsg/publicpraisemsg?eid=' + this.data.nextId,
  498. })
  499. },
  500. prelooktap() {
  501. if (!app.globalData.personMsg.binded.qrcode) {
  502. wx.showToast({
  503. title: "您的二维码为空,请上传二维码!",
  504. icon: 'none',
  505. duration: 2000
  506. })
  507. return false;
  508. }
  509. wx.previewImage({
  510. current: app.globalData.imgUrl + app.globalData.personMsg.binded.qrcode, // 当前显示图片的http链接
  511. urls: [app.globalData.imgUrl + app.globalData.personMsg.binded.qrcode] // 需要预览的图片http链接列表
  512. })
  513. },
  514. callphonetap: function () {
  515. wx.makePhoneCall({
  516. phoneNumber: app.globalData.personMsg.phone
  517. })
  518. },
  519. /**
  520. * 生命周期函数--监听页面显示
  521. */
  522. onShow: function () {
  523. this.setData({
  524. companyobj: app.globalData.companyobj,
  525. personMsg: app.globalData.personMsg,
  526. })
  527. },
  528. /**
  529. * 生命周期函数--监听页面隐藏
  530. */
  531. onHide: function () {
  532. },
  533. /**
  534. * 生命周期函数--监听页面卸载
  535. */
  536. onUnload: function () {
  537. },
  538. /**
  539. * 页面相关事件处理函数--监听用户下拉动作
  540. */
  541. onPullDownRefresh: function () {
  542. },
  543. /**
  544. * 页面上拉触底事件的处理函数
  545. */
  546. onReachBottom: function () {
  547. },
  548. // onShareTimeline: function () {
  549. // this.evidencesharetap();
  550. // var img = this.data.evidencemsg.difference == 1 ? (this.data.evidencemsg.cover ? this.data.evidencemsg.cover : (this.data.evidencemsg.pics[0] + '?x-oss-process=video/snapshot,t_100,f_jpg,w_375,m_fast')) : this.data.evidencemsg.pics[0];
  551. // img = img.replace('http://o.nczyzs.com/', 'https://o.nczyzs.com/');
  552. // return {
  553. // title: this.data.evidencemsg.title,
  554. // imageUrl: img,
  555. // query: '/share/pages/publicpraisemsg/publicpraisemsg?eid=' + this.data.eid + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype
  556. // }
  557. // },
  558. /**
  559. * 用户点击右上角分享
  560. */
  561. onShareAppMessage: function () {
  562. this.evidencesharetap();
  563. var img = this.data.evidencemsg.cover_share_img?this.data.evidencemsg.cover_share_img:this.data.evidencemsg.difference == 1 ? (this.data.evidencemsg.cover ? this.data.evidencemsg.cover : (this.data.evidencemsg.pics[0] + '?x-oss-process=video/snapshot,t_100,f_jpg,w_375,m_fast')) : this.data.evidencemsg.pics[0];
  564. img = img.replace('http://o.nczyzs.com/', 'https://o.nczyzs.com/');
  565. if (this.data.bType == 'b') {
  566. return {
  567. title: this.data.evidencemsg.title,
  568. imageUrl: img,
  569. path: '/share/pages/publicpraisemsg/publicpraisemsg?eid=' + this.data.eid + '&uid=' + app.globalData.agentEmployeEid + '&ctp=' + app.globalData.clientype + '&agid=' + app.globalData.brokeruserId
  570. }
  571. } else {
  572. return {
  573. title: this.data.evidencemsg.title,
  574. imageUrl: img,
  575. path: '/share/pages/publicpraisemsg/publicpraisemsg?eid=' + this.data.eid + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype
  576. }
  577. }
  578. }
  579. })