articleshare.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. var app = getApp();
  2. var utils = require("../../../utils/http");
  3. const util = require("../../../utils/util")
  4. var stoptime = 0;
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. aid: '',
  11. bType: "",
  12. pType: "",
  13. title: '志远装饰数字化平台',
  14. customerFlag: false,
  15. articleObj: {},
  16. imgUrl: app.globalData.imgUrl,
  17. type: 1, //3是我的创作进入视频编辑列表进来的,1是我的创作的列表进入,2是裂变列表进入
  18. nowflag: false,
  19. footflag: true,
  20. wshareshow: false,
  21. priceflag: false,
  22. showTask: true,
  23. datashow: false,
  24. isBroker: false,
  25. loading: false,
  26. showApproval: false,
  27. remark: "",
  28. trackimgarr: [],
  29. nowimagearr: [],
  30. shareApprovallist: []
  31. },
  32. /**
  33. * 生命周期函数--监听页面加载
  34. */
  35. onLoad: function (options) {
  36. if (!!options.clg && options.clg == 3) {
  37. wx.reLaunch({
  38. url: '/pages/index/index?clientype=' + options.cty + "&cid=" + options.cid + "&clg=3",
  39. })
  40. return false;
  41. }
  42. if (!!options.type) {
  43. this.setData({
  44. footflag: false
  45. })
  46. }
  47. if (!!options.ty) {
  48. this.setData({
  49. bType: options.ty,
  50. showTask: false
  51. })
  52. }
  53. if (!!options.tp) {
  54. this.setData({
  55. pType: options.tp
  56. })
  57. }
  58. if (app.globalData.brokeruserId) {
  59. this.setData({
  60. isBroker: true
  61. })
  62. } else {
  63. this.setData({
  64. isBroker: false
  65. })
  66. }
  67. this.setData({
  68. aid: options.aid,
  69. type: options.type,
  70. })
  71. wx.showLoading({
  72. title: '加载中...',
  73. })
  74. this.artileMsg();
  75. },
  76. getPhoneNumberTap: function (res) {
  77. var that = this;
  78. if (res.detail.errMsg == 'getPhoneNumber:ok') {
  79. that.setData({
  80. loading: true,
  81. })
  82. utils.$post({
  83. url: app.globalData.webUrl + 'api/users/setUserMobile',
  84. data: {
  85. encryptedData: res.detail.encryptedData,
  86. iv: res.detail.iv
  87. },
  88. header: {
  89. 'Authorization': 'bearer ' + app.globalData.token
  90. },
  91. success: function (r) {
  92. if (r.data.code == '0') {
  93. that.submitMsg(r.data.mobile);
  94. }
  95. }
  96. })
  97. }
  98. },
  99. /**
  100. * 提交注册数据
  101. */
  102. submitMsg(mobile) {
  103. var that = this;
  104. utils.$post({
  105. url: app.globalData.webUrl + 'api/agents/add_agents',
  106. header: {
  107. 'Authorization': 'bearer ' + app.globalData.token
  108. },
  109. data: {
  110. name: '',
  111. phone: mobile,
  112. employee_id: app.globalData.brokerEmployeeId,
  113. wechat: '',
  114. type: app.globalData.brokerType
  115. },
  116. success: function (res) {
  117. if (res.data.code == '0') {
  118. app.globalData.brokeruserId = res.data.data;
  119. that.setData({
  120. isBroker: true,
  121. loading: false,
  122. wshareshow: true
  123. })
  124. }
  125. }
  126. })
  127. },
  128. setpostertap: function () {
  129. if (this.data.bType == 'b') {
  130. wx.navigateTo({
  131. url: '/index/pages/setposter/setposter?type=article&aid=' + this.data.aid + "&ty=b&listshare=",
  132. })
  133. } else {
  134. wx.navigateTo({
  135. url: '/index/pages/setposter/setposter?type=article&aid=' + this.data.aid + "&listshare=",
  136. })
  137. }
  138. },
  139. priceshowtap() {
  140. this.setData({
  141. priceflag: true
  142. })
  143. },
  144. closepricetap() {
  145. this.setData({
  146. priceflag: false
  147. })
  148. },
  149. /**
  150. * 生命周期函数--监听页面初次渲染完成
  151. */
  152. onReady: function () {
  153. },
  154. articlesharetap: function () {
  155. this.setData({
  156. wshareshow: true
  157. })
  158. },
  159. artileMsg: function () {
  160. var that = this;
  161. utils.$post({
  162. url: app.globalData.webUrl + 'api/article/info',
  163. header: {
  164. 'Authorization': 'bearer ' + app.globalData.token
  165. },
  166. data: {
  167. article_id: that.data.aid
  168. },
  169. success: function (res) {
  170. if (res.data.code == '0') {
  171. that.setData({
  172. articleObj: res.data.data,
  173. title: res.data.data.title
  174. })
  175. wx.setNavigationBarTitle({
  176. title: res.data.data.title
  177. })
  178. }
  179. setTimeout(function () {
  180. wx.hideLoading();
  181. }, 1000)
  182. }
  183. })
  184. },
  185. /**
  186. * 生命周期函数--监听页面显示
  187. */
  188. onShow: function () {
  189. var that = this;
  190. if (app.globalData.sharearticle) {
  191. // wx.showToast({
  192. // title: '即将跳转原页面',
  193. // icon: 'success',
  194. // })
  195. setTimeout(function () {
  196. // wx.redirectTo({
  197. // url: "/mycustomer/pages/mycreation/mycreation?type=3",
  198. // });
  199. if (that.data.type == '2') {
  200. wx.redirectTo({
  201. url: "/mycustomer/pages/mycreation/mycreation?type=2",
  202. });
  203. } else if (that.data.type == '1') {
  204. wx.navigateBack({
  205. delta: 3
  206. });
  207. } else {
  208. wx.navigateBack({
  209. delta: 2
  210. });
  211. }
  212. }, 1000)
  213. }
  214. stoptime = 0;
  215. setTimeout(function () {
  216. stoptime = stoptime * 1 + 1;
  217. }, 1000)
  218. },
  219. shareurltap: function () {
  220. let that = this;
  221. wx.showLoading({
  222. title: '加载中...',
  223. })
  224. if (this.data.bType == 'b') {
  225. util.schemefun('/share/pages/articleshare/articleshare', 'aid=' + that.data.aid + '&userid=' + app.globalData.agentEmployeEid + '&ctp=' + app.globalData.clientype + '&agid=' + app.globalData.brokeruserId, that.data.aid, 'article', '');
  226. } else {
  227. util.schemefun('/share/pages/articleshare/articleshare', 'aid=' + that.data.aid + '&userid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype, that.data.aid, 'article', '');
  228. }
  229. this.sharelogtap();
  230. },
  231. sharealerttap: function (e) {
  232. var that = this;
  233. that.setData({
  234. nowflag: true,
  235. })
  236. },
  237. sendfriendtap() {
  238. this.sharelogtap();
  239. },
  240. sharelogtap: function () {
  241. var that = this;
  242. this.setData({
  243. nowflag: false,
  244. })
  245. utils.$post({
  246. url: app.globalData.webUrl + 'api/share/addlog',
  247. header: {
  248. 'Authorization': 'bearer ' + app.globalData.token
  249. },
  250. data: {
  251. id: that.data.aid,
  252. type: 'article'
  253. },
  254. success: function (r) {}
  255. })
  256. },
  257. collectTap: function () {
  258. var that = this;
  259. utils.$post({
  260. url: app.globalData.webUrl + 'api/article/collect',
  261. header: {
  262. 'Authorization': 'bearer ' + app.globalData.token
  263. },
  264. data: {
  265. id: that.data.aid,
  266. },
  267. success: function (res) {
  268. var articleObj = that.data.articleObj;
  269. if (res.data.code == '0') {
  270. articleObj.collect = 1;
  271. that.setData({
  272. articleObj: articleObj
  273. })
  274. wx.showToast({
  275. title: '收藏成功!',
  276. icon: 'none',
  277. duration: 1000
  278. })
  279. that.setData({
  280. articleObj: articleObj
  281. })
  282. }
  283. }
  284. })
  285. },
  286. cancleTap: function () {
  287. var that = this;
  288. utils.$post({
  289. url: app.globalData.webUrl + 'api/article/collectCancel',
  290. header: {
  291. 'Authorization': 'bearer ' + app.globalData.token
  292. },
  293. data: {
  294. id: that.data.aid,
  295. },
  296. success: function (res) {
  297. var articleObj = that.data.articleObj;
  298. if (res.data.code == '0') {
  299. articleObj.collect = 0;
  300. that.setData({
  301. articleObj: articleObj
  302. })
  303. wx.showToast({
  304. title: '取消收藏成功!',
  305. icon: 'none',
  306. duration: 1000
  307. })
  308. that.setData({
  309. articleObj: articleObj
  310. })
  311. }
  312. }
  313. })
  314. },
  315. zantap: function () {
  316. var that = this;
  317. utils.$post({
  318. url: app.globalData.webUrl + 'api/article/star',
  319. header: {
  320. 'Authorization': 'bearer ' + app.globalData.token
  321. },
  322. data: {
  323. id: that.data.aid,
  324. },
  325. success: function (res) {
  326. var articleObj = that.data.articleObj;
  327. if (res.data.code == '0') {
  328. if (articleObj.stared == 1) {
  329. wx.showToast({
  330. title: '您已点赞!',
  331. icon: 'none',
  332. duration: 1000
  333. })
  334. } else {
  335. articleObj.stared = 1;
  336. wx.showToast({
  337. title: '点赞成功!',
  338. icon: 'none',
  339. duration: 1000
  340. })
  341. articleObj.star_num = articleObj.star_num * 1 + 1;
  342. }
  343. that.setData({
  344. articleObj: articleObj
  345. })
  346. }
  347. }
  348. })
  349. },
  350. /**
  351. * 生命周期函数--监听页面隐藏
  352. */
  353. onHide: function () {
  354. var timearr = app.globalData.timearr,
  355. flag = false;
  356. for (var i = 0; i < timearr.length; i++) {
  357. if (timearr[i].type == 'articleprelook') {
  358. timearr[i].time = timearr[i].time * 1 + stoptime * 1;
  359. flag = true;
  360. }
  361. }
  362. if (!flag) {
  363. var obj = {
  364. type: 'articleprelook',
  365. time: stoptime
  366. };
  367. app.globalData.timearr.push(obj);
  368. } else {
  369. app.globalData.timearr = timearr;
  370. }
  371. },
  372. /**
  373. * 生命周期函数--监听页面卸载
  374. */
  375. onUnload: function () {
  376. },
  377. /**
  378. * 页面相关事件处理函数--监听用户下拉动作
  379. */
  380. onPullDownRefresh: function () {
  381. },
  382. /**
  383. * 页面上拉触底事件的处理函数
  384. */
  385. onReachBottom: function () {
  386. },
  387. /**
  388. * 用户点击右上角分享
  389. */
  390. onShareAppMessage: function () {
  391. var img = this.data.articleObj.cover_share_img?this.data.articleObj.cover_share_img:this.data.articleObj.cover_img;
  392. if (this.data.bType == 'b') {
  393. this.sharelogtap();
  394. return {
  395. title: this.data.articleObj.title,
  396. imageUrl: img,
  397. path: '/share/pages/articleshare/articleshare?aid=' + this.data.aid + '&userid=' + app.globalData.agentEmployeEid + '&ctp=' + app.globalData.clientype + '&agid=' + app.globalData.brokeruserId
  398. }
  399. } else {
  400. this.sharelogtap();
  401. return {
  402. title: this.data.articleObj.title,
  403. imageUrl: img,
  404. path: '/share/pages/articleshare/articleshare?aid=' + this.data.aid + '&userid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype
  405. }
  406. }
  407. },
  408. onAddToFavorites(res) {
  409. var img = this.data.articleObj.cover_share_img?this.data.articleObj.cover_share_img:this.data.articleObj.cover_img;
  410. return {
  411. title: this.data.articleObj.title,
  412. imageUrl: img,
  413. query: 'cid=' + this.data.aid + '&cty=' + app.globalData.clientype + '&clg=3',
  414. }
  415. }
  416. })