普兆健康管家前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

240 lines
4.5 KiB

4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
  1. <template>
  2. <view>
  3. <uv-popup ref="popup" mode="bottom" bgColor="none" >
  4. <view class="popup__view">
  5. <view class="flex header">
  6. <view class="title">选择规格</view>
  7. <button class="btn" @click="close">关闭</button>
  8. </view>
  9. <view class="section info">
  10. <view class="flex card">
  11. <view class="left">
  12. <image class="img" :src="coverImg" mode="aspectFill"></image>
  13. </view>
  14. <view class="right">
  15. <view class="name">{{ data.name }}</view>
  16. <view class="desc">可在以下安全剂量内根据你的额外需求选择颗数</view>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="section option">
  21. <view
  22. v-for="item in options"
  23. :key="item.id"
  24. :class="['option-item', selectId == item.id ? 'is-active' : '']"
  25. @click="selectId = item.id"
  26. >
  27. {{ item.specName }}
  28. </view>
  29. </view>
  30. <view class="footer">
  31. <button class="flex btn" @click="onConfirm">下一步</button>
  32. </view>
  33. </view>
  34. </uv-popup>
  35. </view>
  36. </template>
  37. <script>
  38. import { mapState } from 'vuex'
  39. export default {
  40. props: {
  41. data: {
  42. type: Object,
  43. default() {
  44. return {}
  45. }
  46. }
  47. },
  48. data() {
  49. return {
  50. selectId: null,
  51. }
  52. },
  53. computed : {
  54. ...mapState(['configList']),
  55. coverImg() {
  56. const { image } = this.data
  57. if (!image) {
  58. return ''
  59. }
  60. let arr = Array.isArray(image) ? image : image.split(',')
  61. return arr[0]
  62. },
  63. options() {
  64. const { specs } = this.data
  65. let arr = [...specs]
  66. return arr.sort((a, b) => a.sortOrder - b.sortOrder)
  67. },
  68. },
  69. methods: {
  70. open() {
  71. this.$refs.popup.open()
  72. },
  73. close() {
  74. this.$refs.popup.close()
  75. this.selectId = null
  76. },
  77. onConfirm() {
  78. if (!this.selectId) {
  79. uni.showToast({
  80. title: '请选择规格',
  81. icon: 'none',
  82. })
  83. return
  84. }
  85. this.$emit('confirm', this.selectId)
  86. this.close()
  87. },
  88. },
  89. }
  90. </script>
  91. <style lang="scss" scoped>
  92. .popup__view {
  93. width: 100vw;
  94. display: flex;
  95. flex-direction: column;
  96. box-sizing: border-box;
  97. background: #FFFFFF;
  98. border-top-left-radius: 32rpx;
  99. border-top-right-radius: 32rpx;
  100. }
  101. .header {
  102. position: relative;
  103. width: 100%;
  104. padding: 24rpx 0;
  105. box-sizing: border-box;
  106. .title {
  107. font-family: PingFang SC;
  108. font-weight: 500;
  109. font-size: 34rpx;
  110. line-height: 1.4;
  111. color: #181818;
  112. }
  113. .btn {
  114. font-family: PingFang SC;
  115. font-weight: 500;
  116. font-size: 32rpx;
  117. line-height: 1.4;
  118. color: #8B8B8B;
  119. position: absolute;
  120. top: 26rpx;
  121. left: 40rpx;
  122. }
  123. }
  124. .section {
  125. border-top: 2rpx solid #EEEEEE;
  126. }
  127. .info {
  128. width: 100%;
  129. padding: 32rpx;
  130. box-sizing: border-box;
  131. .card {
  132. width: 100%;
  133. padding: 32rpx;
  134. box-sizing: border-box;
  135. background-image: linear-gradient(#FAFAFF, #F3F3F3);
  136. border-radius: 32rpx;
  137. column-gap: 24rpx;
  138. .left {
  139. width: 144rpx;
  140. height: 144rpx;
  141. border-radius: 16rpx;
  142. overflow: hidden;
  143. .img {
  144. width: 100%;
  145. height: 100%;
  146. }
  147. }
  148. .right {
  149. flex: 1;
  150. .name {
  151. font-family: PingFang SC;
  152. font-weight: 500;
  153. font-size: 28rpx;
  154. line-height: 1.4;
  155. color: #000000;
  156. }
  157. .desc {
  158. margin-top: 8rpx;
  159. font-family: PingFang SC;
  160. font-weight: 400;
  161. font-size: 26rpx;
  162. line-height: 1.5;
  163. color: #8B8B8B;
  164. }
  165. }
  166. }
  167. }
  168. .option {
  169. width: 100%;
  170. padding: 44rpx;
  171. box-sizing: border-box;
  172. display: grid;
  173. grid-template-columns: repeat(2, 1fr);
  174. gap: 24rpx;
  175. &-item {
  176. padding: 18rpx 14rpx;
  177. text-align: center;
  178. font-family: PingFang SC;
  179. font-weight: 400;
  180. font-size: 28rpx;
  181. line-height: 1.4;
  182. color: #181818;
  183. background: #F9F9F9;
  184. border: 2rpx solid #F9F9F9;
  185. border-radius: 16rpx;
  186. &.is-active {
  187. color: #7451DE;
  188. background: #F2EEFF;
  189. border-color: #7451DE;
  190. }
  191. }
  192. }
  193. .footer {
  194. width: 100%;
  195. // todo:check
  196. // height: 214rpx;
  197. padding: 32rpx 40rpx;
  198. box-sizing: border-box;
  199. .btn {
  200. width: 100%;
  201. padding: 16rpx 0;
  202. font-family: PingFang SC;
  203. font-weight: 500;
  204. font-size: 36rpx;
  205. line-height: 1.4;
  206. color: #FFFFFF;
  207. background-image: linear-gradient(to right, #4B348F, #845CFA);
  208. border-radius: 41rpx;
  209. }
  210. }
  211. </style>