info.vue 5.5 KB

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