普兆健康管家前端代码仓库
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.

233 lines
4.4 KiB

  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 data.options"
  23. :key="item.id"
  24. :class="['option-item', selectId == item.id ? 'is-active' : '']"
  25. @click="selectId = item.id"
  26. >
  27. {{ item.label }}
  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. },
  64. methods: {
  65. open() {
  66. this.$refs.popup.open()
  67. },
  68. close() {
  69. this.$refs.popup.close()
  70. this.selectId = null
  71. },
  72. onConfirm() {
  73. if (!this.selectId) {
  74. uni.showToast({
  75. title: '请选择规格',
  76. icon: 'none',
  77. })
  78. return
  79. }
  80. this.$emit('confirm', this.selectId)
  81. this.close()
  82. },
  83. },
  84. }
  85. </script>
  86. <style lang="scss" scoped>
  87. .popup__view {
  88. width: 100vw;
  89. display: flex;
  90. flex-direction: column;
  91. box-sizing: border-box;
  92. background: #FFFFFF;
  93. border-top-left-radius: 32rpx;
  94. border-top-right-radius: 32rpx;
  95. }
  96. .header {
  97. position: relative;
  98. width: 100%;
  99. padding: 24rpx 0;
  100. box-sizing: border-box;
  101. .title {
  102. font-family: PingFang SC;
  103. font-weight: 500;
  104. font-size: 34rpx;
  105. line-height: 1.4;
  106. color: #181818;
  107. }
  108. .btn {
  109. font-family: PingFang SC;
  110. font-weight: 500;
  111. font-size: 32rpx;
  112. line-height: 1.4;
  113. color: #8B8B8B;
  114. position: absolute;
  115. top: 26rpx;
  116. left: 40rpx;
  117. }
  118. }
  119. .section {
  120. border-top: 2rpx solid #EEEEEE;
  121. }
  122. .info {
  123. width: 100%;
  124. padding: 32rpx;
  125. box-sizing: border-box;
  126. .card {
  127. width: 100%;
  128. padding: 32rpx;
  129. box-sizing: border-box;
  130. background-image: linear-gradient(#FAFAFF, #F3F3F3);
  131. border-radius: 32rpx;
  132. column-gap: 24rpx;
  133. .left {
  134. width: 144rpx;
  135. height: 144rpx;
  136. border-radius: 16rpx;
  137. overflow: hidden;
  138. .img {
  139. width: 100%;
  140. height: 100%;
  141. }
  142. }
  143. .right {
  144. flex: 1;
  145. .name {
  146. font-family: PingFang SC;
  147. font-weight: 500;
  148. font-size: 28rpx;
  149. line-height: 1.4;
  150. color: #000000;
  151. }
  152. .desc {
  153. margin-top: 8rpx;
  154. font-family: PingFang SC;
  155. font-weight: 400;
  156. font-size: 26rpx;
  157. line-height: 1.5;
  158. color: #8B8B8B;
  159. }
  160. }
  161. }
  162. }
  163. .option {
  164. width: 100%;
  165. padding: 44rpx;
  166. box-sizing: border-box;
  167. display: grid;
  168. grid-template-columns: repeat(2, 1fr);
  169. gap: 24rpx;
  170. &-item {
  171. padding: 18rpx 14rpx;
  172. text-align: center;
  173. font-family: PingFang SC;
  174. font-weight: 400;
  175. font-size: 28rpx;
  176. line-height: 1.4;
  177. color: #181818;
  178. background: #F9F9F9;
  179. border: 2rpx solid #F9F9F9;
  180. border-radius: 16rpx;
  181. &.is-active {
  182. color: #7451DE;
  183. background: #F2EEFF;
  184. border-color: #7451DE;
  185. }
  186. }
  187. }
  188. .footer {
  189. width: 100%;
  190. // todo:check
  191. // height: 214rpx;
  192. padding: 32rpx 40rpx;
  193. box-sizing: border-box;
  194. .btn {
  195. width: 100%;
  196. padding: 16rpx 0;
  197. font-family: PingFang SC;
  198. font-weight: 500;
  199. font-size: 36rpx;
  200. line-height: 1.4;
  201. color: #FFFFFF;
  202. background-image: linear-gradient(to right, #4B348F, #845CFA);
  203. border-radius: 41rpx;
  204. }
  205. }
  206. </style>