info.vue 5.4 KB

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