sku-popup.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <u-popup :show="popupShow" round="17" mode="bottom" @close="close" :closeable="true" @touchmove.prevent.stop>
  3. <view class="choiceShow-wrap">
  4. <!-- 商品信息 -->
  5. <view class="flex goods">
  6. <view class="goods-left">
  7. <view class="goods-left__image flex">
  8. <image class="image-goods" :src="payInfo.picUrl" mode="aspectFit"></image>
  9. </view>
  10. <view class="goods-left-content flex">
  11. <!-- #ifdef MP-ALIPAY -->
  12. <view class="goods-left-content__titletwo">{{ detailInfo.title }}</view>
  13. <!-- #endif -->
  14. <!-- #ifndef MP-ALIPAY -->
  15. <view class="goods-left-content__title ells">{{ detailInfo.title }}</view>
  16. <!-- #endif -->
  17. </view>
  18. </view>
  19. </view>
  20. <!-- sku -->
  21. <view class="sku" v-for="(item, index) in skuList" :key="index">
  22. <view class="sku-title">{{ item.name }}</view>
  23. <view class="flex sku-list">
  24. <view
  25. class="sku-list-item"
  26. :class="{'action': item.actionIndex == indexs}"
  27. v-for="(ele, indexs) in item.value" :key="indexs" @click="getSku(ele, item, indexs)">
  28. {{ ele }}
  29. </view>
  30. </view>
  31. </view>
  32. <!-- 按钮 -->
  33. <view class="flex btn">
  34. <view class="btn-right">
  35. <view class="confirm" @click="confirmPrize">确定</view>
  36. </view>
  37. </view>
  38. </view>
  39. </u-popup>
  40. </template>
  41. <script>
  42. import env from '@/config/env.js'
  43. import $http from '@/utils/request.js'
  44. export default {
  45. name: "exchange-popup",
  46. props: {
  47. popupShow: {
  48. type: [Boolean],
  49. default: false
  50. },
  51. skuListInit: {
  52. type: Array,
  53. default: () => []
  54. },
  55. skuListPopup: {
  56. type: Array,
  57. default: () => []
  58. },
  59. detailInfo: {
  60. type: [Object],
  61. default: {}
  62. },
  63. popupInfo: {
  64. type: [Object],
  65. default: {}
  66. }
  67. },
  68. data() {
  69. return {
  70. payInfo: {},
  71. skuList: []
  72. };
  73. },
  74. created() {
  75. this.payInfo = this.popupInfo
  76. this.skuList = this.skuListPopup
  77. },
  78. methods: {
  79. getSku(e, item, indexs) {
  80. this.$set(item, 'txt', `${item.name}:${e}`)
  81. this.$set(item, 'actionIndex', indexs)
  82. let actionSku = this.skuList.map(item => {
  83. return item.txt
  84. }).join(';')
  85. let sku = this.skuListInit.find(item => {
  86. return item.properties == actionSku
  87. })
  88. this.payInfo = {
  89. ...sku,
  90. exValue: sku.exchangePrice,
  91. picUrl: env.filePublic + sku.picUrl,
  92. storageId: this.detailInfo.storageId,
  93. }
  94. },
  95. confirmPrize() {
  96. let data = {
  97. properties: this.payInfo.properties,
  98. skuId: this.payInfo.skuId,
  99. storageId: this.payInfo.storageId,
  100. }
  101. this.$emit('success',data)
  102. },
  103. close() {
  104. this.$emit('close')
  105. },
  106. }
  107. }
  108. </script>
  109. <style lang="scss" scoped>
  110. .choiceShow-wrap {
  111. min-height: 400rpx;
  112. padding: 34rpx;
  113. // 商品
  114. .goods {
  115. justify-content: space-between;
  116. margin-bottom: 66rpx;
  117. &-left {
  118. flex: 1;
  119. display: flex;
  120. &__image {
  121. width: 154rpx;
  122. height: 154rpx;
  123. border: 1px solid #EEEEEE;
  124. border-radius: 18rpx;
  125. margin-right: 24rpx;
  126. .image-goods {
  127. width: 154rpx;
  128. height: 154rpx;
  129. }
  130. }
  131. &-content {
  132. height: 154rpx;
  133. flex-direction: column;
  134. align-items: flex-start;
  135. justify-content: space-between;
  136. padding: 34rpx 0;
  137. .image-goods {
  138. width: 154rpx;
  139. height: 154rpx;
  140. border-radius: 18rpx;
  141. border: 1px solid #EEEEEE;
  142. margin-right: 24rpx;
  143. }
  144. &__title {
  145. font-size: 30rpx;
  146. line-height: 30rpx;
  147. font-weight: bold;
  148. height: 30rpx;
  149. overflow: hidden;
  150. }
  151. &__titletwo {
  152. width: 450rpx;
  153. font-size: 30rpx;
  154. line-height: 30rpx;
  155. font-weight: bold;
  156. height: 30rpx;
  157. white-space: nowrap;
  158. overflow: hidden;
  159. text-overflow: ellipsis;
  160. }
  161. &__coin {
  162. color: $uni-btn-color;
  163. .image-coin {
  164. width: 34rpx;
  165. height: 30rpx;
  166. }
  167. }
  168. }
  169. }
  170. &-right {
  171. color: #666;
  172. }
  173. }
  174. // sku
  175. .sku {
  176. &-title {
  177. font-size: 30rpx;
  178. line-height: 30rpx;
  179. font-weight: bold;
  180. margin-bottom: 34rpx;
  181. }
  182. &-list {
  183. justify-content: flex-start;
  184. flex-wrap: wrap;
  185. &-item {
  186. padding: 20rpx 66rpx;
  187. border-radius: 36rpx;
  188. margin-right: 18rpx;
  189. background: #F5F6F8;
  190. margin-bottom: 34rpx;
  191. }
  192. .action {
  193. background-color: #E8DCFD;
  194. color: $uni-btn-color;
  195. }
  196. }
  197. }
  198. // 数量
  199. .quantity {
  200. justify-content: space-between;
  201. margin: 34rpx 0;
  202. &-title {
  203. font-size: 30rpx;
  204. line-height: 30rpx;
  205. font-weight: bold;
  206. }
  207. }
  208. // 按钮
  209. .btn {
  210. padding-top: 36rpx;
  211. border-top: 1px solid #eee;
  212. text-align: center;
  213. &-right {
  214. .confirm {
  215. width: 414rpx;
  216. height: 88rpx;
  217. line-height: 88rpx;
  218. background: $uni-btn-color;
  219. border-radius: 6rpx;
  220. font-size: 36rpx;
  221. color: #fff;
  222. text-align: center;
  223. }
  224. }
  225. }
  226. }
  227. </style>