account.vue 4.5 KB

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