info.vue 7.0 KB

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