info.vue 5.4 KB

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