publicpraisemsg.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. const app = getApp();
  2. var utils = require("../../../utils/http")
  3. const util = require("../../../utils/util")
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. imgUrl: app.globalData.imgUrl,
  10. eid: '',
  11. evidencemsg: {},
  12. lastId: '',
  13. nextId: '',
  14. customerFlag: true,
  15. wshareshow: false,
  16. sharepersonMsg: app.globalData.sharepersonobj,
  17. employeeflag: false, //false是用户,true是员工
  18. priceflag: false,
  19. personMsg:app.globalData.personMsg,
  20. showDsc: false,
  21. companyobj:app.globalData.companyobj,
  22. type: '',//为空就是从微官网进来的,否则就是从工具中进来
  23. },
  24. /**
  25. * 生命周期函数--监听页面加载
  26. */
  27. onLoad: function (options) {
  28. var that = this;
  29. wx.showLoading({
  30. title: '加载中...',
  31. })
  32. that.setData({
  33. eid: options.eid,
  34. employeeflag: (!!app.globalData.personMsg.binded && app.globalData.personMsg.binded.state == '在职') ? true : false
  35. })
  36. if (options.type) {
  37. this.setData({
  38. type: options.type
  39. })
  40. }
  41. that.evidencefun();
  42. this.setData({
  43. personMsg:app.globalData.personMsg,
  44. sharepersonMsg: app.globalData.sharepersonobj,
  45. companyobj:app.globalData.companyobj,
  46. })
  47. },
  48. showDscTextFunc: function () {
  49. if (this.data.evidencemsg.desc.length > 29) {
  50. this.data.showDsc = !this.data.showDsc;
  51. this.setData({
  52. showDsc: this.data.showDsc
  53. })
  54. }
  55. },
  56. prelooktap() {
  57. if (!app.globalData.personMsg.binded.qrcode) {
  58. wx.showToast({
  59. title: "您的二维码为空,请上传二维码!",
  60. icon: 'none',
  61. duration: 2000
  62. })
  63. return false;
  64. }
  65. wx.previewImage({
  66. current: app.globalData.imgUrl + app.globalData.personMsg.binded.qrcode, // 当前显示图片的http链接
  67. urls: [app.globalData.imgUrl + app.globalData.personMsg.binded.qrcode] // 需要预览的图片http链接列表
  68. })
  69. },
  70. callphonetap: function () {
  71. wx.makePhoneCall({
  72. phoneNumber: app.globalData.personMsg.phone
  73. })
  74. },
  75. priceshowtap() {
  76. this.setData({
  77. priceflag: true
  78. })
  79. },
  80. closepricetap() {
  81. this.setData({
  82. priceflag: false
  83. })
  84. },
  85. /**
  86. * 生命周期函数--监听页面初次渲染完成
  87. */
  88. onReady: function () {
  89. },
  90. phonrtap: function () {
  91. wx.makePhoneCall({
  92. phoneNumber: app.globalData.sharepersonobj.phone //仅为示例,并非真实的电话号码
  93. })
  94. },
  95. setpostertap: function () {
  96. wx.navigateTo({
  97. url: '/index/pages/setposter/setposter?type=materialEvidence&aid=' + this.data.eid + "&listshare=",
  98. })
  99. },
  100. sharetap: function () {
  101. this.setData({
  102. wshareshow: true
  103. })
  104. },
  105. evidencefun: function () {
  106. var that = this;
  107. utils.$get({
  108. url: app.globalData.webUrl + 'client/evidencedetail',
  109. header: {
  110. 'Authorization': 'bearer ' + app.globalData.token
  111. },
  112. data: {
  113. id: that.data.eid,
  114. uid: app.globalData.personMsg.id,
  115. },
  116. success: function (res) {
  117. if (res.data.code == '0') {
  118. res.data.data.desc = res.data.data.title + '#' + res.data.data.desc + '#';
  119. that.setData({
  120. evidencemsg: res.data.data,
  121. lastId: res.data.lastId,
  122. nextId: res.data.nextId,
  123. })
  124. wx.setNavigationBarTitle({
  125. title: res.data.data.title
  126. })
  127. if (res.data.data.difference == 1) {
  128. const videoContext = that.selectComponent('#myVideo1');
  129. videoContext.play();
  130. }
  131. }
  132. wx.hideLoading()
  133. }
  134. })
  135. },
  136. prelookimgtap() {
  137. if (!app.globalData.sharepersonobj.qrcode) {
  138. wx.showToast({
  139. title: "当前专属客服的二维码为空!",
  140. icon: 'none',
  141. duration: 2000
  142. })
  143. return false;
  144. }
  145. wx.previewImage({
  146. current: app.globalData.imgUrl + app.globalData.sharepersonobj.qrcode, // 当前显示图片的http链接
  147. urls: [app.globalData.imgUrl + app.globalData.sharepersonobj.qrcode] // 需要预览的图片http链接列表
  148. })
  149. },
  150. collectap: function () {
  151. var that = this;
  152. var list = that.data.evidencemsg;
  153. utils.$post({
  154. url: app.globalData.webUrl + 'api/collect',
  155. header: {
  156. 'Authorization': 'bearer ' + app.globalData.token
  157. },
  158. data: {
  159. user_id: app.globalData.personMsg.id,
  160. content_type: "materialEvidence",
  161. content_id: that.data.eid
  162. },
  163. success: function (res) {
  164. if (res.data.code == '0') {
  165. wx.showToast({
  166. title: res.data.msg,
  167. icon: 'none',
  168. duration: 2000
  169. })
  170. list.collected = !list.collected;
  171. that.setData({
  172. evidencemsg: list
  173. })
  174. }
  175. }
  176. })
  177. },
  178. shareurltap: function () {
  179. wx.showLoading({
  180. title: '加载中...',
  181. })
  182. util.schemefun('/share/pages/publicpraisemsg/publicpraisemsg', 'eid=' + this.data.eid + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype, this.data.eid, 'materialEvidence', '');
  183. this.evidencesharetap();
  184. },
  185. evidencesharetap: function () {
  186. var that = this;
  187. utils.$post({
  188. url: app.globalData.webUrl + 'api/share/addlog',
  189. header: {
  190. 'Authorization': 'bearer ' + app.globalData.token
  191. },
  192. data: {
  193. id: that.data.eid,
  194. type: 'materialEvidence'
  195. },
  196. success: function (r) {}
  197. })
  198. },
  199. pretap: function () {
  200. if (!this.data.lastId) {
  201. wx.showToast({
  202. title: '已经第一篇了!',
  203. icon: 'none',
  204. duration: 2000
  205. })
  206. return false
  207. }
  208. wx.redirectTo({
  209. url: '/index/pages/publicpraisemsg/publicpraisemsg?eid=' + this.data.lastId,
  210. })
  211. },
  212. nextap: function () {
  213. if (!this.data.nextId) {
  214. wx.showToast({
  215. title: '已经最后一篇了!',
  216. icon: 'none',
  217. duration: 2000
  218. })
  219. return false
  220. }
  221. wx.redirectTo({
  222. url: '/index/pages/publicpraisemsg/publicpraisemsg?eid=' + this.data.nextId,
  223. })
  224. },
  225. /**
  226. * 生命周期函数--监听页面显示
  227. */
  228. onShow: function () {
  229. this.setData({
  230. personMsg:app.globalData.personMsg,
  231. companyobj:app.globalData.companyobj,
  232. sharepersonMsg: app.globalData.sharepersonobj,
  233. })
  234. },
  235. /**
  236. * 生命周期函数--监听页面隐藏
  237. */
  238. onHide: function () {
  239. },
  240. /**
  241. * 生命周期函数--监听页面卸载
  242. */
  243. onUnload: function () {
  244. },
  245. /**
  246. * 页面相关事件处理函数--监听用户下拉动作
  247. */
  248. onPullDownRefresh: function () {
  249. },
  250. /**
  251. * 页面上拉触底事件的处理函数
  252. */
  253. onReachBottom: function () {
  254. },
  255. /**
  256. * 用户点击右上角分享
  257. */
  258. onShareAppMessage: function () {
  259. this.evidencesharetap();
  260. 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];
  261. img = img.replace('http://o.nczyzs.com/', 'https://o.nczyzs.com/');
  262. return {
  263. title: this.data.evidencemsg.title,
  264. imageUrl: img,
  265. path: '/share/pages/publicpraisemsg/publicpraisemsg?eid=' + this.data.eid + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype
  266. }
  267. }
  268. })