productSpecifications.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. <template>
  2. <view class="action-sheet-container" v-if="visible" @click="handleMaskClick">
  3. <view class="action-sheet-mask" @click="hide"></view>
  4. <view class="action-sheet" :class="{ 'action-sheet-show': animationShow }" @click.stop>
  5. <!-- 可滚动内容区 -->
  6. <view class="action-sheet-scroll">
  7. <!-- 顶部价格与支持人数 -->
  8. <view class="sheet-header" v-if="currentReward">
  9. <view class="sheet-price">¥{{ currentReward.price }}</view>
  10. <view class="sheet-support">已支持{{ currentReward.sold_count }}份</view>
  11. </view>
  12. <!-- 商品卡片 -->
  13. <view class="sheet-product-card" v-if="currentReward">
  14. <view class="product-info">
  15. <view style="display: flex">
  16. <view class="product-title two-omit">{{title + ' ' + currentReward.title }}</view>
  17. <view class="product-time">
  18. (预计发货时间 {{ currentReward.delivery_year }}年{{ currentReward.delivery_month }}月)
  19. </view>
  20. </view>
  21. <image class="product-img" :src="currentReward.images[0]" mode="aspectFill" />
  22. <view class="product-detail" v-for="(d, i) in currentReward.description.split('\\n')" :key="i">{{ d }}</view>
  23. <view class="product-detail">发货方式:{{ currentReward.delivery_method }}</view>
  24. <view class="product-detail">限购:{{ currentReward.limit_count === 0 ? '不限' : currentReward.limit_count + '份' }}</view>
  25. <view class="product-detail" v-if="currentReward.is_early_bird">早鸟档,限量{{ currentReward.early_bird_limit }},截止{{ currentReward.early_bird_end_time }}</view>
  26. </view>
  27. </view>
  28. <!-- 规格选择 -->
  29. <view class="sheet-spec-area">
  30. <view class="spec-title">
  31. 选择回报
  32. <text class="spec-count">共{{ specList.length }}个</text>
  33. </view>
  34. <view class="spec-list">
  35. <view class="spec-item" v-for="(spec, idx) in specList" :key="idx"
  36. :class="{ selected: selectedSpecIndex === idx }" @click="selectSpec(idx)">
  37. {{ spec }}
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. <!-- 底部按钮 -->
  43. <view class="action-sheet-confirm-btn blick-btn-animation" @click="handleConfirm">立即购买支持</view>
  44. <view class="action-sheet-line"></view>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. export default {
  50. name: "productSpecifications",
  51. props: {
  52. rewards: {
  53. type: Array,
  54. default: () => {
  55. return [];
  56. }
  57. },
  58. title: {
  59. type: String,
  60. default: ''
  61. }
  62. },
  63. data() {
  64. return {
  65. visible: false,
  66. animationShow: false,
  67. selectedSpecIndex: 0, // 默认选中第一个规格
  68. };
  69. },
  70. computed: {
  71. // 当前选中的回报档
  72. currentReward() {
  73. return this.rewards && this.rewards.length > 0
  74. ? this.rewards[this.selectedSpecIndex]
  75. : null;
  76. },
  77. // 规格名列表
  78. specList() {
  79. return this.rewards.map(r => r.title);
  80. }
  81. },
  82. methods: {
  83. // 显示ActionSheet
  84. show() {
  85. this.visible = true;
  86. setTimeout(() => {
  87. this.animationShow = true;
  88. }, 10);
  89. },
  90. // 隐藏ActionSheet
  91. hide() {
  92. this.animationShow = false;
  93. setTimeout(() => {
  94. this.visible = false;
  95. }, 300); // 动画持续时间
  96. },
  97. selectSpec(idx) {
  98. this.selectedSpecIndex = idx;
  99. },
  100. handleConfirm() {
  101. this.$emit("confirm", {
  102. selectedReward: this.currentReward,
  103. selectedSpecIndex: this.selectedSpecIndex
  104. });
  105. this.hide();
  106. },
  107. // 处理遮罩点击
  108. handleMaskClick() {
  109. if (this.maskClosable) {
  110. this.$emit("cancel");
  111. this.hide();
  112. }
  113. },
  114. },
  115. };
  116. </script>
  117. <style lang="scss">
  118. .action-sheet-container {
  119. position: fixed;
  120. top: 0;
  121. right: 0;
  122. bottom: 0;
  123. left: 0;
  124. z-index: 999;
  125. .action-sheet-mask {
  126. position: absolute;
  127. top: 0;
  128. right: 0;
  129. bottom: 0;
  130. left: 0;
  131. background-color: rgba(0, 0, 0, 0.5);
  132. }
  133. .action-sheet {
  134. position: absolute;
  135. left: 0;
  136. right: 0;
  137. bottom: 0;
  138. transform: translateY(100%);
  139. transition: transform 0.3s ease;
  140. background: #f2f6f2;
  141. border-radius: 24rpx 24rpx 0 0;
  142. overflow: hidden;
  143. padding: 0 32rpx;
  144. max-height: 90vh;
  145. display: flex;
  146. flex-direction: column;
  147. padding-top: 40rpx;
  148. &.action-sheet-show {
  149. transform: translateY(0);
  150. }
  151. .sheet-header {
  152. display: flex;
  153. justify-content: space-between;
  154. align-items: center;
  155. padding: 32rpx 0 0 0;
  156. .sheet-price {
  157. font-size: 44rpx;
  158. font-weight: bold;
  159. color: #1F1F1F;
  160. }
  161. .sheet-support {
  162. font-size: 24rpx;
  163. color: #b2b2b2;
  164. }
  165. }
  166. .sheet-product-card {
  167. display: flex;
  168. flex-direction: row;
  169. align-items: flex-start;
  170. background: #f8faf8;
  171. border-radius: 16rpx;
  172. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.03);
  173. padding: 24rpx 24rpx 18rpx 24rpx;
  174. margin: 24rpx 0 0 0;
  175. position: relative;
  176. min-height: 160rpx;
  177. .product-img {
  178. width: 92rpx;
  179. height: 92rpx;
  180. border-radius: 8rpx;
  181. margin-right: 18rpx;
  182. flex-shrink: 0;
  183. margin-top: 2rpx;
  184. margin: 10rpx 0;
  185. }
  186. .product-info {
  187. flex: 1;
  188. display: flex;
  189. flex-direction: column;
  190. justify-content: flex-start;
  191. .product-title {
  192. font-size: 28rpx;
  193. font-weight: bold;
  194. color: #1F1F1F;
  195. line-height: 1.2;
  196. margin-bottom: 2rpx;
  197. margin-top: 2rpx;
  198. max-width: 340rpx;
  199. word-break: break-all;
  200. display: inline-block;
  201. max-width: 300rpx;
  202. }
  203. .product-time {
  204. font-size: 22rpx;
  205. color: #b2b2b2;
  206. margin-bottom: 8rpx;
  207. margin-top: 0;
  208. text-align: left;
  209. font-weight: normal;
  210. }
  211. .product-detail {
  212. font-size: 22rpx;
  213. color: #b2b2b2;
  214. margin-top: 2rpx;
  215. line-height: 1.2;
  216. text-align: left;
  217. padding: 10rpx 0;
  218. }
  219. }
  220. .product-checkbox {
  221. width: 32rpx;
  222. height: 32rpx;
  223. position: absolute;
  224. right: 18rpx;
  225. top: 18rpx;
  226. background: transparent;
  227. }
  228. }
  229. .sheet-spec-area {
  230. background: #fff;
  231. border-radius: 20rpx;
  232. margin: 32rpx 0 0 0;
  233. padding: 24rpx 24rpx 32rpx 24rpx;
  234. .spec-title {
  235. font-size: 28rpx;
  236. color: #1F1F1F;
  237. font-weight: bold;
  238. margin-bottom: 18rpx;
  239. display: flex;
  240. align-items: baseline;
  241. .spec-count {
  242. color: #b2b2b2;
  243. font-size: 22rpx;
  244. font-weight: normal;
  245. margin-left: 12rpx;
  246. }
  247. }
  248. .spec-list {
  249. display: grid;
  250. flex-direction: row;
  251. gap: 18rpx;
  252. .spec-item {
  253. padding: 12rpx 20rpx;
  254. border-radius: 12rpx;
  255. border-radius: 6rpx;
  256. border: 3rpx solid #1F1F1F;
  257. color: #1F1F1F;
  258. font-size: 28rpx;
  259. background: #fff;
  260. text-align: center;
  261. transition: all 0.2s;
  262. box-shadow: none;
  263. font-weight: 500;
  264. overflow: hidden;
  265. position: relative;
  266. left: 0;
  267. top: 0;
  268. &.selected {
  269. background: linear-gradient(-90deg, rgba(172, 249, 52, 0.5) 0%, rgba(172, 249, 52, 0) 100%);
  270. &::after {
  271. content: '';
  272. position: absolute;
  273. bottom: 0;
  274. right: 0;
  275. width: 0;
  276. height: 0;
  277. border-top: 8rpx solid transparent;
  278. border-left: 8rpx solid transparent;
  279. border-right: 8rpx solid #1F1F1F;
  280. border-bottom: 8rpx solid #1F1F1F;
  281. }
  282. }
  283. }
  284. }
  285. }
  286. .action-sheet-confirm-btn {
  287. font-family: "PingFang SC-bold";
  288. font-weight: 400;
  289. font-size: 32rpx;
  290. color: #ACF934;
  291. width: 626rpx;
  292. height: 88rpx;
  293. background: #1F1F1F;
  294. border-radius: 58rpx;
  295. margin:16rpx auto;
  296. margin-top: 16rpx;
  297. text-align: center;
  298. display: flex;
  299. align-items: center;
  300. justify-content: center;
  301. }
  302. .action-sheet-line {
  303. position: absolute;
  304. top: 16rpx;
  305. left: 50%;
  306. transform: translateX(-50%);
  307. width: 62rpx;
  308. height: 8rpx;
  309. background: #d1ded1;
  310. border-radius: 224rpx;
  311. }
  312. }
  313. .action-sheet-scroll {
  314. flex: 1 1 auto;
  315. overflow-y: auto;
  316. max-height: 70vh;
  317. padding: 0;
  318. }
  319. }
  320. </style>