decorateguidemsg.js 21 KB

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