goods-active.vue 8.0 KB

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