sqdl.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. <template>
  2. <view class="content">
  3. <view class="flex nav-list">
  4. <view class="item" v-for="(item,index) in navList" :class="{'action': current == index}"
  5. @click="changeNavT(index)">
  6. {{item.tit}}
  7. </view>
  8. </view>
  9. <view class="" style="height: 20rpx;">
  10. </view>
  11. <view class="tab">
  12. <template v-if="current == 0">
  13. <view class="bd-wrap flex">
  14. <view class="bg-name">
  15. 真实姓名:
  16. </view>
  17. <view class="bg-val">
  18. <input type="text" value="" placeholder="请输入真实姓名" class="val-ipt" v-model="bankInfo.fullname"
  19. ref="name" />
  20. </view>
  21. </view>
  22. <view class="bd-wrap flex">
  23. <view class="bg-name">
  24. 银行卡号:
  25. </view>
  26. <view class="bg-val">
  27. <input type="text" value="" placeholder="请输入银行卡号" class="val-ipt" v-model="bankInfo.bankno"
  28. ref="address" />
  29. </view>
  30. </view>
  31. <view class="bd-wrap flex">
  32. <view class="bg-name">
  33. 开户行:
  34. </view>
  35. <view class="bg-val">
  36. <input type="text" value="" placeholder="请输入开户行" class="val-ipt" v-model="bankInfo.bank"
  37. ref="storenamae" />
  38. </view>
  39. </view>
  40. <view class="bd-wrap flex">
  41. <view class="bg-name">
  42. 所属支行:
  43. </view>
  44. <view class="bg-val">
  45. <input type="text" value="" placeholder="请输入所属支行" class="val-ipt" v-model="bankInfo.subbranch"
  46. ref="storenamae" />
  47. </view>
  48. </view>
  49. <view class="bd-wrap flex">
  50. <view class="bg-name">
  51. 手机号:
  52. </view>
  53. <view class="bg-val">
  54. <input type="text" value="" placeholder="请输入手机号" class="val-ipt" v-model="bankInfo.phone"
  55. ref="phone" />
  56. </view>
  57. </view>
  58. </template>
  59. <template v-if="current == 1">
  60. <view class="bd-wrap flex">
  61. <view class="bg-name">
  62. 真实姓名:
  63. </view>
  64. <view class="bg-val">
  65. <input type="text" value="" placeholder="请输入真实姓名" class="val-ipt" v-model="aliInfo.fullname"
  66. ref="name" />
  67. </view>
  68. </view>
  69. <view class="bd-wrap flex">
  70. <view class="bg-name">
  71. 支付宝账号:
  72. </view>
  73. <view class="bg-val">
  74. <input type="text" value="" placeholder="请输入支付宝账号" class="val-ipt" v-model="aliInfo.alino"
  75. ref="name" />
  76. </view>
  77. </view>
  78. <view class="bd-wrap flex">
  79. <view class="bg-name">
  80. 收款码:
  81. </view>
  82. <view class="bg-val">
  83. <!-- #ifdef APP -->
  84. <image v-if="!aliInfo.qr" src="../../static/img/add.png" mode="" @click="openAuth(1)"></image>
  85. <image v-else :src="aliInfo.qr" mode="" @click="openAuth(1)"></image>
  86. <!-- #endif -->
  87. <!-- #ifndef APP -->
  88. <image v-if="!aliInfo.qr" src="../../static/img/add.png" mode="" @click="upimg(1)"></image>
  89. <image v-else :src="aliInfo.qr" mode="" @click="upimg(1)"></image>
  90. <!-- #endif -->
  91. </view>
  92. </view>
  93. <view class="bd-wrap flex">
  94. <view class="bg-name">
  95. 手机号:
  96. </view>
  97. <view class="bg-val">
  98. <input type="text" value="" placeholder="请输入手机号" class="val-ipt" v-model="aliInfo.phone"
  99. ref="phone" />
  100. </view>
  101. </view>
  102. </template>
  103. <template v-if="current == 2">
  104. <view class="bd-wrap flex">
  105. <view class="bg-name">
  106. 真实姓名:
  107. </view>
  108. <view class="bg-val">
  109. <input type="text" value="" placeholder="请输入真实姓名" class="val-ipt" v-model="wxInfo.fullname"
  110. ref="name" />
  111. </view>
  112. </view>
  113. <view class="bd-wrap flex">
  114. <view class="bg-name">
  115. 微信账号:
  116. </view>
  117. <view class="bg-val">
  118. <input type="text" value="" placeholder="请输入微信账号" class="val-ipt" v-model="wxInfo.wxno"
  119. ref="name" />
  120. </view>
  121. </view>
  122. <view class="bd-wrap flex">
  123. <view class="bg-name">
  124. 收款码:
  125. </view>
  126. <view class="bg-val">
  127. <!-- #ifdef APP -->
  128. <image v-if="!wxInfo.qr" src="../../static/img/add.png" mode="" @click="openAuth()(2)"></image>
  129. <image v-else :src="wxInfo.qr" mode="" @click="openAuth(2)"></image>
  130. <!-- #endif -->
  131. <!-- #ifndef APP -->
  132. <image v-if="!wxInfo.qr" src="../../static/img/add.png" mode="" @click="upimg(2)"></image>
  133. <image v-else :src="wxInfo.qr" mode="" @click="upimg(2)"></image>
  134. <!-- #endif -->
  135. </view>
  136. </view>
  137. <view class="bd-wrap flex">
  138. <view class="bg-name">
  139. 手机号:
  140. </view>
  141. <view class="bg-val">
  142. <input type="text" value="" placeholder="请输入手机号" class="val-ipt" v-model="wxInfo.phone"
  143. ref="phone" />
  144. </view>
  145. </view>
  146. </template>
  147. <!-- <view class="bd-wrap flex">
  148. <view class="bg-name">
  149. 验证码:
  150. </view>
  151. <view class="bg-val flex">
  152. <input type="text" value="" placeholder="请输入验证码" class="val-iptt" v-model="captcha"
  153. ref="captcha" />
  154. <view class="code" @click="verification()">{{ countDown == 0 || countDown<0 ? '验证码' : countDown }}</view>
  155. </view>
  156. </view> -->
  157. </view>
  158. <view class="btm-btn" @click="bank">
  159. {{current == 0? '保存银行卡信息': (current == 1? '保存支付宝信息': '保存微信信息')}}
  160. </view>
  161. <yk-authpup ref="WRITE_EXTERNAL_STORAGE" type="top" @changeAuth="changeAuth"
  162. permissionID="WRITE_EXTERNAL_STORAGE"></yk-authpup>
  163. </view>
  164. </template>
  165. <script>
  166. import ykAuthpup from "@/components/yk-authpup/yk-authpup";
  167. import { register, verify } from '@/api/login.js';
  168. import {
  169. enroll
  170. } from '@/api/index.js'
  171. import {
  172. getLevelList,
  173. bank,
  174. bankInfo,
  175. setWx,
  176. setAli,
  177. getAli,
  178. getWx
  179. } from '@/api/user.js'
  180. import {
  181. mapState,
  182. mapMutations
  183. } from 'vuex';
  184. import { upload } from '@/api/order.js';
  185. export default {
  186. components: {
  187. ykAuthpup
  188. },
  189. data() {
  190. return {
  191. captcha: '',
  192. countDown: 0 ,//倒计时
  193. current: 0,
  194. navList: [{
  195. tit: '银行卡',
  196. info: {},
  197. }, {
  198. tit: '支付宝',
  199. info: {}
  200. },
  201. {
  202. tit: '微信',
  203. info: {}
  204. }
  205. ],
  206. type: 1,
  207. aliInfo: {
  208. fultname: '',
  209. alino: '',
  210. qr: '',
  211. id: 0
  212. },
  213. wxInfo: {
  214. fultname: '',
  215. wxno: '',
  216. qr: '',
  217. id: 0
  218. },
  219. bankInfo: {
  220. fullname: '',
  221. phone: '',
  222. bankno: '',
  223. bank: '',
  224. subbranch: '',
  225. },
  226. loading: false,
  227. };
  228. },
  229. onLoad(opt) {
  230. },
  231. watch: {
  232. current(n, o) {
  233. }
  234. },
  235. onShow() {
  236. this.getbankInfo()
  237. },
  238. onReachBottom() {
  239. },
  240. computed: {
  241. ...mapState('user', ['userInfo'])
  242. },
  243. methods: {
  244. //发送验证码
  245. verification() {
  246. let obj = this;
  247. let index = this.current;
  248. let phone;
  249. if(index == 0) {
  250. phone = this.bankInfo.phone
  251. }else if(index == 1) {
  252. phone = this.aliInfo.phone
  253. }else if(index == 2) {
  254. phone = this.wxInfo.phone
  255. }
  256. if (!phone) {
  257. this.$api.msg('请输入手机号');
  258. return;
  259. }
  260. if (phone.length < 11) {
  261. this.$api.msg('请输入正确的手机号');
  262. return;
  263. }
  264. // 判断是否在倒计时
  265. if (obj.countDown > 0) {
  266. return false;
  267. } else {
  268. obj.countDown = 60;
  269. obj.time = setInterval(() => {
  270. obj.countDown--;
  271. }, 1000);
  272. //调用验证码接口
  273. verify({
  274. phone: phone,
  275. type: 'verify'
  276. })
  277. .then(({ data }) => {})
  278. .catch(err => {
  279. console.log(err);
  280. });
  281. }
  282. },
  283. openAuth(type) {
  284. this.typename = type
  285. this.$refs['WRITE_EXTERNAL_STORAGE'].open()
  286. },
  287. changeAuth() {
  288. this.upimg(this.typename)
  289. },
  290. upimg(type) {
  291. let that = this
  292. upload({
  293. file: ''
  294. })
  295. .then(e => {
  296. console.log(e,'e')
  297. if(type == 1) {
  298. that.aliInfo.qr = e[0].url
  299. }else {
  300. that.wxInfo.qr = e[0].url
  301. }
  302. })
  303. .catch(e => {});
  304. },
  305. changeNavT(index) {
  306. if (index == this.current) {
  307. return
  308. }
  309. this.current = index
  310. },
  311. getbankInfo() {
  312. bankInfo().then(res => {
  313. console.log(res);
  314. if (res.data && res.data.id) {
  315. this.bankInfo = res.data
  316. }
  317. })
  318. getAli().then(res => {
  319. if (res.data && res.data.id) {
  320. this.aliInfo = res.data
  321. }
  322. })
  323. getWx().then(res => {
  324. if (res.data && res.data.id) {
  325. this.wxInfo = res.data
  326. }
  327. })
  328. },
  329. // 选中城市切换
  330. onCityClick({
  331. data
  332. }) {
  333. // let address = this.addressData.address;
  334. // address.province = data[0];
  335. // address.city = data[1];
  336. // address.district = data[2];
  337. this.address = data.join('-');
  338. },
  339. bank() {
  340. let that = this
  341. let setInfo,qdata;
  342. if (that.loading) {
  343. return
  344. }
  345. if (that.current == 0) {
  346. // 校验银行卡
  347. setInfo = bank
  348. if (that.bankInfo.fullname == '') {
  349. return that.$api.msg('请输入您的姓名')
  350. }
  351. if (that.bankInfo.phone == '') {
  352. return that.$api.msg('请输入手机号')
  353. }
  354. if (that.bankInfo.bankno == '') {
  355. return that.$api.msg('请输入银行卡号')
  356. }
  357. if (that.bankInfo.bank == '') {
  358. return that.$api.msg('请输入银行')
  359. }
  360. if (that.bankInfo.subbranch == '') {
  361. return that.$api.msg('请输入所属支行')
  362. }
  363. qdata = that.bankInfo
  364. } else if (that.current == 1) {
  365. //校验支付宝
  366. setInfo = setAli
  367. if (that.aliInfo.fullname == '') {
  368. return that.$api.msg('请输入您的姓名')
  369. }
  370. if (that.aliInfo.wxno == '') {
  371. return that.$api.msg('请输入支付宝账号')
  372. }
  373. if (that.aliInfo.qr == '') {
  374. return that.$api.msg('请上传支付宝收款码')
  375. }
  376. qdata = that.aliInfo
  377. } else if (that.current == 2) {
  378. //校验微信
  379. setInfo = setWx
  380. if (that.wxInfo.fullname == '') {
  381. return that.$api.msg('请输入您的姓名')
  382. }
  383. if (that.wxInfo.wxno == '') {
  384. return that.$api.msg('请输入微信账号')
  385. }
  386. if (that.wxInfo.qr == '') {
  387. return that.$api.msg('请上传微信收款码')
  388. }
  389. qdata = that.wxInfo
  390. }
  391. // qdata.captcha = that.captcha
  392. that.loading = true
  393. setInfo(qdata).then(res => {
  394. console.log(res);
  395. uni.showToast({
  396. title: '提交成功',
  397. duration: 2000
  398. });
  399. }).catch(err => {
  400. console.log('err');
  401. that.loading = false
  402. })
  403. }
  404. }
  405. };
  406. </script>
  407. <style lang="scss" scoped>
  408. .tab {
  409. width: 690rpx;
  410. margin: auto;
  411. // height: 606rpx;
  412. background: #FFFFFF;
  413. border-radius: 10rpx;
  414. }
  415. .bd-wrap {
  416. width: 690rpx;
  417. // height: 100rpx;
  418. padding: 20rpx 0;
  419. background-color: #fff;
  420. border-bottom: 1px solid #f2f2f2;
  421. // line-height: 100rpx;
  422. font-size: 32rpx;
  423. position: relative;
  424. .code {
  425. position: absolute;
  426. width: 100rpx;
  427. height: 100rpx;
  428. right: 10rpx;
  429. color: #f64342;
  430. font-size: 23rpx;
  431. }
  432. .bg-name {
  433. width: 280rpx;
  434. height: 100%;
  435. padding-left: 20rpx;
  436. }
  437. .bg-val {
  438. width: 430rpx;
  439. height: 100%;
  440. .code {
  441. height: 100%;
  442. display: flex;
  443. justify-content: center;
  444. align-items: center;
  445. }
  446. .val-ipt {
  447. padding-top: 10rpx;
  448. display: inline-block;
  449. width: 100%;
  450. height: 100%;
  451. // background-color: #009100;
  452. padding-left: 10rpx;
  453. }
  454. .val-iptt {
  455. width: 70%;
  456. }
  457. image {
  458. width: 150rpx;
  459. height: 150rpx;
  460. }
  461. }
  462. }
  463. .btm-btn {
  464. margin: 60rpx auto 0;
  465. font-size: 34rpx;
  466. font-weight: 500;
  467. color: #FFFFFF;
  468. text-align: center;
  469. line-height: 82rpx;
  470. width: 560rpx;
  471. height: 80rpx;
  472. background: #FA2740;
  473. border-radius: 40rpx;
  474. }
  475. .nav-list {
  476. justify-content: space-around;
  477. background-color: #fff;
  478. font-weight: 500;
  479. color: #333333;
  480. .item {
  481. padding: 28rpx 20rpx 16rpx;
  482. }
  483. .action {
  484. color: #EC5A54;
  485. border-bottom: 2px solid red;
  486. }
  487. }
  488. </style>