BankPay.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <view :class="['qn-page-' + theme]">
  3. <u-navbar title="上传打款凭证" :custom-back="customBack"></u-navbar>
  4. <view class="money-view">
  5. <view class="num">
  6. <text class="icon">¥</text>
  7. {{ payAmount }}
  8. </view>
  9. <view class="label">订单金额</view>
  10. </view>
  11. <view class="bank-view">
  12. <u-form label-width="180">
  13. <u-form-item label="账户名称">
  14. <view class="form-item-in">
  15. <u-input @click="copyData(bank_data.name)" v-model="bank_data.name" disabled />
  16. <text class="copy-text">复制</text>
  17. </view>
  18. </u-form-item>
  19. <u-form-item label="开户行">
  20. <view class="form-item-in">
  21. <u-input @click="copyData(bank_data.bankName)" v-model="bank_data.bankName" disabled />
  22. <text class="copy-text">复制</text>
  23. </view>
  24. </u-form-item>
  25. <u-form-item label="开户人">
  26. <view class="form-item-in">
  27. <u-input @click="copyData(bank_data.bankAccount)" v-model="bank_data.bankAccount" disabled />
  28. <text class="copy-text">复制</text>
  29. </view>
  30. </u-form-item>
  31. <u-form-item label="银行账户">
  32. <view class="form-item-in">
  33. <u-input @click="copyData(bank_data.accountNumber)" v-model="bank_data.accountNumber"
  34. disabled />
  35. <text class="copy-text">复制</text>
  36. </view>
  37. </u-form-item>
  38. <u-form-item label="上传凭证">
  39. <QiniuUpload @uploadSuccess="uploadSuccess" :images="bank_data.image" @handleRemove="imgRemove">
  40. <!-- <div slot="cont">
  41. <view class="bank-license" v-for="item,index in bank_data.image" :key='index'>
  42. <block v-if="item">
  43. <img class="license-pic" :src="item" alt="" />
  44. <u-icon name="close" class='del-icon' size='30' @click.stop="handleRemove(item, index)">
  45. </u-icon>
  46. </block>
  47. </view>
  48. <view class="bank-license">
  49. <text>+</text>
  50. </view>
  51. </div> -->
  52. </QiniuUpload>
  53. </u-form-item>
  54. <u-form-item label="备注">
  55. <view class="form-item-in">
  56. <u-input v-model="bank_data.remark" disabled />
  57. </view>
  58. </u-form-item>
  59. </u-form>
  60. </view>
  61. <view class="confirm-btn primary-bg" @click="backConfirm">
  62. <u-loading v-if="loading" mode="circle"></u-loading>
  63. 确定
  64. </view>
  65. </view>
  66. </template>
  67. <script>
  68. import QiniuUpload from '../components/qiniu/QiniuUpload.vue';
  69. export default {
  70. components: {
  71. QiniuUpload
  72. },
  73. data() {
  74. return {
  75. loading: false,
  76. bank_data: {
  77. // 银行信息
  78. id: '',
  79. name: '',
  80. image: [],
  81. bankName: '',
  82. accountNumber: ''
  83. },
  84. payAmount: 0,
  85. orderId: 0,
  86. tmplIds: []
  87. };
  88. },
  89. onLoad(options) {
  90. this.payAmount = options.payAmount || '0.00';
  91. if (Array.isArray(options.orderId)) {
  92. this.orderId = options.orderId;
  93. } else {
  94. this.orderId = [options.orderId];
  95. }
  96. this.getPaymentType();
  97. // 获取订阅消息模版
  98. // #ifdef MP-WEIXIN
  99. this.getSettingDataByMessageId()
  100. // #endif
  101. },
  102. methods: {
  103. // 复制到剪贴板
  104. copyData(data) {
  105. uni.setClipboardData({
  106. data: data,
  107. success: () => {
  108. this.$u.toast('已复制到剪贴板');
  109. }
  110. });
  111. },
  112. // 上传银行凭证
  113. uploadSuccess(imgData, uploadPicUrl) {
  114. this.bank_data.image.push(uploadPicUrl);
  115. },
  116. // 确定 订阅消息
  117. backConfirm() {
  118. // #ifdef MP-WEIXIN
  119. console.log(this.tmplIds)
  120. if (this.tmplIds.length) {
  121. uni.requestSubscribeMessage({
  122. tmplIds: this.tmplIds,
  123. success: res => {
  124. this.addOrderBankData();
  125. },
  126. fail: res => {
  127. this.addOrderBankData();
  128. }
  129. });
  130. } else {
  131. this.addOrderBankData();
  132. }
  133. // #endif
  134. // #ifdef APP-PLUS
  135. this.addOrderBankData();
  136. // #endif
  137. },
  138. // 确定
  139. addOrderBankData() {
  140. if (this.loading) {
  141. return;
  142. }
  143. if (!this.bank_data.image && !this.bank_data.image.length) {
  144. this.$u.toast('请上传打款凭证');
  145. return;
  146. }
  147. this.loading = true;
  148. this.$u.api
  149. .addOrderBankData({
  150. orderId: this.orderId,
  151. bankData: this.bank_data
  152. })
  153. .then(res => {
  154. this.loading = false;
  155. this.$u.toast('操作成功');
  156. setTimeout(res => {
  157. this.customBack();
  158. }, 1500);
  159. })
  160. .catch(err => {
  161. this.loading = false;
  162. });
  163. },
  164. customBack() {
  165. uni.redirectTo({
  166. url: '/pagesT/order/order?state=0'
  167. });
  168. },
  169. getPaymentType() {
  170. this.$u.api.getPaymentType().then(res => {
  171. const bankType = res.data.find(item => item.id === 4);
  172. if (bankType) {
  173. const accountData = bankType.accountData;
  174. this.bank_data = {
  175. id: accountData.id,
  176. name: accountData.name,
  177. image: [],
  178. bankName: accountData.bankName,
  179. accountNumber: accountData.accountNumber,
  180. bankAccount: accountData.bankAccount,
  181. remark: accountData.remark,
  182. };
  183. }
  184. });
  185. },
  186. // 获取消息模版ID
  187. getSettingDataByMessageId() {
  188. this.$u.api
  189. .getSettingDataByMessageId({
  190. id: [4]
  191. })
  192. .then(res => {
  193. if (res.data.length > 0) {
  194. this.tmplIds = res.data.map(item => {
  195. return item.weixinTemplateId;
  196. });
  197. }
  198. });
  199. },
  200. //移除图片
  201. // handleRemove(url, index) {
  202. // this.bank_data.image.splice(index, 1);
  203. // }
  204. imgRemove(arr) {
  205. this.bank_data.image = arr;
  206. }
  207. }
  208. };
  209. </script>
  210. <style scoped lang="scss">
  211. .bank-view {
  212. background-color: #ffffff;
  213. padding: 0 30rpx;
  214. width: 700rpx;
  215. margin: 0 auto;
  216. border-radius: 16rpx;
  217. .form-item-in {
  218. position: relative;
  219. .copy-text {
  220. position: absolute;
  221. right: 20rpx;
  222. display: block;
  223. top: 50%;
  224. transform: translateY(-50%);
  225. color: #999999;
  226. font-size: 24rpx;
  227. }
  228. }
  229. .bank-license {
  230. width: 124upx;
  231. height: 124upx;
  232. border-radius: 8upx;
  233. border: 2upx #999999 dashed;
  234. margin: 32upx 10rpx;
  235. background: #eee;
  236. text-align: center;
  237. line-height: 100upx;
  238. color: #666;
  239. font-size: 100rpx;
  240. font-weight: 300;
  241. display: inline-block;
  242. vertical-align: middle;
  243. position: relative;
  244. .del-icon {
  245. box-sizing: border-box;
  246. padding-left: 7rpx;
  247. position: absolute;
  248. color: #fff;
  249. right: -12rpx;
  250. top: -20upx;
  251. background-color: #FD463E;
  252. width: 40rpx;
  253. height: 40rpx;
  254. border-radius: 100%;
  255. line-height: 40rpx;
  256. }
  257. }
  258. .license-pic {
  259. width: 120upx;
  260. height: 120upx;
  261. display: block;
  262. }
  263. }
  264. .confirm-btn {
  265. color: #ffffff;
  266. line-height: 90rpx;
  267. text-align: center;
  268. position: fixed;
  269. bottom: 0;
  270. width: 100%;
  271. left: 0;
  272. }
  273. .money-view {
  274. padding: 60rpx 0;
  275. text-align: center;
  276. .num {
  277. font-family: DIN-Medium;
  278. font-weight: bold;
  279. font-size: 64rpx;
  280. .icon {
  281. font-size: 40rpx;
  282. }
  283. }
  284. .label {
  285. color: #6c6c6c;
  286. font-size: 24rpx;
  287. padding-top: 20rpx;
  288. }
  289. }
  290. </style>