info.vue 5.0 KB

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