邪性 3 роки тому
батько
коміт
111791385f

+ 13 - 5
pages/add/config.js → components/template/config.js

@@ -12,7 +12,7 @@ const value = [
     { name: "dpratio", disabled: true, title: "首付比例", type: 'number', _type: "digit", reg: /^\d{0,2}\.\d{1,}$/, value: '' },
     { name: "lamount", title: "申请贷款金额", type: 'number', _type: "number", value: '' },
     { name: "maturity", title: "申请贷款期限", disabled: true, type: "number", value: '' },
-    { name: "laompany", title: "申请贷款产品", value: '' }
+    { name: "laompany", type: "switch", title: "申请贷款产品", value: '' }
   ],
   // 申请人基本信息
   [
@@ -39,10 +39,10 @@ const value = [
     { name: "maddress", title: "邮寄地址", type: 'switch', value: "" },
     { name: "email", title: "电子邮箱", reg: /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/, value: "" },
     { name: "wx", title: "微信号", reg: /^[a-zA-Z]{1}[-_a-zA-Z0-9]{5,19}$/, value: "" },
-    { name: "phone", title: "住宅固定电话", reg: /^((\d{3,4}-)|\d{3.4}-)?\d{7,8}$/, value: "" },
+    { name: "phone", title: "住宅固定电话", _title: "xxx-xxx格式", reg: /^((\d{3,4}-)|\d{3.4}-)?\d{7,8}$/, value: "" },
     { name: "tel", title: "手机号", reg: /^(13[0-9]|14[5|7]|15[0|1|2|3|4|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$/, type: 'number', _type: "number", value: "" },
     { name: "wname", title: "现工作单位名称", value: "" },
-    { name: "wphone", title: "单位电话", reg: /^((\d{3,4}-)|\d{3.4}-)?\d{7,8}$/, value: "" },
+    { name: "wphone", title: "单位电话", _title: "xxx-xxx格式", reg: /^((\d{3,4}-)|\d{3.4}-)?\d{7,8}$/, value: "" },
     { name: "waddress", title: "现工作单位地址", reg: /^.+省.+(市|县).+(区|镇).+\d+$/, value: "" },
     // 0农林牧鱼 1制造业 2批发零售 3信息传输/软件/信息技术服务 4房地产 5建筑业 6住宿/餐饮 7卫生/社会工作 8科研/技术服务 9公共管理/社会保障/社会组织 10采矿业 11文化/体育/娱乐业 12居民服务/修理/其他服务业 13租赁/商务服务业 14交通运输/仓储/邮政业 15教育 16金融 17国际组织 18电热力/燃气/水生产供应业 19水利/环境/公共设施管理 20其他
     { name: "itype", title: "行业类型", type: "switch", value: "" },
@@ -83,7 +83,7 @@ const value = [
   { name: "tsemail", title: "电子邮箱", _title: "共同借款人电子邮箱", reg: /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/, value: "" },
   { name: "tswx", title: "微信号", _title: "共同借款人微信号", reg: /^[a-zA-Z]{1}[-_a-zA-Z0-9]{5,19}$/, value: "" },
   { name: "tswname", title: "现工作单位名称", _title: "共同借款人现工作单位名称", value: "" },
-  { name: "tswphone", title: "单位电话", _title: "共同借款人单位电话", reg: /^((\d{3,4}-)|\d{3.4}-)?\d{7,8}$/, value: "" },
+  { name: "tswphone", title: "单位电话", _title: "xxx-xxx格式", _title: "共同借款人单位电话", reg: /^((\d{3,4}-)|\d{3.4}-)?\d{7,8}$/, value: "" },
   { name: "tswaddress", title: "现工作单位地址", _title: "共同借款人现工作单位地址", reg: /^.+省.+(市|县).+(区|镇).+\d+$/, value: "" },
   { name: "tsmincome", title: "税后月收入", _title: "共同借款人税后月收入", type: 'number', _type: "number", value: "" }
   ]
@@ -100,7 +100,7 @@ const switchs = {
   // 国籍地区
   nationality: ["中国大陆(内地)", "中国香港", "中国台湾", "中国澳门", "外国籍"],
   // 身份证类型
-  itype: ["身份证", "护照", "军官证", "户口", "临时身份证", "港澳台通行证"],
+  ntype: ["身份证", "护照", "军官证", "户口", "临时身份证", "港澳台通行证"],
   // 婚姻状况
   mstatus: ["未婚", "已婚", "离异", "丧偶", "其他"],
   // 教育程度
@@ -119,7 +119,15 @@ const switchs = {
   tsitype: ["身份证", "护照", "军官证", "户口", "临时身份证", "港澳台通行证"],
   // 共同借款人邮寄地址
   tsmaddress: ["同居住地址", "同单位地址"],
+  // 共同借款人与借款人关系
+  tsrelation: ["配偶", "父母亲", "子女", "其他"],
+  // 与借款人关系
+  relation: ["配偶", "父母亲", "子女", "其他"],
 };
+
+// 单选 输入
+// const radioInput = ["配偶", "父母亲", "子女"]
+
 // 当前时间
 const date = () => {
   var date = new Date();

+ 156 - 0
components/template/index.js

@@ -0,0 +1,156 @@
+import { value, switchs, date } from "./config";
+var _value = value;
+const app = getApp();
+Component({
+  options: {
+    addGlobalClass: true,//解决继承全局样式问题
+  },
+  lifetimes: {
+    attached: function () { this.init(); }
+  },
+  properties: {
+    type: { type: String, value: "edit" },
+  },
+  data: {
+    value,
+    active: '',
+    activeObject: {},
+    activeIndex: [],
+    switchB: false,
+    endDate: date(),
+    switchs,
+    submitLock: false,
+    saveLock: false,
+    btn: true,
+    radioInputShow: false,
+  },
+  methods: {
+    //组件石林进入页面接节点树执行
+    init () {
+      // 商品请求
+      wx.$request({ method: "get", url: "/order/productDict/" }).then(res => {
+        this.setData({ shop: res.data })
+      }).catch(err => wx.$err(err));
+
+      let { type, value } = this.data;
+
+      switch (type) {
+        case 'watch':
+          this.watchFunc(value);
+          break;
+        default:
+          break;
+      }
+    },
+
+    //  查看模式
+    watchFunc (data) {
+      data = data.map(itemA => itemA.map(itemB => { if (itemB.hasOwnProperty('value')) itemB['disabled'] = true; return itemB })
+      )
+      this.setData({ data, btn: false })
+    },
+
+    // 提交
+    submitFunc () {
+      let { value, submitLock } = this.data, megs = [], data = {}, cvalue = [], tels = [];
+      if (submitLock) return false;
+      this.setData({ submitLock: true });
+      if (value[2][6]['value'] == 0) {
+        value = [...value[0], ...value[1], ...value[2]];
+        cvalue = [..._value[0], ..._value[1], ..._value[2]];
+      } else {
+        value = [...value[0], ...value[1], ...value[2], ...value[3]];
+        cvalue = [..._value[0], ..._value[1], ..._value[2], ..._value[3]];
+      }
+      value.forEach((item, index) => {
+        // 特殊格式  非必须
+        if (!item.hasOwnProperty('value') || item.norequire) {
+          if (item.hasOwnProperty('value')) data[item.name] = item.value;
+          return false
+        };
+        // 正常流程
+        // 判断是否为空
+        if (!item.value) { megs.push(`${item.title}不能为空!`); return false; };
+        // 数字类型
+        if (item.type == 'number' && !/^\d+.?\d*$/.test(item.value)) { megs.push(`${item.title}必须是数字!`); return false; }
+        // 正则判断
+        if (cvalue[index].reg && !cvalue[index].reg.test(item.value)) {
+          megs.push(`${item.title}格式不正确!`); return false;
+        };
+        // 号码不能相同 tel tstel ctel cttel
+        if (item.name == 'tel' || item.name == 'tstel' || item.name == 'ctel' || item.name == 'cttel') (!tels.some(item.value) || item.vlaue == '') && tels.push(item.value)
+          ;
+        data[item.name] = item.value;
+      });
+      (tels.length !== 4 && tels.length != 0) && megs.push(`手机号码不能重复`);
+      if (megs.length != 0) {
+        this.setData({ errorShow: true, megs, submitLock: false });
+        return false;
+      };
+      console.log(data)
+    },
+
+    // 保存
+    saveFunc () {
+      let { value, saveLock } = this.data, data = {};
+      value = [...value[0], ...value[1], ...value[2], ...value[3]];
+      value.forEach(item => { if (item.hasOwnProperty('value')) data[item.name] = item.value });
+      console.log(data)
+    },
+
+    // 输入
+    inputFunc (e) {
+      let { value } = this.data, { index } = e.currentTarget.dataset;
+      value[index[0]][index[1]]['value'] = e.detail.value;
+      this.setData({ value })
+    },
+
+    // switch 
+    switchFunc (e) {
+      let { value, switchs } = this.data, { index } = e.currentTarget.dataset;
+      let { name } = value[index[0]][index[1]];
+      if (switchs.hasOwnProperty(name)) {
+        console.log(switchs[name])
+        this.setData({ switchB: true, active: name, activeIndex: index })
+      }
+      else {
+        this.setData({ radioInputShow: true, activeIndex: index });
+      }
+    },
+
+    // 隐藏单选框 
+    hideModal () { this.setData({ switchB: false }) },
+    tehideModal () { this.setData({ radioInputShow: false }) },
+    // 单选框赋值
+    changeFunc (e) {
+      let { activeIndex, value } = this.data;
+      let _value = e.detail.value * 1;
+      value[activeIndex[0]][activeIndex[1]]['value'] = _value;
+      // 第一借款人与申请人关系特殊处理
+      if (value[activeIndex[0]][activeIndex[1]]['name'] == 'mstatus') {
+        console.log(_value)
+        value[2][2] = { ...value[2][2], disabled: _value == 1 ? true : false, value: _value == 1 ? 0 : '' }
+      }
+
+      if (value[activeIndex[0]][activeIndex[1]].hasOwnProperty('forlen')) {
+        for (let i = 1; i < (value[activeIndex[0]][activeIndex[1]]['forlen'] + 1); i++) {
+          value[activeIndex[0]][(activeIndex[1] + i)]['norequire'] = _value == 0 ? false : true;
+        }
+      }
+      this.setData({ value })
+    },
+
+    // 单选 输入
+    // radioInputChangeFunc (e) {
+    //   let { activeIndex, value } = this.data;
+    //   value[activeIndex[0]][activeIndex[1]]['value'] = _value;
+    // },
+
+    // 日期
+    DateChange (e) {
+      let { value } = this.data, { index } = e.currentTarget.dataset;
+      value[index[0]][index[1]]['value'] = e.detail.value;
+      this.setData({ value })
+    },
+  }
+})

+ 8 - 0
components/template/index.json

@@ -0,0 +1,8 @@
+{
+  "component": true,
+  "usingComponents": {
+    "van-goods-action": "@vant/weapp/goods-action/index",
+    "van-dialog": "@vant/weapp/dialog/index",
+  "van-goods-action-button": "@vant/weapp/goods-action-button/index"
+  }
+}

+ 204 - 0
components/template/index.wxml

@@ -0,0 +1,204 @@
+<view class="section">
+  <view class="cu-bar bg-white solid-bottom">
+    <view class="action">
+      <text class="cuIcon-title text-orange "></text>
+      <view>
+        <view class="text-xl text-black"><text>车辆和贷款信息</text> <text class="text-red">(必填)</text></view>
+        <view class="text-sm">机动车及与车辆相关的物理附属设备、服务、水费等 </view>
+      </view>
+    </view>
+  </view>
+  <!--form框类型奇特  特殊处理 除开发人员或者经验娴熟的人,其余不建议修改-->
+  <view wx:for="{{value[0]}}" wx:key="index" data-index="{{[0,index]}}"
+    class="cu-form-group {{(item.for && item.norequire) ? 'hide' :'show'}}"
+    bindtap="{{item.type=='switch' && !item.disabled ? 'switchFunc' : ''}}">
+    <!-- 没有输入意义的行 -->
+    <view wx:if="{{item.style}}" class="title">{{item.title}}</view>
+    <!-- 输入行 -->
+    <block wx:elif="{{item.type=='picker'}}">
+      <view class="title">{{item.title}}</view>
+      <picker disabled="{{item.disabled}}" class="picker" style="height:80rpx;line-height: 80rpx;" mode="date"
+        value="{{item.value}}" data-index="{{[0,index]}}" start="1900-01-01" end="{{endDate}}" bindchange="DateChange">
+        <view class="picker">
+          {{item.value}}
+        </view>
+      </picker>
+    </block>
+    <block wx:else>
+      <view class="title {{item.norequire ? 'text-blue' : ''}}" style="">{{item.title}}</view>
+      <input data-index="{{[0,index]}}" data-value="{{item.value}}" id="{{item.name}}"
+        type="{{item._type ? item._type : 'text'}}"
+        value="{{item.type == 'switch' ? switchs[item.name][item.value] : item.value}}" bindinput="inputFunc"
+        style="z-index: 0;height: 60rpx;transform: translateY(-3rpx);"
+        disabled="{{item.disabled || item.type=='switch'}}"
+        placeholder="{{(item.disabled || item.type=='switch') ? '' : item._title ? '请输入' +item._title : '请输入' + item.title}}"></input>
+      <!-- switch 特殊处理 -->
+      <view wx:if="{{item.type=='switch'}}" class="cuIcon-right"></view>
+    </block>
+  </view>
+
+  <view class="cu-bar bg-white solid-bottom solid-top">
+    <view class="action">
+      <text class="cuIcon-title text-orange "></text>
+      <view>
+        <view class="text-xl text-black"><text>申请人基本信息</text> <text class="text-red">(必填)</text></view>
+      </view>
+    </view>
+  </view>
+
+  <!--form框类型奇特  特殊处理 除开发人员或者经验娴熟的人,其余不建议修改-->
+  <view wx:for="{{value[1]}}" wx:key="index" data-index="{{[1,index]}}"
+    class="cu-form-group {{(item.for && item.norequire) ? 'hide' :'show'}}"
+    bindtap="{{item.type=='switch' && !item.disabled ? 'switchFunc' : ''}}">
+    <!-- 没有输入意义的行 -->
+    <view wx:if="{{item.style}}" class="title">{{item.title}}</view>
+    <!-- 输入行 -->
+    <block wx:elif="{{item.type=='picker'}}">
+      <view class="title">{{item.title}}</view>
+      <picker disabled="{{item.disabled}}" class="picker" style="height:80rpx;line-height: 80rpx;" mode="date"
+        value="{{item.value}}" data-index="{{[1,index]}}" start="1900-01-01" end="{{endDate}}" bindchange="DateChange">
+        <view class="picker">
+          {{item.value}}
+        </view>
+      </picker>
+    </block>
+    <block wx:else>
+      <view class="title {{item.norequire ? 'text-blue' : ''}}" style="">{{item.title}}</view>
+      <input data-index="{{[1,index]}}" data-value="{{item.value}}" id="{{item.name}}"
+        type="{{item._type ? item._type : 'text'}}"
+        value="{{item.type == 'switch' ? switchs[item.name][item.value] : item.value}}" bindinput="inputFunc"
+        style="z-index: 0;height: 60rpx;transform: translateY(-3rpx);"
+        disabled="{{item.disabled || item.type=='switch'}}"
+        placeholder="{{(item.disabled || item.type=='switch') ? '' : item._title ? '请输入' +item._title : '请输入' + item.title}}"></input>
+      <!-- switch 特殊处理 -->
+      <view wx:if="{{item.type=='switch'}}" class="cuIcon-right"></view>
+    </block>
+  </view>
+
+  <view class="cu-bar bg-white solid-bottom solid-top">
+    <view class="action">
+      <text class="cuIcon-title text-orange "></text>
+      <view>
+        <view class="text-xl text-black"><text>紧急联系人信息</text> <text class="text-red">(必填)</text></view>
+      </view>
+    </view>
+  </view>
+
+  <!--form框类型奇特  特殊处理 除开发人员或者经验娴熟的人,其余不建议修改-->
+  <view wx:for="{{value[2]}}" wx:key="index" data-index="{{[2,index]}}"
+    class="cu-form-group {{(item.for && item.norequire) ? 'hide' :'show'}}"
+    bindtap="{{item.type=='switch' && !item.disabled ? 'switchFunc' : ''}}">
+    <!-- 没有输入意义的行 -->
+    <view wx:if="{{item.style}}" class="title">{{item.title}}</view>
+    <!-- 输入行 -->
+    <block wx:elif="{{item.type=='picker'}}">
+      <view class="title">{{item.title}}</view>
+      <picker disabled="{{item.disabled}}" class="picker" style="height:80rpx;line-height: 80rpx;" mode="date"
+        value="{{item.value}}" data-index="{{[2,index]}}" start="1900-01-01" end="{{endDate}}" bindchange="DateChange">
+        <view class="picker">
+          {{item.value}}
+        </view>
+      </picker>
+    </block>
+    <block wx:else>
+      <view class="title {{item.norequire ? 'text-blue' : ''}}" style="">{{item.title}}</view>
+      <input data-index="{{[2,index]}}" data-value="{{item.value}}" id="{{item.name}}"
+        type="{{item._type ? item._type : 'text'}}"
+        value="{{item.type == 'switch' ? switchs[item.name][item.value] : item.value}}" bindinput="inputFunc"
+        style="z-index: 0;height: 60rpx;transform: translateY(-3rpx);"
+        disabled="{{item.disabled || item.type=='switch'}}"
+        placeholder="{{(item.disabled || item.type=='switch') ? '' : item._title ? '请输入' +item._title : '请输入' + item.title}}"></input>
+      <!-- switch 特殊处理 -->
+      <view wx:if="{{item.type=='switch'}}" class="cuIcon-right"></view>
+    </block>
+  </view>
+
+  <view wx:if="{{value[2][6]['value']==1}}" class="cu-bar bg-white solid-bottom solid-top">
+    <view class="action">
+      <text class="cuIcon-title text-orange "></text>
+      <view>
+        <view class="text-xl text-black"><text>共同借款人信息</text> <text class="text-red">(必填)</text></view>
+      </view>
+    </view>
+  </view>
+  <!--form框类型奇特  特殊处理 除开发人员或者经验娴熟的人,其余不建议修改-->
+  <view wx:if="{{value[2][6]['value']==1}}" wx:for="{{value[3]}}" wx:key="index" data-index="{{[3,index]}}"
+    class="cu-form-group {{(item.for && item.norequire) ? 'hide' :'show'}}"
+    bindtap="{{item.type=='switch' && !item.disabled ? 'switchFunc' : ''}}">
+    <!-- 没有输入意义的行 -->
+    <view wx:if="{{item.style}}" class="title">{{item.title}}</view>
+    <!-- 输入行 -->
+    <block wx:elif="{{item.type=='picker'}}">
+      <view class="title">{{item.title}}</view>
+      <picker disabled="{{item.disabled}}" class="picker" style="height:80rpx;line-height: 80rpx;" mode="date"
+        value="{{item.value}}" data-index="{{[3,index]}}" start="1900-01-01" end="{{endDate}}" bindchange="DateChange">
+        <view class="picker">
+          {{item.value}}
+        </view>
+      </picker>
+    </block>
+    <block wx:else>
+      <view class="title {{item.norequire ? 'text-blue' : ''}}" style="">{{item.title}}</view>
+      <input data-index="{{[3,index]}}" data-value="{{item.value}}" id="{{item.name}}"
+        type="{{item._type ? item._type : 'text'}}"
+        value="{{item.type == 'switch' ? switchs[item.name][item.value] : item.value}}" bindinput="inputFunc"
+        style="z-index: 0;height: 60rpx;transform: translateY(-3rpx);"
+        disabled="{{item.disabled || item.type=='switch'}}"
+        placeholder="{{(item.disabled || item.type=='switch') ? '' : item._title ? '请输入' +item._title : '请输入' + item.title}}"></input>
+      <!-- switch 特殊处理 -->
+      <view wx:if="{{item.type=='switch'}}" class="cuIcon-right"></view>
+    </block>
+  </view>
+</view>
+<!-- 功能栏 -->
+<van-goods-action wx:if="{{btn}}">
+  <van-goods-action-button type="warning" bind:click="saveFunc" text="保存" />
+  <van-goods-action-button loading="{{submitLock}}" bind:click="submitFunc" text="提交" />
+</van-goods-action>
+
+<!-- 单选 -->
+<view class="cu-modal {{switchB ?'show':''}}" bindtap="hideModal">
+  <view class="cu-dialog" catchtap>
+    <view class="bg-white padding solid-bottom">{{value[activeIndex[0]][activeIndex[1]]['title']}}</view>
+    <scroll-view scroll-y style="max-height: 50vh;">
+      <radio-group bindchange="changeFunc" class="block">
+        <view class="cu-list menu text-left">
+          <view class="cu-item" wx:for="{{switchs[active]}}" wx:key="index">
+            <label class="flex justify-between align-center flex-sub">
+              <view class="flex-sub">{{item}}</view>
+              <radio value="{{index}}" checked="{{value[activeIndex[0]][activeIndex[1]]['value'] === index}}"
+                class="round"></radio>
+            </label>
+          </view>
+        </view>
+      </radio-group>
+    </scroll-view>
+  </view>
+</view>
+
+<!-- 特殊 -->
+<view class="cu-modal {{ radioInputShow ?'show':''}}" bindtap="tehideModal">
+  <view class="cu-dialog" catchtap>
+    <view class="bg-white padding solid-bottom">{{value[activeIndex[0]][activeIndex[1]]['title']}}</view>
+    <scroll-view scroll-y style="max-height: 50vh;">
+      <radio-group bindchange="radioInputChangeFunc" class="block">
+        <view class="cu-list menu text-left">
+          <view class="cu-item" wx:for="{{shop}}" wx:key="index">
+            <label class="flex justify-between align-center flex-sub">
+              <view class="flex-sub">{{item.name}}</view>
+              <radio value="{{item.id}}" checked="{{value[activeIndex[0]][activeIndex[1]]['value']===item.id}} "
+                class="round"></radio>
+            </label>
+          </view>
+        </view>
+      </radio-group>
+    </scroll-view>
+  </view>
+</view>
+
+<!-- 错误提示框 -->
+<van-dialog use-slot title="提示" show="{{ errorShow }}" confirmText="关闭" bind:confirm="errorConfirmFunc">
+  <scroll-view scroll-y style="max-height:50vh;">
+    <view wx:for="{{megs}}" wx:key="index" class="margin-sm">{{index+1}}、 {{item}}</view>
+  </scroll-view>
+</van-dialog>

+ 42 - 0
components/template/index.wxss

@@ -0,0 +1,42 @@
+/* 开发者 */
+.section{
+  margin-bottom: 50px;
+}
+
+.section .title{
+  font-size: 32rpx;
+}
+
+.section .cu-form-group{
+  min-height: 80rpx;
+}
+
+.cu-form-group picker .picker{
+  line-height: 80rpx;
+}
+
+.section .picker::after{
+  font-family: "cuIcon";
+  display: block;
+  content: "\e6a3";
+  position: absolute;
+  font-size: 26rpx;
+  color: #666;
+  line-height: 80rpx;
+  width: 60rpx;
+  text-align: center;
+  top: 0;
+  bottom: 0;
+  right: -18rpx;
+  margin: auto;
+  margin-top: auto;
+  margin-right: auto;
+  margin-bottom: auto;
+  margin-left: auto;
+}
+
+
+
+.section .hide{
+  display: none;
+}

+ 1 - 1
config.js

@@ -1,5 +1,5 @@
 // 请求api
-export const requestUrl = "";
+export const requestUrl = "http://192.168.2.45:8888";
 
 // 拦截
 // 发送请求处理 

+ 2 - 98
pages/add/index.js

@@ -1,108 +1,12 @@
-import { value, switchs, date } from "./config"
 const app = getApp();
 Page({
-  _value: value,
   data: {
     CustomBar: app.globalData.CustomBar,
-    value,
-    active: '',
-    activeObject: {},
-    activeIndex: [],
-    switchB: false,
-    endDate: date(),
-    switchs,
-    submitLock: false,
-    saveLock: false,
-  },
-
-  // 错误提示框
-  errorConfirmFunc () { },
-
-  // 提交
-  submitFunc () {
-    let { value, submitLock } = this.data, megs = [], data = {}, _value = this._value;
-    if (submitLock) return false;
-    this.setData({ submitLock: true });
-    if (value[2][6]['value'] == 0) {
-      value = [...value[0], ...value[1], ...value[2]];
-      _value = [..._value[0], ..._value[1], ..._value[2]];
-    } else {
-      value = [...value[0], ...value[1], ...value[2], ...value[3]];
-      _value = [..._value[0], ..._value[1], ..._value[2], ..._value[3]];
-    }
-    value.forEach((item, index) => {
-      // 特殊格式  非必须
-      if (!item.hasOwnProperty('value') || item.norequire) {
-        if (item.hasOwnProperty('value')) data[item.name] = item.value;
-        return false
-      };
-      // 正常流程
-      // 判断是否为空
-      if (!item.value) { megs.push(`${item.title}不能为空!`); return false; };
-      // 数字类型
-      if (item.type == 'number' && !/^\d+.?\d*$/.test(item.value)) { megs.push(`${item.title}必须是数字!`); return false; }
-      // 正则判断
-      if (_value[index].reg && !_value[index].reg.test(item.value)) {
-        megs.push(`${item.title}格式不正确!`); return false;
-      };
-      data[item.name] = item.value;
-    })
-    if (megs.length != 0) {
-      this.setData({ errorShow: true, megs, submitLock: false });
-      return false;
-    };
-    console.log(data);
-
-  },
-
-  // 保存
-  saveFunc () {
-    let { value, saveLock } = this.data, data = {};
-    value = [...value[0], ...value[1], ...value[2], ...value[3]];
-    value.forEach(item => { if (item.hasOwnProperty('value')) data[item.name] = item.value });
-    console.log(data)
-  },
-
-  // 输入
-  inputFunc (e) {
-    let { value } = this.data, { index } = e.currentTarget.dataset;
-    value[index[0]][index[1]]['value'] = e.detail.value;
-    this.setData({ value })
-  },
 
-  // switch 
-  switchFunc (e) {
-    let { value, switchs } = this.data, { index } = e.currentTarget.dataset;
-    let { name } = value[index[0]][index[1]];
-    if (switchs.hasOwnProperty(name)) {
-      this.setData({ switchB: true, active: name, activeIndex: index })
-    } else {
-      let obj = Object.fromEntries([[`${name}Show`, true]])
-      this.setData({ ...obj });
-    }
   },
+  
 
-  // 隐藏单选框 
-  hideModal () { this.setData({ switchB: false }) },
 
-  // 单选框赋值
-  changeFunc (e) {
-    let { activeIndex, value } = this.data;
-    let _value = e.detail.value * 1;
-    value[activeIndex[0]][activeIndex[1]]['value'] = _value;
-    if (value[activeIndex[0]][activeIndex[1]].hasOwnProperty('forlen')) {
-      for (let i = 1; i < (value[activeIndex[0]][activeIndex[1]]['forlen'] + 1); i++) {
-        value[activeIndex[0]][(activeIndex[1] + i)]['norequire'] = _value == 0 ? false : true;
-      }
-    }
-    this.setData({ value })
-  },
-  // 日期
-  DateChange (e) {
-    let { value } = this.data, { index } = e.currentTarget.dataset;
-    value[index[0]][index[1]]['value'] = e.detail.value;
-    this.setData({ value })
-  },
   onLoad: function (options) {
 
   },
@@ -110,7 +14,7 @@ Page({
 
   },
   onShow: function () {
-
+    if (!app.globalData._initState) { wx.switchTab({ url: '/pages/index/index' }); }
   },
   onHide: function () {
 

+ 1 - 4
pages/add/index.json

@@ -1,8 +1,5 @@
 {
   "usingComponents": {
-    "van-goods-action-icon": "@vant/weapp/goods-action-icon/index",
-    "van-goods-action": "@vant/weapp/goods-action/index",
-    "van-dialog": "@vant/weapp/dialog/index",
-  "van-goods-action-button": "@vant/weapp/goods-action-button/index"
+   "Template":"../../components/template/index"
   }
 }

+ 1 - 184
pages/add/index.wxml

@@ -1,187 +1,4 @@
 <cu-custom bgColor="bg-gradual-blue">
   <view slot="content">新增填报</view>
 </cu-custom>
-<view class="section">
-  <view class="cu-bar bg-white solid-bottom">
-    <view class="action">
-      <text class="cuIcon-title text-orange "></text>
-      <view>
-        <view class="text-xl text-black"><text>车辆和贷款信息</text> <text class="text-red">(必填)</text></view>
-        <view class="text-sm">机动车及与车辆相关的物理附属设备、服务、水费等 </view>
-      </view>
-    </view>
-  </view>
-  <!--form框类型奇特  特殊处理 除开发人员或者经验娴熟的人,其余不建议修改-->
-  <view wx:for="{{value[0]}}" wx:key="index" data-index="{{[0,index]}}"
-    class="cu-form-group {{(item.for && item.norequire) ? 'hide' :'show'}}"
-    bindtap="{{item.type=='switch' ? 'switchFunc' : ''}}">
-    <!-- 没有输入意义的行 -->
-    <view wx:if="{{item.style}}" class="title">{{item.title}}</view>
-    <!-- 输入行 -->
-    <block wx:elif="{{item.type=='picker'}}">
-      <view class="title">{{item.title}}</view>
-      <picker class="picker" style="height:80rpx;line-height: 80rpx;" mode="date" value="{{item.value}}"
-        data-index="{{[0,index]}}" start="1900-01-01" end="{{endDate}}" bindchange="DateChange">
-        <view class="picker">
-          {{item.value}}
-        </view>
-      </picker>
-    </block>
-    <block wx:else>
-      <view class="title {{item.norequire ? 'text-blue' : ''}}" style="">{{item.title}}</view>
-      <input data-index="{{[0,index]}}" data-value="{{item.value}}" id="{{item.name}}"
-        type="{{item._type ? item._type : 'text'}}"
-        value="{{item.type == 'switch' ? switchs[item.name][item.value] : item.value}}" bindinput="inputFunc"
-        style="z-index: 0;height: 60rpx;transform: translateY(-3rpx);"
-        disabled="{{item.disabled || item.type=='switch'}}"
-        placeholder="{{(item.disabled || item.type=='switch') ? '' : item._title ? '请输入' +item._title : '请输入' + item.title}}"></input>
-      <!-- switch 特殊处理 -->
-      <view wx:if="{{item.type=='switch'}}" class="cuIcon-right"></view>
-    </block>
-  </view>
-
-  <view class="cu-bar bg-white solid-bottom solid-top">
-    <view class="action">
-      <text class="cuIcon-title text-orange "></text>
-      <view>
-        <view class="text-xl text-black"><text>申请人基本信息</text> <text class="text-red">(必填)</text></view>
-      </view>
-    </view>
-  </view>
-
-  <!--form框类型奇特  特殊处理 除开发人员或者经验娴熟的人,其余不建议修改-->
-  <view wx:for="{{value[1]}}" wx:key="index" data-index="{{[1,index]}}"
-    class="cu-form-group {{(item.for && item.norequire) ? 'hide' :'show'}}"
-    bindtap="{{item.type=='switch' ? 'switchFunc' : ''}}">
-    <!-- 没有输入意义的行 -->
-    <view wx:if="{{item.style}}" class="title">{{item.title}}</view>
-    <!-- 输入行 -->
-    <block wx:elif="{{item.type=='picker'}}">
-      <view class="title">{{item.title}}</view>
-      <picker class="picker" style="height:80rpx;line-height: 80rpx;" mode="date" value="{{item.value}}"
-        data-index="{{[1,index]}}" start="1900-01-01" end="{{endDate}}" bindchange="DateChange">
-        <view class="picker">
-          {{item.value}}
-        </view>
-      </picker>
-    </block>
-    <block wx:else>
-      <view class="title {{item.norequire ? 'text-blue' : ''}}" style="">{{item.title}}</view>
-      <input data-index="{{[1,index]}}" data-value="{{item.value}}" id="{{item.name}}"
-        type="{{item._type ? item._type : 'text'}}"
-        value="{{item.type == 'switch' ? switchs[item.name][item.value] : item.value}}" bindinput="inputFunc"
-        style="z-index: 0;height: 60rpx;transform: translateY(-3rpx);"
-        disabled="{{item.disabled || item.type=='switch'}}"
-        placeholder="{{(item.disabled || item.type=='switch') ? '' : item._title ? '请输入' +item._title : '请输入' + item.title}}"></input>
-      <!-- switch 特殊处理 -->
-      <view wx:if="{{item.type=='switch'}}" class="cuIcon-right"></view>
-    </block>
-  </view>
-
-  <view class="cu-bar bg-white solid-bottom solid-top">
-    <view class="action">
-      <text class="cuIcon-title text-orange "></text>
-      <view>
-        <view class="text-xl text-black"><text>紧急联系人信息</text> <text class="text-red">(必填)</text></view>
-      </view>
-    </view>
-  </view>
-
-  <!--form框类型奇特  特殊处理 除开发人员或者经验娴熟的人,其余不建议修改-->
-  <view wx:for="{{value[2]}}" wx:key="index" data-index="{{[2,index]}}"
-    class="cu-form-group {{(item.for && item.norequire) ? 'hide' :'show'}}"
-    bindtap="{{item.type=='switch' ? 'switchFunc' : ''}}">
-    <!-- 没有输入意义的行 -->
-    <view wx:if="{{item.style}}" class="title">{{item.title}}</view>
-    <!-- 输入行 -->
-    <block wx:elif="{{item.type=='picker'}}">
-      <view class="title">{{item.title}}</view>
-      <picker class="picker" style="height:80rpx;line-height: 80rpx;" mode="date" value="{{item.value}}"
-        data-index="{{[2,index]}}" start="1900-01-01" end="{{endDate}}" bindchange="DateChange">
-        <view class="picker">
-          {{item.value}}
-        </view>
-      </picker>
-    </block>
-    <block wx:else>
-      <view class="title {{item.norequire ? 'text-blue' : ''}}" style="">{{item.title}}</view>
-      <input data-index="{{[2,index]}}" data-value="{{item.value}}" id="{{item.name}}"
-        type="{{item._type ? item._type : 'text'}}"
-        value="{{item.type == 'switch' ? switchs[item.name][item.value] : item.value}}" bindinput="inputFunc"
-        style="z-index: 0;height: 60rpx;transform: translateY(-3rpx);"
-        disabled="{{item.disabled || item.type=='switch'}}"
-        placeholder="{{(item.disabled || item.type=='switch') ? '' : item._title ? '请输入' +item._title : '请输入' + item.title}}"></input>
-      <!-- switch 特殊处理 -->
-      <view wx:if="{{item.type=='switch'}}" class="cuIcon-right"></view>
-    </block>
-  </view>
-
-  <view wx:if="{{value[2][6]['value']==1}}" class="cu-bar bg-white solid-bottom solid-top">
-    <view class="action">
-      <text class="cuIcon-title text-orange "></text>
-      <view>
-        <view class="text-xl text-black"><text>共同借款人信息</text> <text class="text-red">(必填)</text></view>
-      </view>
-    </view>
-  </view>
-  <!--form框类型奇特  特殊处理 除开发人员或者经验娴熟的人,其余不建议修改-->
-  <view wx:if="{{value[2][6]['value']==1}}" wx:for="{{value[3]}}" wx:key="index" data-index="{{[3,index]}}"
-    class="cu-form-group {{(item.for && item.norequire) ? 'hide' :'show'}}"
-    bindtap="{{item.type=='switch' ? 'switchFunc' : ''}}">
-    <!-- 没有输入意义的行 -->
-    <view wx:if="{{item.style}}" class="title">{{item.title}}</view>
-    <!-- 输入行 -->
-    <block wx:elif="{{item.type=='picker'}}">
-      <view class="title">{{item.title}}</view>
-      <picker class="picker" style="height:80rpx;line-height: 80rpx;" mode="date" value="{{item.value}}"
-        data-index="{{[3,index]}}" start="1900-01-01" end="{{endDate}}" bindchange="DateChange">
-        <view class="picker">
-          {{item.value}}
-        </view>
-      </picker>
-    </block>
-    <block wx:else>
-      <view class="title {{item.norequire ? 'text-blue' : ''}}" style="">{{item.title}}</view>
-      <input data-index="{{[3,index]}}" data-value="{{item.value}}" id="{{item.name}}"
-        type="{{item._type ? item._type : 'text'}}"
-        value="{{item.type == 'switch' ? switchs[item.name][item.value] : item.value}}" bindinput="inputFunc"
-        style="z-index: 0;height: 60rpx;transform: translateY(-3rpx);"
-        disabled="{{item.disabled || item.type=='switch'}}"
-        placeholder="{{(item.disabled || item.type=='switch') ? '' : item._title ? '请输入' +item._title : '请输入' + item.title}}"></input>
-      <!-- switch 特殊处理 -->
-      <view wx:if="{{item.type=='switch'}}" class="cuIcon-right"></view>
-    </block>
-  </view>
-</view>
-<!-- 功能栏 -->
-<van-goods-action>
-  <van-goods-action-button type="warning" bind:click="saveFunc" text="保存" />
-  <van-goods-action-button loading="{{submitLock}}" bind:click="submitFunc" text="提交" />
-</van-goods-action>
-
-<!-- 单选 -->
-<view class="cu-modal {{switchB ?'show':''}}" bindtap="hideModal">
-  <view class="cu-dialog" catchtap>
-    <view class="bg-white padding solid-bottom">{{value[activeIndex[0]][activeIndex[1]]['title']}}</view>
-    <scroll-view scroll-y style="max-height: 50vh;">
-      <radio-group bindchange="changeFunc" class="block">
-        <view class="cu-list menu text-left">
-          <view class="cu-item" wx:for="{{switchs[active]}}" wx:key="index">
-            <label class="flex justify-between align-center flex-sub">
-              <view class="flex-sub">{{item}}</view>
-              <radio value="{{index}}" checked="{{value[activeIndex[0]][activeIndex[1]]['value']===index}}"
-                class="round"></radio>
-            </label>
-          </view>
-        </view>
-      </radio-group>
-    </scroll-view>
-  </view>
-</view>
-
-<!-- 错误提示框 -->
-<van-dialog use-slot title="提示" show="{{ errorShow }}" confirmText="关闭" bind:confirm="errorConfirmFunc">
-  <scroll-view scroll-y style="max-height:50vh;">
-    <view wx:for="{{megs}}" wx:key="index" class="margin-sm">{{index+1}}、 {{item}}</view>
-  </scroll-view>
-</van-dialog>
+<Template />

+ 5 - 1
pages/index/index.js

@@ -23,8 +23,12 @@ Page({
     let { index } = e.currentTarget.dataset, { tips } = this.data;
     console.log(tips[index])
   },
-  onLoad: function (options) {
 
+  onLoad: async function (options) {
+    try {
+      let res = await wx.$request({ method: "get", url: "/order/productDict/" });
+      console.log(res)
+    } catch (err) { wx.$err(err) }
   },
   onReady: function () {
 

+ 65 - 6
pages/login/index.js

@@ -1,18 +1,45 @@
+const app = getApp();
 Page({
   data: {
     waveimg: "../../assets/login/wave.svg",
     // 用户信息
-    login: {
-      imgurl: 'https://ossweb-img.qq.com/images/lol/web201310/skin/big99008.jpg',
-      state: "未登录",
-    },
+    login: {},
     // 列表
     items: [
+      { imgurl: 'loading', title: "更新资料", require: true, success () { this.updateFunc() } },
       { imgurl: 'punch', title: "草稿箱", require: true, success () { wx.navigateTo({ url: '/pages/template/index?data=drafts', }) } },
       { imgurl: 'form', title: "已填报", require: true, success () { wx.navigateTo({ url: '/pages/template/index?data=provided', }) } }
     ],
     update_lock: false,//更新资料按钮锁
     subscriber_lock: false,//订阅消息按钮锁
+    actions: [{ name: "微信快捷登录", color: '#39b54a', openType: "getPhoneNumber" }]
+  },
+  // 更新资料
+  async updateFunc () {
+    function getUserProfile () {
+      return new Promise((resolve, reject) => {
+        wx.getUserProfile({
+          desc: '用于完善会员资料',
+          success: (res) => {
+            let { encryptedData, iv } = res, { appId: appid } = app.globalData.mustArg, { openid } = app.globalData.user;
+            resolve({ encryptedData, iv, appid, openid })
+          },
+          fail: err => reject(err)
+        })
+      })
+    }
+    try {
+      let { encryptedData, iv, appid, openid } = await getUserProfile();
+      let res = await wx.$request({
+        method: "post", url: "/account/setUserInfo/", data: {
+          appid, openid, iv, encryptedData
+        },
+      });
+      let { face, name } = res.data;
+      this.setData({ login: { state: name, imgurl: face } });
+      app.globalData.mustArg = { ...app.globalData.mustArg, encryptedData, iv };
+      app.globalData.user = { ...app.globalData.user, face, name }
+    } catch (err) { wx.$err(err) }
   },
 
   // 功能事件
@@ -20,14 +47,46 @@ Page({
     let { index } = e.currentTarget.dataset, { items } = this.data;
     items[index]['success'].bind(this)();
   },
-  onLoad: function (options) {
 
+  // 登录
+  loginFunc () { this.setData({ show: true }) },
+  onClose () {
+    this.setData({ show: false });
+  },
+  async getphonenumber (e) {
+    try {
+      if (!e.detail.hasOwnProperty('iv')) return false;
+      let { encryptedData, iv } = e.detail, { appId: appid } = app.globalData.mustArg, { openid } = app.globalData.user;
+      let res = await wx.$request({ url: "/account/wxbind/", data: { appid, openid, encryptedData, iv }, method: "post" });
+      let { face, name, tel, token, type, user_id } = res.data;
+      wx.setStorageSync("token", token ? 'JWT ' + token : '');
+      let login = {
+        imgurl: token ? face : app.globalData.mustArg.userInfo.avatarUrl,
+        state: token ? name : "未登录",
+      };
+      this.setData({ login });
+      app.globalData.user = { ...app.globalData.user, ace, name, tel, token, type, user_id };
+    } catch (err) { wx.$err(err) }
+
+  },
+  onSelect (event) {
+
+  },
+  onLoad: function (options) {
   },
   onReady: function () {
 
   },
   onShow: function () {
-
+    if (app.globalData._initState) {
+      let login = {
+        imgurl: (wx.getStorageSync('token') && app.globalData.user.face) ? app.globalData.user.face : app.globalData.mustArg.userInfo.avatarUrl,
+        state: wx.getStorageSync('token') ? app.globalData.user.name : "未登录",
+      };
+      this.setData({ login });
+    } else {
+      wx.switchTab({ url: '/pages/index/index' });
+    }
   },
   onHide: function () {
 

+ 3 - 1
pages/login/index.json

@@ -1,3 +1,5 @@
 {
-  "usingComponents": {}
+  "usingComponents": {
+    "van-action-sheet": "@vant/weapp/action-sheet/index"
+  }
 }

+ 4 - 8
pages/login/index.wxml

@@ -1,18 +1,12 @@
 <scroll-view scroll-y class="DrawerPage ">
   <view class="header bg-blue" style="background-image: url({{waveimg}});">
-    <view class="user">
+    <view bindtap="{{login.state=='未登录' ? 'loginFunc' : ''}}" class="user">
       <view class="cu-avatar xl round margin-bottom" style="background-image:url({{login.imgurl}});"></view>
       <view class="text-center text-xl text-bold">
         <text>{{login.name}}</text>
         <text class="{{login.state=='未登录' ? 'text-red' : 'padding'}}">{{login.state}}</text>
         <text wx:if="!login.usertype" class="text-black">{{login.usertype}}</text>
       </view>
-      <view wx:if="{{login.state !='未登录'}}" class="text-center">
-        <button bindtap="updateFunc" class="cu-btn round bg-olive marign shadow }">
-          <text wx:if="{{update_lock}}" class="cuIcon-loading2 iconfont-spin"> </text>更新资料</button>
-        <button bindtap="subscriberFunc" class="cu-btn round bg-olive margin shadow">
-          <text wx:if="{{subscriber_lock}}" class="cuIcon-loading2 iconfont-spin"></text>订阅消息</button>
-      </view>
     </view>
   </view>
   <view class="cu-list menu margin-bottom-xl shadow-lg radius">
@@ -23,4 +17,6 @@
       </view>
     </view>
   </view>
-</scroll-view>
+</scroll-view>
+<van-action-sheet show="{{ show }}" bind:getphonenumber="getphonenumber" actions="{{ actions }}" bind:close="onClose"
+  bind:select="onSelect" />

+ 1 - 1
project.config.json

@@ -9,7 +9,7 @@
     ]
   },
   "setting": {
-    "urlCheck": true,
+    "urlCheck": false,
     "es6": true,
     "enhance": true,
     "postcss": true,

+ 26 - 1
utils/init.js

@@ -40,14 +40,39 @@ class Index {
     }
     wx.$request = _request;
   }
+  // 小程序需要的参数
+  static mustArg = () => {
+    function login () { return new Promise((resolve, reject) => wx.login({ success: res => resolve(res), fail: () => reject("code获取失败!") })) };
+    function getUserInfo () { return new Promise((resolve, reject) => wx.getUserInfo({ success: res => resolve(res), fail: () => reject("账号信息获取失败!") })) }
+    return new Promise(async (resolve, reject) => {
+      try {
+        // appId
+        const accountinfo = wx.getAccountInfoSync();
+        let { appId } = accountinfo.miniProgram;
+        // code
+        let { code } = await login();
+        // encryptedData, iv, userInfo
+        let { encryptedData, iv, userInfo } = await getUserInfo();
+        resolve({ appId, code, encryptedData, iv, userInfo })
+      } catch (err) { reject(err) }
+    })
+  }
 }
 
 async function init () {
   try {
     await Index.system(this);
     Index.err();
+    // 清空token
+    wx.setStorageSync("token", '');
     Index.request();
-    this.globalData = { ...this.globalData };
+    // 小程序需要的参数
+    let mustArg = await Index.mustArg();
+    // 小程序首次请求
+    let user = await wx.$request({ url: "/account/code2Session/", method: "post", data: { code: mustArg.code, appid: mustArg.appId } });
+    wx.setStorageSync("token", user.data.token ? 'JWT ' + user.data.token : '');
+
+    this.globalData = { ...this.globalData, mustArg, user: user.data, _initState: true, };
     console.log(this.globalData)
 
   } catch (err) {