brokershareinfo.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. // customer/pages/brokershareinfo/brokershareinfo.js
  2. var app = getApp();
  3. var utils = require("../../../utils/http");
  4. var util = require("../../../utils/util");
  5. var page = 1;
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. cid: "",
  12. remark: "",
  13. showdesc: false,
  14. wshareshow: false,
  15. loading: false,
  16. showCutImage: false,
  17. shareArticleInfo: {},
  18. trackimgarr: [],
  19. nowimagearr: [],
  20. fromType: "",
  21. platform: "",
  22. type: "",
  23. xhwwidth: '',
  24. bottom: 26,
  25. isBroker: false
  26. },
  27. /**
  28. * 生命周期函数--监听页面加载
  29. */
  30. onLoad(options) {
  31. if (!!options.from) {
  32. this.setData({
  33. fromType: options.from
  34. })
  35. }
  36. if (app.globalData.brokeruserId) {
  37. this.setData({
  38. isBroker: true
  39. })
  40. } else {
  41. this.setData({
  42. isBroker: false
  43. })
  44. }
  45. if (options.id) {
  46. this.setData({
  47. cid: options.id
  48. })
  49. wx.showLoading({
  50. title: '加载中...',
  51. })
  52. this.getShareArticleInfo();
  53. }
  54. },
  55. getPhoneNumberTap: function (res) {
  56. var that = this;
  57. if (res.detail.errMsg == 'getPhoneNumber:ok') {
  58. that.setData({
  59. loading: true,
  60. })
  61. utils.$post({
  62. url: app.globalData.webUrl + 'api/users/setUserMobile',
  63. data: {
  64. encryptedData: res.detail.encryptedData,
  65. iv: res.detail.iv
  66. },
  67. header: {
  68. 'Authorization': 'bearer ' + app.globalData.token
  69. },
  70. success: function (r) {
  71. if (r.data.code == '0') {
  72. that.submitMsg(r.data.mobile);
  73. }
  74. }
  75. })
  76. }
  77. },
  78. /**
  79. * 提交注册数据
  80. */
  81. submitMsg(mobile) {
  82. var that = this;
  83. utils.$post({
  84. url: app.globalData.webUrl + 'api/agents/add_agents',
  85. header: {
  86. 'Authorization': 'bearer ' + app.globalData.token
  87. },
  88. data: {
  89. name: '',
  90. phone: mobile,
  91. employee_id: app.globalData.brokerEmployeeId,
  92. wechat: '',
  93. type: app.globalData.brokerType
  94. },
  95. success: function (res) {
  96. if (res.data.code == '0') {
  97. app.globalData.brokeruserId = res.data.data;
  98. that.setData({
  99. isBroker: true,
  100. loading: false,
  101. wshareshow: true
  102. })
  103. }
  104. }
  105. })
  106. },
  107. handShowUpload: function() {
  108. this.setData({
  109. trackimgarr: [],
  110. nowimagearr: [],
  111. remark: "",
  112. showCutImage: true
  113. })
  114. },
  115. shareArticleBtn() {
  116. if (this.data.isBroker) {
  117. this.setData({
  118. wshareshow: true
  119. })
  120. }
  121. },
  122. viewdescFunc() {
  123. console.log(this.data.showdesc);
  124. this.data.showdesc = !this.data.showdesc;
  125. this.setData({
  126. showdesc: this.data.showdesc
  127. })
  128. },
  129. setpostertap: function () {
  130. wx.navigateTo({
  131. url: '/index/pages/setposter/setposter?type=shareArticle&aid=' + this.data.cid + '&f=' + this.data.fromType + "&listshare=",
  132. })
  133. },
  134. sendfriendtap() {
  135. this.addsharetap();
  136. },
  137. addsharetap: function () {
  138. let that = this;
  139. utils.$post({
  140. url: app.globalData.webUrl + 'api/agentsWork/agent_sharelog',
  141. header: {
  142. 'Authorization': 'bearer ' + app.globalData.token
  143. },
  144. data: {
  145. type: "AgentArticle",
  146. article_id: that.data.cid,
  147. },
  148. success: function (r) {}
  149. })
  150. },
  151. shareurltap: function () {
  152. wx.showLoading({
  153. title: '加载中...',
  154. })
  155. this.addsharetap();
  156. util.schemefun('/share/pages/brokershareinfo/brokershareinfo', 'cid=' + this.data.cid + '&uid=' + app.globalData.agentEmployeEid + '&ctp=' + app.globalData.clientype + '&agid=' + app.globalData.brokeruserId + '&f=' + this.data.fromType, this.data.cid, 'agentArticle', '','',app.globalData.agentEmployeEid);
  157. },
  158. closeDialog: function() {
  159. this.setData({
  160. showCutImage: false
  161. })
  162. },
  163. getTextarea(e) {
  164. this.setData({
  165. remark: e.detail.value
  166. })
  167. },
  168. submitData() {
  169. if (!this.data.trackimgarr.length) {
  170. wx.showToast({
  171. title: '请上传分享截图!',
  172. icon: "none",
  173. duration: 1500,
  174. })
  175. return false;
  176. }
  177. this.setData({
  178. loading: true
  179. })
  180. this.ossuploadimg();
  181. },
  182. requestUploadImageApi() {
  183. let that = this;
  184. let imgs = that.data.nowimagearr.filter((item,index,itemArr) => {
  185. return itemArr.indexOf(item) == index;
  186. }).map(v => {
  187. return {serverId: "", img: v,};
  188. });
  189. utils.$post({
  190. url: app.globalData.webUrl + 'api/agentsWork/upload_share_log',
  191. header: {
  192. 'Authorization': 'bearer ' + app.globalData.token
  193. },
  194. data: {
  195. type: "AgentArticle",
  196. article_id: that.data.cid,
  197. file_media_id: imgs,
  198. remarks: that.data.remark
  199. },
  200. success: function (res) {
  201. that.setData({
  202. loading: false
  203. })
  204. if (res.data.code == '0') {
  205. wx.showToast({
  206. title: '上传成功',
  207. icon: "success",
  208. duration: 1500
  209. })
  210. that.setData({
  211. showCutImage: false
  212. })
  213. }
  214. }
  215. })
  216. },
  217. uploadImage() {
  218. let _this = this;
  219. wx.chooseMedia({
  220. count: 9,
  221. mediaType: ["image"],
  222. sourceType: ["album","camera"],
  223. sizeType: ['original', 'compressed'],
  224. success: function(res) {
  225. if (res.errMsg == "chooseMedia:ok") {
  226. _this.createImagePayment(res.tempFiles);
  227. }
  228. }
  229. })
  230. },
  231. imageDel(e) {
  232. let index = e.currentTarget.dataset.index;
  233. this.data.trackimgarr.splice(index,1);
  234. this.setData({
  235. trackimgarr: this.data.trackimgarr
  236. })
  237. },
  238. createImagePayment: function (imgUrl) {
  239. var that = this;
  240. if (imgUrl.length == 0) return;
  241. var lent = that.data.trackimgarr.length + imgUrl.length;
  242. if (lent > 9) {
  243. lent = 9
  244. } else {
  245. lent = lent;
  246. }
  247. let trackimgarr = that.data.trackimgarr;
  248. let len = imgUrl.length;
  249. if ((trackimgarr.length + len) > 9) {
  250. for (let j = 0; j < len; j++) {
  251. if (trackimgarr.length < 9) {
  252. trackimgarr.push(imgUrl[j]);
  253. }
  254. }
  255. } else {
  256. trackimgarr = trackimgarr.concat(imgUrl);
  257. }
  258. that.setData({
  259. trackimgarr: trackimgarr
  260. })
  261. },
  262. ossuploadimg: function (e) {
  263. let that = this;
  264. let trackimgarr = that.data.trackimgarr;
  265. var arr = [];
  266. for (let i = 0; i < trackimgarr.length; i++) {
  267. // 随机生成文件名称
  268. var fileRandName = Date.now() + "" + parseInt(Math.random() * 10000) + i;
  269. var imgName = fileRandName + '.' + 'png';
  270. var date = new Date();
  271. var time = date.getFullYear() + '' + (date.getMonth() * 1 + 1) + '' + date.getDate();
  272. var imgstr = 'broker/' + time + '/' + imgName;
  273. var nowimagearr = that.data.nowimagearr;
  274. nowimagearr.push(imgstr);
  275. that.setData({
  276. nowimagearr: nowimagearr
  277. })
  278. wx.uploadFile({
  279. url: 'https://o.nczyzs.com',
  280. filePath: trackimgarr[i].tempFilePath,
  281. name: 'file',
  282. formData: {
  283. key: 'broker/' + time + '/' + imgName,
  284. policy: "eyJleHBpcmF0aW9uIjoiMjAyNS0wMS0wMVQxMjowMDowMC4wMDBaIiwiY29uZGl0aW9ucyI6W1siY29udGVudC1sZW5ndGgtcmFuZ2UiLDAsMTA0ODU3NjAwMF1dfQ==",
  285. OSSaccessKeyId: "LTAI5tHjWupJSCAycy2yVbQZ",
  286. success_action_status: "200",
  287. signature: "bWaeUQYnGAcWynj3FxAfGZLy5n0=",
  288. },
  289. header: {
  290. "Content-Type": "multipart/form-data",
  291. 'accept': 'application/json',
  292. },
  293. success: function (rs) {
  294. if (rs.errMsg == 'uploadFile:ok') {
  295. arr.push('0');
  296. if (arr.length == trackimgarr.length) {
  297. that.requestUploadImageApi();
  298. }
  299. }
  300. },
  301. fail(res) {
  302. wx.hideLoading()
  303. }
  304. })
  305. }
  306. },
  307. copyShareText() {
  308. wx.setClipboardData({
  309. data: this.data.shareArticleInfo.talkskill,
  310. success: function (res) {
  311. console.log(res);
  312. }
  313. })
  314. },
  315. previewImage(e) {
  316. let index = e.currentTarget.dataset.index;
  317. wx.previewImage({
  318. urls: this.data.shareArticleInfo.file,
  319. current: this.data.shareArticleInfo.file[index]
  320. })
  321. },
  322. setype(){
  323. let webUrl = "";
  324. if (this.data.shareArticleInfo.type == 4) {
  325. webUrl = this.data.shareArticleInfo.vr_group_url;
  326. } else {
  327. webUrl = this.data.shareArticleInfo.files;
  328. }
  329. let redurltest='https://hnweizhihui.xiaohongwu.nczyzs.com';//41
  330. let kjlurltest="https://pano337.p.kujiale.com";
  331. let jeajurltest="https://vr-17.justeasy.nczyzs.com";
  332. let jeajurltest1="https://vr.justeasy.nczyzs.com";
  333. let wlurltest1="https://panorama.m2m88.com";//26
  334. let wlurltest2="https://panorama.wlwno1.com";//27
  335. let nowurl="https://wzh.nczyzs.com";//22
  336. let wl360="https://vr.3d66.nczyzs.com"//26
  337. if(webUrl.substr(0, 41)==redurltest){
  338. wx.getSystemInfo({
  339. success (res) {
  340. let width=(res.windowWidth-16)*0.48;
  341. that.setData({
  342. xhwwidth:width,
  343. bottom:res.platform=='android'?'26':36
  344. })
  345. }
  346. })
  347. this.setData({
  348. type:1,
  349. platform:app.globalData.platform,
  350. })
  351. }else if(webUrl.substr(0, 29)==kjlurltest){
  352. this.setData({
  353. type:2,
  354. platform:app.globalData.platform,
  355. })
  356. }else if(webUrl.substr(0, 33)==jeajurltest||webUrl.substr(0, 30)==jeajurltest1){
  357. this.setData({
  358. type:3,
  359. platform:app.globalData.platform,
  360. })
  361. }else if(webUrl.substr(0, 26)==wlurltest1||webUrl.substr(0, 27)==wlurltest2||webUrl.substr(0, 26)==wl360){
  362. this.setData({
  363. type:4,
  364. platform:app.globalData.platform,
  365. })
  366. } else if (webUrl.substr(0, 22)==nowurl){
  367. this.setData({
  368. type:5,
  369. platform:app.globalData.platform,
  370. })
  371. }
  372. },
  373. getShareArticleInfo() {
  374. let that = this;
  375. let params = {
  376. id: that.data.cid,
  377. from: that.data.fromType
  378. };
  379. let api = app.globalData.brokeruserId ? 'api/agentsWork/share_article_details' : 'api/agents/share_article_details';
  380. if (!that.data.fromType && !app.globalData.brokeruserId) {
  381. params.employee_id = app.globalData.brokerEmployeeId;
  382. }
  383. utils.$post({
  384. url: app.globalData.webUrl + api,
  385. header: {
  386. 'Authorization': 'bearer ' + app.globalData.token
  387. },
  388. data: params,
  389. success: function (res) {
  390. wx.hideLoading();
  391. if (res.data.code == '0') {
  392. that.setData({
  393. shareArticleInfo: res.data.data,
  394. })
  395. that.setype();
  396. }
  397. }
  398. })
  399. },
  400. dothis: function() {},
  401. /**
  402. * 生命周期函数--监听页面初次渲染完成
  403. */
  404. onReady() {
  405. },
  406. /**
  407. * 生命周期函数--监听页面显示
  408. */
  409. onShow() {
  410. },
  411. /**
  412. * 生命周期函数--监听页面隐藏
  413. */
  414. onHide() {
  415. },
  416. /**
  417. * 生命周期函数--监听页面卸载
  418. */
  419. onUnload() {
  420. },
  421. /**
  422. * 页面相关事件处理函数--监听用户下拉动作
  423. */
  424. onPullDownRefresh() {
  425. },
  426. /**
  427. * 页面上拉触底事件的处理函数
  428. */
  429. onReachBottom() {
  430. },
  431. /**
  432. * 用户点击右上角分享
  433. */
  434. onShareAppMessage() {
  435. this.addsharetap();
  436. let imgUrl = '';
  437. if (this.data.shareArticleInfo.type == 1) {
  438. imgUrl = `${this.data.shareArticleInfo.file[0]}?x-oss-process=video/snapshot,t_100,f_jpg,w_500,m_fast`;
  439. } else if (this.data.shareArticleInfo.type == 3||this.data.shareArticleInfo.type == 4) {
  440. imgUrl = this.data.shareArticleInfo.file_img;
  441. } else {
  442. imgUrl = this.data.shareArticleInfo.file[0];
  443. }
  444. return {
  445. title: this.data.shareArticleInfo.title,
  446. img: imgUrl,
  447. path: "/share/pages/brokershareinfo/brokershareinfo?ctp=" + app.globalData.clientype + '&cid=' + this.data.shareArticleInfo.id + "&uid=" + app.globalData.agentEmployeEid + '&agid=' + app.globalData.brokeruserId + '&f=' + this.data.fromType
  448. }
  449. }
  450. })