info.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <template>
  2. <mobile-frame>
  3. <view class="main">
  4. <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
  5. <view class="list-scroll-view">
  6. <view class="one">
  7. <rich-text :nodes="info.content.value"></rich-text>
  8. </view>
  9. <view class="two">
  10. <view class="list" v-for="(item,index) in list" :key="index" @tap="toBuy(item)">
  11. <view class="img">
  12. <image class="image" :src="item.goods.file&&item.goods.file.length?item.goods.file[0].url:''" mode=""></image>
  13. </view>
  14. <view class="name">
  15. <text>{{item.goods.name}}</text>
  16. </view>
  17. <view class="money">
  18. <view class="money_1">
  19. <text>¥</text><text>{{item.sell_money||0}}</text>
  20. </view>
  21. <view class="money_2">
  22. <text>¥</text><text>{{item.flow_money||0}}</text>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. <view class="is_bottom" v-if="is_bottom">
  28. <text>{{config.bottom_title}}</text>
  29. </view>
  30. </view>
  31. </scroll-view>
  32. </view>
  33. </mobile-frame>
  34. </template>
  35. <script>
  36. export default {
  37. components: {},
  38. data() {
  39. return {
  40. // 系统设置
  41. config: {},
  42. id: '',
  43. // 详情
  44. info: {},
  45. // 商品列表
  46. list: [],
  47. total: 0,
  48. page: 0,
  49. skip: 0,
  50. limit: 6,
  51. // 数据是否触底
  52. is_bottom: false,
  53. scrollTop: 0,
  54. };
  55. },
  56. onLoad: function(e) {
  57. const that = this;
  58. that.$set(that, `id`, e.id || '634fa595e4ed552882f05a6f');
  59. },
  60. onShow: async function() {
  61. const that = this;
  62. that.searchConfig();
  63. await that.searchAct();
  64. await that.configShare();
  65. },
  66. methods: {
  67. // 查询基本设置
  68. searchConfig() {
  69. const that = this;
  70. uni.getStorage({
  71. key: 'config',
  72. success: function(res) {
  73. if (res.data) that.$set(that, `config`, res.data)
  74. },
  75. fail: function(err) {
  76. console.log(err);
  77. }
  78. })
  79. },
  80. async searchAct() {
  81. const that = this;
  82. // 查询详情
  83. let res = await that.$api(`/platformAct/${that.id}`, 'GET');
  84. if (res.errcode == '0') {
  85. uni.setNavigationBarTitle({
  86. title: res.data.act_time.title
  87. });
  88. if (res.data.content.value) res.data.content.value = res.data.content.value.replace(/\<img/gi, '<img class="rich-img"');
  89. that.$set(that, `info`, res.data);
  90. that.search()
  91. }
  92. },
  93. async search() {
  94. const that = this;
  95. // 查询商品列表
  96. let info = {
  97. skip: that.skip,
  98. limit: that.limit,
  99. platformAct: that.id
  100. }
  101. let res = await that.$api(`/goodsJoinAct`, 'GET', {
  102. ...info,
  103. })
  104. if (res.errcode == '0') {
  105. let list = [...that.list, ...res.data];
  106. that.$set(that, `list`, list)
  107. that.$set(that, `total`, res.total)
  108. }
  109. },
  110. toPage() {
  111. const that = this;
  112. let list = that.list;
  113. let limit = that.limit;
  114. if (that.total > list.length) {
  115. uni.showLoading({
  116. title: '加载中',
  117. mask: true
  118. })
  119. let page = that.page + 1;
  120. that.$set(that, `page`, page)
  121. let skip = page * limit;
  122. that.$set(that, `skip`, skip)
  123. that.search();
  124. uni.hideLoading();
  125. } else that.$set(that, `is_bottom`, true)
  126. },
  127. toScroll(e) {
  128. const that = this;
  129. let up = that.scrollTop;
  130. that.$set(that, `scrollTop`, e.detail.scrollTop);
  131. let num = Math.sign(up - e.detail.scrollTop);
  132. if (num == 1) that.$set(that, `is_bottom`, false);
  133. },
  134. // 购买
  135. toBuy(e) {
  136. const that = this;
  137. that.clearPage();
  138. uni.navigateTo({
  139. url: `/pagesHome/order/detail?id=${e.goods._id}`
  140. })
  141. },
  142. // 清空列表
  143. clearPage() {
  144. const that = this;
  145. that.$set(that, `list`, [])
  146. that.$set(that, `skip`, 0)
  147. that.$set(that, `limit`, 6)
  148. that.$set(that, `page`, 0)
  149. },
  150. // 配置分享内容
  151. configShare() {
  152. const that = this;
  153. let info = that.info;
  154. let imageUrl = that.config.config.logo[0].url;
  155. if (info.share.length > 0) imageUrl = info.share[0].url;
  156. that.$config.share = {
  157. title: info.act_time.title,
  158. path: `/pagesRest/activity/info?id=${that.id}`,
  159. imageUrl: imageUrl
  160. }
  161. }
  162. }
  163. }
  164. </script>
  165. <style lang="scss">
  166. .main {
  167. display: flex;
  168. flex-direction: column;
  169. width: 100vw;
  170. height: 100vh;
  171. .one {
  172. padding: 2vw;
  173. .rich-img {
  174. width: 100% !important;
  175. display: block;
  176. }
  177. }
  178. .two {
  179. display: flex;
  180. flex-wrap: wrap;
  181. padding: 2vw;
  182. .list {
  183. padding: 2vw;
  184. background-color: var(--f1Color);
  185. margin: 0 2vw 2vw 0;
  186. border-radius: 5px;
  187. width: 43vw;
  188. .img {
  189. .image {
  190. width: 100%;
  191. height: 30vh;
  192. border-radius: 5px;
  193. }
  194. }
  195. .name {
  196. margin: 0 0 1vw 0;
  197. text {
  198. font-size: var(--font14Size);
  199. }
  200. }
  201. .money {
  202. display: flex;
  203. .money_1 {
  204. color: var(--fFB1Color);
  205. font-size: 12px;
  206. text:last-child {
  207. font-size: 16px;
  208. padding: 0 0 0 1vw;
  209. }
  210. }
  211. .money_2 {
  212. font-size: 12px;
  213. margin: 0 0 0 2vw;
  214. color: var(--f99Color);
  215. text {
  216. text-decoration: line-through;
  217. }
  218. text:last-child {
  219. font-size: 16px;
  220. padding: 0 0 0 1vw;
  221. }
  222. }
  223. }
  224. }
  225. .list:nth-child(2n) {
  226. margin: 0 0 2vw 0;
  227. }
  228. }
  229. }
  230. .scroll-view {
  231. position: absolute;
  232. top: 0;
  233. left: 0;
  234. right: 0;
  235. bottom: 0;
  236. .list-scroll-view {
  237. display: flex;
  238. flex-direction: column;
  239. }
  240. }
  241. .is_bottom {
  242. text-align: center;
  243. width: 100vw;
  244. text {
  245. padding: 2vw 0;
  246. display: inline-block;
  247. color: #858585;
  248. font-size: 14px;
  249. }
  250. }
  251. </style>