account.vue 4.9 KB

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