medicatedFoodDetails.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. "use strict";
  2. var common_vendor = require("../common/vendor.js");
  3. var api_adv = require("../api/adv.js");
  4. var api_index = require("../api/index.js");
  5. require("../common/request.js");
  6. const _sfc_main = {
  7. data() {
  8. return {
  9. advs: [],
  10. advImgs: [],
  11. item: {}
  12. };
  13. },
  14. onLoad(option) {
  15. this.id = option.id;
  16. },
  17. onShow() {
  18. this.getAdvList();
  19. this.getMedicatedFoodById();
  20. },
  21. onShareAppMessage(res) {
  22. if (this.utils.isLogin()) {
  23. return {
  24. title: this.item.foodName,
  25. path: "/pages_index/medicatedFoodDetails?id=" + this.id,
  26. imageUrl: "https://hos-1309931967.cos.ap-chongqing.myqcloud.com/fs/20230106/6b459adfb1004c1a96219bcdf07e337c.png"
  27. };
  28. }
  29. },
  30. onShareTimeline(res) {
  31. if (this.utils.isLogin()) {
  32. return {
  33. title: this.item.title,
  34. imageUrl: "https://hos-1309931967.cos.ap-chongqing.myqcloud.com/fs/20230106/6b459adfb1004c1a96219bcdf07e337c.png"
  35. };
  36. }
  37. },
  38. methods: {
  39. handleAdvClick(index) {
  40. var ad = this.advs[index];
  41. console.log(ad.advUrl);
  42. if (ad.showType == 1) {
  43. common_vendor.index.setStorageSync("url", ad.advUrl);
  44. common_vendor.index.navigateTo({
  45. url: "h5"
  46. });
  47. } else if (ad.showType == 2) {
  48. common_vendor.index.navigateTo({
  49. url: ad.advUrl
  50. });
  51. } else if (ad.showType == 3) {
  52. common_vendor.index.setStorageSync("content", ad.content);
  53. common_vendor.index.navigateTo({
  54. url: "content"
  55. });
  56. }
  57. },
  58. getAdvList() {
  59. var that = this;
  60. var data = {
  61. advType: 4
  62. };
  63. api_adv.getAdvList(data).then((res) => {
  64. if (res.code == 200) {
  65. that.advImgs = [];
  66. that.advs = [];
  67. res.data.forEach(function(element) {
  68. if (element.imageUrl != null && element.imageUrl != "") {
  69. that.advs.push(element);
  70. that.advImgs.push(element.imageUrl);
  71. }
  72. });
  73. } else {
  74. common_vendor.index.showToast({
  75. icon: "none",
  76. title: "\u8BF7\u6C42\u5931\u8D25"
  77. });
  78. }
  79. });
  80. },
  81. getMedicatedFoodById() {
  82. let data = { id: this.id };
  83. api_index.getMedicatedFoodById(data).then((res) => {
  84. if (res.code == 200) {
  85. this.item = res.data;
  86. } else {
  87. common_vendor.index.showToast({
  88. icon: "none",
  89. title: "\u8BF7\u6C42\u5931\u8D25"
  90. });
  91. }
  92. }, (rej) => {
  93. });
  94. }
  95. }
  96. };
  97. if (!Array) {
  98. const _easycom_u_swiper2 = common_vendor.resolveComponent("u-swiper");
  99. _easycom_u_swiper2();
  100. }
  101. const _easycom_u_swiper = () => "../uni_modules/uview-plus/components/u-swiper/u-swiper.js";
  102. if (!Math) {
  103. _easycom_u_swiper();
  104. }
  105. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  106. return common_vendor.e({
  107. a: $data.item != null
  108. }, $data.item != null ? {
  109. b: $data.item.imgUrl,
  110. c: common_vendor.t($data.item.foodName),
  111. d: common_vendor.t($data.item.pinyin),
  112. e: common_vendor.t($data.item.actionTitle),
  113. f: $data.item.descs,
  114. g: common_vendor.o($options.handleAdvClick),
  115. h: common_vendor.p({
  116. list: $data.advImgs,
  117. indicator: true,
  118. indicatorMode: "line",
  119. circular: true
  120. })
  121. } : {});
  122. }
  123. var MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "E:/Project/2023/\u95EE\u8BCA\u5E73\u53F0/his_user_miniapp/pages_index/medicatedFoodDetails.vue"]]);
  124. _sfc_main.__runtimeHooks = 6;
  125. wx.createPage(MiniProgramPage);