goods-active.vue 8.1 KB

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