nummanage.vue 6.3 KB

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