publicpraisemsg.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  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. bType: "",
  16. pType: "",
  17. wshareshow: false,
  18. showTask: true,
  19. datashow: false,
  20. personMsg: app.globalData.personMsg,
  21. companyobj: app.globalData.companyobj,
  22. priceflag: false,
  23. showDsc: false,
  24. ltype: '',//不为空是从名片中点击进去
  25. playflag: 2,//1是播放中,2是暂停
  26. isBroker: false,
  27. loading: false,
  28. showApproval: false,
  29. isfullScreen: false,
  30. remark: "",
  31. trackimgarr: [],
  32. nowimagearr: [],
  33. shareApprovallist: []
  34. },
  35. /**
  36. * 生命周期函数--监听页面加载
  37. */
  38. onLoad: function (options) {
  39. if (!!options.clg && options.clg == 5) {
  40. wx.reLaunch({
  41. url: '/pages/index/index?clientype=' + options.cty + "&cid=" + options.cid + "&clg=5",
  42. })
  43. return false;
  44. }
  45. var that = this;
  46. wx.showLoading({
  47. title: '加载中...',
  48. })
  49. that.setData({
  50. eid: options.eid,
  51. ltype: options.ltype ? options.ltype : ''
  52. })
  53. if (!!options.ty) {
  54. this.setData({
  55. bType: options.ty,
  56. showTask: false
  57. })
  58. }
  59. if (!!options.tp) {
  60. this.setData({
  61. pType: options.tp
  62. })
  63. }
  64. if (app.globalData.brokeruserId) {
  65. that.setData({
  66. isBroker: true
  67. })
  68. } else {
  69. that.setData({
  70. isBroker: false
  71. })
  72. }
  73. that.evidencefun();
  74. },
  75. getPhoneNumberTap: function (res) {
  76. var that = this;
  77. if (res.detail.errMsg == 'getPhoneNumber:ok') {
  78. that.setData({
  79. loading: true,
  80. })
  81. utils.$post({
  82. url: app.globalData.webUrl + 'api/users/setUserMobile',
  83. data: {
  84. encryptedData: res.detail.encryptedData,
  85. iv: res.detail.iv
  86. },
  87. header: {
  88. 'Authorization': 'bearer ' + app.globalData.token
  89. },
  90. success: function (r) {
  91. if (r.data.code == '0') {
  92. that.submitMsg(r.data.mobile);
  93. }
  94. }
  95. })
  96. }
  97. },
  98. /**
  99. * 提交注册数据
  100. */
  101. submitMsg(mobile) {
  102. var that = this;
  103. utils.$post({
  104. url: app.globalData.webUrl + 'api/agents/add_agents',
  105. header: {
  106. 'Authorization': 'bearer ' + app.globalData.token
  107. },
  108. data: {
  109. name: '',
  110. phone: mobile,
  111. employee_id: app.globalData.brokerEmployeeId,
  112. wechat: '',
  113. type: app.globalData.brokerType
  114. },
  115. success: function (res) {
  116. if (res.data.code == '0') {
  117. app.globalData.brokeruserId = res.data.data;
  118. that.setData({
  119. isBroker: true,
  120. loading: false,
  121. wshareshow: true
  122. })
  123. }
  124. }
  125. })
  126. },
  127. onFullScreenChange(e) {
  128. let isBol = e.detail.detail.fullScreen;
  129. this.setData({
  130. isfullScreen: isBol
  131. })
  132. },
  133. showDscTextFunc: function () {
  134. if (this.data.evidencemsg.desc.length > 29) {
  135. this.data.showDsc = !this.data.showDsc;
  136. this.setData({
  137. showDsc: this.data.showDsc
  138. })
  139. }
  140. },
  141. priceshowtap() {
  142. videoContext.pause();
  143. this.setData({
  144. priceflag: true
  145. })
  146. },
  147. videotap() {
  148. videoContext.play();
  149. wx.showLoading()
  150. },
  151. bindprogress() {
  152. wx.hideLoading();
  153. this.setData({
  154. playflag: 1
  155. })
  156. },
  157. closepricetap() {
  158. this.setData({
  159. priceflag: false
  160. })
  161. },
  162. /**
  163. * 生命周期函数--监听页面初次渲染完成
  164. */
  165. onReady: function () {
  166. },
  167. setpostertap: function () {
  168. if (this.data.bType == 'b') {
  169. wx.navigateTo({
  170. url: '/index/pages/setposter/setposter?type=materialEvidence&aid=' + this.data.eid + "&ty=b&listshare=",
  171. })
  172. } else {
  173. wx.navigateTo({
  174. url: '/index/pages/setposter/setposter?type=materialEvidence&aid=' + this.data.eid + "&listshare=",
  175. })
  176. }
  177. },
  178. sharetap: function () {
  179. this.setData({
  180. wshareshow: true
  181. })
  182. },
  183. evidencefun: function () {
  184. var that = this;
  185. utils.$get({
  186. url: app.globalData.webUrl + 'api/evidencedetail',
  187. header: {
  188. 'Authorization': 'bearer ' + app.globalData.token
  189. },
  190. data: {
  191. id: that.data.eid,
  192. uid: app.globalData.personMsg.id,
  193. },
  194. success: function (res) {
  195. wx.hideLoading()
  196. if (res.data.code == '0') {
  197. res.data.data.desc = res.data.data.title + '#' + res.data.data.desc + '#';
  198. that.setData({
  199. evidencemsg: res.data.data,
  200. lastId: res.data.lastId,
  201. nextId: res.data.nextId,
  202. })
  203. wx.setNavigationBarTitle({
  204. title: res.data.data.title
  205. })
  206. if (res.data.data.difference == 1) {
  207. videoContext = that.selectComponent('#myVideo');
  208. videoContext.play();
  209. }
  210. }
  211. }
  212. })
  213. },
  214. collectap: function () {
  215. var that = this;
  216. var list = that.data.evidencemsg;
  217. utils.$post({
  218. url: app.globalData.webUrl + 'api/collect',
  219. header: {
  220. 'Authorization': 'bearer ' + app.globalData.token
  221. },
  222. data: {
  223. user_id: app.globalData.personMsg.id,
  224. content_type: "materialEvidence",
  225. content_id: that.data.eid
  226. },
  227. success: function (res) {
  228. if (res.data.code == '0') {
  229. wx.showToast({
  230. title: res.data.msg,
  231. icon: 'none',
  232. duration: 2000
  233. })
  234. list.collected = !list.collected;
  235. that.setData({
  236. evidencemsg: list
  237. })
  238. }
  239. }
  240. })
  241. },
  242. shareurltap: function () {
  243. wx.showLoading({
  244. title: '加载中...',
  245. })
  246. if (this.data.bType == 'b') {
  247. util.schemefun('/share/pages/publicpraisemsg/publicpraisemsg', 'eid=' + this.data.eid + '&uid=' + app.globalData.agentEmployeEid + '&ctp=' + app.globalData.clientype + '&agid=' + app.globalData.brokeruserId, this.data.eid, 'materialEvidence', '');
  248. } else {
  249. util.schemefun('/share/pages/publicpraisemsg/publicpraisemsg', 'eid=' + this.data.eid + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype, this.data.eid, 'materialEvidence', '');
  250. }
  251. this.evidencesharetap();
  252. },
  253. sendfriendtap() {
  254. this.evidencesharetap();
  255. },
  256. evidencesharetap: function () {
  257. var that = this;
  258. utils.$post({
  259. url: app.globalData.webUrl + 'api/share/addlog',
  260. header: {
  261. 'Authorization': 'bearer ' + app.globalData.token
  262. },
  263. data: {
  264. id: that.data.eid,
  265. type: 'materialEvidence'
  266. },
  267. success: function (r) { }
  268. })
  269. },
  270. pretap: function () {
  271. if (!this.data.lastId) {
  272. wx.showToast({
  273. title: '已经第一篇了!',
  274. icon: 'none',
  275. duration: 2000
  276. })
  277. return false
  278. }
  279. wx.redirectTo({
  280. url: '/index/pages/publicpraisemsg/publicpraisemsg?eid=' + this.data.lastId,
  281. })
  282. },
  283. nextap: function () {
  284. if (!this.data.nextId) {
  285. wx.showToast({
  286. title: '已经最后一篇了!',
  287. icon: 'none',
  288. duration: 2000
  289. })
  290. return false
  291. }
  292. wx.redirectTo({
  293. url: '/index/pages/publicpraisemsg/publicpraisemsg?eid=' + this.data.nextId,
  294. })
  295. },
  296. prelooktap() {
  297. if (!app.globalData.personMsg.binded.qrcode) {
  298. wx.showToast({
  299. title: "您的二维码为空,请上传二维码!",
  300. icon: 'none',
  301. duration: 2000
  302. })
  303. return false;
  304. }
  305. wx.previewImage({
  306. current: app.globalData.imgUrl + app.globalData.personMsg.binded.qrcode, // 当前显示图片的http链接
  307. urls: [app.globalData.imgUrl + app.globalData.personMsg.binded.qrcode] // 需要预览的图片http链接列表
  308. })
  309. },
  310. callphonetap: function () {
  311. wx.makePhoneCall({
  312. phoneNumber: app.globalData.personMsg.phone
  313. })
  314. },
  315. /**
  316. * 生命周期函数--监听页面显示
  317. */
  318. onShow: function () {
  319. this.setData({
  320. companyobj: app.globalData.companyobj,
  321. personMsg: app.globalData.personMsg,
  322. })
  323. },
  324. /**
  325. * 生命周期函数--监听页面隐藏
  326. */
  327. onHide: function () {
  328. },
  329. /**
  330. * 生命周期函数--监听页面卸载
  331. */
  332. onUnload: function () {
  333. },
  334. /**
  335. * 页面相关事件处理函数--监听用户下拉动作
  336. */
  337. onPullDownRefresh: function () {
  338. },
  339. /**
  340. * 页面上拉触底事件的处理函数
  341. */
  342. onReachBottom: function () {
  343. },
  344. // onShareTimeline: function () {
  345. // this.evidencesharetap();
  346. // var img = this.data.evidencemsg.difference == 1 ? (this.data.evidencemsg.cover ? this.data.evidencemsg.cover : (this.data.evidencemsg.pics[0] + '?x-oss-process=video/snapshot,t_100,f_jpg,w_375,m_fast')) : this.data.evidencemsg.pics[0];
  347. // img = img.replace('http://o.nczyzs.com/', 'https://o.nczyzs.com/');
  348. // return {
  349. // title: this.data.evidencemsg.title,
  350. // imageUrl: img,
  351. // query: '/share/pages/publicpraisemsg/publicpraisemsg?eid=' + this.data.eid + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype
  352. // }
  353. // },
  354. /**
  355. * 用户点击右上角分享
  356. */
  357. onShareAppMessage: function () {
  358. this.evidencesharetap();
  359. 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[0] + '?x-oss-process=video/snapshot,t_100,f_jpg,w_375,m_fast')) : this.data.evidencemsg.pics[0];
  360. img = img.replace('http://o.nczyzs.com/', 'https://o.nczyzs.com/');
  361. if (this.data.bType == 'b') {
  362. return {
  363. title: this.data.evidencemsg.title,
  364. imageUrl: img,
  365. path: '/share/pages/publicpraisemsg/publicpraisemsg?eid=' + this.data.eid + '&uid=' + app.globalData.agentEmployeEid + '&ctp=' + app.globalData.clientype + '&agid=' + app.globalData.brokeruserId
  366. }
  367. } else {
  368. return {
  369. title: this.data.evidencemsg.title,
  370. imageUrl: img,
  371. path: '/share/pages/publicpraisemsg/publicpraisemsg?eid=' + this.data.eid + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype
  372. }
  373. }
  374. },
  375. onAddToFavorites(res) {
  376. 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[0] + '?x-oss-process=video/snapshot,t_100,f_jpg,w_375,m_fast')) : this.data.evidencemsg.pics[0];
  377. img = img.replace('http://o.nczyzs.com/', 'https://o.nczyzs.com/');
  378. return {
  379. title: this.data.evidencemsg.title,
  380. imageUrl: img,
  381. query: 'cid=' + this.data.eid + '&cty=' + app.globalData.clientype + '&clg=5',
  382. }
  383. }
  384. })