info.vue 6.2 KB

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