account.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <template>
  2. <view class="content" v-if="!sh">
  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 { mapState, mapMutations } from 'vuex';
  27. import { orderData, getUserInfo,service,edit } from '@/api/user.js';
  28. export default {
  29. data() {
  30. return {
  31. sh:false,
  32. tabCurrentIndex: 0,
  33. navList: [
  34. {
  35. state: 0,
  36. text: '支付宝',
  37. loadingType: 'more',
  38. orderList: {
  39. name: '',
  40. code: '',
  41. id:''
  42. }
  43. },
  44. {
  45. state: 1,
  46. text: '银行卡',
  47. loadingType: 'more',
  48. orderList: {
  49. name: '',
  50. code: '',
  51. bankName: '',
  52. id:''
  53. }
  54. }
  55. ]
  56. };
  57. },
  58. computed: {
  59. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  60. },
  61. onLoad(options) {
  62. // loadIndexs({}).then(({data}) =>{
  63. // console.log(data,'123')
  64. // this.sh = true
  65. // })
  66. this.tabCurrentIndex = +options.state || 0;
  67. console.log(this.userInfo,'123456')
  68. if(this.userInfo.alipay_code != null){
  69. this.navList[0].orderList.code = this.userInfo.alipay_code
  70. }
  71. if(this.userInfo.alipay_name != null){
  72. this.navList[0].orderList.name = this.userInfo.alipay_name
  73. }
  74. if(this.userInfo.bank_code != null){
  75. this.navList[1].orderList.code = this.userInfo.bank_code
  76. }
  77. if(this.userInfo.bank_name != null){
  78. this.navList[1].orderList.bankName = this.userInfo.bank_name
  79. }
  80. if(this.userInfo.bank_user_name != null){
  81. this.navList[1].orderList.name = this.userInfo.bank_user_name
  82. }
  83. },
  84. methods: {
  85. ...mapMutations('user', ['setUserInfo', 'setOrderInfo']),
  86. //swiper 切换
  87. changeTab(e) {
  88. this.tabCurrentIndex = e.target.current;
  89. },
  90. //顶部tab点击
  91. tabClick(index) {
  92. this.tabCurrentIndex = index;
  93. },
  94. // 提交保存
  95. confirm() {
  96. let obj = this;
  97. let arr = obj.navList[obj.tabCurrentIndex].orderList;
  98. console.log(arr);
  99. let pages = getCurrentPages(); //获取所有页面栈实例列表
  100. console.log(pages);
  101. let nowPage = pages[pages.length - 1]; //当前页页面实例
  102. let prevPage = pages[pages.length - 2]; //上一页页面实例
  103. console.log(prevPage);
  104. // prevPage.$vm.sh = 100; //修改上一页data里面的sh参数值为100
  105. if (obj.tabCurrentIndex == 1) {
  106. if (!arr.name) {
  107. return this.$api.msg('请输入提款人姓名');
  108. }
  109. if (!arr.bankName) {
  110. return this.$api.msg('请输入所属银行');
  111. }
  112. if (!arr.code) {
  113. return this.$api.msg('请输入银行卡号');
  114. }
  115. let data = {
  116. bank_user_name: arr.name,
  117. bank_name: arr.bankName,
  118. bank_code: arr.code
  119. };
  120. edit({
  121. bank_user_name: arr.name,
  122. bank_name: arr.bankName,
  123. bank_code: arr.code
  124. }).then(e => {
  125. obj.$api.msg('修改成功');
  126. obj.getUserInfo();
  127. });
  128. }
  129. if (obj.tabCurrentIndex == 0) {
  130. if (!arr.name) {
  131. return this.$api.msg('请输入提款人姓名');
  132. }
  133. if (!arr.code) {
  134. return this.$api.msg('请输入支付宝账号');
  135. }
  136. let data = {
  137. alipay_name: arr.name,
  138. alipay_code: arr.code
  139. };
  140. console.log(111);
  141. edit({
  142. alipay_name: arr.name,
  143. alipay_code: arr.code
  144. })
  145. .then(e => {
  146. console.log(e, '123456');
  147. obj.$api.msg('修改成功');
  148. obj.getUserInfo();
  149. })
  150. .catch(e => {
  151. console.log(e);
  152. });
  153. }
  154. },
  155. // 更新用户信息
  156. getUserInfo() {
  157. getUserInfo({})
  158. .then(({ data }) => {
  159. console.log(data)
  160. this.setUserInfo(data);
  161. // 获取用户数据完毕后在获取订单数据防止多次跳转到登录页
  162. orderData({})
  163. .then(({ data }) => {
  164. this.setOrderInfo(data);
  165. uni.navigateBack({
  166. delta: 1
  167. });
  168. })
  169. .catch(e => {
  170. this.setOrderInfo({
  171. complete_count: 0, //完成
  172. received_count: 0, //待收货
  173. unshipped_count: 0, //待发货
  174. order_count: 0, //订单总数
  175. unpaid_count: 0 //待付款
  176. });
  177. });
  178. })
  179. .catch(e => {
  180. console.log(e);
  181. });
  182. },
  183. }
  184. };
  185. </script>
  186. <style lang="scss">
  187. .row {
  188. display: flex;
  189. align-items: center;
  190. position: relative;
  191. padding: 0 30rpx;
  192. height: 110rpx;
  193. background: #fff;
  194. .tit {
  195. flex-shrink: 0;
  196. width: 120rpx;
  197. font-size: 30rpx;
  198. color: $font-color-dark;
  199. }
  200. .input {
  201. flex: 1;
  202. font-size: 30rpx;
  203. color: $font-color-dark;
  204. }
  205. .iconlocation {
  206. font-size: 36rpx;
  207. color: $font-color-light;
  208. }
  209. }
  210. page,
  211. .content {
  212. background: $page-color-base;
  213. height: 100%;
  214. }
  215. .swiper-box {
  216. height: 750rpx;
  217. }
  218. .navbar {
  219. display: flex;
  220. height: 40px;
  221. padding: 0 5px;
  222. background: #fff;
  223. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  224. position: relative;
  225. z-index: 10;
  226. .nav-item {
  227. flex: 1;
  228. display: flex;
  229. justify-content: center;
  230. align-items: center;
  231. height: 100%;
  232. font-size: 15px;
  233. color: $font-color-dark;
  234. position: relative;
  235. &.current {
  236. color: $base-color;
  237. &:after {
  238. content: '';
  239. position: absolute;
  240. left: 50%;
  241. bottom: 0;
  242. transform: translateX(-50%);
  243. width: 44px;
  244. height: 0;
  245. }
  246. }
  247. }
  248. }
  249. .add-btn {
  250. &.up {
  251. background: $base-color;
  252. color: #fff;
  253. }
  254. display: flex;
  255. align-items: center;
  256. justify-content: center;
  257. width: 690rpx;
  258. height: 80rpx;
  259. margin: 0 auto;
  260. margin-top: 30rpx;
  261. font-size: $font-lg;
  262. border-radius: 10rpx;
  263. // box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
  264. }
  265. </style>