detail.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <view>
  3. <view v-if="(data || null) != null">
  4. <view class="padding-horizontal-main padding-top-main">
  5. <!-- 基础信息 -->
  6. <view class="base-container tc pr padding-main border-radius-main bg-main oh spacing-mb" :style="'background-color:'+data.color+' !important;background-image:url('+data.cover+')'">
  7. <view class="text cr-white pa bs-bb text-size wh-auto ht-auto">{{data.describe}}</view>
  8. </view>
  9. <!-- 关键字 -->
  10. <view v-if="data.keywords_arr.length > 0" class="word-content scroll-view-horizontal margin-bottom-sm">
  11. <scroll-view scroll-x>
  12. <block v-for="(kv, ki) in data.keywords_arr" :key="ki">
  13. <navigator :url="'/pages/goods-search/goods-search?keywords=' + kv" hover-class="none" class="word-icon dis-inline-block bg-main-light text-size-xs cr-main round padding-top-xs padding-bottom-xs padding-left padding-right">{{kv}}</navigator>
  14. </block>
  15. </scroll-view>
  16. </view>
  17. <!-- 推荐商品 -->
  18. <view v-if="(data.goods_list || null) != null && data.goods_list.length > 0">
  19. <view class="spacing-nav-title">
  20. <text class="text-wrapper">活动商品</text>
  21. <text class="cr-grey text-size-xs margin-left-lg">{{data.vice_title}}</text>
  22. <navigator url="/pages/plugins/activity/index/index" hover-class="none" class="arrow-right padding-right-xxxl cr-gray fr">更多活动</navigator>
  23. </view>
  24. <component-goods-list :propData="{style_type: 1, goods_list: data.goods_list}" :propCurrencySymbol="currency_symbol"></component-goods-list>
  25. </view>
  26. <view v-else>
  27. <!-- 提示信息 -->
  28. <component-no-data propStatus="0" propMsg="没有相关商品"></component-no-data>
  29. </view>
  30. </view>
  31. <!-- 结尾 -->
  32. <component-bottom-line :propStatus="data_bottom_line_status"></component-bottom-line>
  33. </view>
  34. <view v-else>
  35. <!-- 提示信息 -->
  36. <component-no-data :propStatus="data_list_loding_status" :propMsg="data_list_loding_msg"></component-no-data>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. const app = getApp();
  42. import componentNoData from "../../../../components/no-data/no-data";
  43. import componentBottomLine from "../../../../components/bottom-line/bottom-line";
  44. import componentGoodsList from "../../../../components/goods-list/goods-list";
  45. export default {
  46. data() {
  47. return {
  48. data_bottom_line_status: false,
  49. data_list_loding_status: 1,
  50. data_list_loding_msg: '',
  51. currency_symbol: app.globalData.data.currency_symbol,
  52. params: null,
  53. user: null,
  54. data_base: null,
  55. data: null,
  56. // 自定义分享信息
  57. share_info: {}
  58. };
  59. },
  60. components: {
  61. componentNoData,
  62. componentBottomLine,
  63. componentGoodsList
  64. },
  65. props: {},
  66. onLoad(params) {
  67. //params['id'] = 1;
  68. this.setData({
  69. params: params
  70. });
  71. },
  72. onShow() {
  73. // 初始化配置
  74. this.init_config();
  75. // 获取数据
  76. this.get_data();
  77. },
  78. // 下拉刷新
  79. onPullDownRefresh() {
  80. this.get_data();
  81. },
  82. methods: {
  83. // 初始化配置
  84. init_config(status) {
  85. if ((status || false) == true) {
  86. this.setData({
  87. currency_symbol: app.globalData.get_config('currency_symbol'),
  88. });
  89. } else {
  90. app.globalData.is_config(this, 'init_config');
  91. }
  92. },
  93. // 获取数据
  94. get_data() {
  95. uni.request({
  96. url: app.globalData.get_request_url("detail", "index", "activity"),
  97. method: 'POST',
  98. data: {
  99. id: this.params.id || 0
  100. },
  101. dataType: 'json',
  102. success: res => {
  103. uni.stopPullDownRefresh();
  104. if (res.data.code == 0) {
  105. var data = res.data.data;
  106. this.setData({
  107. data_base: data.base || null,
  108. data: data.data || null,
  109. data_list_loding_msg: '',
  110. data_list_loding_status: 0,
  111. data_bottom_line_status: ((data.data || null) != null && (data.data.goods_list || null) != null && data.data.goods_list.length > 0)
  112. });
  113. if ((this.data || null) != null) {
  114. // 基础自定义分享
  115. this.setData({
  116. share_info: {
  117. title: this.data.seo_title || this.data.title,
  118. desc: this.data.seo_desc || this.data.describe,
  119. path: '/pages/plugins/activity/detail/detail',
  120. query: 'id='+this.data.id,
  121. img: this.data.cover
  122. }
  123. });
  124. // 标题
  125. if((this.data.title || null) != null) {
  126. uni.setNavigationBarTitle({
  127. title: this.data.title
  128. });
  129. }
  130. }
  131. } else {
  132. this.setData({
  133. data_bottom_line_status: false,
  134. data_list_loding_status: 2,
  135. data_list_loding_msg: res.data.msg
  136. });
  137. }
  138. // 分享菜单处理
  139. app.globalData.page_share_handle(this.share_info);
  140. },
  141. fail: () => {
  142. uni.stopPullDownRefresh();
  143. this.setData({
  144. data_bottom_line_status: false,
  145. data_list_loding_status: 2,
  146. data_list_loding_msg: '服务器请求出错'
  147. });
  148. app.globalData.showToast('服务器请求出错');
  149. }
  150. });
  151. }
  152. }
  153. };
  154. </script>
  155. <style>
  156. @import './detail.css';
  157. </style>