info.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <template>
  2. <mobile-frame>
  3. <view class="main">
  4. <view class="one">
  5. <view class="one_1" v-if="barActive=='0'">
  6. <scroll-view scroll-y="true" class="scroll-view">
  7. <view class="content">
  8. <u-parse :content="info.content.value"></u-parse>
  9. </view>
  10. </scroll-view>
  11. </view>
  12. <view class="one_2" v-else-if="barActive=='1'">
  13. <view class="one_2_1">
  14. <input type="text" v-model="searchInfo.name" @blur="toInput" placeholder="搜索商品">
  15. </view>
  16. <view class="one_2_2">
  17. <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
  18. <view class="list-scroll-view">
  19. <view class="pubu">
  20. <view class="list" v-for="(item,index) in list" :key="index">
  21. {{item.goods}}
  22. </view>
  23. </view>
  24. <view class="is_bottom" v-if="is_bottom">
  25. <text>我们也是有底线的!</text>
  26. </view>
  27. </view>
  28. </scroll-view>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="two">
  33. <view class="list" v-for="(item,index) in barList" :key="index" @tap="barChange(index,item)">
  34. <view class="icon">
  35. <text :class="['iconfont',barActive==index?item.acticon:item.icon]"></text>
  36. </view>
  37. <view :class="['name',barActive==index?'activename':'']">
  38. {{item.name}}
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </mobile-frame>
  44. </template>
  45. <script>
  46. import uParse from "@/components/u-parse/u-parse.vue";
  47. export default {
  48. components: {
  49. uParse,
  50. },
  51. data() {
  52. return {
  53. id: '',
  54. barActive: '0',
  55. barList: [ //底部菜单
  56. {
  57. icon: 'icon-shangdian',
  58. acticon: "icon-shangdian-copy",
  59. name: '活动详情'
  60. },
  61. {
  62. icon: 'icon-shangpinfenlei',
  63. acticon: "icon-shangpinfenlei-copy",
  64. name: '商品列表'
  65. }
  66. ],
  67. // 详情
  68. info: {},
  69. // 商品列表
  70. list: [],
  71. total: 0,
  72. page: 0,
  73. skip: 0,
  74. limit: 6,
  75. // 查询
  76. searchInfo: {},
  77. // 数据是否触底
  78. is_bottom: false,
  79. scrollTop: 0,
  80. };
  81. },
  82. onLoad: function(e) {
  83. const that = this;
  84. that.$set(that, `id`, e.id || '634fa595e4ed552882f05a6f');
  85. },
  86. onShow: function() {
  87. const that = this;
  88. that.searchAct();
  89. },
  90. methods: {
  91. async searchAct() {
  92. const that = this;
  93. if (that.id) {
  94. // 查询详情
  95. let res = await that.$api(`/platformAct/${that.id}`, 'GET');
  96. if (res.errcode == '0') {
  97. uni.setNavigationBarTitle({
  98. title: res.data.title
  99. });
  100. that.$set(that, `info`, res.data)
  101. }
  102. that.search()
  103. }
  104. },
  105. // 查询列表
  106. async search() {
  107. const that = this;
  108. // 查询商品列表
  109. let info = {
  110. skip: that.skip,
  111. limit: that.limit,
  112. platformAct: that.id
  113. }
  114. let res = await that.$api(`/goodsJoinAct`, 'GET', {
  115. ...info,
  116. ...that.searchInfo
  117. })
  118. if (res.errcode == '0') {
  119. let list = [...that.list, ...res.data];
  120. that.$set(that, `list`, list)
  121. that.$set(that, `total`, res.total)
  122. }
  123. },
  124. toPage() {
  125. const that = this;
  126. let list = that.list;
  127. let limit = that.limit;
  128. if (that.total > list.length) {
  129. uni.showLoading({
  130. title: '加载中',
  131. mask: true
  132. })
  133. let page = that.page + 1;
  134. that.$set(that, `page`, page)
  135. let skip = page * limit;
  136. that.$set(that, `skip`, skip)
  137. that.search();
  138. uni.hideLoading();
  139. } else that.$set(that, `is_bottom`, true)
  140. },
  141. toScroll(e) {
  142. const that = this;
  143. let up = that.scrollTop;
  144. that.$set(that, `scrollTop`, e.detail.scrollTop);
  145. let num = Math.sign(up - e.detail.scrollTop);
  146. if (num == 1) that.$set(that, `is_bottom`, false);
  147. },
  148. // 输入框
  149. toInput(e) {
  150. const that = this;
  151. if (e.detail.value) that.$set(that.searchInfo, `name`, e.detail.value);
  152. that.clearPage();
  153. that.search();
  154. },
  155. // 选择底部菜单
  156. barChange(index, item) {
  157. const that = this;
  158. that.$set(that, `barActive`, index);
  159. // uni.setNavigationBarTitle({
  160. // title: item.name
  161. // });
  162. },
  163. // 清空列表
  164. clearPage() {
  165. const that = this;
  166. that.$set(that, `list`, [])
  167. that.$set(that, `skip`, 0)
  168. that.$set(that, `limit`, 6)
  169. that.$set(that, `page`, 0)
  170. }
  171. }
  172. }
  173. </script>
  174. <style lang="scss">
  175. .main {
  176. display: flex;
  177. flex-direction: column;
  178. width: 100vw;
  179. height: 100vh;
  180. .one {
  181. position: relative;
  182. flex-grow: 1;
  183. .one_1 {
  184. height: 92vh;
  185. .content {
  186. padding: 2vw;
  187. }
  188. image {
  189. width: 100% !important;
  190. }
  191. }
  192. .one_2 {
  193. height: 92vh;
  194. .one_2_1 {
  195. border-bottom: 1px solid var(--f85Color);
  196. padding: 2vw;
  197. input {
  198. padding: 2vw;
  199. background-color: var(--f1Color);
  200. font-size: var(--font14Size);
  201. border-radius: 5px;
  202. }
  203. }
  204. .one_2_2 {
  205. padding: 2vw;
  206. }
  207. }
  208. }
  209. .two {
  210. display: flex;
  211. flex-direction: row;
  212. justify-content: space-around;
  213. border-top: 1px solid #f1f1f1;
  214. .list {
  215. padding: 1vw 0;
  216. text-align: center;
  217. .icon {}
  218. .name {
  219. font-size: 12px;
  220. }
  221. .activename {
  222. color: var(--fFB1Color);
  223. }
  224. }
  225. }
  226. }
  227. .scroll-view {
  228. position: absolute;
  229. top: 0;
  230. left: 0;
  231. right: 0;
  232. bottom: 0;
  233. .list-scroll-view {
  234. display: flex;
  235. flex-direction: row;
  236. flex-wrap: wrap;
  237. }
  238. }
  239. </style>