companystrengthmsg.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  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. wshareshow: false,
  16. personMsg: app.globalData.personMsg,
  17. showDsc: false,
  18. showTask: true,
  19. datashow: false,
  20. companyobj: app.globalData.companyobj,
  21. type: '',
  22. bType: "",
  23. pType: "",
  24. playflag: 2,//1是播放中,2是暂停
  25. showCutImage: false,
  26. loading: false,
  27. showApproval: false,
  28. remark: "",
  29. trackimgarr: [],
  30. nowimagearr: [],
  31. shareApprovallist: []
  32. },
  33. /**
  34. * 生命周期函数--监听页面加载
  35. */
  36. onLoad: function (options) {
  37. var that = this;
  38. wx.showLoading({
  39. title: '加载中...',
  40. })
  41. that.setData({
  42. eid: options.eid
  43. })
  44. if (options.type) {
  45. this.setData({
  46. type: options.type
  47. })
  48. }
  49. if (!!options.tp) {
  50. this.setData({
  51. pType: options.tp
  52. })
  53. }
  54. if (!!options.ty) {
  55. this.setData({
  56. bType: options.ty,
  57. showTask: false
  58. })
  59. }
  60. that.evidencefun();
  61. },
  62. handShowUpload: function () {
  63. this.setData({
  64. trackimgarr: [],
  65. nowimagearr: [],
  66. remark: "",
  67. showCutImage: true
  68. })
  69. },
  70. handleShowApproval() {
  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: "CompanyStrength"
  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: "CompanyStrength"
  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. /**
  338. * 生命周期函数--监听页面初次渲染完成
  339. */
  340. onReady: function () {
  341. },
  342. videotap(){
  343. videoContext.play();
  344. wx.showLoading()
  345. },
  346. bindprogress(){
  347. wx.hideLoading();
  348. this.setData({
  349. playflag:1
  350. })
  351. },
  352. showDscContent: function () {
  353. if (this.data.evidencemsg.desc.length > 28) {
  354. this.data.showDsc = !this.data.showDsc;
  355. this.setData({
  356. showDsc: this.data.showDsc
  357. })
  358. }
  359. },
  360. setpostertap: function () {
  361. if (this.data.bType == 'b') {
  362. wx.navigateTo({
  363. url: '/index/pages/setposter/setposter?type=CompanyStrength&aid=' + this.data.eid + "&ty=b&listshare=",
  364. })
  365. } else {
  366. wx.navigateTo({
  367. url: '/index/pages/setposter/setposter?type=CompanyStrength&aid=' + this.data.eid + "&listshare=",
  368. })
  369. }
  370. },
  371. sharetap: function () {
  372. this.setData({
  373. wshareshow: true
  374. })
  375. },
  376. evidencefun: function () {
  377. var that = this;
  378. utils.$get({
  379. url: app.globalData.webUrl + 'api/company_strength/read',
  380. header: {
  381. 'Authorization': 'bearer ' + app.globalData.token
  382. },
  383. data: {
  384. id: that.data.eid,
  385. uid: app.globalData.personMsg.id,
  386. },
  387. success: function (res) {
  388. wx.hideLoading()
  389. if (res.data.code == '0') {
  390. res.data.data.desc = res.data.data.title + '#' + res.data.data.desc + '#';
  391. that.setData({
  392. evidencemsg: res.data.data,
  393. })
  394. wx.setNavigationBarTitle({
  395. title: res.data.data.title
  396. })
  397. if (res.data.data.difference == 1) {
  398. videoContext = that.selectComponent('#myVideo');
  399. videoContext.play();
  400. }
  401. }
  402. }
  403. })
  404. },
  405. collectap: function () {
  406. var that = this;
  407. var list = that.data.evidencemsg;
  408. let weburl = '';
  409. if (that.data.evidencemsg.collect) {
  410. weburl = 'api/companyStrength/no_collect'
  411. } else {
  412. weburl = 'api/companyStrength/collect'
  413. }
  414. utils.$post({
  415. url: app.globalData.webUrl + weburl,
  416. header: {
  417. 'Authorization': 'bearer ' + app.globalData.token
  418. },
  419. data: {
  420. id: that.data.eid
  421. },
  422. success: function (res) {
  423. if (res.data.code == '0') {
  424. wx.showToast({
  425. title: res.data.msg,
  426. icon: 'none',
  427. duration: 2000
  428. })
  429. list.collect = !list.collect;
  430. that.setData({
  431. evidencemsg: list
  432. })
  433. }
  434. }
  435. })
  436. },
  437. shareurltap: function () {
  438. wx.showLoading({
  439. title: '加载中...',
  440. })
  441. if (this.data.bType == 'b') {
  442. util.schemefun('/share/pages/companystrengthmsg/companystrengthmsg', 'eid=' + this.data.eid + '&uid=' + app.globalData.agentEmployeEid + '&ctp=' + app.globalData.clientype + '&agid=' + app.globalData.brokeruserId, this.data.eid, 'CompanyStrength', '');
  443. } else {
  444. util.schemefun('/share/pages/companystrengthmsg/companystrengthmsg', 'eid=' + this.data.eid + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype, this.data.eid, 'CompanyStrength', '');
  445. }
  446. this.evidencesharetap();
  447. },
  448. sendfriendtap() {
  449. this.evidencesharetap();
  450. },
  451. evidencesharetap: function () {
  452. var that = this;
  453. utils.$post({
  454. url: app.globalData.webUrl + 'api/share/addlog',
  455. header: {
  456. 'Authorization': 'bearer ' + app.globalData.token
  457. },
  458. data: {
  459. id: that.data.eid,
  460. type: 'CompanyStrength',
  461. alertshow: '456'
  462. },
  463. success: function (r) {
  464. }
  465. })
  466. },
  467. prelooktap() {
  468. if (!app.globalData.personMsg.binded.qrcode) {
  469. wx.showToast({
  470. title: "您的二维码为空,请上传二维码!",
  471. icon: 'none',
  472. duration: 2000
  473. })
  474. return false;
  475. }
  476. wx.previewImage({
  477. current: app.globalData.imgUrl + app.globalData.personMsg.binded.qrcode, // 当前显示图片的http链接
  478. urls: [app.globalData.imgUrl + app.globalData.personMsg.binded.qrcode]// 需要预览的图片http链接列表
  479. })
  480. },
  481. callphonetap: function () {
  482. wx.makePhoneCall({
  483. phoneNumber: app.globalData.personMsg.phone
  484. })
  485. },
  486. /**
  487. * 生命周期函数--监听页面显示
  488. */
  489. onShow: function () {
  490. this.setData({
  491. companyobj: app.globalData.companyobj,
  492. })
  493. },
  494. /**
  495. * 生命周期函数--监听页面隐藏
  496. */
  497. onHide: function () {
  498. },
  499. /**
  500. * 生命周期函数--监听页面卸载
  501. */
  502. onUnload: function () {
  503. },
  504. /**
  505. * 页面相关事件处理函数--监听用户下拉动作
  506. */
  507. onPullDownRefresh: function () {
  508. },
  509. /**
  510. * 页面上拉触底事件的处理函数
  511. */
  512. onReachBottom: function () {
  513. },
  514. /**
  515. * 用户点击右上角分享
  516. */
  517. onShareAppMessage: function () {
  518. this.evidencesharetap();
  519. 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 + '?x-oss-process=video/snapshot,t_100,f_jpg,w_375,m_fast')) : this.data.evidencemsg.cover;
  520. img = img.replace('http://o.nczyzs.com/', 'https://o.nczyzs.com/');
  521. if (this.data.bType == 'b') {
  522. return {
  523. title: this.data.evidencemsg.title,
  524. imageUrl: img,
  525. path: '/share/pages/companystrengthmsg/companystrengthmsg?eid=' + this.data.eid + '&uid=' + app.globalData.agentEmployeEid + '&ctp=' + app.globalData.clientype + '&agid=' + app.globalData.brokeruserId
  526. }
  527. } else {
  528. return {
  529. title: this.data.evidencemsg.title,
  530. imageUrl: img,
  531. path: '/share/pages/companystrengthmsg/companystrengthmsg?eid=' + this.data.eid + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype
  532. }
  533. }
  534. }
  535. })