Explorar o código

部分接口完成

wangxin %!s(int64=2) %!d(string=hai) anos
pai
achega
3b48f47f20

+ 2 - 0
miniprogram/api/api.ts

@@ -15,6 +15,8 @@ export default {
 		getHwUserInfo: '/api/hwUser/getHwUserInfo', //获取个人信息
 		changeAvatar: '/api/hwUser/changeAvatar', //更改头像
 		banner: '/api/hwUser/banner', //获取首页banner
+		getOcrKey: '/api/hwUser/getOcrKey',//获取ocr秘钥
+		authenticate: '/api/hwUser/authenticate', // 实名认证
 	},
 	hwOrder: {
 		getOrders: '/api/hwOrder/getOrders', //获取订单列表

+ 1 - 0
miniprogram/app.json

@@ -16,6 +16,7 @@
 		"pages/version/version",
 		"pages/web-view/web-view",
 		"pages/realNameAuthentication/realNameAuthentication",
+		"pages/realNameAuthentication/success",
 		"ocrsdk/pages/id-card/id-card",
 		"ocrsdk/pages/index/index"
 	],

+ 245 - 225
miniprogram/pages/my-order/my-order.ts

@@ -1,241 +1,261 @@
 // pages/my-order/my-order.js
 const app = getApp();
+import { getHwUserInfo } from "../../utils/util";
 import { confirmOrderImpl, getOrdersImpl, confirmECOrdersImpl } from '../../service/impl/hwOrder.impl'
 Page({
 
-  /**
-   * 页面的初始数据
-   */
-  data: {
-    list: [], //订单列表
-    show: false, //展示无数据页面
-    pageNo: 1, //页码
-    isLast: false, //是否是最后一页
-    offline: false,
-    status: 0,
-    listNumber: 0
-  },
-  /**
-   * 点击切换状态
-   * @param e 
-   */
-  changeSelect(e: any) {
-    const index = e.currentTarget.dataset.index;
-    this.setData({
-      status: Number(index),
-      list: []
-    }, () => {
-      this.getList(1)
-    })
-  },
-  /**
-   * 跳转详情页
-   * @id {string} 订单ID
-   */
-  toDetail(e: any) {
-    const id = e.currentTarget.dataset.id;
-    wx.navigateTo({
-      url: `/pages/detail/detail?id=${id}&&status=2`,
-    })
-  },
-  /**
-   * 查看合同
-   * @contract {string}  合同
-   * 
-   */
-  checkContract(e: any) {
-    const contract = e.currentTarget.dataset.contract;
-    if (contract) {
-      wx.downloadFile({
-        url: contract,
-        success: (res) => {
-          wx.openDocument({
-            filePath: res.tempFilePath,
-          })
-        }
-      })
-    } else {
+	/**
+	 * 页面的初始数据
+	 */
+	data: {
+		list: [], //订单列表
+		show: false, //展示无数据页面
+		pageNo: 1, //页码
+		isLast: false, //是否是最后一页
+		offline: false,
+		status: 0,
+		listNumber: 0
+	},
+	/**
+	 * 点击切换状态
+	 * @param e 
+	 */
+	changeSelect(e: any) {
+		const index = e.currentTarget.dataset.index;
+		this.setData({
+			status: Number(index),
+			list: []
+		}, () => {
+			this.getList(1)
+		})
+	},
+	/**
+	 * 跳转详情页
+	 * @id {string} 订单ID
+	 */
+	toDetail(e: any) {
+		const id = e.currentTarget.dataset.id;
+		wx.navigateTo({
+			url: `/pages/detail/detail?id=${id}&&status=2`,
+		})
+	},
+	/**
+	 * 查看合同
+	 * @contract {string}  合同
+	 * 
+	 */
+	checkContract(e: any) {
+		const contract = e.currentTarget.dataset.contract;
+		if (contract) {
+			wx.downloadFile({
+				url: contract,
+				success: (res) => {
+					wx.openDocument({
+						filePath: res.tempFilePath,
+					})
+				}
+			})
+		} else {
 
-    }
-  },
-  /**
-   * 确认订单
-   * @orderId {string} 订单ID
-   */
-  confirm(e: any) {
-    const id = e.currentTarget.dataset.id;
-    // const index = e.currentTarget.dataset.index;
-    const workContractType = e.currentTarget.dataset.workcontracttype;
-    // const parentindex = e.currentTarget.dataset.parentindex;
-    // 电子合同确认
-    if (workContractType === 1) {
-      confirmECOrdersImpl({
-        orderId: id
-      }).then(res => {
-        if (res.errCode === 0) {
-          // 跳转webview
-          wx.reLaunch({
-            url: `/pages/web-view/web-view?url=${encodeURIComponent(res.data.url)}`,
-            success: () => {
-              // 存入缓存方便跳回
-              app.globalData.webview = `/${this.route}`;
-              // wx.setStorageSync('web_view', `/${this.route}`)
-            }
-          })
-        }
-      })
-    }
-    // 非电子合同确认
-    if (workContractType === 0) {
-      confirmOrderImpl({
-        orderId: id
-      }).then(res => {
-        if (res.errCode === 0) {
-          wx.showToast({
-            title: '订单已确认',
-            success: () => {
-              // 确认成功  更改页面订单状态
-              this.getList()
-              // this.setData({
-              //   [`list[${parentindex}][${index}].status`]: 2,
-              //   // [`list[${parentindex}][${index}].serviceStage`]: 2,
-              // })
-            }
-          })
-        }
-      })
-    }
-  },
-  /**
-   * 获取订单列表
-   * @pageNo {number} 页码
-   * @pageSize {number} 页面条数
-   */
-  getList(pageNumber?: number) {
-    let pageNo: number = pageNumber || this.data.pageNo
-    getOrdersImpl({
-      pageNo,
-      pageSize: 10,
-      status: this.data.status
-    }).then(res => {
-      if (res.errCode === 0) {
-        if (pageNo === 1 && res.data.hwOrderList && res.data.hwOrderList.length === 0) {
-          this.setData({
-            show: true
-          }, () => {
-            if (this.data.status === 0) {
-              this.setData({
-                listNumber: this.data.list.length
-              })
-            }
-          })
-        } else {
-          pageNo++;
-          this.setData({
-            list: this.data.list.concat(res.data.hwOrderList),
-            isLast: res.data.isLast,
-            pageNo
-          }, () => {
-            if (this.data.status === 0) {
-              this.setData({
-                listNumber: this.data.list.length
-              })
-            }
-          })
-        }
-      }
-    }).catch(err => {
-      if (err === 'offline') {
-        this.setData({
-          offline: true
-        })
-      }
-    })
-  },
-  /**
-   * 列表重载
-   */
-  reload() {
-    this.getList(1)
-  },
-  checkLogin(): Boolean {
-    if (wx.getStorageSync('userId') && wx.getStorageSync('userToken')) {
-      return true
-    } else {
-      wx.reLaunch({
-        url: '/pages/login/login',
-      })
-      return false
-    }
-  },
-  /**
-   * 生命周期函数--监听页面加载
-   */
-  onLoad: function () {
-    this.checkLogin()
-  },
+		}
+	},
+	/**
+	 * 确认订单
+	 * @orderId {string} 订单ID
+	 */
+	async confirm(e: any) {
+		const id = e.currentTarget.dataset.id;
+		// const index = e.currentTarget.dataset.index;
+		const workContractType = e.currentTarget.dataset.workcontracttype;
+		// const parentindex = e.currentTarget.dataset.parentindex;
+		const userInfo = await getHwUserInfo()
+		if (userInfo.authenticationStatus === 1) {
+			// 电子合同确认
+			if (workContractType === 1) {
+				confirmECOrdersImpl({
+					orderId: id
+				}).then(res => {
+					if (res.errCode === 0) {
+						// 跳转webview
+						// wx.reLaunch({
+						// 	url: `/pages/web-view/web-view?url=${encodeURIComponent(res.data.url)}`,
+						// 	success: () => {
+						// 		// 存入缓存方便跳回
+						// 		app.globalData.webview = `/${this.route}`;
+						// 		// wx.setStorageSync('web_view', `/${this.route}`)
+						// 	}
+						// })
+						wx.openEmbeddedMiniProgram({
+							appId: 'wxa023b292fd19d41d',
+							// path: "/" + data
+						});
+					}
+				})
+			}
+			// 非电子合同确认
+			if (workContractType === 0) {
+				confirmOrderImpl({
+					orderId: id
+				}).then(res => {
+					if (res.errCode === 0) {
+						wx.showToast({
+							title: '订单已确认',
+							success: () => {
+								// 确认成功  更改页面订单状态
+								this.getList()
+								// this.setData({
+								//   [`list[${parentindex}][${index}].status`]: 2,
+								//   // [`list[${parentindex}][${index}].serviceStage`]: 2,
+								// })
+							}
+						})
+					}
+				})
+			}
+		} else {
+			// wx.showModal({
+			// 	title: '提示',
+			// 	content: '您还未实名,是否立即实名?',
+			// 	success: res => {
+			// 		if (res.confirm) {
+			wx.navigateTo({
+				url: "/pages/realNameAuthentication/realNameAuthentication",
+			});
+			// 		}
+			// 	}
+			// })
+		}
+	},
+	/**
+	 * 获取订单列表
+	 * @pageNo {number} 页码
+	 * @pageSize {number} 页面条数
+	 */
+	getList(pageNumber?: number) {
+		let pageNo: number = pageNumber || this.data.pageNo
+		getOrdersImpl({
+			pageNo,
+			pageSize: 10,
+			status: this.data.status
+		}).then(res => {
+			if (res.errCode === 0) {
+				if (pageNo === 1 && res.data.hwOrderList && res.data.hwOrderList.length === 0) {
+					this.setData({
+						show: true
+					}, () => {
+						if (this.data.status === 0) {
+							this.setData({
+								listNumber: this.data.list.length
+							})
+						}
+					})
+				} else {
+					pageNo++;
+					this.setData({
+						list: this.data.list.concat(res.data.hwOrderList),
+						isLast: res.data.isLast,
+						pageNo
+					}, () => {
+						if (this.data.status === 0) {
+							this.setData({
+								listNumber: this.data.list.length
+							})
+						}
+					})
+				}
+			}
+		}).catch(err => {
+			if (err === 'offline') {
+				this.setData({
+					offline: true
+				})
+			}
+		})
+	},
+	/**
+	 * 列表重载
+	 */
+	reload() {
+		this.getList(1)
+	},
+	checkLogin(): Boolean {
+		if (wx.getStorageSync('userId') && wx.getStorageSync('userToken')) {
+			return true
+		} else {
+			wx.reLaunch({
+				url: '/pages/login/login',
+			})
+			return false
+		}
+	},
+	/**
+	 * 生命周期函数--监听页面加载
+	 */
+	onLoad: function () {
+		this.checkLogin()
+	},
 
-  /**
-   * 生命周期函数--监听页面初次渲染完成
-   */
-  onReady: function () {
+	/**
+	 * 生命周期函数--监听页面初次渲染完成
+	 */
+	onReady: function () {
 
-  },
+	},
 
-  /**
-   * 生命周期函数--监听页面显示
-   */
-  onShow: function () {
-    wx.hideHomeButton();
-    if (this.checkLogin()) {
-      // 获取订单列表
-      this.setData({
-        list: [],
-        pageNo: 1
-      }, () => {
-        this.getList()
-      })
-    }
-  },
+	/**
+	 * 生命周期函数--监听页面显示
+	 */
+	onShow: function () {
+		wx.hideHomeButton();
+		if (this.checkLogin()) {
+			// 获取订单列表
+			this.setData({
+				list: [],
+				pageNo: 1
+			}, () => {
+				this.getList()
+			})
+		}
+	},
 
-  /**
-   * 生命周期函数--监听页面隐藏
-   */
-  onHide: function () {
+	/**
+	 * 生命周期函数--监听页面隐藏
+	 */
+	onHide: function () {
 
-  },
+	},
 
-  /**
-   * 生命周期函数--监听页面卸载
-   */
-  onUnload: function () {
+	/**
+	 * 生命周期函数--监听页面卸载
+	 */
+	onUnload: function () {
 
-  },
+	},
 
-  /**
-   * 页面相关事件处理函数--监听用户下拉动作
-   */
-  onPullDownRefresh: function () {
-    this.setData({
-      list: [],
-      pageNo: 1
-    }, () => {
-      this.getList()
-    })
-  },
+	/**
+	 * 页面相关事件处理函数--监听用户下拉动作
+	 */
+	onPullDownRefresh: function () {
+		this.setData({
+			list: [],
+			pageNo: 1
+		}, () => {
+			this.getList()
+		})
+	},
 
-  /**
-   * 页面上拉触底事件的处理函数
-   */
-  onReachBottom: function () {
-    const isLast = this.data.isLast;
-    if (isLast) {
-      // wx.showToast({
-      //   icon: 'none',
-      //   title: '已经是最后一页了',
-      // })
-    } else {
-      this.getList()
-    }
-  }
+	/**
+	 * 页面上拉触底事件的处理函数
+	 */
+	onReachBottom: function () {
+		const isLast = this.data.isLast;
+		if (isLast) {
+			// wx.showToast({
+			//   icon: 'none',
+			//   title: '已经是最后一页了',
+			// })
+		} else {
+			this.getList()
+		}
+	}
 })

+ 29 - 2
miniprogram/pages/realNameAuthentication/realNameAuthentication.ts

@@ -1,4 +1,6 @@
 // pages/realNameAuthentication/realNameAuthentication.ts
+import { getOcrKeyApi, authenticateApi } from "../../service/hwUser";
+import { upLoadImage } from "../../utils/util";
 enum IdCardType {
 	headPortrait,
 	nationalEmblem
@@ -18,7 +20,8 @@ Page({
 		name: '',
 		idCard: '',
 		nationalEmblemImgBase64: '',
-		nationalEmblemImg: ''
+		nationalEmblemImg: '',
+		canSubmit: false
 	},
 	submit() {
 		if (this.checkInfo()) {
@@ -35,6 +38,19 @@ Page({
 				name: this.data.name,
 				idcardNumber: this.data.idCard,
 			};
+			upLoadImage({ url: '/api/hwUser/imgUpload', files: [data.idcardFront], name: 'file', formData: { upType: 1, } }).then(res => {
+				console.log(res);
+				data.idcardFront = res[0].imgUrl
+				upLoadImage({ url: '/api/hwUser/imgUpload', files: [data.idcardBack], name: 'file', formData: { upType: 2, } }).then(res => {
+					console.log(res);
+					data.idcardBack = res[0].imgUrl
+					authenticateApi({ ...data }).then(res => {
+						wx.redirectTo({
+							url: "/pages/realNameAuthentication/success",
+						});
+					})
+				})
+			})
 			console.log(data);
 		}
 	},
@@ -69,6 +85,9 @@ Page({
 								nationalEmblemImg: filePath
 							})
 						}
+						this.setData({
+							canSubmit: this.checkInfo(true)
+						})
 					},
 				});
 			},
@@ -145,7 +164,15 @@ Page({
 	 * 生命周期函数--监听页面加载
 	 */
 	onLoad() {
-
+		getOcrKeyApi().then(res => {
+			const data = <responseOptionsType<getOcrKeyResponseType>>res
+			this.setData({
+				secretInfo: {
+					secretId: data.data?.secretId || '',
+					secretKey: data.data?.secretKey || ''
+				}
+			})
+		})
 	},
 
 	/**

+ 2 - 2
miniprogram/pages/realNameAuthentication/realNameAuthentication.wxml

@@ -38,7 +38,7 @@
               <image src="./images/top-right.png" class="top-right corner" />
               <view class="card-img">
                 <image wx:if="{{nationalEmblemImgBase64}}" src="{{nationalEmblemImgBase64}}" class="national-emblem-img" />
-                <view v-else class="card nationalEmblem">
+                <view wx:else class="card nationalEmblem">
                   <image src="./images/national-emblem.png" class="nationalEmblem" />
                   <image src="./images/national-emblem-icon.png" class="nationalEmblemIcon" />
                 </view>
@@ -60,7 +60,7 @@
                 姓名
               </view>
               <view class="input">
-							  <input name="name" disabled="{{!headPortraitImg}}" type="text" placeholder="姓名" bindinput="nameChange"/>
+							  <input name="name" value="{{name}}" disabled="{{!headPortraitImg}}" type="text" placeholder="姓名" bindinput="nameChange"/>
               </view>
             </view>
           </view>

+ 3 - 0
miniprogram/pages/realNameAuthentication/success.json

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

+ 103 - 0
miniprogram/pages/realNameAuthentication/success.scss

@@ -0,0 +1,103 @@
+/* pages/realNameAuthentication/success.wxss */
+.container {
+
+  .bg {
+    width: 100%;
+    height: 853.88rpx;
+    position: fixed;
+    left: 0;
+    top: 0;
+    z-index: -1;
+  }
+
+  .logo-container {
+    width: 100%;
+    position: fixed;
+    left: 0;
+    bottom: 64rpx;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+
+    .logo {
+      width: 245rpx;
+      height: 90rpx;
+    }
+  }
+
+  .content {
+    padding-top: 217rpx;
+    box-sizing: border-box;
+
+    .icon-container {
+      width: 100%;
+      height: 204rpx;
+      position: relative;
+
+      .icon {
+        width: 159rpx;
+        height: 204rpx;
+        display: flex;
+        align-items: center;
+        justify-content: center;
+        position: absolute;
+        left: 286.5rpx;
+        top: 0;
+
+        .bg1 {
+          width: 159rpx;
+          height: 204rpx;
+        }
+
+        .bg2 {
+          width: 134.4rpx;
+          height: 172.8rpx;
+        }
+
+        .bg3 {
+          width: 117.4rpx;
+          height: 150rpx;
+        }
+
+        .bg4 {
+          width: 94.68rpx;
+          height: 120.96rpx;
+        }
+
+        .bg5 {
+          width: 48rpx;
+          height: 35.94rpx;
+        }
+      }
+    }
+
+    .title {
+      font-family: 'Source Han Sans CN';
+      font-weight: 500;
+      font-size: 48rpx;
+      align-items: center;
+      text-align: center;
+      color: #FFFFFF;
+      margin-top: 28.5rpx;
+    }
+
+    .btn-container {
+      margin-top: 64rpx;
+      display: flex;
+      align-items: center;
+      justify-content: center;
+
+      .btn {
+        line-height: 64rpx;
+        width: 240rpx;
+        font-family: 'Source Han Sans CN';
+        font-weight: 500;
+        font-size: 28rpx;
+        text-align: center;
+        color: #19459A;
+        background: #FFFFFF;
+        border-radius: 12rpx;
+      }
+    }
+  }
+}

+ 71 - 0
miniprogram/pages/realNameAuthentication/success.ts

@@ -0,0 +1,71 @@
+// pages/realNameAuthentication/success.ts
+import { getHwUserInfo } from '../../utils/util'
+Page({
+
+	/**
+	 * 页面的初始数据
+	 */
+	data: {
+
+	},
+	tpPage() {
+		wx.navigateBack({
+			delta: 1,
+		});
+	},
+	/**
+	 * 生命周期函数--监听页面加载
+	 */
+	onLoad() {
+		getHwUserInfo()
+	},
+
+	/**
+	 * 生命周期函数--监听页面初次渲染完成
+	 */
+	onReady() {
+
+	},
+
+	/**
+	 * 生命周期函数--监听页面显示
+	 */
+	onShow() {
+
+	},
+
+	/**
+	 * 生命周期函数--监听页面隐藏
+	 */
+	onHide() {
+
+	},
+
+	/**
+	 * 生命周期函数--监听页面卸载
+	 */
+	onUnload() {
+
+	},
+
+	/**
+	 * 页面相关事件处理函数--监听用户下拉动作
+	 */
+	onPullDownRefresh() {
+
+	},
+
+	/**
+	 * 页面上拉触底事件的处理函数
+	 */
+	onReachBottom() {
+
+	},
+
+	/**
+	 * 用户点击右上角分享
+	 */
+	onShareAppMessage() {
+
+	}
+})

+ 34 - 0
miniprogram/pages/realNameAuthentication/success.wxml

@@ -0,0 +1,34 @@
+<!--pages/realNameAuthentication/success.wxml-->
+<view class="container">
+      <image src="./images/bg-success.png" class="bg" />
+      <view class="logo-container">
+        <image src="./images/logo.png" class="logo" />
+      </view>
+      <view class="content">
+        <view class="icon-container">
+          <view class="icon">
+            <image src="./images/bg1.png" class="bg1" />
+          </view>
+          <view class="icon">
+            <image src="./images/bg2.png" class="bg2" />
+          </view>
+          <view class="icon">
+            <image src="./images/bg3.png" class="bg3" />
+          </view>
+          <view class="icon">
+            <image src="./images/bg4.png" class="bg4" />
+          </view>
+          <view class="icon">
+            <image src="./images/bg5.png" class="bg5" />
+          </view>
+        </view>
+        <view class="title">
+          您已实名认证成功
+        </view>
+        <view class="btn-container">
+          <view class="btn" bindtap="tpPage">
+            知道了
+          </view>
+        </view>
+      </view>
+    </view>

+ 24 - 0
miniprogram/service/hwUser.ts

@@ -46,4 +46,28 @@ export const phoneLoginApi = (data: phoneLoginDataType): Promise<responseOptions
     type: 'post'
   }
   return $request(options)
+}
+
+/**
+ * 获取ocr秘钥
+ * @param data 
+ */
+export const getOcrKeyApi = (): Promise<responseOptions> => {
+  const options: requestOptionsType<any> = {
+    url: api.hwUser.getOcrKey,
+    data:{},
+  }
+  return $request(options)
+}
+
+/**
+ * 实名认证
+ * @param data 
+ */
+export const authenticateApi = (data: authenticateDataType): Promise<responseOptions> => {
+  const options: requestOptionsType<any> = {
+    url: api.hwUser.authenticate,
+    data,
+  }
+  return $request(options)
 }

+ 21 - 8
miniprogram/service/service.d.ts

@@ -61,18 +61,31 @@ type getRequirementDetailDataType = {
 };
 
 interface getRequirementsData {
-  pageNo: number
-  pageSize: number
-  province_code?: number
-  city_code?: number
-  country_code?: number
-  trade_type?: number
-  priceType?: number
-  platform_id?: number
+	pageNo: number
+	pageSize: number
+	province_code?: number
+	city_code?: number
+	country_code?: number
+	trade_type?: number
+	priceType?: number
+	platform_id?: number
+}
+
+type authenticateDataType = {
+	id: string
+	idcardFront: string
+	idcardBack: string
+	name: string
+	idcardNumber: string
 }
 
 type taxRegistrationResponseType = {
 	taxUrl: string,
 	taxMessage: string,
 	taxName: string
+}
+
+type getOcrKeyResponseType = {
+	secretId: string,
+	secretKey: string
 }

+ 174 - 158
miniprogram/utils/util.ts

@@ -13,45 +13,45 @@ import { apiUrl } from "../config"; // 加载接口地址文件
  * 执行跳转登录页面操作
  */
 export function login(message: string = '你还未登录,请立即登录') {
-  wx.showModal({
-    title: '提示',
-    content: message,
-    cancelColor: '#888A8E',
-    confirmColor: '#31364C',
-    success: res => {
-      if (res.confirm) {
-        wx.reLaunch({
-          url: '/pages/login/login',
-        })
-      }
-    }
-  })
+	wx.showModal({
+		title: '提示',
+		content: message,
+		cancelColor: '#888A8E',
+		confirmColor: '#31364C',
+		success: res => {
+			if (res.confirm) {
+				wx.reLaunch({
+					url: '/pages/login/login',
+				})
+			}
+		}
+	})
 }
 
 /* 
-   格式化时间
-   @date {Date} 传入的时间
-   @status {Boolean} 是否需要时分秒开关 true 关闭时分秒选项  false  打开时分秒选项
-  */
+	 格式化时间
+	 @date {Date} 传入的时间
+	 @status {Boolean} 是否需要时分秒开关 true 关闭时分秒选项  false  打开时分秒选项
+	*/
 export function formatTime(date: string, status: boolean = false) {
-  date = date.replace(RegExp('-', 'g'), '/');
-  const _date = new Date(date);
-  const year = _date.getFullYear();
-  const month = _date.getMonth() + 1;
-  const day = _date.getDate();
-  const hour = _date.getHours();
-  const minute = _date.getMinutes();
-  const second = _date.getSeconds();
-  if (status) {
-    return [year, month, day].map(formatNumber).join('/');
-  }
-  return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':');
+	date = date.replace(RegExp('-', 'g'), '/');
+	const _date = new Date(date);
+	const year = _date.getFullYear();
+	const month = _date.getMonth() + 1;
+	const day = _date.getDate();
+	const hour = _date.getHours();
+	const minute = _date.getMinutes();
+	const second = _date.getSeconds();
+	if (status) {
+		return [year, month, day].map(formatNumber).join('/');
+	}
+	return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':');
 }
 
 /* 格式化数字 */
 export function formatNumber(n: number | string): string {
-  n = n.toString();
-  return n[1] ? n : '0' + n;
+	n = n.toString();
+	return n[1] ? n : '0' + n;
 }
 
 /* 
@@ -59,72 +59,72 @@ export function formatNumber(n: number | string): string {
  @data {any} 数据
 */
 export function getDataType(data: any) {
-  const result = /^\[object (.*)\]$/.exec(Object.prototype.toString.call(data));
-  if (result) {
-    return result[1]
-  }
-  return ''
+	const result = /^\[object (.*)\]$/.exec(Object.prototype.toString.call(data));
+	if (result) {
+		return result[1]
+	}
+	return ''
 }
 
 /* 
-    获取url 
-    @url {String} 待处理的URL
-    @return {String} 处理过的字符串 
-    根据URL是否有http或者https判断是否拼接字符串
-  */
+		获取url 
+		@url {String} 待处理的URL
+		@return {String} 处理过的字符串 
+		根据URL是否有http或者https判断是否拼接字符串
+	*/
 export function getUrl(url: string): Promise<string> {
-  return new Promise(resolve => {
+	return new Promise(resolve => {
 
-    if (url.indexOf('https://') === -1 && url.indexOf('http://') === -1) {
-      resolve(apiUrl + url)
-    } else {
-      if (url.indexOf('http://') === -1) {
-        resolve(url)
-        return
-      }
-      resolve(url.replace('http://', 'https://'))
-    }
-  })
+		if (url.indexOf('https://') === -1 && url.indexOf('http://') === -1) {
+			resolve(apiUrl + url)
+		} else {
+			if (url.indexOf('http://') === -1) {
+				resolve(url)
+				return
+			}
+			resolve(url.replace('http://', 'https://'))
+		}
+	})
 }
 
 /**
-   * 获取网络状态
-   */
+	 * 获取网络状态
+	 */
 export function getNetworkType(): Promise<string> {
-  return new Promise((resolve, reject) => {
-    wx.getNetworkType({
-      success: function (res) {
-        if (res.networkType === 'none') {
-          resolve('offline')
-        } else {
-          resolve(res.networkType)
-        }
-      },
-      fail: function () {
-        reject('fail')
-      }
-    })
-  })
+	return new Promise((resolve, reject) => {
+		wx.getNetworkType({
+			success: function (res) {
+				if (res.networkType === 'none') {
+					resolve('offline')
+				} else {
+					resolve(res.networkType)
+				}
+			},
+			fail: function () {
+				reject('fail')
+			}
+		})
+	})
 }
 
 /**
-   * 获取userid与userToken
-   * @options {Object} 传入的对象参数
-   * @return 返回参数对象
-   * 设置request参数中的userID和usertoken
-   */
+	 * 获取userid与userToken
+	 * @options {Object} 传入的对象参数
+	 * @return 返回参数对象
+	 * 设置request参数中的userID和usertoken
+	 */
 export function getUserId(data: any) {
-  return new Promise((reslove) => {
-    const userId = wx.getStorageSync('userId');
-    const userToken = wx.getStorageSync('userToken');
-    data.user_id = userId;
-    data.user_token = userToken;
-    reslove(data)
-  })
+	return new Promise((reslove) => {
+		const userId = wx.getStorageSync('userId');
+		const userToken = wx.getStorageSync('userToken');
+		data.user_id = userId;
+		data.user_token = userToken;
+		reslove(data)
+	})
 }
 
 export function isValidKey(key: string | number | symbol, object: object): key is keyof typeof object {
-  return key in object;
+	return key in object;
 }
 
 /**
@@ -133,77 +133,93 @@ export function isValidKey(key: string | number | symbol, object: object): key i
  * @return {Array} 
  */
 export function upLoadImage(options: { files: string[]; formData?: {}; url: string; name: string; }): Promise<any> {
-  const _type = getDataType(options.files);
-  options.formData = options.formData || {};
-  const formData = {
-    user_id: wx.getStorageSync('userId'),
-    user_token: wx.getStorageSync('userToken'),
-    ...options.formData
-  };
-  wx.showLoading({
-    mask: true,
-    title: '上传中...'
-  })
-  return new Promise(async (resolve, reject) => {
-    if (_type === "Array") {
-      const _arr: string[] = [];
-      const _files = options.files;
-      const _len = _files.length - 1;
-      const _url: string = await getUrl(options.url);
-      _files.forEach((val: string, key: number) => {
-        wx.uploadFile({
-          url: _url,
-          filePath: val,
-          name: options.name,
-          formData,
-          success: res => {
-            if (res.statusCode === 200) {
-              const data = JSON.parse(res.data);
-              if (data.errcode === 0) {
-                _arr.push(data.data);
-                if (_len === key) {
-                  wx.hideLoading()
-                  resolve(_arr)
-                }
-              }
-            }
-          },
-          fail: (e: any) => {
-            console.log(e)
-            reject({
-              type: getDataType(val)
-            })
-            wx.hideLoading()
-            throw new Error(e)
-          }
-        })
-      })
-    } else {
-      reject({
-        type: _type
-      })
-      wx.hideLoading()
-      throw new Error('输入格式有误')
-    }
-  })
+
+	const _type = getDataType(options.files);
+	options.formData = options.formData || {};
+	const formData = {
+		user_id: wx.getStorageSync('userId'),
+		user_token: wx.getStorageSync('userToken'),
+		...options.formData
+	};
+	console.log('upLoadImage=>', formData);
+	wx.showLoading({
+		mask: true,
+		title: '上传中...'
+	})
+	return new Promise(async (resolve, reject) => {
+		if (_type === "Array") {
+			const _arr: string[] = [];
+			const _files = options.files;
+			const _len = _files.length - 1;
+			const _url: string = await getUrl(options.url);
+			_files.forEach((val: string, key: number) => {
+				wx.uploadFile({
+					url: _url,
+					filePath: val,
+					name: options.name,
+					header: {
+						user_id: wx.getStorageSync('userId'),
+						user_token: wx.getStorageSync('userToken'),
+					},
+					formData,
+					success: res => {
+						if (res.statusCode === 200) {
+							const data = JSON.parse(res.data);
+							if (data.errcode === 0) {
+								_arr.push(data.data);
+								if (_len === key) {
+									wx.hideLoading()
+									resolve(_arr)
+								}
+							} else {
+								wx.showToast({
+									title: data.message,
+									icon: 'none'
+								})
+								reject({
+									type: getDataType(val)
+								})
+								wx.hideLoading()
+								return false
+							}
+						}
+					},
+					fail: (e: any) => {
+						console.log(e)
+						reject({
+							type: getDataType(val)
+						})
+						wx.hideLoading()
+						throw new Error(e)
+					}
+				})
+			})
+		} else {
+			reject({
+				type: _type
+			})
+			wx.hideLoading()
+			throw new Error('输入格式有误')
+		}
+	})
 }
 
 /**
  * 获取用户信息
  */
-export function getHwUserInfo() {
-  return new Promise(resolve => {
-    getHwUserInfoApi().then(data => {
-      const res = <responseOptionsType>data
-      if (res.data) {
-        //成功后存入缓存
-        wx.setStorageSync('userInfo', res.data.hwUser);
-        resolve(res.data.hwUser)
-      }
-    }).catch(error => {
-      console.error(error);
-    })
-  })
+export function getHwUserInfo(): AnyObject {
+	return new Promise(resolve => {
+		getHwUserInfoApi().then(data => {
+			const res = <responseOptionsType>data
+			if (res.data) {
+				//成功后存入缓存
+				wx.setStorageSync('userInfo', res.data.hwUser);
+				resolve(res.data.hwUser)
+			}
+		}).catch(error => {
+			console.error(error);
+		})
+	})
 }
 
 /**
@@ -213,9 +229,9 @@ export function getHwUserInfo() {
  * @param time 
  */
 export function putStorageSync(key: string, value: any, time: number = 86400000): void {
-  wx.setStorageSync(key, value)
-  const _time: number = Date.now()
-  wx.setStorageSync(key + 'redis', _time + time)
+	wx.setStorageSync(key, value)
+	const _time: number = Date.now()
+	wx.setStorageSync(key + 'redis', _time + time)
 }
 
 /**
@@ -223,12 +239,12 @@ export function putStorageSync(key: string, value: any, time: number = 86400000)
  * @param key 
  */
 export function getStorageSync(key: string): any {
-  const time: number = wx.getStorageSync(key + 'redis')
-  if (!time || Date.now() > time) {
-    wx.removeStorageSync(key)
-    wx.removeStorageSync(key + 'redis')
-    return ''
-  } else {
-    return wx.getStorageSync(key)
-  }
+	const time: number = wx.getStorageSync(key + 'redis')
+	if (!time || Date.now() > time) {
+		wx.removeStorageSync(key)
+		wx.removeStorageSync(key + 'redis')
+		return ''
+	} else {
+		return wx.getStorageSync(key)
+	}
 }

+ 1 - 1
project.private.config.json

@@ -18,5 +18,5 @@
 	},
 	"projectname": "mina-b-t",
 	"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
-	"libVersion": "2.30.1"
+	"libVersion": "2.30.2"
 }