goods-active.vue 9.7 KB

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