info.vue 5.7 KB

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