payModal.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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. payData: {
  56. type: Object,
  57. default: ()=>{
  58. return null
  59. }
  60. },
  61. cancelPayMessage: {
  62. type: String,
  63. default: '您的订单在30分钟内未支付将被取消,请尽快完成支付。'
  64. },
  65. closeCurPage:{
  66. type: Boolean,
  67. default: false
  68. }
  69. },
  70. data() {
  71. return {
  72. submitOk: false,
  73. showModal: this.showPopu
  74. }
  75. },
  76. watch: {
  77. showPopu(val){
  78. this.showModal = val
  79. if(val){
  80. this.submitOk = false
  81. }
  82. },
  83. showModal(val){
  84. if(!val){
  85. this.$emit('close', val)
  86. }
  87. }
  88. },
  89. methods: {
  90. beforeClose(){
  91. if(this.showModal){
  92. this.cancelPay()
  93. }
  94. },
  95. // 关闭确定订单弹窗后
  96. closePopu(){
  97. if(!this.showModal){
  98. if(this.closeCurPage){
  99. uni.navigateBack()
  100. }
  101. // 确认付款,去订单详情页
  102. if(this.submitOk){
  103. this.$emit('payComplete',this.payInfo, true)
  104. }else{
  105. this.$emit('payComplete',this.payInfo, false)
  106. }
  107. }
  108. this.showModal = false
  109. },
  110. // 确认取消付款弹框
  111. cancelPay(){
  112. const _this = this
  113. uni.showModal({
  114. title: '确定取消支付吗?',
  115. content: _this.cancelPayMessage,
  116. confirmText: '继续支付',
  117. cancelText: '取消支付',
  118. success(ret) {
  119. // 确定取消,跳转到订单详情页
  120. if(ret.cancel){
  121. if(_this.showModal){
  122. _this.showModal = false
  123. _this.submitOk = false
  124. }else{
  125. if(_this.closeCurPage){
  126. uni.navigateBack()
  127. }
  128. _this.$emit('payComplete',_this.payInfo, false)
  129. }
  130. }
  131. // 继续支付
  132. if(ret.confirm){
  133. // 继续支付
  134. if(!_this.showModal){
  135. _this.showModal = true
  136. _this.submitOk = false
  137. }
  138. }
  139. }
  140. })
  141. },
  142. // 确认付款
  143. confirmPay(){
  144. const _this = this
  145. // uni.showLoading({
  146. // title: '正在支付...',
  147. // mask: true
  148. // })
  149. // 确认付款
  150. const data = _this.payData
  151. uni.showToast({
  152. mask: true,
  153. title: data ? '支付成功' : '支付失败',
  154. icon: 'none'
  155. })
  156. _this.showModal = false
  157. _this.submitOk = data
  158. },
  159. }
  160. }
  161. </script>
  162. <style lang="less">
  163. .popu-content{
  164. display: flex;
  165. flex-direction: column;
  166. align-items: center;
  167. padding: 10px 15px;
  168. .popu-close{
  169. padding: 10px;
  170. position: absolute;
  171. right: 0;
  172. top: 0;
  173. z-index: 1000;
  174. }
  175. .pupu-box-item,.pupu-box-pay-item{
  176. width: 100%;
  177. > view{
  178. padding: 10px 0;
  179. }
  180. }
  181. .pupu-box-pay-item{
  182. > view{
  183. padding: 6px 0;
  184. }
  185. .popu-content-amount{
  186. font-size: 24px;
  187. color: red;
  188. padding-top: 30px;
  189. }
  190. .popu-content-title{
  191. font-weight: bold;
  192. }
  193. }
  194. .popu-content-btn{
  195. width: 100%;
  196. display: flex;
  197. align-items: center;
  198. justify-content: space-around;
  199. margin: 20px 0 10px;
  200. .popu-content-btn-item{
  201. width: 30%;
  202. height: 34px;
  203. font-size: 14px;
  204. display: flex;
  205. align-items: center;
  206. justify-content: center;
  207. border-radius: 100px;
  208. }
  209. .cancelBtn{
  210. background-color: #f8f8f8;
  211. color: #666;
  212. }
  213. .okbtn{
  214. background-color: #f70000;
  215. color: #FFFFFF;
  216. width: 65%;
  217. .payAmount{
  218. margin-left: 5px;
  219. }
  220. }
  221. }
  222. }
  223. </style>