addWithdrawalAccount.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <template>
  2. <view class="addWithdrawalAccount">
  3. <u--form :model="form" :rules="rules" ref="uForm" labelWidth="90" errorType="toast">
  4. <u-form-item label="开户名称" prop="bank_user">
  5. <u-input v-model="form.bank_user" placeholder="请输入" type="text" border="none"
  6. customStyle="text-align: right;" />
  7. </u-form-item>
  8. <u-form-item label="开户银行" prop="bank_wseq" @click="show = true">
  9. <view class="bank-text-wrap">
  10. <text :class="['bank-text', { isPlaceholder: !form.bank_wseq }]">{{
  11. form.bank_name || "下拉选择银行/支付宝"
  12. }}</text>
  13. <u-icon name="arrow-down"></u-icon>
  14. </view>
  15. </u-form-item>
  16. <u-form-item label="账号" prop="bank_code">
  17. <u-input type="number" placeholder="请输入" v-model="form.bank_code" border="none"
  18. customStyle="text-align: right;" />
  19. </u-form-item>
  20. </u--form>
  21. <view class="submit-btn" @click="submit" type="warning">提交</view>
  22. <view class="agree-box">
  23. <view class="unchecked-tips" v-show="showUnchecked">请先阅读并同意协议</view>
  24. <u-checkbox-group @change="termsChange" v-model="termsChecked">
  25. <u-checkbox name="term" shape="circle" size="36rpx"></u-checkbox>
  26. </u-checkbox-group>
  27. <text class="item-text">
  28. 已阅读并同意
  29. <text class="text-primary fs14 fw600" @click="checkPrimary('2')">《隐私保护协议》</text>
  30. <text class="text-primary fs14 fw600" @click="checkPrimary('1')">《用户协议》</text>
  31. </text>
  32. </view>
  33. <u-popup class="select-banks-popup" :show="show" mode="bottom" @close="close" :customStyle="{
  34. maxHeight: '68vh',
  35. padding: '0 20rpx',
  36. 'overflow-y': 'auto',
  37. }">
  38. <view class="select-banks-title">
  39. <text>选择银行</text>
  40. <u-icon name="close" @click="close"></u-icon>
  41. </view>
  42. <view v-for="b in banksList" :key="b.id" class="select-banks-item" :style="{ backgroundColor: b.bank_bg }"
  43. @click="handleBank(b)">
  44. <view class="left">
  45. <u--image v-if="b.bank_logo" width="60rpx" height="60rpx" radius="100%" shape="circle"
  46. customStyle="border-radius:100%;" :src="b.bank_logo" :fade="true" duration="450"></u--image>
  47. <view class="name">{{ b.bank_name }}</view>
  48. </view>
  49. <u-icon name="arrow-right"></u-icon>
  50. </view>
  51. </u-popup>
  52. </view>
  53. </template>
  54. <script>
  55. import { getBanksList, addBanks } from "@/common/api/withdrawal";
  56. export default {
  57. data() {
  58. return {
  59. banksList: [],
  60. show: false,
  61. showUnchecked: false,
  62. termsChecked: false,
  63. form: {
  64. bank_user: "",
  65. bank_code: "",
  66. bank_wseq: "",
  67. bank_name: "",
  68. },
  69. rules: {
  70. bank_user: [{
  71. required: true,
  72. message: "请输入开户名称",
  73. }, ],
  74. bank_wseq: [{
  75. required: true,
  76. message: "请选择开户银行",
  77. }, ],
  78. bank_code: [{
  79. required: true,
  80. message: "请输入账号",
  81. }, ],
  82. },
  83. };
  84. },
  85. onShow() {
  86. this.getBanksList();
  87. },
  88. methods: {
  89. termsChange(value) {
  90. if (value.length) {
  91. this.showUnchecked = false;
  92. } else {
  93. this.showUnchecked = true;
  94. }
  95. },
  96. checkPrimary(name) {
  97. uni.navigateTo({
  98. url: '/pages/singlePage/index?name=' + name
  99. });
  100. },
  101. getBanksList() {
  102. getBanksList().then(({ data = [] }) => {
  103. console.log("data=>", data);
  104. this.banksList = data;
  105. });
  106. },
  107. close() {
  108. this.show = false;
  109. },
  110. handleBank(b) {
  111. this.form.bank_name = b.bank_name;
  112. this.form.bank_wseq = b.bank_wseq;
  113. this.close();
  114. },
  115. submit() {
  116. if (!this.termsChecked.length) {
  117. this.showUnchecked = true;
  118. return;
  119. }
  120. this.$refs.uForm
  121. .validate()
  122. .then(() => {
  123. addBanks({
  124. bank_wseq: this.form.bank_wseq,
  125. bank_user: this.form.bank_user,
  126. bank_code: this.form.bank_code,
  127. status: 1,
  128. }).then(({ data }) => {
  129. console.log("data=>", data);
  130. uni.$u.toast("添加成功");
  131. uni.navigateBack();
  132. });
  133. })
  134. .catch((errors) => {
  135. const firstError = errors[0];
  136. console.log("errors=>", errors);
  137. uni.$u.toast(firstError.message);
  138. });
  139. },
  140. },
  141. };
  142. </script>
  143. <style lang="scss" scoped>
  144. .addWithdrawalAccount {
  145. padding: 20rpx 20rpx 40rpx;
  146. ::v-deep {
  147. .u-form-item {
  148. justify-content: center;
  149. margin-bottom: 20rpx;
  150. padding: 0 30rpx 0 25rpx;
  151. background-color: #fff;
  152. border-radius: 10rpx;
  153. min-height: 112rpx;
  154. .u-form-item__body__left__content__label {
  155. font-size: 32rpx;
  156. font-weight: 500;
  157. color: #232323;
  158. line-height: 1;
  159. }
  160. .u-border {
  161. border: none;
  162. }
  163. .uni-input-wrapper {
  164. text-align: right;
  165. }
  166. }
  167. }
  168. .agree-box {
  169. display: flex;
  170. color: $gray-1;
  171. position: relative;
  172. align-items: center;
  173. margin: 20rpx 30rpx;
  174. .unchecked-tips {
  175. position: absolute;
  176. height: 50rpx;
  177. color: #fff;
  178. background-color: rgba($color: #27282a, $alpha: 1);
  179. top: -60rpx;
  180. left: 0;
  181. border-radius: 8rpx;
  182. line-height: 50rpx;
  183. font-size: 24rpx;
  184. padding: 0 16rpx;
  185. &::after {
  186. display: "block";
  187. content: "";
  188. position: absolute;
  189. width: 20rpx;
  190. height: 20rpx;
  191. // background: rgba($color: #27282a, $alpha: 1);
  192. bottom: -6rpx;
  193. left: 10rpx;
  194. transform: rotate(45deg);
  195. border-radius: 4rpx;
  196. }
  197. }
  198. }
  199. .bank-text-wrap {
  200. display: flex;
  201. width: 100%;
  202. align-items: center;
  203. justify-content: flex-end;
  204. .bank-text {
  205. margin-right: 10rpx;
  206. &.isPlaceholder {
  207. color: #c0c4cc;
  208. }
  209. }
  210. }
  211. .submit-btn {
  212. display: flex;
  213. justify-content: center;
  214. align-items: center;
  215. width: 100%;
  216. height: 84rpx;
  217. margin-top: 40rpx;
  218. background: #f39800;
  219. border-radius: 39rpx;
  220. font-size: 32rpx;
  221. font-weight: 500;
  222. color: #ffffff;
  223. line-height: 1;
  224. }
  225. }
  226. .select-banks-popup {
  227. padding: 0 30rpx;
  228. }
  229. .select-banks-title {
  230. display: flex;
  231. justify-content: space-between;
  232. align-items: center;
  233. font-size: 32rpx;
  234. font-family: PingFangSC-Medium, PingFang SC;
  235. font-weight: 500;
  236. color: #1d161f;
  237. height: 100rpx;
  238. flex-shrink: 0;
  239. }
  240. .select-banks-item {
  241. display: flex;
  242. justify-content: space-between;
  243. height: 80rpx;
  244. padding: 25rpx 20rpx;
  245. margin-bottom: 15rpx;
  246. background-color: #f5f6f8;
  247. border-radius: 10rpx;
  248. .left {
  249. display: flex;
  250. align-items: center;
  251. align-items: center;
  252. }
  253. .name {
  254. margin-left: 23rpx;
  255. font-size: 32rpx;
  256. font-weight: bold;
  257. color: #1d161f;
  258. line-height: 1;
  259. }
  260. }
  261. </style>