brokershareinfo.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. // customer/pages/brokershareinfo/brokershareinfo.js
  2. const app = getApp();
  3. var utils = require("../../../utils/http");
  4. var time = 0;
  5. var timer = null;
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. loginFlag: false,
  12. datashow: false,
  13. mobileflag: false,
  14. showAction: false,
  15. showdesc: false,
  16. priceflag: false,
  17. imgUrl: app.globalData.imgUrl,
  18. cid: "",
  19. agid: "",
  20. shareid: "",
  21. clientype: "",
  22. fromType: "",
  23. platform: "",
  24. personMsg: {},
  25. sharepersonMsg: {},
  26. shareArticleInfo: {},
  27. companyobj: {},
  28. showMask: false,
  29. fPhone: ""
  30. },
  31. /**
  32. * 生命周期函数--监听页面加载
  33. */
  34. onLoad(options) {
  35. wx.hideHomeButton();
  36. let that = this;
  37. if (!!options.scene) {
  38. options = unescape(options.scene);
  39. let arr = options.split('&');
  40. let obj = {};
  41. for (let i = 0; i < arr.length; i++) {
  42. let arr1 = arr[i].split('=');
  43. obj[arr1[0]] = arr1[1];
  44. }
  45. that.setData({
  46. cid: obj.c,
  47. shareid: obj.u,
  48. agid: obj.ag,
  49. fromType: obj.f
  50. })
  51. app.globalData.clientype = obj.ct;
  52. app.globalData.shareuserid = obj.u;
  53. } else {
  54. if (!!options.ctp) {
  55. app.globalData.clientype = options.ctp;
  56. }
  57. if (!!options.uid) {
  58. app.globalData.shareuserid = options.uid;
  59. }
  60. if (!!options.cid) {
  61. that.setData({
  62. clientype: options.ctp,
  63. cid: options.cid,
  64. shareid: options.uid,
  65. agid: options.agid,
  66. fromType: options.f
  67. })
  68. }
  69. }
  70. this.logindata();
  71. },
  72. logindata: function () {
  73. var that = this;
  74. wx.showLoading();
  75. wx.login({
  76. success: function (data) {
  77. if (data.errMsg == 'login:ok') {
  78. utils.$post({
  79. url: app.globalData.webUrl + 'api/users/code2sessionmini',
  80. data: {
  81. client_type: that.data.clientype,
  82. code: data.code,
  83. share: app.globalData.shareuserid,
  84. share_agent_id: that.data.agid
  85. },
  86. success: function (r) {
  87. if (r.data.code == '0') {
  88. app.globalData.sharepersonobj = r.data.share;
  89. app.globalData.token = r.data.token;
  90. that.sharecompany();
  91. that.setData({
  92. sharepersonMsg: app.globalData.sharepersonobj,
  93. })
  94. if (!!r.data.user.phone) {
  95. app.globalData.use_id = r.data.user.id;
  96. app.globalData.personMsg = r.data.user;
  97. app.globalData.userflag = false; //有个人信息
  98. var nickname = r.data.user.nickname;
  99. var phone = r.data.user.phone;
  100. that.setData({
  101. fPhone: phone,
  102. loginFlag: false,
  103. datashow: true,
  104. personMsg:r.data.user,
  105. mobileflag: false,
  106. })
  107. that.getShareArticleInfo();
  108. } else {
  109. that.getShareArticleInfo();
  110. wx.hideLoading();
  111. that.setData({
  112. loginFlag: false,
  113. mobileflag: true
  114. })
  115. }
  116. }
  117. }
  118. })
  119. }
  120. wx.hideLoading();
  121. }
  122. })
  123. },
  124. presharelooktap() {
  125. if (!app.globalData.sharepersonobj.qrcode) {
  126. wx.showToast({
  127. title: "当前专属客服的二维码为空!",
  128. icon: 'none',
  129. duration: 2000
  130. })
  131. return false;
  132. }
  133. wx.previewImage({
  134. current: app.globalData.imgUrl + app.globalData.sharepersonobj.qrcode, // 当前显示图片的http链接
  135. urls: [app.globalData.imgUrl + app.globalData.sharepersonobj.qrcode]// 需要预览的图片http链接列表
  136. })
  137. },
  138. previewImage(e) {
  139. let index = e.currentTarget.dataset.index;
  140. wx.previewImage({
  141. urls: this.data.shareArticleInfo.file,
  142. current: this.data.shareArticleInfo.file[index]
  143. })
  144. },
  145. hiddenMaskFunc() {
  146. this.setData({
  147. showMask: false
  148. })
  149. },
  150. getPhoneNumberTap: function (res) {
  151. var that = this;
  152. if (res.detail.errMsg == 'getPhoneNumber:ok') {
  153. utils.$post({
  154. url: app.globalData.webUrl + 'api/users/setUserMobile',
  155. data: {
  156. encryptedData: res.detail.encryptedData,
  157. iv: res.detail.iv
  158. },
  159. header: {
  160. 'Authorization': 'bearer ' + app.globalData.token
  161. },
  162. success: function (r) {
  163. if (r.data.code == '0') {
  164. that.setData({
  165. fPhone: r.data.mobile,
  166. })
  167. if (res.currentTarget.dataset.type == 'broker') {
  168. that.setData({
  169. showMask: true
  170. })
  171. }
  172. }
  173. }
  174. })
  175. } else {
  176. this.setData({
  177. showMask: true
  178. })
  179. }
  180. },
  181. viewdescFunc() {
  182. console.log(this.data.showdesc);
  183. this.data.showdesc = !this.data.showdesc;
  184. this.setData({
  185. showdesc: this.data.showdesc
  186. })
  187. },
  188. priceshowtap() {
  189. this.setData({
  190. priceflag: true
  191. })
  192. },
  193. closepricetap() {
  194. this.setData({
  195. priceflag: false
  196. })
  197. },
  198. setype(){
  199. let webUrl = this.data.shareArticleInfo.files;
  200. let redurltest='https://hnweizhihui.xiaohongwu.com';
  201. let kjlurltest="https://pano337.p.kujiale.com";
  202. let jeajurltest="https://vr-17.justeasy.cn";
  203. let jeajurltest1="https://vr.justeasy.cn";
  204. if(webUrl.substr(0, 34)==redurltest){
  205. this.setData({
  206. type:1,
  207. platform:app.globalData.platform,
  208. })
  209. }
  210. if(webUrl.substr(0, 29)==kjlurltest){
  211. this.setData({
  212. type:2,
  213. platform:app.globalData.platform,
  214. })
  215. }
  216. if(webUrl.substr(0, 25)==jeajurltest||webUrl.substr(0, 22)==jeajurltest1){
  217. this.setData({
  218. type:3,
  219. platform:app.globalData.platform,
  220. })
  221. }
  222. if (webUrl.substr(0, 29)!=kjlurltest && webUrl.substr(0, 34)!=redurltest&& webUrl.substr(0, 25)!=jeajurltest&&webUrl.substr(0, 22)!=jeajurltest1 && this.data.shareArticleInfo.type == 3) {
  223. this.setData({
  224. type:'',
  225. platform:''
  226. })
  227. wx.hideShareMenu({
  228. menus: ['shareAppMessage', 'shareTimeline']
  229. })
  230. }
  231. },
  232. /**
  233. * 前往个人名片
  234. */
  235. toPageNameCard() {
  236. wx.navigateTo({
  237. url: '/share/pages/shareCard/shareCard?uid='+ app.globalData.shareuserid + '&ctp=' + app.globalData.clientype + '&empid=' + app.globalData.sharempid + '&ftype=share',
  238. })
  239. },
  240. callphonetap: function () {
  241. console.log()
  242. wx.makePhoneCall({
  243. phoneNumber: app.globalData.sharepersonobj.phone //仅为示例,并非真实的电话号码
  244. })
  245. },
  246. sharecompany: function () {
  247. const that = this;
  248. utils.$post({
  249. url: app.globalData.webUrl + 'client/index/content_belong_company',
  250. header: {
  251. 'Authorization': 'bearer ' + app.globalData.token
  252. },
  253. data: {
  254. client_type: app.globalData.clientype,
  255. uid: app.globalData.shareuserid
  256. },
  257. success: function (res) {
  258. if (res.data.code == '0') {
  259. app.globalData.companyobj=res.data.data;
  260. app.globalData.sharempid = res.data.data.employee_id;
  261. that.setData({
  262. companyobj: res.data.data
  263. })
  264. }
  265. },
  266. complete(res) {
  267. wx.hideLoading()
  268. }
  269. })
  270. },
  271. cancelGetPhone() {},
  272. getShareArticleInfo() {
  273. let that = this;
  274. utils.$post({
  275. url: app.globalData.webUrl + 'client/agent/info',
  276. header: {
  277. 'Authorization': 'bearer ' + app.globalData.token
  278. },
  279. data: {
  280. article_id: that.data.cid
  281. },
  282. success: function (res) {
  283. wx.hideLoading();
  284. if (res.data.code == '0') {
  285. that.setData({
  286. shareArticleInfo: res.data.data
  287. })
  288. wx.setNavigationBarTitle({
  289. title: that.data.shareArticleInfo.title,
  290. })
  291. that.setype();
  292. }
  293. }
  294. })
  295. },
  296. dothis: function() {},
  297. visitimefun() {
  298. const that = this;
  299. utils.$post({
  300. url: app.globalData.webUrl + 'client/index/visit_due_time',
  301. header: {
  302. 'Authorization': 'bearer ' + app.globalData.token
  303. },
  304. data: {
  305. id: that.data.cid,
  306. pipe_type: 'agentArticle',
  307. time: time,
  308. },
  309. success: function (res) {
  310. }
  311. })
  312. },
  313. /**
  314. * 生命周期函数--监听页面初次渲染完成
  315. */
  316. onReady() {
  317. },
  318. /**
  319. * 生命周期函数--监听页面显示
  320. */
  321. onShow() {
  322. time = 0;
  323. timer = setInterval(function () {
  324. time = time * 1 + 1;
  325. }, 1000)
  326. },
  327. /**
  328. * 生命周期函数--监听页面隐藏
  329. */
  330. onHide() {
  331. if (timer) {
  332. clearInterval(timer);
  333. }
  334. this.visitimefun();
  335. },
  336. /**
  337. * 生命周期函数--监听页面卸载
  338. */
  339. onUnload() {
  340. if (timer) {
  341. clearInterval(timer);
  342. }
  343. this.visitimefun();
  344. },
  345. /**
  346. * 页面相关事件处理函数--监听用户下拉动作
  347. */
  348. onPullDownRefresh() {
  349. },
  350. /**
  351. * 页面上拉触底事件的处理函数
  352. */
  353. onReachBottom() {
  354. },
  355. addsharetap: function () {
  356. let that = this;
  357. utils.$post({
  358. url: app.globalData.webUrl + 'api/agentsWork/agent_sharelog',
  359. header: {
  360. 'Authorization': 'bearer ' + app.globalData.token
  361. },
  362. data: {
  363. article_id: that.data.cid,
  364. },
  365. success: function (r) {}
  366. })
  367. },
  368. /**
  369. * 用户点击右上角分享
  370. */
  371. onShareAppMessage() {
  372. this.addsharetap();
  373. let imgUrl = '';
  374. if (this.data.shareArticleInfo.type == 1) {
  375. imgUrl = `${this.data.shareArticleInfo.file[0]}?x-oss-process=video/snapshot,t_100,f_jpg,w_200,m_fast`;
  376. } else if (this.data.shareArticleInfo.type == 3) {
  377. imgUrl = this.data.shareArticleInfo.file_img;
  378. } else {
  379. imgUrl = this.data.shareArticleInfo.file[0];
  380. }
  381. return {
  382. title: this.data.shareArticleInfo.title,
  383. img: imgUrl,
  384. path: "/share/pages/brokershareinfo/brokershareinfo?ctp=" + app.globalData.clientype + '&cid=' + this.data.shareArticleInfo.id + "&uid=" + app.globalData.shareuserid + '&agid=' + this.data.agid + '&f=' + this.data.fromType
  385. }
  386. }
  387. })