topicDetail.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * @Author: error: git config user.name && git config user.email & please set dead value or install git
  3. * @Date: 2020-09-21 21:13:18
  4. * @LastEditors: error: git config user.name && git config user.email & please set dead value or install git
  5. * @LastEditTime: 2022-07-18 14:16:13
  6. * @FilePath: \renard-wx\pages\topicDetail\topicDetail.js
  7. * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  8. */
  9. var app = getApp();
  10. var WxParse = require('../../lib/wxParse/wxParse.js');
  11. var util = require('../../utils/util.js');
  12. var api = require('../../config/api.js');
  13. Page({
  14. data: {
  15. id: 0,
  16. topic: {},
  17. topicList: []
  18. },
  19. onShareAppMessage: function() {
  20. return {
  21. title: '特惠商品',
  22. desc: '特惠商品',
  23. path: '/pages/topicDetail/topicDetail?id=' + this.data.id
  24. }
  25. },
  26. onLoad: function(options) {
  27. // 页面初始化 options为页面跳转所带来的参数
  28. var that = this;
  29. that.setData({
  30. id: options.id
  31. });
  32. util.request(api.TopicDetail, {
  33. id: that.data.id
  34. }).then(function(res) {
  35. if (res.errno === 0) {
  36. that.setData({
  37. topic: res.data.topic
  38. });
  39. WxParse.wxParse('topicDetail', 'html', res.data.topic.content, that);
  40. }
  41. });
  42. util.request(api.TopicRelated, {
  43. id: that.data.id
  44. }).then(function(res) {
  45. if (res.errno === 0) {
  46. that.setData({
  47. topicList: res.data.list
  48. });
  49. }
  50. });
  51. },
  52. onReady: function() {
  53. },
  54. onShow: function() {
  55. // 页面显示
  56. },
  57. onHide: function() {
  58. // 页面隐藏
  59. },
  60. onUnload: function() {
  61. // 页面关闭
  62. }
  63. })