bind-pay.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <v-page>
  3. <v-header :title="$t('otc.j6')"></v-header>
  4. <view class="layout-main">
  5. <template v-if="query.type=='alipay'">
  6. <view class="m-md p-md rounded-sm bg-panel-3 box-shadow">
  7. <view class="form-item m-b-sm">
  8. <view class="label">{{$t('otc.d7')}}</view>
  9. <v-input
  10. :placeholder="$t('otc.d8')"
  11. class="p-xs rounded-xs bg-panel-1 box-shadow m-t-xs"
  12. type="text"
  13. v-model="alipay.card_no"
  14. ></v-input>
  15. </view>
  16. <view class="form-item m-b-sm">
  17. <view class="label">{{$t('otc.d9')}}</view>
  18. <v-input
  19. :placeholder="$t('otc.e0')"
  20. class="p-xs rounded-xs bg-panel-1 box-shadow m-t-xs"
  21. type="text"
  22. v-model="alipay.real_name"
  23. ></v-input>
  24. </view>
  25. <view class="form-item m-b-sm">
  26. <view class="label">{{$t('otc.e1')}}</view>
  27. <view @click="getFile(alipay)" class="upload-box d-flex justify-center align-center rounded-sm bg-panel-1 box-shadow m-t-xs box-shadow w-100 h-100">
  28. <van-icon v-if="!alipay.code_img" class="color-light fn-30" name="photograph" />
  29. <img class="w-max h-max" v-else :src="$imgUrl+'/'+alipay.code_img" alt />
  30. </view>
  31. </view>
  32. </view>
  33. <view class="m-md">
  34. <v-button type="green" block class="rounded-lg" @click="add(alipay)">
  35. {{$t('otc.e2')}}
  36. </v-button>
  37. </view>
  38. </template>
  39. <template v-if="query.type=='wechat'">
  40. <view class="m-md p-md rounded-sm bg-panel-3">
  41. <view class="form-item m-b-sm">
  42. <view class="label">{{$t('otc.e3')}}</view>
  43. <v-input
  44. :placeholder="$t('otc.d8')"
  45. class="p-xs rounded-xs bg-panel-1 box-shadow m-t-xs"
  46. type="text"
  47. v-model="wechat.card_no"
  48. ></v-input>
  49. </view>
  50. <view class="form-item m-b-sm">
  51. <view class="label">{{$t('otc.d9')}}</view>
  52. <v-input
  53. :placeholder="$t('otc.e0')"
  54. class="p-xs rounded-xs bg-panel-1 box-shadow m-t-xs"
  55. type="text"
  56. v-model="wechat.real_name"
  57. ></v-input>
  58. </view>
  59. <view class="form-item m-b-sm">
  60. <view class="label">{{$t('otc.e1')}}</view>
  61. <view @click="getFile(wechat)" class="upload-box d-flex justify-center align-center rounded-sm bg-panel-1 box-shadow m-t-xs box-shadow w-100 h-100">
  62. <van-icon v-if="!wechat.code_img" class="color-light fn-30" name="photograph" />
  63. <img class="w-max h-max" v-else :src="$imgUrl+'/'+wechat.code_img" alt />
  64. </view>
  65. </view>
  66. </view>
  67. <view class="m-md">
  68. <v-button type="green" block class="rounded-lg" @click="add(wechat)">
  69. {{$t('otc.e2')}}
  70. </v-button>
  71. </view>
  72. </template>
  73. <template v-if="query.type=='bank_card'">
  74. <view class="m-md p-md rounded-sm bg-panel-3">
  75. <view class="form-item m-b-sm">
  76. <view class="label">{{$t('otc.e4')}}</view>
  77. <v-input
  78. :placeholder="$t('otc.e9')"
  79. class="p-xs rounded-xs bg-panel-1 box-shadow m-t-xs"
  80. type="text"
  81. v-model="bank_card.bank_name"
  82. ></v-input>
  83. </view>
  84. <view class="form-item m-b-sm">
  85. <view class="label">{{$t('otc.e6')}}</view>
  86. <v-input
  87. :placeholder="$t('otc.e7')"
  88. class="p-xs rounded-xs bg-panel-1 box-shadow m-t-xs"
  89. type="text"
  90. v-model="bank_card.open_bank"
  91. ></v-input>
  92. </view>
  93. <view class="form-item m-b-sm">
  94. <view class="label">{{$t('otc.e8')}}</view>
  95. <v-input
  96. :placeholder="$t('otc.e9')"
  97. class="p-xs rounded-xs bg-panel-1 box-shadow m-t-xs"
  98. type="text"
  99. v-model="bank_card.card_no"
  100. ></v-input>
  101. </view>
  102. <view class="form-item m-b-sm">
  103. <view class="label">{{$t('otc.d9')}}</view>
  104. <v-input
  105. :placeholder="$t('otc.e0')"
  106. class="p-xs rounded-xs bg-panel-1 box-shadow m-t-xs"
  107. type="text"
  108. v-model="bank_card.real_name"
  109. ></v-input>
  110. </view>
  111. </view>
  112. <view class="m-md">
  113. <v-button type="green" block class="rounded-lg" @click="add(bank_card)">
  114. {{$t('otc.e2')}}
  115. </v-button>
  116. </view>
  117. </template>
  118. </view>
  119. </v-page>
  120. </template>
  121. <script>
  122. import Otc from "@/api/otc";
  123. import Member from "@/api/member";
  124. export default {
  125. name:"bindPay",
  126. data(){
  127. return {
  128. query:{},
  129. alipay: {
  130. pay_type: "alipay",
  131. real_name: "",
  132. card_no: "",
  133. code_img: "",
  134. },
  135. bank_card: {
  136. pay_type: "bank_card",
  137. real_name: "",
  138. card_no: "",
  139. bank_name: "",
  140. open_bank: "",
  141. },
  142. wechat: {
  143. pay_type: "wechat",
  144. real_name: "",
  145. card_no: "",
  146. code_img: "",
  147. },
  148. }
  149. },
  150. onLoad(query) {
  151. this.query = query
  152. console.log(this.query)
  153. this.getList();
  154. },
  155. methods: {
  156. getList() {
  157. Otc.userPayment().then((res) => {
  158. this.alipay = res.data.alipay || this.alipay;
  159. this.bank_card = res.data.bank_card || this.bank_card;
  160. this.wechat = res.data.wechat || this.wechat;
  161. });
  162. },
  163. add(obj) {
  164. let data = {
  165. ...obj,
  166. };
  167. for (let i in data) {
  168. if (data[i] == null) delete data[i];
  169. }
  170. if (data.id) {
  171. data._method = "put";
  172. Otc.editUserPayment(data).then(() => {
  173. this.$toast.success(this.$t('otc.f0'));
  174. this.$back()
  175. });
  176. } else {
  177. Otc.addUserPayment(data).then((res) => {
  178. this.$toast.success(this.$t('otc.f1'));
  179. this.$back()
  180. });
  181. }
  182. },
  183. // 上传图片
  184. getFile(obj) {
  185. this.$getFile({ count: 1 }).then((res) => {
  186. this.upLoadImg(res,obj);
  187. });
  188. },
  189. // 上传图片
  190. upLoadImg(chooseImageRes,obj) {
  191. Member.uploadImage(chooseImageRes).then((res) => {
  192. obj.code_img = res.data.path;
  193. this.$toast.success(this.$t("auth.c1"));
  194. });
  195. },
  196. },
  197. };
  198. </script>