Browse Source

添加银行卡信息

xiaohaizhao 2 năm trước cách đây
mục cha
commit
b934a5608e

+ 77 - 0
pages/bankAccount/index.js

@@ -0,0 +1,77 @@
+const _Http = getApp().globalData.http;
+Page({
+  data: {
+    "content": {
+      nocache: true,
+      sys_enterpriseid: "",
+      pageNumber: 1,
+      pageTotal: 1,
+      "where": {
+        "condition": "",
+        "workaddress": 1
+      }
+    }
+  },
+  onLoad(options) {
+    this.setData({
+      "content.sys_enterpriseid": options.id
+    })
+    this.getList(true);
+  },
+  /* 获取产品 */
+  getList(init = false) {
+    if (init.detail != undefined) init = init.detail;
+    let content = this.data.content;
+    if (init) content.pageNumber = 1;
+    if (content.pageNumber > content.pageTotal) return;
+    _Http.basic({
+      "id": "20221022165803",
+      content
+    }).then(res => {
+      console.log("账户列表", res)
+      this.selectComponent('#ListBox').RefreshToComplete();
+      if (res.msg != '成功') return wx.showToast({
+        title: res.msg,
+        icon: "none",
+        mask: true
+      });
+      content.pageNumber = res.pageNumber + 1;
+      content.pageTotal = res.pageTotal;
+      this.setData({
+        list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
+      })
+    })
+  },
+  /* 单击卡号 */
+  onClick({
+    detail
+  }) {
+    if (getApp().globalData.handleSelect) return getApp().globalData.handleSelect(detail);
+    wx.navigateTo({
+      url: `/pages/bankAccount/update?item=${JSON.stringify(detail)}&id=${detail.sys_enterpriseid}`,
+    })
+  },
+  /* 开始搜索 */
+  onSearch({
+    detail
+  }) {
+    if (detail == this.data.content.where.condition) return;
+    this.data.content.where.condition = detail;
+    this.getList(true);
+  },
+  onClear(e) {
+    this.data.content.where.condition = "";
+    this.getList(true);
+  },
+  onReady() {
+    this.selectComponent("#ListBox").setHeight(".top", this);
+  },
+  deleteItem() {
+    _Http.basic({
+      "id": "20221022165903",
+      "content": {
+        "sys_enterprise_bankids": [7]
+      }
+    })
+  }
+})

+ 5 - 0
pages/bankAccount/index.json

@@ -0,0 +1,5 @@
+{
+  "usingComponents": {
+    "List": "./modules/list/index"
+  }
+}

+ 1 - 0
pages/bankAccount/index.scss

@@ -0,0 +1 @@
+/* pages/bankAccount/index.wxss */

+ 7 - 0
pages/bankAccount/index.wxml

@@ -0,0 +1,7 @@
+<van-search class="top" value="{{ content.where.condition }}" use-action-slot placeholder="请输入搜索关键词" bind:search="onSearch" bind:clear='onClear'>
+    <navigator url="/pages/bankAccount/update?id={{content.sys_enterpriseid}}" slot="action">添加卡号</navigator>
+</van-search>
+<Yl_ListBox id='ListBox' bind:getlist='getList'>
+    <view style="height: 20rpx;" />
+    <List list="{{list}}" bind:onClick="onClick" />
+</Yl_ListBox>

+ 14 - 0
pages/bankAccount/modules/list/index.js

@@ -0,0 +1,14 @@
+Component({
+  properties: {
+    list: Array,
+    onClick: Function
+  },
+  methods: {
+    handleClick(e) {
+      const {
+        item
+      } = e.currentTarget.dataset;
+      this.triggerEvent("onClick", item)
+    },
+  }
+})

+ 4 - 0
pages/bankAccount/modules/list/index.json

@@ -0,0 +1,4 @@
+{
+  "component": true,
+  "usingComponents": {}
+}

+ 33 - 0
pages/bankAccount/modules/list/index.scss

@@ -0,0 +1,33 @@
+.item {
+    width: 100vw;
+    margin-bottom: 20rpx;
+    background-color: #ffffff;
+
+    .content {
+        position: relative;
+        padding: 20rpx 30rpx;
+        padding-top: 0;
+        box-sizing: border-box;
+
+        .num {
+            font-size: 28rpx;
+            color: #333333;
+            padding: 20rpx 0 10rpx;
+            font-weight: 700;
+        }
+
+        .exp {
+            line-height: 34rpx;
+            font-size: 24rpx;
+            margin-bottom: 8rpx;
+            color: #999999;
+        }
+    }
+}
+
+/* 文本行数限制 */
+.line-1 {
+    overflow: hidden;
+    white-space: nowrap;
+    text-overflow: ellipsis;
+}

+ 15 - 0
pages/bankAccount/modules/list/index.wxml

@@ -0,0 +1,15 @@
+<view class="item" wx:for="{{list}}" wx:key="index" data-item="{{item}}" bindtap="handleClick">
+	<navigator url="#" class="content">
+		<view class="num">
+			卡号:{{item.bankcardno}}
+		</view>
+		<view class="exp">
+			开户行:{{item.bank}}
+		</view>
+		<view class="exp">
+			联系人:{{item.name + ' '+ item.phonenumber}}
+		</view>
+	</navigator>
+</view>
+
+<Yl_Empty wx:if="{{list.length==0}}" />

+ 142 - 0
pages/bankAccount/update.js

@@ -0,0 +1,142 @@
+const _Http = getApp().globalData.http;
+let sys_enterpriseid = null,
+  sys_enterprise_bankid = 0;
+
+Page({
+  data: {
+    form: [{
+      label: "联系人",
+      error: false,
+      errMsg: "",
+      type: "text",
+      value: "",
+      placeholder: "请填写",
+      valueName: "name",
+      required: true,
+      checking: "base"
+    }, {
+      label: "手机号",
+      error: false,
+      errMsg: "",
+      type: "number",
+      value: "",
+      placeholder: "联系人手机号码",
+      valueName: "phonenumber",
+      required: true,
+      checking: "phone"
+    }, {
+      label: "开户行",
+      error: false,
+      errMsg: "",
+      type: "textarea",
+      value: "",
+      placeholder: "开户银行",
+      valueName: "bank",
+      required: true,
+      checking: "base"
+    }, {
+      label: "银行卡号",
+      error: false,
+      errMsg: "",
+      type: "number",
+      value: "",
+      placeholder: "银行卡号",
+      hint: "银行卡号格式错误!",
+      valueName: "bankcardno",
+      required: true,
+      checking: `^([1-9]{1})(\\d{15}|\\d{16}|\\d{18})$`
+    }],
+    disabled: true,
+    isDelete: false, //是否允许删除
+  },
+  onLoad(options) {
+    sys_enterpriseid = options.id
+    if (options.item) {
+      let item = JSON.parse(options.item);
+      sys_enterprise_bankid = item.sys_enterprise_bankid;
+      this.setData({
+        form: this.data.form.map(v => {
+          v.value = item[v.valueName] || "";
+          return v
+        }),
+        isDelete: true
+      })
+      this.selectComponent("#Form").confirm();
+    }
+  },
+  submit() {
+    let content = this.selectComponent("#Form").submit();
+    content.sys_enterpriseid = sys_enterpriseid;
+    content.sys_enterprise_bankid = sys_enterprise_bankid;
+    content.isdefault = 0;
+    _Http.basic({
+      "id": 20221022165703,
+      content
+    }).then(res => {
+      console.log("新建卡号", res)
+      wx.showToast({
+        title: res.msg != '成功' ? res.msg : "保存成功",
+        icon: "none",
+        mask: true
+      });
+      if (res.msg == '成功') setTimeout(() => {
+        let page = getCurrentPages()[getCurrentPages().length - 2];
+        let con = page.data.content;
+        con.pageSize = (con.pageNumber - 1) * 20;
+        con.pageNumber = 1;
+        _Http.basic({
+          "id": "20221022165803",
+          content: con
+        }).then(res => {
+          wx.navigateBack();
+          if (res.msg == '成功') {
+            page.setData({
+              list: res.data
+            });
+          } else {
+            page.getList(true);
+          }
+        })
+      }, 500)
+    })
+  },
+  /* 处理删除 */
+  handleDelete() {
+    wx.showModal({
+      title: '提示',
+      content: '是否确认删除?',
+      complete: ({
+        confirm
+      }) => {
+        if (confirm) _Http.basic({
+          "id": "20221022165903",
+          "content": {
+            "sys_enterprise_bankids": [sys_enterprise_bankid]
+          }
+        }).then(res => {
+          console.log("删除", res)
+          wx.showToast({
+            title: res.msg != '成功' ? res.msg : "删除成功",
+            icon: "none",
+            mask: true
+          });
+          if (res.msg == '成功') setTimeout(() => {
+            let page = getCurrentPages()[getCurrentPages().length - 2];
+            page.setData({
+              list: page.data.list.filter(v => v.sys_enterprise_bankid != sys_enterprise_bankid)
+            })
+            wx.navigateBack();
+          }, 500)
+        })
+      }
+    })
+  },
+  /* 表单是否填写完成 */
+  onConfirm({
+    detail
+  }) {
+    this.setData({
+      disabled: detail
+    })
+  },
+})

+ 3 - 0
pages/bankAccount/update.json

@@ -0,0 +1,3 @@
+{
+  "usingComponents": {}
+}

+ 35 - 0
pages/bankAccount/update.scss

@@ -0,0 +1,35 @@
+.footer {
+	display: flex;
+	justify-content: center;
+	padding: 0 30rpx;
+	position: fixed;
+	width: 100vw;
+	height: 130rpx;
+	background: #FFFFFF;
+	box-shadow: 0px -4rpx 16rpx 2rpx rgba(150, 157, 165, 0.16);
+	bottom: 0;
+	box-sizing: border-box;
+	z-index: 9999;
+	padding-top: 10rpx;
+
+	.but {
+		width: 690rpx;
+		height: 90rpx;
+		background: var(--warning);
+		border-radius: 16rpx;
+		font-size: 28rpx;
+		font-family: PingFang SC-Bold, PingFang SC;
+		font-weight: bold;
+		color: #fff;
+	}
+
+	.w5{
+		width: 520rpx !important;
+	}
+
+	.delete{
+		width: 200rpx;
+		background: var(--error);
+	}
+
+}

+ 6 - 0
pages/bankAccount/update.wxml

@@ -0,0 +1,6 @@
+<Yl_Field id='Form' form="{{form}}" bind:onConfirm='onConfirm' />
+
+<view class="footer">
+	<van-button wx:if="{{isDelete}}" custom-class='but delete' bind:click="handleDelete" disabled='{{disabled}}'>删除</van-button>
+	<van-button custom-class='but {{isDelete?"w5":""}}' bind:click="submit" disabled='{{disabled}}'>保存</van-button>
+</view>

+ 11 - 3
pages/index/userCenter/index.wxml

@@ -14,6 +14,17 @@
 		</navigator>
 	</view>
 	<view class="operating">
+		<navigator class="item" wx:if="{{userMsg.enterprise.sys_enterpriseid}}" url="/pages/bankAccount/index?id={{userMsg.enterprise.sys_enterpriseid}}">
+			<view class="con">
+				<view class="label">
+					<text class="iconfont icon-zhanghu" style="font-size: 32rpx !important; margin-left: 8rpx;margin-right: 16rpx;color:rgb(255, 145, 0);" />
+					银行卡信息
+				</view>
+				<view class="item-right">
+					<van-icon size='30rpx' name="arrow" />
+				</view>
+			</view>
+		</navigator>
 		<navigator class="item" wx:if="{{userMsg.enterprise.sys_enterpriseid}}" url="/pages/address/index?id={{userMsg.enterprise.sys_enterpriseid}}">
 			<view class="con">
 				<view class="label">
@@ -53,11 +64,8 @@
 				</view>
 			</view>
 		</navigator>
-
 	</view>
 	<view style="width: 100vw;text-align: center;margin-top: 200rpx;">
 		<van-button custom-class='out-login' color="#CCC" bindtap="outLogin" plain>退出登录</van-button>
 	</view>
-
-
 </scroll-view>