payment-code.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <app-layout>
  3. <view v-if="edit" class="back-t">
  4. <view class="code-box set">
  5. <view style="text-align: left;">收款金额</view>
  6. <view class="dir-left-nowrap cross-center code-input">
  7. <view>¥</view>
  8. <input v-model="tmp_price" type="digit"/>
  9. </view>
  10. <view class="set-line"></view>
  11. <view @click="submit" class="btn main-center cross-center">确认</view>
  12. </view>
  13. </view>
  14. <view v-else class="back-o">
  15. <view class="code-box dir-top-nowrap main-center cross-center">
  16. <view class="box-grow-0 code-title">扫描二维码,向我付钱</view>
  17. <view v-if="price > 0" class="price">¥{{price}}</view>
  18. <image @click="qrcodeClick" class="box-grow-0" :src="pic_url"></image>
  19. <view class="dir-left-nowrap cross-center end">
  20. <view @click="savePrice">设置金额</view>
  21. <view class="line"></view>
  22. <view @click="saveQrcode">保存图片</view>
  23. </view>
  24. </view>
  25. </view>
  26. </app-layout>
  27. </template>
  28. <script>
  29. export default {
  30. name: "payment-code",
  31. components: {},
  32. data() {
  33. return {
  34. edit: false,
  35. pic_url: '',
  36. save_loading: false,
  37. price: '',
  38. tmp_price: '',
  39. is_clerk_enter: 0
  40. }
  41. },
  42. onLoad(options) { this.$commonLoad.onload(options);
  43. this.is_clerk_enter = options.is_clerk_enter ? 1 : 0;
  44. this.submit();
  45. },
  46. methods: {
  47. savePrice: function () {
  48. this.edit = true;
  49. },
  50. submit: function () {
  51. const tmp_price = this.tmp_price ? parseFloat(this.tmp_price).toFixed(2) : '';
  52. this.$showLoading({text: `生成中`});
  53. this.$request({
  54. url: this.$api.scan_code_pay.qr_code,
  55. method: 'POST',
  56. data: {
  57. price: tmp_price,
  58. is_clerk_enter: this.is_clerk_enter
  59. }
  60. }).then(info => {
  61. this.$hideLoading();
  62. if (info.code === 0) {
  63. [
  64. this.pic_url,
  65. this.price,
  66. this.tmp_price,
  67. this.edit
  68. ] = [
  69. info.data.qr_code.file_path,
  70. tmp_price,
  71. tmp_price,
  72. false
  73. ]
  74. } else {
  75. uni.showToast({icon: 'none', title: info.msg});
  76. }
  77. }).catch(() => {
  78. this.$hideLoading();
  79. });
  80. },
  81. //预览
  82. qrcodeClick: function () {
  83. uni.previewImage({
  84. urls: [this.pic_url],
  85. });
  86. },
  87. //保存
  88. saveQrcode: function () {
  89. const self = this;
  90. uni.showLoading({mask: true,title: `图片保存中`});
  91. self.$utils.batchSave(self.pic_url, 'image').then(result => {
  92. uni.showToast({title: '保存成功'});
  93. });
  94. },
  95. }
  96. }
  97. </script>
  98. <style scoped lang="scss">
  99. .back-o {
  100. background: #fb8a36;
  101. height: 100vh;
  102. padding-top: #{32rpx};
  103. }
  104. .back-t {
  105. width: 100%;
  106. height: 100%;
  107. padding-top: #{32rpx};
  108. }
  109. .code-box {
  110. text-align: center;
  111. background: #fff;
  112. margin: 0 auto;
  113. width: #{686rpx};
  114. border-radius: #{16rpx};
  115. }
  116. .code-box.set {
  117. padding: #{48rpx};
  118. color: #353535;
  119. }
  120. .set .receipt {
  121. font-size: #{68rpx};
  122. }
  123. .code-box .btn {
  124. color: #fff;
  125. height: #{88rpx};
  126. background: #ff4544;
  127. font-size: #{32rpx};
  128. margin-top: #{48rpx};
  129. border-radius: #{44rpx};
  130. }
  131. .code-box image {
  132. width: #{360rpx};
  133. height: #{360rpx};
  134. }
  135. .code-box .code-title {
  136. color: #353535;
  137. font-size: #{36rpx};
  138. margin-top: #{120rpx};
  139. margin-bottom: #{64rpx};
  140. }
  141. .code-box .end {
  142. color: #418bfb;
  143. font-size: #{32rpx};
  144. margin-top: #{80rpx};
  145. margin-bottom: #{100rpx};
  146. }
  147. .code-box .line {
  148. height: #{32rpx};
  149. background: #418bfb;
  150. width: 1px;
  151. margin: 0 #{60rpx};
  152. }
  153. .code-box .set-line {
  154. width: 100%;
  155. height: 1px;
  156. background: #e2e2e2;
  157. margin-top: #{40rpx};
  158. }
  159. .code-box .price {
  160. font-size: #{56rpx};
  161. color: #353535;
  162. margin-bottom: #{40rpx};
  163. }
  164. .code-input {
  165. font-size: #{68rpx};
  166. margin-top: #{40rpx};
  167. }
  168. .code-input > view {
  169. padding-right: #{22rpx};
  170. }
  171. .code-input input {
  172. height: #{100rpx};
  173. text-align: left;
  174. }
  175. </style>