yh_coupon.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <u-popup :show="show" @close="onClose" round="12" :closeable="true" :closeOnClickOverlay="false">
  3. <view :class="[AppTheme]" class="app">
  4. <view class="price-box">
  5. <text class="price-box_1">选择优惠券</text>
  6. <text class="price" v-if="money>=0">已选着一张优惠券,共优惠{{money}}元</text>
  7. <text class="price" v-else>已选着一张优惠券,共优惠0元</text>
  8. </view>
  9. <view class="pay-type-list">
  10. <view v-for="(item, index) in orderList.djq" :key="index">
  11. <view class="type-item" @click="changePayType(index,item)">
  12. <view class="type-item_1">
  13. <view class="type-item_2">
  14. <text>¥</text>
  15. <text class="text_2">{{item.money}}</text>
  16. </view>
  17. <view class="type-item_3">满{{item.usemoney}}元可用</view>
  18. </view>
  19. <view class="type-item_4">
  20. <text class="type-item_5">优惠券</text>
  21. <text class="type-item_6">领取后{{item.day}}天内有效</text>
  22. </view>
  23. <label class="radio">
  24. <radio value="index" :color="primary" :checked='payType == index' />
  25. </radio>
  26. </label>
  27. </view>
  28. <view style="margin-left: 5%;">
  29. <u-line color="gray" length="95%"></u-line>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="zhan_1" @click="changePayType(-1)">
  34. <view class="zhan_2">
  35. <view>暂不使用优惠券</view>
  36. <label class="radio">
  37. <radio value="-1" :color="primary" :checked='payType ==-1' />
  38. </radio>
  39. </label>
  40. </view>
  41. <view style="margin-left: 5%;">
  42. <u-line color="gray" length="95%"></u-line>
  43. </view>
  44. </view>
  45. <text class="mix-btn bg-linear-gradient" @click="confirm">完成</text>
  46. </view>
  47. </u-popup>
  48. </template>
  49. <script>
  50. export default {
  51. name: "yhcoupon",
  52. props: {
  53. orderList: Object,
  54. showModal: {
  55. type: Boolean,
  56. }
  57. },
  58. data() {
  59. return {
  60. primary: this.$theme.primary,
  61. show: false,
  62. payType: '',
  63. money: 0,
  64. djqid: ''
  65. }
  66. },
  67. watch: {
  68. //因为是单项数据流,v-modal控制的组件显示隐藏,父组件不可以通过props内的参数直接改变子元素参数,所以我们通过watch来监控数据的变化,间接修改show的数据
  69. showModal(val) {
  70. console.log('val', val)
  71. this.show = val
  72. }
  73. },
  74. mounted() {
  75. this.monitoring() // 注册监听事件
  76. },
  77. methods: {
  78. confirm() {
  79. this.onClose()
  80. },
  81. monitoring() {
  82. console.log(' this.orderList', this.orderList)
  83. this.orderList.djq.forEach((item, index) => {
  84. if (this.orderList.totalprice >= item.usemoney) {
  85. this.payType = index
  86. this.djqid = item.id
  87. this.money = item.money
  88. }
  89. })
  90. this.onClose()
  91. },
  92. onClose() {
  93. this.show = false
  94. this.$emit('close', {
  95. show: this.show,
  96. money: this.money,
  97. djqid: this.djqid
  98. }) //通知父组件隐藏了
  99. },
  100. changePayType(index, item) {
  101. if (index >= 0) {
  102. this.payType = index
  103. this.money = item.money
  104. this.djqid = item.id
  105. } else {
  106. this.djqid = ''
  107. this.payType = index
  108. this.money = -2
  109. }
  110. }
  111. }
  112. }
  113. </script>
  114. <style lang='scss'>
  115. .codeinput {
  116. justify-content: space-evenly;
  117. display: flex;
  118. }
  119. .app {
  120. width: 100%;
  121. }
  122. .money {
  123. font-size: 80rpx;
  124. position: relative;
  125. text-align: center;
  126. .close {
  127. position: absolute;
  128. top: 20rpx;
  129. right: 20rpx;
  130. line-height: 28rpx;
  131. font-size: 28rpx;
  132. }
  133. }
  134. .tips {
  135. color: $u-tips-color;
  136. text-align: center;
  137. }
  138. .price-box {
  139. background-color: #fff;
  140. display: flex;
  141. flex-direction: column;
  142. /* justify-content: center; */
  143. padding: 25rpx;
  144. .price-box_1 {
  145. font-size: 30upx;
  146. font-weight: 600;
  147. }
  148. .price {
  149. padding: 10rpx 0;
  150. color: darkgrey;
  151. font-size: 26upx;
  152. margin-top: 12upx;
  153. }
  154. }
  155. .zhan_1 {
  156. display: flex;
  157. flex-direction: column;
  158. .zhan_2 {
  159. display: flex;
  160. justify-content: space-between;
  161. padding: 80rpx 30rpx 20rpx 30rpx;
  162. }
  163. }
  164. .pay-type-list {
  165. background-color: #fff;
  166. .type-item {
  167. padding: 40upx 30rpx 30rpx 30rpx;
  168. display: flex;
  169. justify-content: space-between;
  170. align-items: center;
  171. font-size: 30upx;
  172. position: relative;
  173. .type-item_1 {
  174. display: flex;
  175. flex-direction: column;
  176. .type-item_2 {
  177. color: red;
  178. font-size: 34rpx;
  179. margin-bottom: 20rpx;
  180. .text_2 {
  181. font-weight: 600;
  182. }
  183. }
  184. .type-item_3 {
  185. color: darkgrey;
  186. font-size: 28rpx;
  187. }
  188. }
  189. .type-item_4 {
  190. display: flex;
  191. flex-direction: column;
  192. margin-left: -10vh;
  193. .type-item_5 {
  194. margin-bottom: 20rpx;
  195. font-size: 35rpx;
  196. }
  197. .type-item_6 {
  198. color: darkgrey;
  199. font-size: 28rpx;
  200. }
  201. }
  202. }
  203. .icon {
  204. width: 100upx;
  205. font-size: 52upx;
  206. }
  207. .icon-erjiye-yucunkuan {
  208. color: #fe8e2e;
  209. }
  210. .icon-weixinzhifu {
  211. color: #36cb59;
  212. }
  213. .icon-alipay {
  214. color: #01aaef;
  215. }
  216. .tit {
  217. font-size: $font-lg;
  218. color: $font-color-dark;
  219. margin-bottom: 4upx;
  220. }
  221. .con {
  222. flex: 1;
  223. display: flex;
  224. flex-direction: column;
  225. font-size: $font-sm;
  226. color: $font-color-light;
  227. }
  228. }
  229. .mix-btn {
  230. display: flex;
  231. align-items: center;
  232. justify-content: center;
  233. width: 630upx;
  234. height: 80upx;
  235. margin: 80upx auto 30upx;
  236. font-size: $font-lg;
  237. color: #fff;
  238. border-radius: 40upx;
  239. }
  240. </style>