info.vue 7.5 KB

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