goods-active.vue 9.5 KB

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