account.vue 6.4 KB

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