diff --git a/app.js b/app.js new file mode 100644 index 0000000..2055584 --- /dev/null +++ b/app.js @@ -0,0 +1,133 @@ +const util=require('./utils/js/util') +import { postRequest, getRequest } from "./utils/js/request" +import { platformInfo, queryInfo, signIn } from "./utils/js/locales" +App({ + onLaunch(query) { + // 展示本地存储能力 + const logs = wx.getStorageSync('logs') || [] + logs.unshift(Date.now()) + wx.setStorageSync('logs', logs) + let scene = ''; + if (query.query.q) { + let url = decodeURIComponent(query.query.q) + scene = util.getQueryString(url,'bind') + wx.setStorageSync('bind', scene) + } + // 获取用户信息 + // wx.getSetting({ + // success: res => { + // if (res.authSetting['scope.userInfo']) { + // // 已经授权,可以直接调用 getUserProfile 获取头像昵称,不会弹框 + // wx.getUserProfile({ + // desc: '用于展示头像', + // success: (res) => { + // // 可以将 res 发送给后台解码出 unionId + // this.globalData.userInfo = res.userInfo + // } + // }) + // } + // } + // }) + }, + + onShow() { + this.upDataApp(); + }, + // 存储公共信息 + globalData: { + uploadUrl: "https://office-ssl.iilink.cn/coconut", // 开发环境 + // uploadUrl: "https://office-ssl.iilink.cn/coconut-uat", // 测试环境 + // uploadUrl: 'https://cherry.amtcloud.cn/cherry-api', // 生产 + systemConfiguration: { + backgroundColor: '#01ae42' + }, + id: '', // 商铺id shop_id + actor: '', // 用户身份 代采buyer 销售seller 游客visitor + platformInfo: {}, // 平台信息 + buyerItem: { // 买家信息 + gmtOrder: '', + memberId: '', + name: '' + }, + info: {}, // login获取的数据 + userInfo: {}, // 授权的昵称和logo + user_info: {}, // 信息里的昵称和logo + member_info: {}, // 认证信息 + operator_info: {}, // + behaviorRecord: 0, // 认证 操作记录 + authentication: { // 认证信息缓存 + personal: { + name: '', + card_number: '', + id_main: '', + id_extra: '', + id_card: [], + }, + enterprise: { + corporation_name: '', + unified_tax_code: '', + business_licence: '', + enterprise: [], + } + } + }, + // 小程序登录 + loginCloudBird: function (scene) { + let app = this + // wx.login({ + // success: res => { + // let data = { + // code: res.code, + // } + // postRequest('/v1/p/login', data).then(res => { + // wx.setStorageSync('tokenKey', res.data.token); + //用户类型 代采buyer 销售seller 游客visitor + // wx.setStorageSync('actor', res.data.info.actor); // res.data.actor buyer seller + // app.globalData.actor = res.data.info.actor; + // app.globalData.info = res.data.info; + // platformInfo(app); + wx.reLaunch({ + url: '/pages/home/home', + }) + // }).catch(err => { + // signIn(err); + // }) + // } + // }) + }, + //版本更新 + upDataApp: function () { + if (wx.canIUse('getUpdateManager')) { //判断当前微信版本是否支持版本更新 + const updateManager = wx.getUpdateManager(); + updateManager.onCheckForUpdate(function (res) { + if (res.hasUpdate) { // 请求完新版本信息的回调 + updateManager.onUpdateReady(function () { + wx.showModal({ + title: '更新提示', + content: '新版本已经准备好,是否重启应用?', + success: function (res) { + // res: {errMsg: "showModal: ok", cancel: false, confirm: true} + if (res.confirm) { + // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 + updateManager.applyUpdate() + } + } + }) + }); + updateManager.onUpdateFailed(function () { + // 新的版本下载失败 + wx.showModal({ + title: '已经有新版本了哟~', + content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~', + }) + }) + } + }) + } else { + wx.showModal({ // 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示 + title: '提示', + content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。' + }) + } + } +}) \ No newline at end of file diff --git a/app.json b/app.json new file mode 100644 index 0000000..3a074e7 --- /dev/null +++ b/app.json @@ -0,0 +1,48 @@ +{ + "pages":[ + "pages/firstpage/firstpage", + "pages/home/home", + "pages/order/order", + "pages/index/index", + "pages/authorizationPage/index", + "pages/openAuthentication/index" + ], + "window":{ + "backgroundTextStyle":"light", + "navigationBarTextStyle": "white", + "navigationBarBackgroundColor": "#01ae42" + }, + "tabBar": { + "selectedColor":"#01ae42", + "list": [ + { + "pagePath":"pages/home/home", + "text": "供应商", + "iconPath":"./utils/images/shouye1.png", + "selectedIconPath":"./utils/replace-images/shouye.png" + + }, { + "pagePath": "pages/order/order", + "text": "订单", + "iconPath":"./utils/images/dingdan1.png", + "selectedIconPath":"./utils/replace-images/dingdan.png" + }, { + "pagePath": "pages/index/index", + "text": "个人中心", + "iconPath":"./utils/images/gerenzhongxin1.png", + "selectedIconPath":"./utils/replace-images/gerenzhongxin.png" + } + ] + }, + "style": "v2", + "sitemapLocation": "sitemap.json", + "useExtendedLib": { + "kbone": true, + "weui": true + }, + "usingComponents": { + "mp-navigation-bar": "weui-miniprogram/navigation-bar/navigation-bar", + "i-load-more": "components/load-more/index", + "i-no-data": "components/no-data-available/index" + } +} diff --git a/app.wxss b/app.wxss new file mode 100644 index 0000000..27dd9ec --- /dev/null +++ b/app.wxss @@ -0,0 +1,44 @@ +/**app.wxss**/ +.container { + height: 100%; + display: flex; + flex-direction: column; + align-items: center; + justify-content: space-between; + padding: 200rpx 0; + box-sizing: border-box; +} +button { + color: #ffffff !important; + background-color: #01ae42!important; +} + +.i-background-color{ + background-color: #01ae42 !important; +} +.i-color{ + color: #01ae42 !important; +} +.i-border-color{ + border: 2rpx solid #01ae42 !important; +} +.i-border-color-left{ + border-left: 15rpx solid #01ae42; +} +.i-border-bottom{ + border-bottom: 8rpx solid #01ae42; +} +.i-transparent-color{ + background: #01ae4220; +} + +/* 小众的颜色 */ +.i-yellow-background-color{ + background: #ffb565 !important; +} +.i-yellow-border-color{ + border: 2rpx solid #ffb565 !important; +} +.i-yellow-color{ + color: #ffb565 !important; +} \ No newline at end of file diff --git a/components/load-more/index.js b/components/load-more/index.js new file mode 100644 index 0000000..d0cd46c --- /dev/null +++ b/components/load-more/index.js @@ -0,0 +1,14 @@ +Component({ + externalClasses: ['i-class'], + + properties: { + loading: { + type: Boolean, + value: true + }, + tip: { + type: String, + value: '' + } + }, +}); diff --git a/components/load-more/index.json b/components/load-more/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/components/load-more/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/components/load-more/index.wxml b/components/load-more/index.wxml new file mode 100644 index 0000000..66571af --- /dev/null +++ b/components/load-more/index.wxml @@ -0,0 +1,8 @@ + + + + {{ tip }} + 正在加载 + + + \ No newline at end of file diff --git a/components/load-more/index.wxss b/components/load-more/index.wxss new file mode 100644 index 0000000..c5144d9 --- /dev/null +++ b/components/load-more/index.wxss @@ -0,0 +1,79 @@ +.i-load-more { + width: 65%; + margin: 1.5em auto; + line-height: 1.6em; + font-size: 14px; + text-align: center +} + +.i-load-more-loading { + display: inline-block; + margin-right: 12px; + vertical-align: middle; + width: 14px; + height: 14px; + background: 0 0; + border-radius: 50%; + border: 2px solid #e9eaec; + border-color: #e9eaec #e9eaec #e9eaec #2d8cf0; + animation: btn-spin .6s linear; + animation-iteration-count: infinite +} + +.i-load-more-tip { + display: inline-block; + vertical-align: middle; + color: #495060 +} + +.i-load-more-line { + border-top: 1px solid #dddee1; + display: flex; + border-top: 0 +} + +.i-load-more-line::before { + position: relative; + top: -1px; + -webkit-box-flex: 1; + -webkit-flex: 1; + flex: 1; + content: ''; + border-top: 1px solid #dddee1 +} + +.i-load-more-line::after { + position: relative; + top: -1px; + -webkit-box-flex: 1; + -webkit-flex: 1; + flex: 1; + content: ''; + border-top: 1px solid #dddee1 +} + +.i-load-more-line .i-load-more-tip { + position: relative; + padding: 0 .55em +} + +.i-load-more-empty { + width: 4px; + height: 4px; + border-radius: 50%; + background-color: #e5e5e5; + display: inline-block; + position: relative; + vertical-align: 0; + top: -.16em +} + +@keyframes btn-spin { + 0% { + transform: rotate(0) + } + + 100% { + transform: rotate(360deg) + } +} \ No newline at end of file diff --git a/components/no-data-available/index.js b/components/no-data-available/index.js new file mode 100644 index 0000000..7d834db --- /dev/null +++ b/components/no-data-available/index.js @@ -0,0 +1,38 @@ +Component({ + externalClasses: ['i-class'], + data: { + loading: false + }, + // properties: { + // tip: { + // type: String, + // value: '' + // } + // }, + // 在组件实例刚刚被创建时执行 + created: function() { + let that = this; + setTimeout(function() { + that.setData({ loading: true }) + }, 2000) + }, + // 在组件在视图层布局完成后执行 + // ready: function() { + // }, + pageLifetimes: { + // 页面被展示 + show: function() { + let that = this; + setTimeout(function() { + that.setData({ loading: true }) + }, 1000) + }, + // 页面被隐藏 + hide: function() { + this.setData({ loading: false }) + }, + // 页面尺寸变化 + resize: function(size) { + } + } +}); diff --git a/components/no-data-available/index.json b/components/no-data-available/index.json new file mode 100644 index 0000000..467ce29 --- /dev/null +++ b/components/no-data-available/index.json @@ -0,0 +1,3 @@ +{ + "component": true +} diff --git a/components/no-data-available/index.wxml b/components/no-data-available/index.wxml new file mode 100644 index 0000000..e8f61e5 --- /dev/null +++ b/components/no-data-available/index.wxml @@ -0,0 +1,5 @@ + + 暂无数据 + 暂无数据 + + \ No newline at end of file diff --git a/components/no-data-available/index.wxss b/components/no-data-available/index.wxss new file mode 100644 index 0000000..447e267 --- /dev/null +++ b/components/no-data-available/index.wxss @@ -0,0 +1,12 @@ +.no_data_available { + height: 350rpx; + text-align: center; + padding-top: 100rpx; +} +.no_data_available ._image{ + width: 300rpx; + height: 200rpx; +} +.no_data{ + color: #999999; +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..7f1629c --- /dev/null +++ b/package-lock.json @@ -0,0 +1,13 @@ +{ + "name": "cherry_mini", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "umtrack-wx": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/umtrack-wx/-/umtrack-wx-2.6.2.tgz", + "integrity": "sha512-EdxHh5pW7TYhE8A7AUzqLBXV+P6Sk3y86iBnAbq/7IFd3Bwl0LoQZ+lA6aMAnd1Ylxe+68uO7xekKMS2NLB5xQ==" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..c8b2a51 --- /dev/null +++ b/package.json @@ -0,0 +1,18 @@ +{ + "name": "cherry_mini", + "version": "1.0.0", + "description": "", + "main": "app.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "https://gitea.amtcloud.cn/tokamak/cherry_mini.git" + }, + "author": "", + "license": "ISC", + "dependencies": { + "umtrack-wx": "^2.6.2" + } +} diff --git a/pages/authorizationPage/index.js b/pages/authorizationPage/index.js new file mode 100644 index 0000000..0f6ee7f --- /dev/null +++ b/pages/authorizationPage/index.js @@ -0,0 +1,99 @@ +import { postRequest, getRequest, putRequest } from '../../utils/js/request' +import { queryLogin, queryInfo, signIn } from '../../utils/js/locales' +let app = getApp(); +Page({ + data: { + userInfo: {}, + logo: '', + hasUserInfo: false, + canIUseGetUserProfile: false, + }, + onLoad: function (options) { + this.setData({ + userInfo: {}, + logo: app.globalData.info.logo, + hasUserInfo: false, + canIUseGetUserProfile: false + }) + }, + onShow: function () { + if (wx.getUserProfile) { + this.setData({ + canIUseGetUserProfile: true + }) + } + }, + getUserProfile(e) { + // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认 + // 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗 + let that = this; + wx.getUserProfile({ + desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写 + success: (res) => { + putRequest('/v1/p/info', { nick: res.userInfo.nickName, logo: res.userInfo.avatarUrl }).then(res => { + }).catch(err => { + signIn(err) + }) + app.globalData.userInfo = res.userInfo + wx.setStorageSync('nickName', res.userInfo.nickName); + wx.setStorageSync('avatarUrl', res.userInfo.avatarUrl); + this.setData({ + hasUserInfo: true, + logo: res.userInfo.avatarUrl, + userInfo: res.userInfo + }) + } + }) + }, + getUserInfo(e) { + // 不推荐使用getUserInfo获取用户信息,预计自2021年4月13日起,getUserInfo将不再弹出弹窗,并直接返回匿名的用户个人信息 + app.globalData.userInfo = e.detail.userInfo + this.setData({ + hasUserInfo: true, + userInfo: e.detail.userInfo + }) + }, + // 点击用户登录 + decryptPhoneNumber(e) { + let that = this; + wx.checkSession({ + success (item) { + if (e.detail.encryptedData) { + let data = { + encrypt: e.detail.encryptedData, + errMsg: e.detail.errMsg, + iv: e.detail.iv, + name: that.data.userInfo.nickName ? that.data.userInfo.nickName : ('肉仔仔' + e.detail.iv.substring(6,13)) + } + wx.showLoading({ title: '授权中' }) + postRequest('/v1/m/cert/phone/encrypt',data).then(res => { + setTimeout(function () { + queryLogin(app) + }, 3000); + setTimeout(function () { + queryInfo(app) + wx.showToast({ icon: 'none', title: '授权成功!', duration: 2000 }) + }, 4000); + setTimeout(function () { + wx.hideLoading(); + wx.reLaunch({ + url: '/pages/index/index' + }) + }, 5000); + }).catch(err => { + wx.hideLoading(); + signIn(err) + }) + } + }, + fail () { + // session_key 已经失效,需要重新执行登录流程 + wx.login({ }) + } + }) + }, + // /** 用户点击右上角分享 */ + // onShareAppMessage: function () { + // return { path: "pages/firstpage/firstpage?from=share" } + // } +}) \ No newline at end of file diff --git a/pages/authorizationPage/index.json b/pages/authorizationPage/index.json new file mode 100644 index 0000000..ac928e8 --- /dev/null +++ b/pages/authorizationPage/index.json @@ -0,0 +1,4 @@ +{ + "backgroundTextStyle":"dark", + "navigationBarTitleText": "登录" + } \ No newline at end of file diff --git a/pages/authorizationPage/index.wxml b/pages/authorizationPage/index.wxml new file mode 100644 index 0000000..a030a97 --- /dev/null +++ b/pages/authorizationPage/index.wxml @@ -0,0 +1,16 @@ + + + + + 手机号验证 + + + + + + + + + diff --git a/pages/authorizationPage/index.wxss b/pages/authorizationPage/index.wxss new file mode 100644 index 0000000..b6606c1 --- /dev/null +++ b/pages/authorizationPage/index.wxss @@ -0,0 +1,31 @@ +.logo{ + text-align: center; +} +.logo ._image{ + width: 640rpx; + height: 480rpx; +} +._title{ + width: 74%; + margin: auto; + color: #999999; + font-size: 28rpx; + margin-top: 40rpx; +} +.logo_mobile_image{ + text-align: center; + padding-top: 220rpx; + text-align: center; +} +.logo_mobile_image .mobile_image{ + width: 280rpx; + height: 280rpx; +} +.to-grant{ + width: 100%; +} +.to-grant-authorization{ + width: 80% !important; + margin: auto; + margin-top: 40rpx; +} \ No newline at end of file diff --git a/pages/firstpage/firstpage.js b/pages/firstpage/firstpage.js new file mode 100644 index 0000000..27ae01f --- /dev/null +++ b/pages/firstpage/firstpage.js @@ -0,0 +1,71 @@ +let app = getApp() +import { pageTitle } from '../../utils/js/replace' +Page({ + /** 页面的初始数据 */ + data: { + canLogin: true, + }, + + /** 生命周期函数--监听页面加载 */ + onLoad: function (options) { + wx.setNavigationBarTitle({ + title: `${pageTitle}` + }) + wx.showLoading({ title: '加载中' }) + }, + + /** 生命周期函数--监听页面显示 */ + onShow: function () { + let startDate = new Date("2020/05/29 22:00:00"); + let endDate = new Date("2020/05/30 22:00:00"); + let d = new Date() + if(d >= startDate && d <= endDate){ + this.setData({ + canLogin : false + }) + wx.showModal({ + showCancel: false, + mask: true, + content:"给您带来不便敬请谅解 \r\n 预计恢复时间:2020.05.30 22:00:00", + title:"系统更新维护中" + }) + } + // 获取缓存里的扫码内容 登录 + let bind = wx.getStorageSync('bind') + setTimeout(function () { + app.loginCloudBird(bind); + }, 1000) + }, + + /** 用户点击右上角分享 */ + onShareAppMessage: function () { + return { path: "pages/firstpage/firstpage?from=share" } + }, + + gologin () { + if(!this.data.canLogin){ + wx.showModal({ + showCancel: false, + mask: true, + content:"给您带来不便敬请谅解 \r\n 预计恢复时间:2020.05.30 22:00:00", + title:"系统更新维护中" + }) + return; + } + wx.showModal({ + title: '您还未登录', + content: '请先登录再进行操作!', + showCancel: true,//是否显示取消按钮 + success: function (res) { + if (res.cancel) { + //点击取消 + } else if (res.confirm) { + //点击确定 + wx.navigateTo({ + url: '../wxlogin/wxlogin' + }) + } + } + }) + } +}) \ No newline at end of file diff --git a/pages/firstpage/firstpage.json b/pages/firstpage/firstpage.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/pages/firstpage/firstpage.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/pages/firstpage/firstpage.wxml b/pages/firstpage/firstpage.wxml new file mode 100644 index 0000000..dfedf18 --- /dev/null +++ b/pages/firstpage/firstpage.wxml @@ -0,0 +1,3 @@ + + + diff --git a/pages/firstpage/firstpage.wxss b/pages/firstpage/firstpage.wxss new file mode 100644 index 0000000..b6557bb --- /dev/null +++ b/pages/firstpage/firstpage.wxss @@ -0,0 +1,4 @@ +page{ + background-color: #F9F9FB; + font-family: PingFangSC-Regular; +} \ No newline at end of file diff --git a/pages/home/home.js b/pages/home/home.js new file mode 100644 index 0000000..c443dcd --- /dev/null +++ b/pages/home/home.js @@ -0,0 +1,19 @@ +let app = getApp() +Page({ + data: { + canLogin: true, + }, + /** 生命周期函数--监听页面加载 */ + onLoad: function (options) { + // wx.showLoading({ title: '加载中' }) + }, + /** 生命周期函数--监听页面显示 */ + onShow: function () { + + }, + /** 用户点击右上角分享 */ + onShareAppMessage: function () { + return { path: "pages/firstpage/firstpage?from=share" } + }, + +}) \ No newline at end of file diff --git a/pages/home/home.json b/pages/home/home.json new file mode 100644 index 0000000..969e226 --- /dev/null +++ b/pages/home/home.json @@ -0,0 +1,9 @@ +{ + "usingComponents": { + "mp-cells": "weui-miniprogram/cells/cells", + "mp-cell": "weui-miniprogram/cell/cell" + }, + "backgroundTextStyle":"dark", + "navigationBarTitleText": "供应商", + "enablePullDownRefresh": true +} \ No newline at end of file diff --git a/pages/home/home.wxml b/pages/home/home.wxml new file mode 100644 index 0000000..dfedf18 --- /dev/null +++ b/pages/home/home.wxml @@ -0,0 +1,3 @@ + + + diff --git a/pages/home/home.wxss b/pages/home/home.wxss new file mode 100644 index 0000000..b6557bb --- /dev/null +++ b/pages/home/home.wxss @@ -0,0 +1,4 @@ +page{ + background-color: #F9F9FB; + font-family: PingFangSC-Regular; +} \ No newline at end of file diff --git a/pages/index/index.js b/pages/index/index.js new file mode 100644 index 0000000..c493f19 --- /dev/null +++ b/pages/index/index.js @@ -0,0 +1,32 @@ +let app = getApp() +Page({ + data: { + canLogin: true, + }, + /** 生命周期函数--监听页面加载 */ + onLoad: function (options) { + + wx.showLoading({ title: '加载中' }) + }, + /** 生命周期函数--监听页面显示 */ + onShow: function () { + // 判断有没有授权 + if (!app.globalData.user_info.mobile) { + wx.redirectTo({ + url: '/pages/authorizationPage/index' + }) + return + } + // 获取数据 + this.getData(); + }, + // 获取数据 + getData() { + + }, + /** 用户点击右上角分享 */ + onShareAppMessage: function () { + return { path: "pages/firstpage/firstpage?from=share" } + }, + +}) \ No newline at end of file diff --git a/pages/index/index.json b/pages/index/index.json new file mode 100644 index 0000000..e0a3616 --- /dev/null +++ b/pages/index/index.json @@ -0,0 +1,7 @@ +{ + "usingComponents": { + "mp-cells": "weui-miniprogram/cells/cells", + "mp-cell": "weui-miniprogram/cell/cell" + }, + "navigationBarTitleText": "个人中心" +} \ No newline at end of file diff --git a/pages/index/index.wxml b/pages/index/index.wxml new file mode 100644 index 0000000..dfedf18 --- /dev/null +++ b/pages/index/index.wxml @@ -0,0 +1,3 @@ + + + diff --git a/pages/index/index.wxss b/pages/index/index.wxss new file mode 100644 index 0000000..b6557bb --- /dev/null +++ b/pages/index/index.wxss @@ -0,0 +1,4 @@ +page{ + background-color: #F9F9FB; + font-family: PingFangSC-Regular; +} \ No newline at end of file diff --git a/pages/openAuthentication/index.js b/pages/openAuthentication/index.js new file mode 100644 index 0000000..5e56c9a --- /dev/null +++ b/pages/openAuthentication/index.js @@ -0,0 +1,291 @@ +var app = getApp(); +import { postRequest, getRequest, putRequest } from '../../utils/js/request' +import { queryLogin, queryInfo, signIn } from '../../utils/js/locales' +Page({ + data: { + backgroundColor: '', + refund: '1', + selectFile: '', + uplaodFile: '', + + corporation_name: '', + unified_tax_code: '', + business_licence: '', + contacts_name: '', + contacts_mobile: '', + enterprise: [], + + name: '', + card_number: '', + id_main: '', + id_extra: '', + id_card: [], + + isfront: '', // 上传的图片类型 + openState: false, // 开户状态 + }, + /** 生命周期函数--监听页面加载 */ + onLoad: function (options) { + this.setData({ + openState: false, + selectFile: this.selectFile.bind(this), + uplaodFile: this.uplaodFile.bind(this), + uplaodFileEnterprise: this.uplaodFileEnterprise.bind(this), + backgroundColor: app.globalData.systemConfiguration.backgroundColor, + + corporation_name: app.globalData.member_info.name, + name: app.globalData.operator_info.name + }) + // 查询认证信息 + // this.queryAuthenticationInformation() + }, + + onShow: function () { + const { corporation_name, name, } = this.data; + let enterprise = app.globalData.authentication.enterprise + let personal = app.globalData.authentication.personal + this.setData({ + corporation_name: corporation_name ? corporation_name : enterprise.corporation_name, + unified_tax_code: enterprise.unified_tax_code, + business_licence: enterprise.business_licence, + enterprise: enterprise.enterprise, + name: name ? name : personal.name, + card_number: personal.card_number, + id_main: personal.id_main, + id_extra: personal.id_extra, + id_card: personal.id_card + }) + }, + // 查询认证信息 目前缺少 身份证号 企业统一税号 等 + // queryAuthenticationInformation() { + // getRequest('/v1/m/my/cert',{}).then(res => { + // console.log(res) + // }).catch(err => { + // wx.hideLoading(); + // signIn(err); + // }) + // }, + + // 选择认证类型 + radioChange(e) { + this.setData({ refund: e.detail.value }) + }, + // 选择图片时的过滤函数,返回true表示图片有效, 返回false可以阻止某次文件上传 + selectFile(files) { + let tempFiles = files.tempFiles + if (tempFiles[0].size > (7 * 1024 * 1024)) { + wx.showToast({ title: '请选择小于7MB的图片', icon: 'none', duration: 2000 }) + return false + } + }, + // 上传企业执照图片, + uplaodFileEnterprise(files) { + // 文件上传的函数,返回一个promise + return new Promise((resolve, reject) => { + let tempFilePaths = files.tempFilePaths; + let that = this; + wx.showLoading({ title: '正在上传...', mask: true }) + wx.uploadFile({ + url: 'https://tokamak.amtcloud.cn/uploader/v1/upload', //需要用HTTPS,同时在微信公众平台后台添加服务器地址 + filePath: tempFilePaths[0], //上传的文件本地地址 + name: 'file', + success: function(res) { + let data = JSON.parse(res.data); + if (data.Code === 0) { + let _data = data.Data + that.setData({ business_licence: _data[0].Preview, enterprise: [ { url: _data[0].Preview } ] }); + that.ocrLicense(_data[0].Preview); + resolve(_data) + } else { + wx.showToast({ icon: 'none', title: '上传失败', duration: 2000 }) + reject(res) + } + }, + fail: function(err) { + wx.hideLoading(); + wx.showToast({ icon: 'none', title: '上传失败', duration: 2000 }) + } + }) + }) + }, + // 营业执照ocR + ocrLicense(preview) { + let that = this; + getRequest(`/v1/di/ocr/license?imageurl=${preview}`,{}).then(res => { + that.setData({ + corporation_name: res.data.Name, + unified_tax_code: res.data.RegNum + }) + wx.hideLoading(); + }).catch(err => { + wx.hideLoading(); + }) + }, + // 上传身份证照图片, + uplaodFile(files) { + // 文件上传的函数,返回一个promise + return new Promise((resolve, reject) => { + let tempFilePaths = files.tempFilePaths; + let that = this; + wx.showLoading({ title: '正在上传...', mask: true }) + wx.uploadFile({ + url: 'https://tokamak.amtcloud.cn/uploader/v1/upload', + filePath: tempFilePaths[0], //上传的文件本地地址 + name: 'file', + success: function(res) { + wx.hideLoading(); + let data = JSON.parse(res.data); + if (data.Code === 0) { + let _data = data.Data + that.setData({ id_main: _data[0].Preview, id_extra: _data[0].Preview, id_card: [ { url: _data[0].Preview } ] }); + resolve(_data) + } else { + wx.showToast({ icon: 'none', title: '上传失败', duration: 2000 }) + reject(res) + } + }, + fail: function(err) { + wx.hideLoading(); + wx.showToast({ icon: 'none', title: '上传失败', duration: 2000 }) + } + }) + }) + }, + // 图片上传失败的事件 + uploadError(e) { + console.log('upload error', e.detail) + }, + // 图片上传成功的事件 + uploadSuccess(e) { + wx.showToast({ icon: 'none', title: '上传图片失败,请删除后重新上传!', duration: 3000 }) + }, + // 删除图片 + binddelete(e) { + if (this.data.refund === '1') { + this.setData({ business_licence: '', enterprise: [] }) + } else { + this.setData({ id_main: '', id_extra: '', id_card: [] }) + } + }, + inputCorporationName(e) { + this.setData({ corporation_name: e.detail.value }) + }, + inputUnifiedTaxCode(e) { + this.setData({ unified_tax_code: e.detail.value }) + }, + inputContactsName(e) { + this.setData({ contacts_name: e.detail.value }) + }, + inputContactsMobile(e) { + this.setData({ contacts_mobile: e.detail.value }) + }, + inputName(e) { + this.setData({ name: e.detail.value }) + }, + inputCardNumber(e) { + this.setData({ card_number: e.detail.value }) + }, + + // 提交 + submit() { + const { refund, corporation_name, unified_tax_code, contacts_name, business_licence, name, card_number, id_main, id_extra } = this.data; + let that = this; + if (refund === '1') { // 认证公司企业 + if (!business_licence) return wx.showToast({ icon: 'none', title: '请上传营业执照!', duration: 2000 }) + if (!corporation_name) return wx.showToast({ icon: 'none', title: '请输入企业名称!', duration: 2000 }) + if (!unified_tax_code) return wx.showToast({ icon: 'none', title: '请输入纳税人识别号!', duration: 2000 }) + if (!contacts_name) return wx.showToast({ icon: 'none', title: '请输入联系人姓名!', duration: 2000 }) + let data = { + corporation_name, + // main_business: [businessList[main_business]], + unified_tax_code, + business_licence, + contacts_name, + } + wx.showLoading({ title: '认证中' }) + if (app.globalData.member_info.name && (app.globalData.member_info.name !== '')) { + putRequest('/v1/m/cert/enterprise', data).then(res => { + setTimeout(function() { + queryLogin(app); + }, 2000) + setTimeout(function() { + queryInfo(app); + wx.hideLoading(); + app.globalData.authentication.enterprise = { + corporation_name: corporation_name, + unified_tax_code: unified_tax_code, + business_licence: business_licence, + enterprise: [ { url: business_licence } ] + } + that.setData({ openState: true }) + }, 3000); + }).catch(err => { + signIn(err); + wx.hideLoading(); + }) + } else { + postRequest('/v1/m/cert/enterprise', data).then(res => { + setTimeout(function() { + queryLogin(app); + }, 2000) + setTimeout(function() { + queryInfo(app); + wx.hideLoading(); + app.globalData.authentication.enterprise = { + corporation_name: corporation_name, + unified_tax_code: unified_tax_code, + business_licence: business_licence, + enterprise: [ { url: business_licence } ] + } + that.setData({ openState: true }) + }, 3000); + }).catch(err => { + signIn(err); + wx.hideLoading(); + }) + } + } else if (refund === '2') { // 认证个人 + if (!id_main) return wx.showToast({ icon: 'none', title: '请上传身份证正面!', duration: 2000 }) + if (!id_extra) return wx.showToast({ icon: 'none', title: '请上传身份证反面!', duration: 2000 }) + if (!name) return wx.showToast({ icon: 'none', title: '请输入姓名!', duration: 2000 }) + if (!card_number) return wx.showToast({ icon: 'none', title: '请输入身份证号!', duration: 2000 }) + let data = { + name: name, + card_number: card_number, + id_main: id_main, + id_extra: id_extra, + } + wx.showLoading({ title: '认证中' }) + postRequest('/v1/m/cert/personal', data).then(res => { + setTimeout(function() { + queryLogin(app); + }, 2000) + setTimeout(function() { + queryInfo(app); + wx.hideLoading(); + app.globalData.authentication.personal = { + name: name, + card_number: card_number, + id_main: id_main, + id_extra: id_extra, + id_card: [ { url: id_main } ] + } + that.setData({ openState: true }) + }, 3000); + }).catch(err => { + signIn(err); + wx.hideLoading(); + }) + } + }, + // 去开平安银行户 + openAccount() { + let that = this; + app.globalData.behaviorRecord = 1; + setTimeout(function() { + that.setData({ openState: false }) + wx.navigateBack({ delta: 1 }) + }, 1000) + } + +}) \ No newline at end of file diff --git a/pages/openAuthentication/index.json b/pages/openAuthentication/index.json new file mode 100644 index 0000000..5616607 --- /dev/null +++ b/pages/openAuthentication/index.json @@ -0,0 +1,8 @@ +{ + "usingComponents": { + "mp-cells": "weui-miniprogram/cells/cells", + "mp-cell": "weui-miniprogram/cell/cell", + "mp-uploader": "weui-miniprogram/uploader/uploader" + }, + "navigationBarTitleText": "开通平安银行" +} \ No newline at end of file diff --git a/pages/openAuthentication/index.wxml b/pages/openAuthentication/index.wxml new file mode 100644 index 0000000..52adc39 --- /dev/null +++ b/pages/openAuthentication/index.wxml @@ -0,0 +1,82 @@ + + + 认证类型 + + + 企业 + 个人 + + + + + + + 上传照片 + + + + + + 企业名称 + + + + + + + 纳税人识别号 + + + + + + * 证件信息识别如有偏差,请手动调整 + + 联系人姓名 + + + + + + + + + 上传照片 + + + + + + + 姓名 + + + + + + + 身份证号 + + + + + + + + + + + + + 在客服对话框中,输入1获取开户链接 + + + + + + diff --git a/pages/openAuthentication/index.wxss b/pages/openAuthentication/index.wxss new file mode 100644 index 0000000..1e37c8b --- /dev/null +++ b/pages/openAuthentication/index.wxss @@ -0,0 +1,120 @@ +page{ + height: 100%; + background: #f1f1f1; +} +.i-tabs-cell{ + display: flex; + justify-content: space-between; + padding: 30rpx 40rpx; + border-bottom: 2rpx solid #eeeeee; + background-color: #FFFFFF; + position: relative; +} +.i-tabs-cel{ + padding: 30rpx 40rpx; + border-bottom: 2rpx solid #eeeeee; + background-color: #FFFFFF; + position: relative; +} +._text{ + font-size: 26rpx; + color: rgba(49,104,233,0.6); + padding: 20rpx 40rpx; + background-color: #ffffff; + margin-bottom: 20rpx; +} +.i-tabs-cel ._image{ + width: 50rpx; + height: 50rpx; + position: absolute; + top: 26rpx; + left: 0; +} +.i-upload-pictures{ + position: relative; +} +.i-upload-pictures .image_text{ + pointer-events: none; + position: absolute; + top: 220rpx; + left: 48rpx; + color: #999999; + font-size: 26rpx; + z-index: 90; +} +.i-upload-pictures .weui-uploader__file{ + width: 300rpx; + height: 300rpx; +} +.i-tabs-cel .weui-uploader__input-box{ + width: 200rpx; + height: 200rpx; + background: #fff; + border: 2rpx dashed #e2e2e2; + border-radius: 10rpx; +} +.weui-uploader__input-box::before { + top: 30%; + height: 46rpx; +} +.weui-uploader__input-box::after{ + top: 30%; + width: 46rpx; +} +.i-cell-left{ + width: 250rpx; + color: #999999; + font-size: 32rpx; +} +.i-cell-right ._com{ + margin-right: 40rpx; +} +.weui-uploader__title{ + font-size: 32rpx; + color: #999999; + margin-bottom: 20rpx; +} +.i-page-section ._button{ + width: 85%; + margin: auto; + margin-top: 60rpx; + margin-bottom: 80rpx; + font-size: 36rpx; +} +.i-page-section .button_grey{ + width: 85%; + margin: auto; + margin-top: 60rpx; + margin-bottom: 80rpx; + background-color: #999999 !important; + font-size: 36rpx; +} + + +/* 自定义弹窗 */ +.mask { + position: fixed; + width: 100%; + height: 100%; + top: 0; + background: rgba(0, 0, 0, 0.6); + overflow: hidden; + z-index: 99; +} +.head_center{ + margin: 50% 40rpx; + background-color: #ffffff; + padding: 30rpx 50rpx 60rpx 50rpx; + border-radius: 10rpx; +} +._center{ + margin-bottom: 60rpx; + text-align: center; + font-size: 30rpx; +} +._center text:nth-child(2){ + font-size: 90rpx; + font-weight: 700; + color: red; + margin: 0 10rpx; +} \ No newline at end of file diff --git a/pages/order/order.js b/pages/order/order.js new file mode 100644 index 0000000..cd9318e --- /dev/null +++ b/pages/order/order.js @@ -0,0 +1,33 @@ +let app = getApp() +Page({ + data: { + canLogin: true, + }, + /** 生命周期函数--监听页面加载 */ + onLoad: function (options) { + + wx.showLoading({ title: '加载中' }) + }, + /** 生命周期函数--监听页面显示 */ + onShow: function () { + // 判断有没有授权 + if (!app.globalData.user_info.mobile) { + wx.redirectTo({ + url: '/pages/authorizationPage/index' + }) + return + } + // 获取数据 + this.getData(); + }, + // 获取数据 + getData() { + + }, + /** 用户点击右上角分享 */ + onShareAppMessage: function () { + return { path: "pages/firstpage/firstpage?from=share" } + }, + + +}) \ No newline at end of file diff --git a/pages/order/order.json b/pages/order/order.json new file mode 100644 index 0000000..f3f1ded --- /dev/null +++ b/pages/order/order.json @@ -0,0 +1,9 @@ +{ + "navigationBarTitleText": "我的订单", + "backgroundTextStyle":"dark", + "enablePullDownRefresh": true, + "usingComponents": { + "mp-icon": "weui-miniprogram/icon/icon", + "mp-navigation-bar": "weui-miniprogram/navigation-bar/navigation-bar" + } +} \ No newline at end of file diff --git a/pages/order/order.wxml b/pages/order/order.wxml new file mode 100644 index 0000000..dfedf18 --- /dev/null +++ b/pages/order/order.wxml @@ -0,0 +1,3 @@ + + + diff --git a/pages/order/order.wxss b/pages/order/order.wxss new file mode 100644 index 0000000..b6557bb --- /dev/null +++ b/pages/order/order.wxss @@ -0,0 +1,4 @@ +page{ + background-color: #F9F9FB; + font-family: PingFangSC-Regular; +} \ No newline at end of file diff --git a/project.config.json b/project.config.json new file mode 100644 index 0000000..6fc3856 --- /dev/null +++ b/project.config.json @@ -0,0 +1,72 @@ +{ + "description": "项目配置文件", + "packOptions": { + "ignore": [] + }, + "setting": { + "urlCheck": false, + "es6": true, + "enhance": false, + "postcss": true, + "preloadBackgroundData": false, + "minified": true, + "newFeature": false, + "coverView": true, + "nodeModules": true, + "autoAudits": false, + "showShadowRootInWxmlPanel": true, + "scopeDataCheck": false, + "uglifyFileName": false, + "checkInvalidKey": true, + "checkSiteMap": true, + "uploadWithSourceMap": true, + "compileHotReLoad": false, + "useMultiFrameRuntime": true, + "useApiHook": true, + "useApiHostProcess": false, + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + }, + "enableEngineNative": false, + "bundle": false, + "useIsolateContext": true, + "useCompilerModule": true, + "userConfirmedUseCompilerModuleSwitch": false, + "userConfirmedBundleSwitch": false, + "packNpmManually": false, + "packNpmRelationList": [], + "minifyWXSS": true + }, + "compileType": "miniprogram", + "libVersion": "2.16.0", + "appid": "wx1429ce8fccdd5005", + "projectname": "cherry_mini", + "debugOptions": { + "hidedInDevtools": [] + }, + "scripts": {}, + "isGameTourist": false, + "condition": { + "plugin": { + "list": [] + }, + "game": { + "list": [] + }, + "gamePlugin": { + "list": [] + }, + "miniprogram": { + "list": [ + { + "name": "pages/firstpage/firstpage", + "pathName": "pages/firstpage/firstpage", + "query": "bind=M001", + "scene": null + } + ] + } + } +} \ No newline at end of file diff --git a/sitemap.json b/sitemap.json new file mode 100644 index 0000000..ca02add --- /dev/null +++ b/sitemap.json @@ -0,0 +1,7 @@ +{ + "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html", + "rules": [{ + "action": "allow", + "page": "*" + }] +} \ No newline at end of file diff --git a/utils/css/public.wxss b/utils/css/public.wxss new file mode 100644 index 0000000..0d80459 --- /dev/null +++ b/utils/css/public.wxss @@ -0,0 +1,15 @@ +.flex{ + display: flex; + flex-direction: row; + justify-content:space-between; +} +.flex__item{ + width: 48%; + height: 120rpx; +} +.mini-btn2{ + font-weight: normal!important; + letter-spacing: 5rpx; + color: #FFF!important; + border-radius: 50rpx; +} \ No newline at end of file diff --git a/utils/images/dingdan1.png b/utils/images/dingdan1.png new file mode 100644 index 0000000..0babc33 Binary files /dev/null and b/utils/images/dingdan1.png differ diff --git a/utils/images/gerenzhongxin1.png b/utils/images/gerenzhongxin1.png new file mode 100644 index 0000000..5dd47f6 Binary files /dev/null and b/utils/images/gerenzhongxin1.png differ diff --git a/utils/images/moblie_image.png b/utils/images/moblie_image.png new file mode 100644 index 0000000..1254ec1 Binary files /dev/null and b/utils/images/moblie_image.png differ diff --git a/utils/images/no_data_available.png b/utils/images/no_data_available.png new file mode 100644 index 0000000..e3f883c Binary files /dev/null and b/utils/images/no_data_available.png differ diff --git a/utils/images/shouye1.png b/utils/images/shouye1.png new file mode 100644 index 0000000..8b13def Binary files /dev/null and b/utils/images/shouye1.png differ diff --git a/utils/js/locales.js b/utils/js/locales.js new file mode 100644 index 0000000..fd42240 --- /dev/null +++ b/utils/js/locales.js @@ -0,0 +1,79 @@ +import { getRequest, postRequest } from './request.js' + +// 查询用户信息 +function queryInfo(app) { + getRequest('/v1/m/info',{}).then(res => { + let user_info = {}; + user_info.name = '' + user_info.user_id = '' + user_info.mobile = '' + let member_info = {}; + member_info.name = '' + member_info.member_id = '' + member_info.rank = '' + member_info.vip_level = '' + member_info.type = '' + member_info.status = '' + let operator_info = {}; + operator_info.mobile = '' + operator_info.operator_id = '' + operator_info.position = '' + operator_info.status = '' + app.globalData.user_info = res.data.user_info ? res.data.user_info : user_info + app.globalData.member_info = res.data.member_info ? res.data.member_info : member_info + app.globalData.operator_info = res.data.operator_info ? res.data.operator_info : operator_info + }).catch(err => { + console.log(err,'03') + }) +} + +// 查询平台信息 +function platformInfo(app) { + getRequest('/v1/m/platform/info',{}).then(res => { + app.globalData.platformInfo = res.data + }).catch(err => { + console.log(err,'03') + }) +} + +// 重新登录 +function queryLogin(app) { + wx.login({ + success: function (loginRes) { + if (loginRes.errMsg === 'login:ok') { + postRequest('/v1/p/login',{ code: loginRes.code }).then(res => { + wx.setStorageSync('tokenKey', res.data.token); + wx.setStorageSync('actor', res.data.info.actor); // res.data.actor buyer seller + app.globalData.actor = res.data.info.actor + app.globalData.info = res.data.info + }).catch(err => { + console.log(err,'03') + }) + } + } + }) +} + +// 登录过期处理 +function signIn(err) { + if (err.statusCode === 401) { + wx.showToast({ title: '登录过期,重新加载小程序', icon: 'none', duration: 3000 }) + setTimeout(function () { + // 获取缓存里的扫码内容 登录 + let bind = wx.getStorageSync('bind') + app.loginCloudBird(bind); + }, 2000) + return + } + let errMsg = err.data ? err.data.error_message : ''; + if (errMsg !== '') { + wx.showToast({ title: errMsg, icon: 'none', duration: 2000 }) + } +} + +module.exports = { + queryInfo, + platformInfo, + queryLogin, + signIn, +} diff --git a/utils/js/replace.js b/utils/js/replace.js new file mode 100644 index 0000000..b7ef28e --- /dev/null +++ b/utils/js/replace.js @@ -0,0 +1,7 @@ + +let pageTitle = '云禽助手'; // 页面标题 +// "navigationBarTitleText": "云禽小助手" + +module.exports = { + pageTitle, +} \ No newline at end of file diff --git a/utils/js/request.js b/utils/js/request.js new file mode 100644 index 0000000..ec06d8d --- /dev/null +++ b/utils/js/request.js @@ -0,0 +1,148 @@ +let tokenKey = "access-token"; +// let serverUrl = "https://yapi.amtcloud.cn/mock/11/coconut"; // mock +// let serverUrl = "https://office-ssl.iilink.cn/coconut"; // 开发环境 +// let serverUrl = "https://office-ssl.iilink.cn/coconut-uat"; // 测试环境 +let serverUrl ='https://tokamak.amtcloud.cn/coconut'; // 生产 +// 例外不用token的地址 +let exceptionAddrArr = ['/login',]; + +//请求头处理函数 +function CreateHeader(url, type) { + let header = {} + if (type == 'POST_PARAMS'){ + header = { + 'content-type': 'application/x-www-form-urlencoded' + } + }else{ + header = { + 'content-type': 'application/json' + } + } + if (exceptionAddrArr.indexOf(url) == -1) { //排除请求的地址不需要token的地址 + let token = wx.getStorageSync('tokenKey'); + // header.Authorization = token; + header['access-token'] = token; + } + return header; +} +//post请求,数据在body中 +function postRequest(url,data){ + let header = CreateHeader(url,'POST'); + return new Promise((resolve, reject) => { + wx.request({ + url: serverUrl + url, + data: data, + header: header, + method: 'POST', + success: (res => { + if (200<=res.statusCode&&res.statusCode<300) { + //200: 服务端业务处理正常结束 + resolve(res) + } else { + reject(res) + } + }), + fail: (res => { + reject(res) + }) + }) + }) +} +//post请求,数据按照query方式传给后端 +function postParamsRequest(url, data) { + let header = CreateHeader(url,'POST_PARAMS'); + let useurl = url; + return new Promise((resolve, reject) => { + wx.request({ + url: serverUrl + useurl, + data: data, + header: header , + method: 'POST', + success: (res => { + if (200<=res.statusCode&&res.statusCode<300) { + //200: 服务端业务处理正常结束 + resolve(res) + } else { + reject(res) + } + }), + fail: (res => { + reject(res) + }) + }) + }) +} +//get 请求 +function getRequest(url, data) { + let header = CreateHeader(url, 'GET'); + return new Promise((resolve, reject) => { + wx.request({ + url: serverUrl + url, + data: data, + header: header, + method: 'GET', + success: (res => { + if (200<=res.statusCode&&res.statusCode<300) { + //200: 服务端业务处理正常结束 + resolve(res) + } else { + reject(res) + } + }), + fail: (res => { + reject(res) + }) + }) + }) +} +//put请求 +function putRequest(url, data) { + let header = CreateHeader(url, 'PUT'); + return new Promise((resolve, reject) => { + wx.request({ + url: serverUrl + url, + data: data, + header: header, + method: 'PUT', + success: (res => { + if (200<=res.statusCode&&res.statusCode<300) { + //200: 服务端业务处理正常结束 + resolve(res) + } else { + reject(res) + } + }), + fail: (res => { + reject(res) + }) + }) + }) +} +//delete请求 +function deleteRequest(url, data) { + let header = CreateHeader(url, 'DELETE'); + return new Promise((resolve, reject) => { + wx.request({ + url: serverUrl + url, + data: data, + header: header, + method: 'DELETE', + success: (res => { + if (200<=res.statusCode&&res.statusCode<300) { + //200: 服务端业务处理正常结束 + resolve(res) + } else { + reject(res) + } + }), + fail: (res => { + reject(res) + }) + }) + }) +} +module.exports.getRequest = getRequest; +module.exports.postRequest = postRequest; +module.exports.postParamsRequest = postParamsRequest; +module.exports.putRequest = putRequest; +module.exports.deleteRequest = deleteRequest; \ No newline at end of file diff --git a/utils/js/util.js b/utils/js/util.js new file mode 100644 index 0000000..7c0a9d0 --- /dev/null +++ b/utils/js/util.js @@ -0,0 +1,162 @@ +function formatTime(date,fmt) { + date = new Date(date); + var o = { + "M+": date.getMonth() + 1, //月份 + "d+": date.getDate(), //日 + "h+": date.getHours(), //小时 + "m+": date.getMinutes(), //分 + "s+": date.getSeconds(), //秒 + "q+": Math.floor((date.getMonth() + 3) / 3), //季度 + "S": date.getMilliseconds() //毫秒 + }; + if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length)); + for (var k in o) + if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); + return fmt; +} + +function checkAuditTime(beginTime,endTime){ + var nowDate = new Date(); + var beginDate = new Date(nowDate); + var endDate = new Date(nowDate); + var beginIndex = beginTime.lastIndexOf("\:"); + var beginHour = beginTime.substring(0,beginIndex); + var beginMinue = beginTime.substring(beginIndex+1,beginTime.length); + beginDate.setHours(beginHour,beginMinue, 0, 0); + + var endIndex = endTime.lastIndexOf("\:"); + var endHour = endTime.substring(0,endIndex); + var endMinue = endTime.substring(endIndex+1,endTime.length); + endDate.setHours(endHour, endMinue, 0, 0); + if(nowDate.getTime()-beginDate.getTime() >= 0 && nowDate.getTime() <= endDate.getTime()){ + return true; + }else{ + return false; + } +} + +function formatNumber(n) { + n = n.toString() + return n[1] ? n : '0' + n +} + +/** +* 时间戳转化为年 月 日 时 分 秒 +* number: 传入时间戳 +* format:返回格式,支持自定义,但参数必须与formateArr里保持一致 +*/ +function formatTimeTwo(number, format) { + number=new Date(number); + var formateArr = ['Y', 'M', 'D', 'h', 'm', 's']; + var returnArr = []; + var date = new Date(number * 1000); + returnArr.push(date.getFullYear()); + returnArr.push(formatNumber(date.getMonth() + 1)); + returnArr.push(formatNumber(date.getDate())); + returnArr.push(formatNumber(date.getHours())); + returnArr.push(formatNumber(date.getMinutes())); + returnArr.push(formatNumber(date.getSeconds())); + for (var i in returnArr) { + format = format.replace(formateArr[i], returnArr[i]); + } + return format; +} + + //截图url参数 + var getQueryString = function (url, name) { + var reg = new RegExp('(^|&|/?)' + name + '=([^&|/?]*)(&|/?|$)', 'i') + var r = url.substr(1).match(reg) + if (r != null) { + return r[2] + } + return null; + } + /** + ** 加法函数,用来得到精确的加法结果 + ** 说明:javascript的加法结果会有误差,在两个浮点数相加的时候会比较明显。这个函数返回较为精确的加法结果。 + ** 调用:accAdd(arg1,arg2) + ** 返回值:arg1加上arg2的精确结果 + **/ + function addStringNumber(arg1, arg2) { + var r1, r2, m, c; + try { + r1 = arg1.toString().split(".")[1].length; + } + catch (e) { + r1 = 0; + } + try { + r2 = arg2.toString().split(".")[1].length; + } + catch (e) { + r2 = 0; + } + c = Math.abs(r1 - r2); + m = Math.pow(10, Math.max(r1, r2)); + if (c > 0) { + var cm = Math.pow(10, c); + if (r1 > r2) { + arg1 = Number(arg1.toString().replace(".", "")); + arg2 = Number(arg2.toString().replace(".", "")) * cm; + } else { + arg1 = Number(arg1.toString().replace(".", "")) * cm; + arg2 = Number(arg2.toString().replace(".", "")); + } + } else { + arg1 = Number(arg1.toString().replace(".", "")); + arg2 = Number(arg2.toString().replace(".", "")); + } + return (((arg1 + arg2) / m) !== 0) ? ((arg1 + arg2) / m) : '0.00'; + } + + /** + ** 减法函数,用来得到精确的减法结果 + ** 说明:javascript的减法结果会有误差,在两个浮点数相减的时候会比较明显。这个函数返回较为精确的减法结果。 + ** 调用:accSub(arg1,arg2) + ** 返回值:arg1加上arg2的精确结果 + **/ + function subtractStringNumber(arg1, arg2) { + var r1, r2, m, n; + try { + r1 = arg1.toString().split(".")[1].length; + } + catch (e) { + r1 = 0; + } + try { + r2 = arg2.toString().split(".")[1].length; + } + catch (e) { + r2 = 0; + } + m = Math.pow(10, Math.max(r1, r2)); //last modify by deeka //动态控制精度长度 + n = (r1 >= r2) ? r1 : r2; + return (((arg1 * m - arg2 * m) / m).toFixed(n) !== 0) ? ((arg1 * m - arg2 * m) / m).toFixed(n) : '0.00'; + } + + /** 乘法函数,用来得到精确的乘法结果 说明:javascript的乘法结果会有误差,在两个浮点数相乘的时候会比较明显。这个函数返回较为精确的乘法结果。 调用:accMul(arg1,arg2) 返回值:arg1乘以 arg2的精确结果**/ + + function accMul(arg1, arg2) { + var m = 0, s1 = arg1.toString(), s2 = arg2.toString(); + try { + m += s1.split(".")[1].length; + } + catch (e) { + } + try { + m += s2.split(".")[1].length; + } + catch (e) { + } + return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m); + } + +module.exports = { + formatTime, + checkAuditTime, + formatTimeTwo, + getQueryString, + addStringNumber, + subtractStringNumber, + accMul +} diff --git a/utils/replace-images/account-statement.png b/utils/replace-images/account-statement.png new file mode 100644 index 0000000..24db81f Binary files /dev/null and b/utils/replace-images/account-statement.png differ diff --git a/utils/replace-images/dingdan.png b/utils/replace-images/dingdan.png new file mode 100644 index 0000000..d10ace9 Binary files /dev/null and b/utils/replace-images/dingdan.png differ diff --git a/utils/replace-images/gerenzhongxin.png b/utils/replace-images/gerenzhongxin.png new file mode 100644 index 0000000..294a538 Binary files /dev/null and b/utils/replace-images/gerenzhongxin.png differ diff --git a/utils/replace-images/icon1.png b/utils/replace-images/icon1.png new file mode 100644 index 0000000..65fc486 Binary files /dev/null and b/utils/replace-images/icon1.png differ diff --git a/utils/replace-images/icon4.png b/utils/replace-images/icon4.png new file mode 100644 index 0000000..5fef55c Binary files /dev/null and b/utils/replace-images/icon4.png differ diff --git a/utils/replace-images/icon5.png b/utils/replace-images/icon5.png new file mode 100644 index 0000000..fc0982f Binary files /dev/null and b/utils/replace-images/icon5.png differ diff --git a/utils/replace-images/logo.png b/utils/replace-images/logo.png new file mode 100644 index 0000000..e663c25 Binary files /dev/null and b/utils/replace-images/logo.png differ diff --git a/utils/replace-images/moblie_image.png b/utils/replace-images/moblie_image.png new file mode 100644 index 0000000..4c01c45 Binary files /dev/null and b/utils/replace-images/moblie_image.png differ diff --git a/utils/replace-images/shouye.png b/utils/replace-images/shouye.png new file mode 100644 index 0000000..72e241f Binary files /dev/null and b/utils/replace-images/shouye.png differ