info.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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. shop: that.$config.shop,
  117. }
  118. let res = await that.$api(`/goodsJoinAct`, 'GET', {
  119. ...info,
  120. })
  121. if (res.errcode == '0') {
  122. let list = [...that.list, ...res.data];
  123. that.$set(that, `list`, list)
  124. that.$set(that, `total`, res.total)
  125. }
  126. },
  127. toPage() {
  128. const that = this;
  129. let list = that.list;
  130. let limit = that.limit;
  131. if (that.total > list.length) {
  132. uni.showLoading({
  133. title: '加载中',
  134. mask: true
  135. })
  136. let page = that.page + 1;
  137. that.$set(that, `page`, page)
  138. let skip = page * limit;
  139. that.$set(that, `skip`, skip)
  140. that.search();
  141. uni.hideLoading();
  142. } else that.$set(that, `is_bottom`, true)
  143. },
  144. toScroll(e) {
  145. const that = this;
  146. let up = that.scrollTop;
  147. that.$set(that, `scrollTop`, e.detail.scrollTop);
  148. let num = Math.sign(up - e.detail.scrollTop);
  149. if (num == 1) that.$set(that, `is_bottom`, false);
  150. },
  151. // 购买
  152. toBuy(e) {
  153. const that = this;
  154. uni.navigateTo({
  155. url: `/pagesHome/order/detail?id=${e.goods}`
  156. })
  157. },
  158. // 清空列表
  159. clearPage() {
  160. const that = this;
  161. that.$set(that, `list`, [])
  162. that.$set(that, `skip`, 0)
  163. that.$set(that, `limit`, 6)
  164. that.$set(that, `page`, 0)
  165. },
  166. // 配置分享内容
  167. configShare() {
  168. const that = this;
  169. let info = that.info;
  170. let imageUrl = that.config?.config?.logo[0].url;
  171. if (info.share.length > 0) imageUrl = info.share[0].url;
  172. that.$config.share = {
  173. title: info.act_time.title,
  174. path: `/pagesRest/activity/info?id=${that.id}`,
  175. imageUrl: imageUrl
  176. }
  177. }
  178. }
  179. }
  180. </script>
  181. <style lang="scss">
  182. .main {
  183. display: flex;
  184. flex-direction: column;
  185. width: 100vw;
  186. height: 100vh;
  187. .one {
  188. padding: 2vw;
  189. .rich-img {
  190. width: 100% !important;
  191. display: block;
  192. }
  193. }
  194. .two {
  195. display: flex;
  196. flex-wrap: wrap;
  197. padding: 2vw;
  198. .list {
  199. position: relative;
  200. padding: 2vw;
  201. background-color: var(--f1Color);
  202. margin: 0 2vw 2vw 0;
  203. border-radius: 5px;
  204. width: 43vw;
  205. .img {
  206. .image {
  207. width: 100%;
  208. height: 28vh;
  209. border-radius: 5px;
  210. }
  211. }
  212. .name {
  213. margin: 0 0 1vw 0;
  214. text {
  215. font-size: var(--font14Size);
  216. }
  217. }
  218. .money {
  219. display: flex;
  220. .money_1 {
  221. color: var(--fFB1Color);
  222. font-size: 12px;
  223. text:last-child {
  224. font-size: 16px;
  225. padding: 0 0 0 1vw;
  226. }
  227. }
  228. .money_2 {
  229. font-size: 12px;
  230. margin: 0 0 0 2vw;
  231. color: var(--f99Color);
  232. text {
  233. text-decoration: line-through;
  234. }
  235. text:last-child {
  236. font-size: 16px;
  237. padding: 0 0 0 1vw;
  238. }
  239. }
  240. }
  241. .acttags {
  242. position: absolute;
  243. top: 2vw;
  244. width: 93%;
  245. text {
  246. display: inline-block;
  247. background-color: var(--fFB1Color);
  248. color: #fff;
  249. border-radius: 1vw;
  250. padding: 0.5vw;
  251. font-size: 12px;
  252. margin: 0 1vw 0 0;
  253. }
  254. }
  255. }
  256. .list:nth-child(2n) {
  257. margin: 0 0 2vw 0;
  258. }
  259. }
  260. }
  261. .scroll-view {
  262. position: absolute;
  263. top: 0;
  264. left: 0;
  265. right: 0;
  266. bottom: 0;
  267. .list-scroll-view {
  268. display: flex;
  269. flex-direction: column;
  270. }
  271. }
  272. .is_bottom {
  273. text-align: center;
  274. width: 100vw;
  275. text {
  276. padding: 2vw 0;
  277. display: inline-block;
  278. color: #858585;
  279. font-size: 14px;
  280. }
  281. }
  282. </style>