info.vue 6.6 KB

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