account.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  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. <view class="row b-b">
  7. <text class="tit">姓名</text>
  8. <input class="input" v-model="name" type="text" placeholder="请输入姓名"
  9. placeholder-class="placeholder" />
  10. </view>
  11. <view class="row b-b" >
  12. <text class="tit">{{type==3?'银行卡号':'账号'}}</text>
  13. <input class="input" v-model="payment" type="text" :placeholder="'请输入'+ (type==3?'银行卡号':'账号')"
  14. placeholder-class="placeholder" />
  15. </view>
  16. <view class="row b-b" v-if="type==3">
  17. <text class="tit">手机号码</text>
  18. <input class="input" v-model="phone" type="text" placeholder="请输入手机号码"
  19. placeholder-class="placeholder" />
  20. </view>
  21. <view class="row b-b" v-if="type==3">
  22. <text class="tit">所属银行</text>
  23. <input class="input" v-model="bank" type="text" placeholder="请输入所属银行"
  24. placeholder-class="placeholder" />
  25. </view>
  26. <!-- <view class="row b-b" v-if="type==3">
  27. <text class="tit">所属支行</text>
  28. <input class="input" v-model="bank_name" type="text" placeholder="请输入所属支行"
  29. placeholder-class="placeholder" />
  30. </view> -->
  31. <button class="add-btn up" @click="confirm">提 交 保 存</button>
  32. </view>
  33. </template>
  34. <script>
  35. import {
  36. aliInfo,
  37. bankInfo,
  38. setAliInfo,
  39. setBankInfo,
  40. setBank,
  41. getBank
  42. } from '@/api/wallet.js';
  43. export default {
  44. data() {
  45. return {
  46. type: 0,
  47. payment: '',
  48. name:'',
  49. bank: '',
  50. phone:'',
  51. bank_name: '',
  52. loading: false
  53. };
  54. },
  55. onLoad(options) {
  56. // this.tabCurrentIndex = +options.state || 0;
  57. // this.loadAli();
  58. // this.loadBank();
  59. this.type = options.type
  60. this.getBank()
  61. },
  62. methods: {
  63. //加载数据
  64. loadAli(source) {
  65. aliInfo({}).then(({
  66. data
  67. }) => {
  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(({
  76. data
  77. }) => {
  78. let order = this.navList[1].orderList;
  79. this.$set(order, 'name', data.fullname);
  80. this.$set(order, 'code', data.bankno);
  81. this.$set(order, 'bankName', data.bank);
  82. this.$set(order, 'id', data.id)
  83. });
  84. },
  85. //swiper 切换
  86. changeTab(e) {
  87. this.tabCurrentIndex = e.target.current;
  88. },
  89. //顶部tab点击
  90. tabClick(index) {
  91. this.tabCurrentIndex = index;
  92. },
  93. // 提交保存
  94. confirm() {
  95. let obj = this;
  96. if(obj.loading) {
  97. return
  98. }
  99. if(obj.name == '') {
  100. return obj.$api.msg('请输入姓名')
  101. }
  102. if(obj.payment == '') {
  103. if(obj.type == 3) {
  104. return obj.$api.msg('请输入银行卡号')
  105. }
  106. if(obj.type == 2) {
  107. return obj.$api.msg('请输入账号')
  108. }
  109. }
  110. if(obj.type == 3) {
  111. if(obj.phone == '') {
  112. return obj.$api.msg('请输入手机号')
  113. }
  114. if(obj.bank == '') {
  115. return obj.$api.msg('请输入所属银行')
  116. }
  117. // if(obj.bank_name == '') {
  118. // return obj.$api.msg('请输入所属支行')
  119. // }
  120. }
  121. obj.loading = true
  122. setBank({
  123. type: obj.type,
  124. name: obj.name,
  125. phone: obj.phone,
  126. payment: obj.payment,
  127. bank: obj.bank,
  128. // bank_name: obj.bank_name
  129. }).then(res => {
  130. obj.loading = false
  131. uni.showToast({
  132. title: '修改成功',
  133. duration: 2000,
  134. position: 'top'
  135. });
  136. console.log('修改成功')
  137. obj.$api.prePage().dataUp()
  138. setTimeout(() => {
  139. uni.navigateBack()
  140. }, 1500)
  141. }).catch(err => {
  142. obj.loading = false
  143. })
  144. },
  145. getBank() {
  146. let obj = this
  147. getBank().then(res => {
  148. let bank;
  149. console.log(obj.type)
  150. if(obj.type == 2) {
  151. bank = res.data.zfb
  152. }
  153. if(obj.type == 3) {
  154. console.log( res.data.bank)
  155. bank = res.data.bank
  156. console.log(bank)
  157. }
  158. console.log(bank)
  159. if(bank.name) {
  160. obj.name = bank.name
  161. obj.phone= bank.phone
  162. obj.payment= bank.payment
  163. obj.bank= bank.bank
  164. obj.bank_name= bank.bank_name
  165. }
  166. })
  167. },
  168. /* 保存银行卡详细 */
  169. setBankInfo(obj) {
  170. setBankInfo(obj)
  171. .then(e => {
  172. uni.showToast({
  173. title: '修改成功',
  174. duration: 2000,
  175. position: 'top'
  176. });
  177. this.$api.prePage().dataUp()
  178. setTimeout(() => {
  179. uni.navigateBack()
  180. }, 1500)
  181. })
  182. .catch(e => {
  183. console.log(e);
  184. });
  185. },
  186. // 修改支付宝信息
  187. setAliInfo(obj) {
  188. setAliInfo(obj)
  189. .then(e => {
  190. uni.showToast({
  191. title: '修改成功',
  192. duration: 2000,
  193. position: 'top'
  194. });
  195. this.$api.prePage().dataUp()
  196. setTimeout(() => {
  197. uni.navigateBack()
  198. }, 1500)
  199. })
  200. .catch(e => {
  201. console.log(e);
  202. });
  203. },
  204. }
  205. };
  206. </script>
  207. <style lang="scss">
  208. .row {
  209. display: flex;
  210. align-items: center;
  211. position: relative;
  212. padding: 0 30rpx;
  213. height: 110rpx;
  214. background: #fff;
  215. .tit {
  216. flex-shrink: 0;
  217. width: 200rpx;
  218. font-size: 30rpx;
  219. color: $font-color-dark;
  220. }
  221. .input {
  222. flex: 1;
  223. font-size: 30rpx;
  224. color: $font-color-dark;
  225. }
  226. .iconlocation {
  227. font-size: 36rpx;
  228. color: $font-color-light;
  229. }
  230. }
  231. page,
  232. .content {
  233. background: $page-color-base;
  234. height: 100%;
  235. }
  236. .swiper-box {
  237. height: 750rpx;
  238. }
  239. .navbar {
  240. display: flex;
  241. height: 40px;
  242. padding: 0 5px;
  243. background: #fff;
  244. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  245. position: relative;
  246. z-index: 10;
  247. .nav-item {
  248. flex: 1;
  249. display: flex;
  250. justify-content: center;
  251. align-items: center;
  252. height: 100%;
  253. font-size: 15px;
  254. color: $font-color-dark;
  255. position: relative;
  256. &.current {
  257. color: $base-color;
  258. &:after {
  259. content: '';
  260. position: absolute;
  261. left: 50%;
  262. bottom: 0;
  263. transform: translateX(-50%);
  264. width: 44px;
  265. height: 0;
  266. border-bottom: 2px solid $base-color;
  267. }
  268. }
  269. }
  270. }
  271. .add-btn {
  272. &.up {
  273. background-color:#ff4072;
  274. color: #fff;
  275. }
  276. display: flex;
  277. align-items: center;
  278. justify-content: center;
  279. width: 690rpx;
  280. height: 80rpx;
  281. margin: 0 auto;
  282. margin-top: 30rpx;
  283. font-size: $font-lg;
  284. border-radius: 10rpx;
  285. // box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
  286. }
  287. </style>