medicatedFoodDetails.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <view class="content" v-if="item!=null">
  3. <view class="image">
  4. <image mode="aspectFill" :src="item.imgUrl"></image>
  5. </view>
  6. <view class="detail-cont">
  7. <view class="title-box">
  8. <view class="line"></view>
  9. <view class="title">{{item.foodName}}</view>
  10. <view class="title-py">{{item.pinyin}}</view>
  11. </view>
  12. <view class="desc">
  13. {{item.actionTitle}}
  14. </view>
  15. <view class="line-h"></view>
  16. <view class="content" v-html="item.descs">
  17. </view>
  18. </view>
  19. <view class="ad">
  20. <u-swiper
  21. :list="advImgs"
  22. indicator
  23. indicatorMode="line"
  24. circular
  25. @click="handleAdvClick"
  26. ></u-swiper>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import {getAdvList} from '@/api/adv.js'
  32. import {getMedicatedFoodById} from '@/api/index'
  33. export default {
  34. data() {
  35. return {
  36. advs:[],
  37. advImgs:[],
  38. item:{},
  39. };
  40. },
  41. onLoad(option) {
  42. this.id=option.id;
  43. },
  44. onShow() {
  45. this.getAdvList();
  46. this.getMedicatedFoodById();
  47. },
  48. onShareAppMessage(res) {
  49. if(this.utils.isLogin()){
  50. return {
  51. title: this.item.foodName,
  52. path: '/pages_index/medicatedFoodDetails?id='+this.id,
  53. imageUrl: 'https://hos-1309931967.cos.ap-chongqing.myqcloud.com/fs/20230106/6b459adfb1004c1a96219bcdf07e337c.png' //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  54. }
  55. }
  56. },
  57. //分享到朋友圈
  58. onShareTimeline(res) {
  59. if(this.utils.isLogin()){
  60. return {
  61. title: this.item.title,
  62. imageUrl: 'https://hos-1309931967.cos.ap-chongqing.myqcloud.com/fs/20230106/6b459adfb1004c1a96219bcdf07e337c.png' //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  63. }
  64. }
  65. },
  66. methods:{
  67. handleAdvClick(index){
  68. var ad=this.advs[index];
  69. console.log(ad.advUrl);
  70. if(ad.showType==1){
  71. uni.setStorageSync('url',ad.advUrl);
  72. uni.navigateTo({
  73. url:"h5"
  74. })
  75. }
  76. else if(ad.showType==2){
  77. uni.navigateTo({
  78. url:ad.advUrl
  79. })
  80. }
  81. else if(ad.showType==3){
  82. uni.setStorageSync('content',ad.content);
  83. uni.navigateTo({
  84. url:"content"
  85. })
  86. }
  87. },
  88. getAdvList() {
  89. //联网加载数据
  90. var that = this;
  91. var data = {
  92. advType:4
  93. };
  94. getAdvList(data).then(res => {
  95. if(res.code==200){
  96. that.advImgs=[];
  97. that.advs=[];
  98. res.data.forEach(function(element) {
  99. if(element.imageUrl!=null&&element.imageUrl!=""){
  100. that.advs.push(element);
  101. that.advImgs.push(element.imageUrl);
  102. }
  103. });
  104. }else{
  105. uni.showToast({
  106. icon:'none',
  107. title: "请求失败",
  108. });
  109. }
  110. });
  111. },
  112. getMedicatedFoodById(){
  113. let data = {id:this.id};
  114. getMedicatedFoodById(data).then(
  115. res => {
  116. if(res.code==200){
  117. this.item=res.data;
  118. }else{
  119. uni.showToast({
  120. icon:'none',
  121. title: "请求失败",
  122. });
  123. }
  124. },
  125. rej => {}
  126. );
  127. },
  128. }
  129. }
  130. </script>
  131. <style lang="scss">
  132. page{
  133. height: 100%;
  134. }
  135. .content{
  136. height: 100%;
  137. image{
  138. height:450rpx;
  139. width:100%;
  140. }
  141. .detail-cont{
  142. flex: 1;
  143. padding: 20upx;
  144. overflow-y: auto;
  145. .title-box{
  146. width: 100%;
  147. display: flex;
  148. justify-content: flex-start;
  149. align-items: center;
  150. .line{
  151. border-radius: 5rpx;
  152. width: 8rpx;
  153. height:30rpx;
  154. background-color: #C39A58;
  155. }
  156. .title{
  157. margin-left: 15rpx;
  158. font-size: 40upx;
  159. font-family: PingFang SC;
  160. font-weight: bold;
  161. color: #333;
  162. }
  163. .title-py{
  164. margin-left: 15rpx;
  165. font-size: 32upx;
  166. font-family: PingFang SC;
  167. color: #333;
  168. }
  169. }
  170. .desc{
  171. margin-top: 20rpx;
  172. font-size: 32upx;
  173. font-family: PingFang SC;
  174. color: #333;
  175. }
  176. .line-h{
  177. margin: 15rpx 0rpx;
  178. border-bottom: 1rpx dashed #d4d4d4;
  179. }
  180. .tabs{
  181. width: 100%;
  182. margin: 20rpx 0rpx;
  183. display: flex;
  184. justify-content: space-between;
  185. align-items: center;
  186. // border: 1rpx solid #C39A58;
  187. border-radius: 30rpx;
  188. line-height: 60rpx;
  189. .tab1{
  190. border-radius: 30rpx 0rpx 0rpx 30rpx;
  191. width: 25%;
  192. display: flex;
  193. justify-content: center;
  194. align-items: center;
  195. background-color: #fff;
  196. color: #4F575A;
  197. font-size: 28upx;
  198. font-weight: bold;
  199. font-family: PingFang SC;
  200. }
  201. .tab2{
  202. width: 25%;
  203. display: flex;
  204. justify-content: center;
  205. align-items: center;
  206. background-color: #fff;
  207. color: #4F575A;
  208. font-size: 28upx;
  209. font-weight: bold;
  210. font-family: PingFang SC;
  211. }
  212. .tab3{
  213. width: 25%;
  214. display: flex;
  215. justify-content: center;
  216. align-items: center;
  217. background-color: #fff;
  218. color: #4F575A;
  219. font-size: 28upx;
  220. font-weight: bold;
  221. font-family: PingFang SC;
  222. }
  223. .tab4{
  224. border-radius: 0rpx 30rpx 30rpx 0rpx;
  225. width: 25%;
  226. display: flex;
  227. justify-content: center;
  228. align-items: center;
  229. background-color: #fff;
  230. color: #4F575A;
  231. font-size: 28upx;
  232. font-weight: bold;
  233. font-family: PingFang SC;
  234. }
  235. .active{
  236. background-color: #C39A58;
  237. color: #fff;
  238. }
  239. }
  240. }
  241. .ad{
  242. margin-bottom: 50rpx;
  243. width: 100%;
  244. padding: 15rpx;
  245. }
  246. }
  247. </style>