casemsg.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. const app = getApp(),util = require("../../../utils/util"),utils = require("../../../utils/http");
  2. let videoContext=null;
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. top: app.globalData.statusBarHeight,
  9. hgt: app.globalData.titleBarHeight,
  10. imgUrl: app.globalData.imgUrl,
  11. communityht: '',
  12. cid: '',
  13. casemsgobj: {},
  14. page: 1,
  15. personMsg: app.globalData.personMsg,
  16. wshareshow: false,
  17. showTask: true,
  18. datashow: false,
  19. caselist: [],
  20. leftcaselist: [],
  21. rightcaselist: [],
  22. companyobj: app.globalData.companyobj,
  23. showAddress: false,
  24. imgarr: [],
  25. type: '',
  26. priceflag: false,
  27. swiperIndex:0,
  28. tab: [{
  29. name: 'VR案例',
  30. type: 'vr',
  31. count: 0
  32. }, {
  33. name: '视频案例',
  34. type: 'video',
  35. count: 0
  36. }],
  37. activeType: '',
  38. bType: "",
  39. pType: "",
  40. ltype:'',//不为空是从名片中点击进去
  41. showCutImage: false,
  42. loading: false,
  43. showApproval: false,
  44. remark: "",
  45. trackimgarr: [],
  46. nowimagearr: [],
  47. shareApprovallist: [],
  48. playflag: 2,//1是播放中,2是暂停
  49. isBroker: false
  50. },
  51. /**
  52. * 生命周期函数--监听页面加载
  53. */
  54. onLoad: function (options) {
  55. if (!!options.clg && options.clg == 1) {
  56. wx.reLaunch({
  57. url: '/pages/index/index?clientype=' + options.cty + "&cid=" + options.cid + "&clg=1",
  58. })
  59. return false;
  60. }
  61. var that = this;
  62. if(!!options.ty) {
  63. this.setData({
  64. bType: options.ty,
  65. showTask: false
  66. })
  67. }
  68. if (!!options.tp) {
  69. this.setData({
  70. pType: options.tp
  71. })
  72. }
  73. wx.showLoading({
  74. title: '加载中...',
  75. })
  76. that.setData({
  77. cid: options.cid,
  78. companyobj: app.globalData.companyobj,
  79. ltype:options.ltype?options.ltype:'',
  80. })
  81. if (app.globalData.brokeruserId) {
  82. that.setData({
  83. isBroker: true
  84. })
  85. } else {
  86. that.setData({
  87. isBroker: false
  88. })
  89. }
  90. that.casemsgfun();
  91. },
  92. getPhoneNumberTap: function (res) {
  93. var that = this;
  94. if (res.detail.errMsg == 'getPhoneNumber:ok') {
  95. that.setData({
  96. loading: true,
  97. })
  98. utils.$post({
  99. url: app.globalData.webUrl + 'api/users/setUserMobile',
  100. data: {
  101. encryptedData: res.detail.encryptedData,
  102. iv: res.detail.iv
  103. },
  104. header: {
  105. 'Authorization': 'bearer ' + app.globalData.token
  106. },
  107. success: function (r) {
  108. if (r.data.code == '0') {
  109. that.submitMsg(r.data.mobile);
  110. }
  111. }
  112. })
  113. }
  114. },
  115. /**
  116. * 提交注册数据
  117. */
  118. submitMsg(mobile) {
  119. var that = this;
  120. utils.$post({
  121. url: app.globalData.webUrl + 'api/agents/add_agents',
  122. header: {
  123. 'Authorization': 'bearer ' + app.globalData.token
  124. },
  125. data: {
  126. name: '',
  127. phone: mobile,
  128. employee_id: app.globalData.brokerEmployeeId,
  129. wechat: '',
  130. type: app.globalData.brokerType
  131. },
  132. success: function (res) {
  133. if (res.data.code == '0') {
  134. app.globalData.brokeruserId = res.data.data;
  135. that.setData({
  136. isBroker: true,
  137. loading: false,
  138. wshareshow: true
  139. })
  140. }
  141. }
  142. })
  143. },
  144. setypetap(e) {
  145. this.setData({
  146. type: e.currentTarget.dataset.type
  147. })
  148. },
  149. priceshowtap() {
  150. this.setData({
  151. priceflag: true
  152. })
  153. },
  154. closepricetap() {
  155. this.setData({
  156. priceflag: false
  157. })
  158. },
  159. showAddressName(e) {
  160. let type = e.currentTarget.dataset.type;
  161. if (type == 'hide') {
  162. this.setData({
  163. showAddress: false
  164. })
  165. } else {
  166. this.setData({
  167. showAddress: true
  168. })
  169. }
  170. },
  171. designertap(){
  172. if(!!this.data.casemsgobj.designer_id){
  173. wx.navigateTo({
  174. url: '/customer/pages/designermsg/designermsg?did='+this.data.casemsgobj.designer_id+"&sid="+this.data.casemsgobj.designer_id+'&type='+(this.data.ltype?1:2)
  175. })
  176. }
  177. },
  178. prelook(e) {
  179. let arr = [];
  180. for (let i in this.data.imgarr) {
  181. arr.push(app.globalData.imgUrl + this.data.imgarr[i].img);
  182. }
  183. wx.previewImage({
  184. current: e.currentTarget.dataset.img, // 当前显示图片的 http 链接
  185. urls: arr // 需要预览的图片 http 链接列表
  186. })
  187. },
  188. presharelooktap() {
  189. if (!app.globalData.personMsg.binded.qrcode) {
  190. wx.showToast({
  191. title: "您的微信二维码为空,请上传二维码!",
  192. icon: 'none',
  193. duration: 2000
  194. })
  195. return false;
  196. }
  197. wx.previewImage({
  198. current: app.globalData.imgUrl + app.globalData.personMsg.binded.qrcode, // 当前显示图片的http链接
  199. urls: [app.globalData.imgUrl + app.globalData.personMsg.binded.qrcode]// 需要预览的图片http链接列表
  200. })
  201. },
  202. opintap() {
  203. wx.showToast({
  204. title: '员工不能预约!',
  205. icon: 'none',
  206. duration: 2000
  207. })
  208. },
  209. swiperChange (e) {
  210. let type = e.detail.currentItemId.split('-')[0];
  211. this.setData({
  212. activeType: type
  213. })
  214. },
  215. sharecardtap: function () {
  216. wx.navigateTo({
  217. url: '/index/pages/namecard/namecard'
  218. })
  219. },
  220. handleSwitch(e) {
  221. let type = e.currentTarget.dataset.type;
  222. let swiperIndex=0;
  223. if (type == 'vr') {
  224. swiperIndex = 0;
  225. } else if (type == 'video') {
  226. swiperIndex = !!this.data.casemsgobj.vr_case?1:0;
  227. }
  228. this.setData({
  229. swiperIndex: swiperIndex,
  230. activeType: type,
  231. })
  232. },
  233. casemsgfun: function () {
  234. var that = this;
  235. utils.$get({
  236. url: app.globalData.webUrl + 'api/casedetail',
  237. header: {
  238. 'Authorization': 'bearer ' + app.globalData.token
  239. },
  240. data: {
  241. id: this.data.cid,
  242. uid: app.globalData.personMsg.id,
  243. },
  244. success: function (res) {
  245. let tab=that.data.tab;
  246. if (res.data.code == '0') {
  247. wx.setNavigationBarTitle({
  248. title: res.data.data.title
  249. })
  250. if(!!res.data.data.video_case){
  251. tab[1].count=1;
  252. that.setData({
  253. tab: tab,
  254. activeType:'video'
  255. })
  256. }
  257. if(!!res.data.data.vr_case){
  258. tab[0].count=1;
  259. that.setData({
  260. tab: tab,
  261. activeType:'vr'
  262. })
  263. }
  264. if (!res.data.data.desc) {
  265. if (!res.data.data.real_case) {
  266. that.setData({
  267. type: ''
  268. })
  269. } else {
  270. that.setData({
  271. type: 2
  272. })
  273. }
  274. } else {
  275. if (res.data.data.desc != '<p><br></p>') {
  276. that.setData({
  277. type: 1
  278. })
  279. } else {
  280. that.setData({
  281. type: 2
  282. })
  283. }
  284. }
  285. that.setData({
  286. casemsgobj: res.data.data,
  287. caselist: res.data.data.designer_related_cases,
  288. })
  289. if (res.data.data.from == 1) {
  290. that.setData({
  291. imgarr: JSON.parse(res.data.data.img_content)
  292. })
  293. }
  294. if (that.data.caselist.length > 0) {
  295. that.imgload();
  296. }
  297. }
  298. wx.hideLoading()
  299. }
  300. })
  301. },
  302. videotap() {
  303. videoContext = this.selectComponent('#myVideo');
  304. videoContext.play();
  305. wx.showLoading()
  306. },
  307. bindprogress() {
  308. wx.hideLoading();
  309. this.setData({
  310. playflag: 1
  311. })
  312. },
  313. openVRLink(e) {
  314. let type = e.currentTarget.dataset.type;
  315. if (type == 1) {
  316. let vrlink = this.data.casemsgobj.vr_case;
  317. wx.navigateTo({
  318. url: '/pages/other/other?type=565&vrlink=' + encodeURIComponent(vrlink) + '&cty=materialCase' + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype + '&aid=' + this.data.casemsgobj.id,
  319. })
  320. } else {
  321. let vrlink = e.currentTarget.dataset.vrlink;
  322. let aid = e.currentTarget.dataset.id;
  323. wx.navigateTo({
  324. url: '/pages/other/other?type=565&vrlink=' + encodeURIComponent(vrlink) + '&cty=materialCase' + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype + '&aid=' + aid,
  325. })
  326. }
  327. },
  328. imgload: function () {
  329. var that = this;
  330. var leftlist = that.data.leftcaselist;
  331. var rightlist = that.data.rightcaselist;
  332. var indexlist = that.data.caselist;
  333. if (indexlist.length == 0) {
  334. return false;
  335. }
  336. if (leftlist.length == 0) {
  337. leftlist.push(indexlist[0]);
  338. indexlist.shift();
  339. that.setData({
  340. caselist: indexlist,
  341. leftcaselist: leftlist,
  342. rightcaselist: rightlist
  343. })
  344. } else {
  345. var leftheight, rightheight;
  346. const query = wx.createSelectorQuery()
  347. query.select('.leftcasebox').boundingClientRect();
  348. query.exec(function (res) {
  349. leftheight = res[0].height;
  350. const queryright = wx.createSelectorQuery()
  351. queryright.select('.rightcasebox').boundingClientRect();
  352. queryright.exec(function (rs) {
  353. leftlist = that.data.leftcaselist;
  354. rightlist = that.data.rightcaselist;
  355. indexlist = that.data.caselist;
  356. rightheight = rs[0].height;
  357. if (leftheight <= rightheight) {
  358. leftlist.push(indexlist[0]);
  359. indexlist.shift();
  360. } else {
  361. rightlist.push(indexlist[0]);
  362. indexlist.shift();
  363. }
  364. that.setData({
  365. caselist: indexlist,
  366. leftcaselist: leftlist,
  367. rightcaselist: rightlist
  368. })
  369. })
  370. })
  371. }
  372. },
  373. callphonetap: function () {
  374. wx.makePhoneCall({
  375. phoneNumber: app.globalData.personMsg.phone //仅为示例,并非真实的电话号码
  376. })
  377. },
  378. sendfriendtap() {
  379. this.addsharetap();
  380. },
  381. addsharetap: function () {
  382. let that = this;
  383. utils.$post({
  384. url: app.globalData.webUrl + 'api/share/addlog',
  385. header: {
  386. 'Authorization': 'bearer ' + app.globalData.token
  387. },
  388. data: {
  389. id: that.data.cid,
  390. type: 'materialCase',
  391. },
  392. success: function (r) {}
  393. })
  394. },
  395. setpostertap: function () {
  396. if (this.data.bType == 'b') {
  397. wx.navigateTo({
  398. url: '/index/pages/setposter/setposter?type=materialCase&aid=' + this.data.cid + "&ty=b&listshare=",
  399. })
  400. } else {
  401. wx.navigateTo({
  402. url: '/index/pages/setposter/setposter?type=materialCase&aid=' + this.data.cid + "&listshare=",
  403. })
  404. }
  405. },
  406. casemsgtap: function (e) {
  407. wx.redirectTo({
  408. url: '/index/pages/casemsg/casemsg?cid=' + e.currentTarget.dataset.cid
  409. })
  410. },
  411. precasetap: function () {
  412. if (!this.data.casemsgobj.preid) {
  413. wx.showToast({
  414. title: '已经第一篇了!',
  415. icon: 'none',
  416. duration: 2000
  417. })
  418. return false
  419. }
  420. wx.redirectTo({
  421. url: '/index/pages/casemsg/casemsg?cid=' + this.data.casemsgobj.preid
  422. })
  423. },
  424. nextcasetap: function () {
  425. if (!this.data.casemsgobj.nextid) {
  426. wx.showToast({
  427. title: '已经到头了!',
  428. icon: 'none',
  429. duration: 2000
  430. })
  431. return false
  432. }
  433. wx.redirectTo({
  434. url: '/index/pages/casemsg/casemsg?cid=' + this.data.casemsgobj.nextid
  435. })
  436. },
  437. collectap: function () {
  438. var that = this;
  439. var casemsgobj = that.data.casemsgobj;
  440. utils.$post({
  441. url: app.globalData.webUrl + 'api/collect',
  442. header: {
  443. 'Authorization': 'bearer ' + app.globalData.token
  444. },
  445. data: {
  446. user_id: app.globalData.personMsg.id,
  447. content_type: "materialCase",
  448. content_id: that.data.cid
  449. },
  450. success: function (res) {
  451. if (res.data.code == '0') {
  452. wx.showToast({
  453. title: res.data.msg,
  454. icon: 'none',
  455. duration: 2000
  456. })
  457. casemsgobj.collected = !casemsgobj.collected;
  458. that.setData({
  459. casemsgobj: casemsgobj
  460. })
  461. }
  462. }
  463. })
  464. },
  465. casesharetap: function () {
  466. this.setData({
  467. wshareshow: true
  468. })
  469. },
  470. shareurltap: function () {
  471. wx.showLoading({
  472. title: '加载中...',
  473. })
  474. this.addsharetap();
  475. if (this.data.bType == 'b') {
  476. util.schemefun('/share/pages/materialcase/materialcase', 'cid=' + this.data.cid + '&uid=' + app.globalData.agentEmployeEid + '&ctp=' + app.globalData.clientype + '&agid=' + app.globalData.brokeruserId, this.data.cid, 'materialCase', '');
  477. } else {
  478. util.schemefun('/share/pages/materialcase/materialcase', 'cid=' + this.data.cid + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype, this.data.cid, 'materialCase', '');
  479. }
  480. },
  481. /**
  482. * 生命周期函数--监听页面初次渲染完成
  483. */
  484. onReady: function () {
  485. },
  486. lasttap: function () {
  487. wx.navigateBack()
  488. },
  489. /**
  490. * 生命周期函数--监听页面显示
  491. */
  492. onShow: function () {
  493. },
  494. otherlistfun: function () {
  495. var that = this;
  496. var page = that.data.page;
  497. page = page * 1 + 1;
  498. utils.$post({
  499. url: app.globalData.webUrl + 'api/designercases',
  500. header: {
  501. 'Authorization': 'bearer ' + app.globalData.token
  502. },
  503. data: {
  504. page: page,
  505. limit: 4,
  506. designer_id: that.data.casemsgobj.designer_id,
  507. material_case_id:this.data.cid
  508. },
  509. success: function (res) {
  510. that.setData({
  511. page: page
  512. })
  513. if (res.data.code == '0') {
  514. // caselist:indexlist,
  515. // leftcaselist:leftlist,
  516. // rightcaselist:rightlist
  517. var caselist = that.data.caselist;
  518. var arrflag = false;
  519. if (res.data.data.length == 0) {
  520. wx.showToast({
  521. title: '暂无更多数据',
  522. icon: 'none',
  523. duration: 2000
  524. })
  525. } else {
  526. if (caselist.length != 0) {
  527. arrflag = true;
  528. }
  529. console.log(caselist)
  530. caselist = caselist.concat(res.data.data);
  531. that.setData({
  532. caselist: caselist
  533. });
  534. if (!arrflag) {
  535. that.imgload();
  536. }
  537. }
  538. }
  539. }
  540. })
  541. },
  542. /**
  543. * 生命周期函数--监听页面隐藏
  544. */
  545. onHide: function () {
  546. },
  547. /**
  548. * 生命周期函数--监听页面卸载
  549. */
  550. onUnload: function () {
  551. },
  552. /**
  553. * 页面相关事件处理函数--监听用户下拉动作
  554. */
  555. onPullDownRefresh: function () {
  556. },
  557. /**
  558. * 页面上拉触底事件的处理函数
  559. */
  560. onReachBottom: function () {
  561. },
  562. /**
  563. * 用户点击右上角分享
  564. */
  565. onShareAppMessage: function () {
  566. var img = this.data.casemsgobj.cover_share_img?this.data.casemsgobj.cover_share_img:this.data.casemsgobj.cover_img;
  567. if (this.data.bType == 'b') {
  568. this.addsharetap();
  569. img = img.replace('http://o.nczyzs.com/', 'https://o.nczyzs.com/');
  570. return {
  571. title: this.data.casemsgobj.title,
  572. imageUrl: img,
  573. path: '/share/pages/materialcase/materialcase?cid=' + this.data.cid + '&uid=' + app.globalData.agentEmployeEid + '&ctp=' + app.globalData.clientype + '&agid=' + app.globalData.brokeruserId
  574. }
  575. } else {
  576. this.addsharetap();
  577. img = img.replace('http://o.nczyzs.com/', 'https://o.nczyzs.com/');
  578. return {
  579. title: this.data.casemsgobj.title,
  580. imageUrl: img,
  581. path: '/share/pages/materialcase/materialcase?cid=' + this.data.cid + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype
  582. }
  583. }
  584. },
  585. onAddToFavorites(res) {
  586. var img = this.data.casemsgobj.cover_share_img?this.data.casemsgobj.cover_share_img:this.data.casemsgobj.cover_img;
  587. img = img.replace('http://o.nczyzs.com/', 'https://o.nczyzs.com/');
  588. return {
  589. title: this.data.casemsgobj.title,
  590. imageUrl: img,
  591. query: 'cid=' + this.data.cid + '&cty=' + app.globalData.clientype + '&clg=1',
  592. }
  593. }
  594. })