payModal.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <page-container
  3. :show="showModal"
  4. :round="true"
  5. :z-index="100"
  6. position="bottom"
  7. customStyle="border-radius:15px 15px 0 0;"
  8. @beforeleave="beforeClose"
  9. @afterleave="closePopu">
  10. <view class="popu-content" v-if="payInfo">
  11. <view class="popu-close" @click="cancelPay">
  12. <uni-icons size="26" type="closeempty"></uni-icons>
  13. </view>
  14. <view class="pupu-box-pay-item">
  15. <view class="popu-content-amount flex align_center justify_center">
  16. <view>¥{{payInfo.totalAmount}}</view>
  17. </view>
  18. <view class="flex align_center justify_between" v-if="payInfo.totalSpecialGiveAmount>0">
  19. <text>总优惠</text>
  20. <view class="popu-content-price">¥{{payInfo.totalSpecialGiveAmount}}</view>
  21. </view>
  22. <view class="flex align_center justify_between" v-if="payInfo.totalTicketGiveAmount>0">
  23. <text>代金券</text>
  24. <view class="popu-content-price">¥{{payInfo.totalTicketGiveAmount}}</view>
  25. </view>
  26. <view style="height: 5px;"></view>
  27. <view class="popu-content-title flex align_center justify_between">
  28. <text>付款方式</text>
  29. <view></view>
  30. </view>
  31. <view class="popu-content-pay flex align_center justify_between">
  32. <view class="flex align_center"><uni-icons size="20" type="weixin" color="#4CAF50"></uni-icons> <text style="margin-left: 5px;">微信支付</text></view>
  33. <view><uni-icons size="22" type="checkbox-filled" color="red"></uni-icons></view>
  34. </view>
  35. </view>
  36. <view class="popu-content-btn">
  37. <view class="popu-content-btn-item okbtn" @click="confirmPay">确定付款</view>
  38. </view>
  39. </view>
  40. </page-container>
  41. </template>
  42. <script>
  43. export default {
  44. props: {
  45. showPopu: {
  46. type: Boolean,
  47. default: false
  48. },
  49. payInfo: {
  50. type: Object,
  51. default: ()=>{
  52. return null
  53. }
  54. },
  55. cancelPayMessage: {
  56. type: String,
  57. default: '您的订单在30分钟内未支付将被取消,请尽快完成支付。'
  58. },
  59. closeCurPage:{
  60. type: Boolean,
  61. default: false
  62. }
  63. },
  64. data() {
  65. return {
  66. submitOk: false,
  67. showModal: this.showPopu
  68. }
  69. },
  70. watch: {
  71. showPopu(val){
  72. this.showModal = val
  73. if(val){
  74. this.submitOk = false
  75. }
  76. },
  77. showModal(val){
  78. if(!val){
  79. this.$emit('close', val)
  80. }
  81. }
  82. },
  83. methods: {
  84. beforeClose(){
  85. if(this.showModal){
  86. this.cancelPay()
  87. }
  88. },
  89. // 关闭确定订单弹窗后
  90. closePopu(){
  91. if(!this.showModal){
  92. if(this.closeCurPage){
  93. uni.navigateBack()
  94. }
  95. // 确认付款,去订单详情页
  96. if(this.submitOk){
  97. this.$emit('payComplete',this.payInfo, true)
  98. }else{
  99. this.$emit('payComplete',this.payInfo, false)
  100. }
  101. }
  102. this.showModal = false
  103. },
  104. // 确认取消付款弹框
  105. cancelPay(){
  106. const _this = this
  107. uni.showModal({
  108. title: '确定取消支付吗?',
  109. content: _this.cancelPayMessage,
  110. confirmText: '继续支付',
  111. cancelText: '取消支付',
  112. success(ret) {
  113. // 确定取消,跳转到订单详情页
  114. if(ret.cancel){
  115. if(_this.showModal){
  116. _this.showModal = false
  117. _this.submitOk = false
  118. }else{
  119. if(_this.closeCurPage){
  120. uni.navigateBack()
  121. }
  122. _this.$emit('payComplete',_this.payInfo, false)
  123. }
  124. }
  125. // 继续支付
  126. if(ret.confirm){
  127. // 继续支付
  128. if(!_this.showModal){
  129. _this.showModal = true
  130. _this.submitOk = false
  131. }
  132. }
  133. }
  134. })
  135. },
  136. // 确认付款
  137. confirmPay(){
  138. this.showModal = false
  139. this.submitOk = true
  140. },
  141. }
  142. }
  143. </script>
  144. <style lang="less">
  145. .popu-content{
  146. display: flex;
  147. flex-direction: column;
  148. align-items: center;
  149. padding: 10px 15px;
  150. .popu-close{
  151. padding: 10px;
  152. position: absolute;
  153. right: 0;
  154. top: 0;
  155. z-index: 1000;
  156. }
  157. .pupu-box-item,.pupu-box-pay-item{
  158. width: 100%;
  159. > view{
  160. padding: 10px 0;
  161. }
  162. }
  163. .pupu-box-pay-item{
  164. > view{
  165. padding: 6px 0;
  166. }
  167. .popu-content-amount{
  168. font-size: 24px;
  169. color: red;
  170. padding-top: 30px;
  171. }
  172. .popu-content-title{
  173. font-weight: bold;
  174. }
  175. }
  176. .popu-content-btn{
  177. width: 100%;
  178. display: flex;
  179. align-items: center;
  180. justify-content: space-around;
  181. margin: 20px 0 10px;
  182. .popu-content-btn-item{
  183. width: 30%;
  184. height: 34px;
  185. font-size: 14px;
  186. display: flex;
  187. align-items: center;
  188. justify-content: center;
  189. border-radius: 100px;
  190. }
  191. .cancelBtn{
  192. background-color: #f8f8f8;
  193. color: #666;
  194. }
  195. .okbtn{
  196. background-color: #f70000;
  197. color: #FFFFFF;
  198. width: 65%;
  199. .payAmount{
  200. margin-left: 5px;
  201. }
  202. }
  203. }
  204. }
  205. </style>