account.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <template>
  2. <view class="content">
  3. <view class="navbar">
  4. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  5. </view>
  6. <swiper :current="tabCurrentIndex" class="swiper-box" duration="300" @change="changeTab">
  7. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  8. <view class="row b-b">
  9. <text class="tit">姓名</text>
  10. <input class="input" v-model="tabItem.orderList.name" type="text" placeholder="提款人姓名" placeholder-class="placeholder" />
  11. </view>
  12. <view class="row b-b">
  13. <text class="tit">{{ tabIndex == 0 ? '账号' : '银行卡号' }}</text>
  14. <input class="input" v-model="tabItem.orderList.code" type="text" placeholder="请输入账号" placeholder-class="placeholder" />
  15. </view>
  16. <view class="row b-b" v-if="tabIndex == 1">
  17. <text class="tit">所属银行</text>
  18. <input class="input" v-model="tabItem.orderList.bankName" type="text" placeholder="请输入账号" placeholder-class="placeholder" />
  19. </view>
  20. </swiper-item>
  21. </swiper>
  22. <button class="add-btn up" @click="confirm">提交申请</button>
  23. </view>
  24. </template>
  25. <script>
  26. import { aliInfo, bankInfo, setAliInfo, setBankInfo } from '@/api/wallet.js';
  27. import {
  28. prePage
  29. } from '@/utils/rocessor.js';
  30. export default {
  31. data() {
  32. return {
  33. tabCurrentIndex: 0,
  34. navList: [
  35. {
  36. state: 0,
  37. text: '支付宝',
  38. loadingType: 'more',
  39. orderList: {
  40. name: '',
  41. code: '',
  42. id:''
  43. }
  44. },
  45. {
  46. state: 1,
  47. text: '银行卡',
  48. loadingType: 'more',
  49. orderList: {
  50. name: '',
  51. code: '',
  52. bankName: '',
  53. id:''
  54. }
  55. }
  56. ]
  57. };
  58. },
  59. onLoad(options) {
  60. this.tabCurrentIndex = +options.state || 0;
  61. this.loadAli();
  62. this.loadBank();
  63. },
  64. methods: {
  65. //加载数据
  66. loadAli(source) {
  67. aliInfo({}).then(({data}) => {
  68. let order = this.navList[0].orderList;
  69. this.$set(order,'name',data.fullname)
  70. this.$set(order,'code',data.alino)
  71. this.$set(order,'id',data.id)
  72. });
  73. },
  74. loadBank() {
  75. bankInfo({}).then(({data}) => {
  76. let order = this.navList[1].orderList;
  77. this.$set(order,'name',data.fullname);
  78. this.$set(order,'code',data.bankno);
  79. this.$set(order,'bankName',data.bank);
  80. this.$set(order,'id',data.id)
  81. });
  82. },
  83. //swiper 切换
  84. changeTab(e) {
  85. this.tabCurrentIndex = e.target.current;
  86. },
  87. //顶部tab点击
  88. tabClick(index) {
  89. this.tabCurrentIndex = index;
  90. },
  91. // 提交保存
  92. confirm() {
  93. let obj = this;
  94. let arr = obj.navList[obj.tabCurrentIndex].orderList;
  95. if (obj.tabCurrentIndex == 1) {
  96. obj.setBankInfo({
  97. fullname: arr.name,
  98. bank: arr.bankName,
  99. bankno: arr.code,
  100. id:arr.id
  101. });
  102. }
  103. if (obj.tabCurrentIndex == 0) {
  104. obj.setAliInfo({
  105. fullname: arr.name,
  106. alino: arr.code,
  107. id:arr.id
  108. });
  109. }
  110. },
  111. /* 保存银行卡详细 */
  112. setBankInfo(obj) {
  113. setBankInfo(obj)
  114. .then(e => {
  115. uni.showToast({
  116. title: '修改成功',
  117. duration: 2000,
  118. position: 'top'
  119. });
  120. prePage().dataUp()
  121. setTimeout(() => {
  122. uni.navigateBack()
  123. },1500)
  124. })
  125. .catch(e => {
  126. console.log(e);
  127. });
  128. },
  129. // 修改支付宝信息
  130. setAliInfo(obj) {
  131. setAliInfo(obj)
  132. .then(e => {
  133. uni.showToast({
  134. title: '修改成功',
  135. duration: 2000,
  136. position: 'top'
  137. });
  138. prePage().dataUp()
  139. setTimeout(() => {
  140. uni.navigateBack()
  141. },1500)
  142. })
  143. .catch(e => {
  144. console.log(e);
  145. });
  146. },
  147. }
  148. };
  149. </script>
  150. <style lang="scss">
  151. .row {
  152. display: flex;
  153. align-items: center;
  154. position: relative;
  155. padding: 0 30rpx;
  156. height: 110rpx;
  157. background: #fff;
  158. .tit {
  159. flex-shrink: 0;
  160. width: 120rpx;
  161. font-size: 30rpx;
  162. color: $font-color-dark;
  163. }
  164. .input {
  165. flex: 1;
  166. font-size: 30rpx;
  167. color: $font-color-dark;
  168. }
  169. .iconlocation {
  170. font-size: 36rpx;
  171. color: $font-color-light;
  172. }
  173. }
  174. page,
  175. .content {
  176. background: $page-color-base;
  177. height: 100%;
  178. }
  179. .swiper-box {
  180. height: 750rpx;
  181. }
  182. .navbar {
  183. display: flex;
  184. height: 40px;
  185. padding: 0 5px;
  186. background: #fff;
  187. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  188. position: relative;
  189. z-index: 10;
  190. .nav-item {
  191. flex: 1;
  192. display: flex;
  193. justify-content: center;
  194. align-items: center;
  195. height: 100%;
  196. font-size: 15px;
  197. color: $font-color-dark;
  198. position: relative;
  199. &.current {
  200. color: $base-color;
  201. &:after {
  202. content: '';
  203. position: absolute;
  204. left: 50%;
  205. bottom: 0;
  206. transform: translateX(-50%);
  207. width: 44px;
  208. height: 0;
  209. border-bottom: 2px solid $base-color;
  210. }
  211. }
  212. }
  213. }
  214. .add-btn {
  215. &.up {
  216. background-color: $base-color;
  217. color: #fff;
  218. }
  219. display: flex;
  220. align-items: center;
  221. justify-content: center;
  222. width: 690rpx;
  223. height: 80rpx;
  224. margin: 0 auto;
  225. margin-top: 30rpx;
  226. font-size: $font-lg;
  227. border-radius: 10rpx;
  228. // box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
  229. }
  230. </style>