info.vue 5.7 KB

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