goods-active.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <template>
  2. <view class="container" v-show="isRepuest">
  3. <view class="container-title">
  4. <view class="name">【{{ promotionsInfo.name }}】{{ promotionsInfo.description }}</view>
  5. <view class="text">
  6. <text class="span">促销时间:</text>
  7. <text class="span r">
  8. <text class="txt" v-if="promotionsInfo.status == 1">不限时</text>
  9. <text class="txt" v-else>{{ promotionsInfo.beginTime }} ~ {{ promotionsInfo.endTime }}</text>
  10. </text>
  11. </view>
  12. <view class="text">下面为参与本次凑单满赠活动的全部商品</view>
  13. </view>
  14. <view class="tui-order-content">
  15. <view class="hotgoods-swiper">
  16. <view class="scoll-wrapper clearfix">
  17. <view
  18. class="floor-item"
  19. v-for="(item, index) in productList"
  20. :key="index"
  21. @click.stop="detail(item.productId)"
  22. >
  23. <image class="tui-skeleton-fillet" :src="item.image" mode="aspectFill"></image>
  24. <view class="floor-item-content">
  25. <view class="title"
  26. ><text class="mclap">{{ item.name }}</text></view
  27. >
  28. <view class="price">
  29. <text class="p sm">¥</text> <text class="p big">{{ item.price | NumFormat }}</text>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. <!--加载loadding-->
  36. <tui-loadmore :visible="loadding" :index="3" type="black"></tui-loadmore>
  37. <tui-nomore :visible="!pullUpOn" :backgroundColor="'#ffffff'" :text="nomoreText"></tui-nomore>
  38. <!--加载loadding-->
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. import tuiLoadmore from '@/components/tui-components/loadmore/loadmore'
  44. import tuiNomore from '@/components/tui-components/nomore/nomore'
  45. import { mapState, mapMutations } from 'vuex'
  46. export default {
  47. components: {
  48. tuiLoadmore,
  49. tuiNomore
  50. },
  51. data() {
  52. return {
  53. isRepuest: false,
  54. userId: 0,
  55. listQuery:{
  56. promotionsId: 0,
  57. pageSize: 10,
  58. pageNum: 1,
  59. identity:0
  60. },
  61. productList: [],
  62. modal: false,
  63. promotionsInfo: {},
  64. loadding: false,
  65. pullUpOn: true,
  66. hasNextPage: false,
  67. pullFlag: true,
  68. nomoreText: '上拉显示更多'
  69. }
  70. },
  71. computed: {
  72. ...mapState(['identity'])
  73. },
  74. onLoad(option) {
  75. this.listQuery.promotionsId = option.id
  76. this.initGetStotage()
  77. },
  78. filters: {
  79. NumFormat: function(text) {
  80. //处理金额
  81. return Number(text).toFixed(2)
  82. }
  83. },
  84. methods: {
  85. async initGetStotage() {// 初始化
  86. const userInfo = await this.$api.getStorage()
  87. this.userId = userInfo.userId ? userInfo.userId : 0
  88. this.listQuery.identity = this.identity
  89. this.initSsoMemberCollectionList()
  90. },
  91. initSsoMemberCollectionList() {
  92. //凑单初始化
  93. this.ProductService.queryProductPromotionInfo({
  94. promotionsId: this.listQuery.promotionsId
  95. })
  96. .then(response => {
  97. let data = response.data
  98. this.promotionsInfo = data
  99. this.queryProductPromotionList()
  100. })
  101. .catch(error => {
  102. this.$util.msg(error.message, 2000)
  103. })
  104. },
  105. queryProductPromotionList() {
  106. //查询凑单商品列表
  107. this.ProductService.queryProductPromotionList(this.listQuery)
  108. .then(response => {
  109. let data = response.data
  110. if (data.list && data.list.length > 0) {
  111. this.hasNextPage = data.hasNextPage
  112. this.productList = data.list
  113. this.getProductPrice()
  114. // 防上拉暴滑
  115. this.pullFlag = false
  116. setTimeout(() => {
  117. this.pullFlag = true
  118. }, 500)
  119. // 底部提示文案
  120. if (this.hasNextPage) {
  121. this.pullUpOn = false
  122. this.nomoreText = '上拉显示更多'
  123. } else {
  124. if (this.productList.length < 2) {
  125. this.pullUpOn = true
  126. } else {
  127. this.pullUpOn = false
  128. this.nomoreText = '已至底部'
  129. }
  130. }
  131. }
  132. })
  133. .catch(error => {
  134. this.$util.msg(error.message, 2000)
  135. })
  136. },
  137. getOnReachBottomData() {
  138. //上滑加载
  139. this.listQuery.pageNum += 1
  140. this.ProductService.queryProductPromotionList(this.listQuery)
  141. .then(response => {
  142. let data = response.data
  143. if (data.list && data.list.length > 0) {
  144. this.hasNextPage = data.hasNextPage
  145. this.productList = this.productList.concat(data.list)
  146. this.getProductPrice()
  147. this.pullFlag = false // 防上拉暴滑
  148. setTimeout(() => {
  149. this.pullFlag = true
  150. }, 500)
  151. if (this.hasNextPage) {
  152. this.pullUpOn = false
  153. this.nomoreText = '上拉显示更多'
  154. } else {
  155. this.pullUpOn = false
  156. this.loadding = false
  157. this.nomoreText = '已至底部'
  158. }
  159. }
  160. })
  161. .catch(error => {
  162. this.$util.msg(error.msg, 2000)
  163. })
  164. },
  165. getProductPrice() {
  166. //获取商品或者活动价格
  167. let productIdArr = []
  168. let productIds = ''
  169. this.productList.map(item => {
  170. productIdArr.push(item.productId)
  171. })
  172. productIds = productIdArr.join(',')
  173. this.ProductService.querySearchProductPrice({
  174. userId: this.userId,
  175. productIds: productIds,
  176. source: 2
  177. })
  178. .then(response => {
  179. this.productList = this.ReturnNewProducts(this.productList, response.data)
  180. this.isRepuest = true
  181. })
  182. .catch(error => {
  183. this.$util.msg(error.msg, 2000)
  184. })
  185. },
  186. ReturnNewProducts(Array, list) {
  187. let NewArray = []
  188. Array.map(item => {
  189. for (let i = 0; i < list.length; i++) {
  190. if (item.productId == list[i].productId) {
  191. NewArray.push(Object.assign(item, list[i]))
  192. }
  193. }
  194. })
  195. return NewArray
  196. },
  197. detail(id) {
  198. this.$api.navigateTo(`/pages/goods/product?id=${id}`)
  199. }
  200. },
  201. onReachBottom() {
  202. if (this.hasNextPage) {
  203. this.loadding = true
  204. this.pullUpOn = true
  205. this.getOnReachBottomData()
  206. }
  207. },
  208. onPullDownRefresh() {
  209. //下拉刷新
  210. this.listQuery.pageNum = 1
  211. this.queryProductPromotionList()
  212. uni.stopPullDownRefresh()
  213. },
  214. onShow() {}
  215. }
  216. </script>
  217. <style lang="scss">
  218. page {
  219. background-color: #f7f7f7;
  220. }
  221. .container {
  222. padding-bottom: 0;
  223. }
  224. .container-title {
  225. width: 100%;
  226. height: 242rpx;
  227. box-sizing: border-box;
  228. padding: 21rpx 24rpx 23rpx 24rpx;
  229. background: url(https://static.caimei365.com/app/img/bg/icon-activity-bg@2x.png);
  230. background-size: cover;
  231. .name {
  232. width: 100%;
  233. box-sizing: border-box;
  234. height: 96rpx;
  235. line-height: 36rpx;
  236. padding: 12rpx 0;
  237. font-size: $font-size-28;
  238. color: #ffffff;
  239. }
  240. .text {
  241. width: 100%;
  242. height: 48rpx;
  243. line-height: 48rpx;
  244. font-size: $font-size-24;
  245. color: #ffffff;
  246. .span {
  247. display: inline-block;
  248. float: left;
  249. &.r {
  250. padding: 0 20rpx;
  251. height: 36rpx;
  252. line-height: 36rpx;
  253. border-radius: 6rpx;
  254. text-align: center;
  255. color: $color-system;
  256. font-size: $font-size-26;
  257. margin-top: 4rpx;
  258. background-color: #ffffff;
  259. margin-left: 10rpx;
  260. }
  261. }
  262. }
  263. }
  264. .hotgoods-swiper {
  265. width: 100%;
  266. height: auto;
  267. overflow: hidden;
  268. margin-bottom: 20rpx;
  269. .scoll-wrapper {
  270. width: 100%;
  271. height: auto;
  272. box-sizing: border-box;
  273. padding: 24rpx;
  274. background: #f7f7f7;
  275. .floor-item {
  276. width: 340rpx;
  277. height: auto;
  278. margin-right: 20rpx;
  279. font-size: $font-size-24;
  280. color: $text-color;
  281. background: #ffffff;
  282. line-height: 36rpx;
  283. border-radius: 14rpx;
  284. margin-bottom: 20rpx;
  285. float: left;
  286. box-sizing: border-box;
  287. padding-bottom: 16rpx;
  288. &:nth-child(2n) {
  289. margin-right: 0;
  290. }
  291. image {
  292. width: 341rpx;
  293. height: 341rpx;
  294. border-radius: 20rpx 20rpx 0 0;
  295. display: block;
  296. margin-bottom: 20rpx;
  297. }
  298. .floor-item-content {
  299. width: 100%;
  300. padding: 0 15rpx;
  301. box-sizing: border-box;
  302. }
  303. .title {
  304. width: 100%;
  305. height: 72rpx;
  306. display: flex;
  307. flex-direction: column;
  308. padding: 10rpx 0;
  309. .mclap {
  310. width: 100%;
  311. line-height: 36rpx;
  312. text-overflow: ellipsis;
  313. display: -webkit-box;
  314. word-break: break-all;
  315. -webkit-box-orient: vertical;
  316. -webkit-line-clamp: 2;
  317. overflow: hidden;
  318. font-size: 26rpx;
  319. }
  320. }
  321. .price {
  322. color: #ff2a2a;
  323. line-height: 44rpx;
  324. .sm {
  325. font-size: $font-size-24;
  326. }
  327. .big {
  328. font-size: $font-size-28;
  329. }
  330. }
  331. }
  332. }
  333. }
  334. </style>