goods-active.vue 9.2 KB

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