goods_gift.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <view>
  3. <scroll-view
  4. v-if="top"
  5. class="wrapper"
  6. :style="{ top: top + 'px' }"
  7. scroll-y
  8. refresher-enabled
  9. refresher-default-style="white"
  10. @refresherrefresh="pullRefresh"
  11. :refresher-triggered="refreshing"
  12. >
  13. <view class="paddingX14 paddingB20">
  14. <view class="cell" v-for="item in tableData" :key="item.tradeNo">
  15. <view class="flex-align-between time">
  16. <view>赠送时间:{{ item.createTime }}</view>
  17. </view>
  18. <scroll-view scroll-x class="scroll-wrapper" v-if="item.list.length > 4">
  19. <view class="item" v-for="(goods, index) in item.list" :key="index">
  20. <image
  21. class="super"
  22. :src="LEVEL_MAP[goods.data.level].bg"
  23. mode="scaleToFill"
  24. />
  25. <image
  26. class="super-image translateX"
  27. mode="aspectFit"
  28. :src="goods.data.cover"
  29. />
  30. <view
  31. class="bg-title bold"
  32. :style="{ background: LEVEL_MAP[goods.data.level].bgColor }"
  33. >
  34. x {{ goods.total }}
  35. </view>
  36. </view>
  37. </scroll-view>
  38. <view v-else class="flex-align-around padding15">
  39. <view class="item" v-for="(goods, index) in item.list" :key="index">
  40. <image
  41. class="super"
  42. :src="LEVEL_MAP[goods.data.level].bg"
  43. mode="scaleToFill"
  44. />
  45. <image
  46. class="super-image translateX"
  47. mode="aspectFit"
  48. :src="goods.data.cover"
  49. />
  50. <view
  51. class="bg-title bold"
  52. :style="{ background: LEVEL_MAP[goods.data.level].bgColor }"
  53. >
  54. x {{ goods.total }}
  55. </view>
  56. </view>
  57. </view>
  58. <view class="flex-align top-line">
  59. <view class="order-no">订单号:{{ item.tradeNo }}</view>
  60. <button
  61. class="btn-clear copy marginL5 flex-shrink0"
  62. @click.stop="$common.copy(item.tradeNo)"
  63. >
  64. 复制
  65. </button>
  66. </view>
  67. <view class="flex-align">
  68. <view class="gift-no">受赠人:</view>
  69. <view class="flex-align">
  70. <image class="gift_img" :src="item.toUser.avatar" mode="aspectFit" />
  71. <view class="color-white">{{ item.toUser.nickname }}</view>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. <empty v-if="isEmpty" :top="200" light />
  77. </scroll-view>
  78. </view>
  79. </template>
  80. <script>
  81. import pageMixin from '../../mixin/page'
  82. import empty from '@/components/empty'
  83. import { LEVEL_MAP } from '@/utils/config'
  84. export default {
  85. mixins: [pageMixin],
  86. components: { empty },
  87. data() {
  88. return {
  89. LEVEL_MAP,
  90. refreshing: false,
  91. flag: 0
  92. }
  93. },
  94. computed: {
  95. top() {
  96. let height = this.$store.state.systemInfo.statusBarHeight + 36 + 50 + 10
  97. return height
  98. }
  99. },
  100. mounted() {
  101. this.refresh(true)
  102. },
  103. methods: {
  104. pullRefresh() {
  105. this.refreshing = true
  106. this.refresh()
  107. },
  108. async loadData(loading = false) {
  109. const res = await this.$service.award.transferOrderPageMy(
  110. this.pageNum,
  111. this.pageSize,
  112. loading
  113. )
  114. setTimeout(() => {
  115. this.refreshing = false
  116. }, 1000)
  117. return this.changeData(res)
  118. },
  119. changeData(res) {
  120. if (!res) return false
  121. res.forEach((item) => {
  122. let goods = item.itemList
  123. let goodsMap = {}
  124. goods.forEach((item) => {
  125. let key = item.spuId + '_' + item.level
  126. let obj = goodsMap[key]
  127. if (obj) {
  128. goodsMap[key] = {
  129. total: obj.total + 1,
  130. data: obj.data
  131. }
  132. } else {
  133. goodsMap[key] = {
  134. total: 1,
  135. data: item
  136. }
  137. }
  138. })
  139. item.list = Object.values(goodsMap)
  140. })
  141. return res
  142. }
  143. }
  144. }
  145. </script>
  146. <style lang="scss" scoped>
  147. .bg {
  148. position: fixed;
  149. z-index: -1;
  150. left: 0;
  151. right: 0;
  152. top: 0;
  153. width: 100%;
  154. height: 100%;
  155. opacity: 0.3;
  156. }
  157. .wrapper {
  158. position: fixed;
  159. left: 0;
  160. right: 0;
  161. bottom: 0;
  162. }
  163. .cell {
  164. background: rgba(0, 0, 0, 0.3);
  165. box-shadow: 0px 0px 20rpx 0px rgba(167, 110, 244, 0.5);
  166. border: 2rpx solid rgba(255, 255, 255, 0.4);
  167. border-radius: 16rpx;
  168. padding: 0;
  169. margin-bottom: 20rpx;
  170. position: relative;
  171. overflow: hidden;
  172. .time,
  173. .order-no {
  174. margin: 0 30rpx;
  175. color: #fff;
  176. font-size: 24rpx;
  177. height: 60rpx;
  178. line-height: 60rpx;
  179. }
  180. .time {
  181. border-bottom: 2rpx solid rgba($color: #e9d9ff, $alpha: 0.2);
  182. }
  183. .top-line {
  184. border-top: 2rpx solid rgba($color: #e9d9ff, $alpha: 0.2);
  185. }
  186. .item-wrapper {
  187. margin: 40rpx 0 30rpx 0;
  188. height: 182rpx;
  189. width: 100%;
  190. }
  191. .scroll-wrapper {
  192. margin: 40rpx 0 30rpx 30rpx;
  193. overflow: hidden;
  194. height: 182rpx;
  195. white-space: nowrap;
  196. width: 100%;
  197. .item {
  198. display: inline-block;
  199. margin-right: 8rpx;
  200. }
  201. }
  202. .copy {
  203. padding: 0 6rpx;
  204. height: 32rpx;
  205. line-height: 32rpx;
  206. border-radius: 8rpx;
  207. text-align: center;
  208. font-size: 24rpx;
  209. border: 1px solid #4d6fff;
  210. color: #4d6fff;
  211. }
  212. .item {
  213. width: 120rpx;
  214. height: 182rpx;
  215. position: relative;
  216. .super {
  217. position: absolute;
  218. z-index: 0;
  219. left: 0;
  220. top: 0;
  221. width: 120rpx;
  222. height: 182rpx;
  223. }
  224. .super-image {
  225. position: absolute;
  226. top: 14rpx;
  227. width: 109rpx;
  228. height: 120rpx;
  229. }
  230. .bg-title {
  231. color: #fff;
  232. font-size: 24rpx;
  233. text-align: center;
  234. position: absolute;
  235. left: 0;
  236. right: 0;
  237. bottom: 16rpx;
  238. padding: 2rpx 0;
  239. }
  240. }
  241. .gift-no {
  242. margin: 0 10rpx 0 30rpx;
  243. color: #fff;
  244. font-size: 24rpx;
  245. height: 60rpx;
  246. line-height: 60rpx;
  247. }
  248. .gift_img {
  249. width: 40rpx;
  250. height: 40rpx;
  251. font-size: 24rpx;
  252. border-radius: 50%;
  253. margin-right: 10rpx;
  254. }
  255. }
  256. </style>