goods-active.vue 7.8 KB

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