goods-active.vue 8.0 KB

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