info.vue 6.2 KB

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