addCash.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <template>
  2. <view class="home">
  3. <view class="putWarp dffd">
  4. <block v-if="type == 1">
  5. <view class="title">{{ edit ? '编辑支付宝' : '添加支付宝' }}</view>
  6. <view class="subtit fontmid textgrey">请绑定本人的支付宝账号</view>
  7. <view class="putin dffs bb">
  8. <text class="fontmid">实名姓名</text>
  9. <input @confirm="clickHandle" type="text" v-model="name" placeholder="" />
  10. </view>
  11. <view class="putin dffs bb">
  12. <text class="fontmid">支付宝账号</text>
  13. <input @confirm="clickHandle" type="text" v-model="num" placeholder="" />
  14. </view>
  15. </block>
  16. <block v-if="type == 2">
  17. <view class="title">添加银行卡</view>
  18. <view class="subtit fontmid textgrey">请绑定本人的银行卡账号</view>
  19. <view class="putin dffs bb">
  20. <text class="fontmid">持卡人</text>
  21. <input @confirm="clickHandle" type="text" v-model="idname" placeholder="" />
  22. </view>
  23. <view class="putin dffs bb">
  24. <text class="fontmid">卡号</text>
  25. <input @confirm="clickHandle" type="text" v-model="idcode" placeholder="" />
  26. </view>
  27. <view class="putin dffs bb">
  28. <text class="fontmid">所属银行</text>
  29. <input @confirm="clickHandle" type="text" v-model="bank" placeholder="" />
  30. </view>
  31. </block>
  32. <view class="putin dffs bb">
  33. <text class="fontmid">绑定手机号</text>
  34. <input @confirm="clickHandle" type="text" v-model="phone" placeholder="" />
  35. </view>
  36. <view class="putin dffs bb">
  37. <text class="fontmid">验证码</text>
  38. <view class="dfsb">
  39. <input type="text" v-model="code" placeholder="" />
  40. <verif class="yzBox" :flag="3" :phone="phone"></verif>
  41. </view>
  42. </view>
  43. <block v-if="type == 1">
  44. <view @tap="choose" class="putin spec dffd">
  45. <view class="fontmid">收款码</view>
  46. <view v-if="img" class="pre-item dffs"><image class="pre-item-image" :src="img_name" mode="widthFix"></image></view>
  47. <view v-if="!img" class="imgBox dffd"><u-icon name="camera-fill" size="84" color="#999"></u-icon></view>
  48. </view>
  49. </block>
  50. <view @tap="clickHandle" class="clickbtn">{{ edit ? '确认修改' : '确认添加' }}</view>
  51. <view class="fontsm textgrey dffs">
  52. 点击确认即视为同意
  53. <navigator url="/pages/user/mine/service?type=2" class="fontsm prosecond">《用户隐私协议》</navigator>
  54. </view>
  55. </view>
  56. </view>
  57. </template>
  58. <script>
  59. import { pathToBase64 } from '@/common/tool/pathToBase64.js';
  60. var _this;
  61. import verif from '@/components/comPage/verif.vue';
  62. export default {
  63. components: {
  64. verif
  65. },
  66. data() {
  67. return {
  68. edit: false, //支付宝已经存在 为true
  69. type: '', //1支付宝 2 银行卡
  70. name: '',
  71. num: '',
  72. phone: '',
  73. img: '',
  74. img_name: '',
  75. idname: '',
  76. idcode: '',
  77. bank: '',
  78. code: ''
  79. };
  80. },
  81. onLoad(opt) {
  82. this.type = opt.type || '1';
  83. if (this.type == 1) {
  84. this.getList();
  85. }
  86. },
  87. methods: {
  88. getList() {
  89. this.$api.request('bank/withdrawAccount', { identify: 1 }).then(data => {
  90. if (data.code == 200) {
  91. let arr = data.data;
  92. if (arr.length > 0) {
  93. arr.forEach(item => {
  94. if (item.type == 2&&item.account) {
  95. this.name = item.name;
  96. this.num = item.account;
  97. this.edit = true;
  98. }
  99. });
  100. }
  101. } else {
  102. this.$api.toast(data.msg);
  103. }
  104. });
  105. },
  106. choose() {
  107. let that = this;
  108. uni.chooseImage({
  109. count: 1, //默认9
  110. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  111. success: function(res) {
  112. var imageSrc = res.tempFilePaths[0];
  113. pathToBase64(imageSrc).then(base64 => {
  114. that.$api
  115. .request('common/doupload', {
  116. imgdata: base64
  117. })
  118. .then(res => {
  119. that.img_name = res.data.imgurl;
  120. that.img = res.data.img_id;
  121. });
  122. });
  123. }
  124. });
  125. },
  126. clickHandle() {
  127. if (this.type == 1) {
  128. if (!this.name) {
  129. return this.$api.toast('请输入用户名');
  130. }
  131. if (!this.num) {
  132. return this.$api.toast('请输入账号');
  133. }
  134. if (!this.img) {
  135. return this.$api.toast('请上传收款码');
  136. }
  137. } else {
  138. if (!this.idname) {
  139. return this.$api.toast('请输入持卡人');
  140. }
  141. if (!this.idcode) {
  142. return this.$api.toast('请输入卡号');
  143. }
  144. if (!this.bank) {
  145. return this.$api.toast('请输入银行名称');
  146. }
  147. }
  148. let phoneReg = /^(1[3-9])\d{9}$/;
  149. if (!phoneReg.test(this.phone)) {
  150. return this.$api.toast('手机号码不合法!');
  151. }
  152. if (!this.code) {
  153. return this.$api.toast('请输入验证码');
  154. }
  155. let url = this.type == 1 ? (this.edit ? 'bank/changeAccount' : 'bank/account') : 'bank/add';
  156. this.$api
  157. .request(url, {
  158. name: this.type == 1 ? this.name : this.idname,
  159. account: this.num,
  160. mobile: this.phone,
  161. code: this.code,
  162. img: this.img,
  163. bank_name: this.bank,
  164. bank_number: this.idcode,
  165. type: 1
  166. })
  167. .then(data => {
  168. console.log(data);
  169. if (data.code == 200) {
  170. this.$api.toast(data.msg);
  171. setTimeout(res => {
  172. uni.navigateBack({
  173. delta: 1
  174. });
  175. }, 800);
  176. } else {
  177. this.$api.toast(data.msg);
  178. }
  179. });
  180. }
  181. }
  182. };
  183. </script>
  184. <style lang="scss">
  185. .home {
  186. min-height: 100vh;
  187. background-color: #fff;
  188. .pageImg {
  189. image {
  190. margin: 80rpx auto 80rpx;
  191. width: 160rpx;
  192. height: 160rpx;
  193. }
  194. }
  195. .putWarp {
  196. background-color: #fff;
  197. padding: 61rpx 0rpx 0;
  198. align-items: center;
  199. .title {
  200. margin-bottom: 21rpx;
  201. font-size: 42rpx;
  202. font-family: PingFang SC;
  203. font-weight: 500;
  204. line-height: 59rpx;
  205. color: #333333;
  206. }
  207. .putin {
  208. width: 100%;
  209. font-size: 32rpx;
  210. padding: 7rpx 43rpx 0rpx;
  211. border-radius: 8rpx;
  212. border-bottom: 1rpx solid #f5f5f5;
  213. input {
  214. border-radius: 8rpx;
  215. flex: 1;
  216. height: 110rpx;
  217. font-size: $font-mid;
  218. }
  219. .fontmid {
  220. width: 210rpx;
  221. }
  222. }
  223. .spec {
  224. padding: 30rpx 43rpx;
  225. .fontmid {
  226. margin-bottom: 30rpx;
  227. }
  228. .imgBox {
  229. border: 1px solid #f3f3f3;
  230. justify-content: center;
  231. align-items: center;
  232. width: 400rpx;
  233. height: 240rpx;
  234. padding: 40rpx;
  235. margin: 0 auto;
  236. }
  237. .pre-item {
  238. margin: 0 auto;
  239. width: 420rpx;
  240. // height: 420rpx;
  241. position: relative;
  242. }
  243. .pre-item-image {
  244. width: 100%;
  245. }
  246. .u-delete-icon {
  247. position: absolute;
  248. top: -10rpx;
  249. right: -10rpx;
  250. z-index: 10;
  251. background-color: #333;
  252. border-radius: 100rpx;
  253. width: 40rpx;
  254. height: 40rpx;
  255. }
  256. }
  257. .yzBox {
  258. margin-left: 30rpx;
  259. border-radius: 8rpx;
  260. }
  261. .xyTips {
  262. width: 100%;
  263. font-size: 28rpx;
  264. color: #999;
  265. }
  266. }
  267. .clickbtn {
  268. margin-top: 106rpx;
  269. border-radius: 45rpx;
  270. }
  271. }
  272. </style>