diff --git a/.gitignore b/.gitignore
index 9e353a2..d25dbf7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
/unpackage
-/.vscode
\ No newline at end of file
+/.vscode
+jsconfig.json
\ No newline at end of file
diff --git a/App.vue b/App.vue
index 2cf70cb..c6f1183 100644
--- a/App.vue
+++ b/App.vue
@@ -2,23 +2,30 @@
import { go2 } from '@/utils/hook.js'
import store from '@/store/index.js'
export default {
- onLaunch: function () {
- const token = store.state.qnToken
- if (!token) {
- go2('login')
+ onLaunch: function (options) {
+ const { query } = options
+ // 判断是否从分享进入
+ if (query.share) {
+ let supplierId = query.id
+ if (!supplierId) {
+ go2('error')
+ } else {
+ store.commit('setSupplierId', supplierId)
+ }
+ } else {
+ console.log('非分享进入', store.state.supplierId)
+ if (!store.state.supplierId) {
+ go2('error')
+ }
}
- console.log('App launched')
},
- onShow: function () {
- console.log('App Show')
- },
- onHide: function () {
- console.log('App Hide')
- }
+ onShow: function () {},
+ onHide: function () {}
}
diff --git a/apis/clientApi.js b/apis/clientApi.js
deleted file mode 100644
index bc70e2d..0000000
--- a/apis/clientApi.js
+++ /dev/null
@@ -1,16 +0,0 @@
-import http from '../utils/http/index.js'
-export const getList = (data) => {
- return http.get({
- url:'/trading-center/wechatapplet/get/paper-brand/brand-list',
- data,
- })
-}
-
-/**
- * @param {Object} data :{filePath:'',fileType:'',fileName:''}
- */
-export const upload = (data) => {
- return http.uploadFile({
- data
- })
-}
\ No newline at end of file
diff --git a/apis/commonApi.js b/apis/commonApi.js
new file mode 100644
index 0000000..7a5aa00
--- /dev/null
+++ b/apis/commonApi.js
@@ -0,0 +1,62 @@
+import http from '../utils/http/index.js'
+let areaCache = null
+/**
+ * 获取省市区街道
+ * @returns array
+ */
+export function getArea(data = {}) {
+ return new Promise((resolve, reject) => {
+ if (areaCache) {
+ resolve(areaCache)
+ } else {
+ http.get({ url: '/yyt-uec/get/regions', data }).then((res) => {
+ if (res) {
+ areaCache = res
+ resolve(res)
+ } else {
+ resolve(null)
+ }
+ })
+ }
+ })
+}
+
+let baseInfo = null
+/**
+ * 获取当前账号的基础信息
+ * @param {object} data 参数,暂时不需要,可以传{}
+ * @param {boolean} refresh 是否强制刷新,默认false拿缓存数据
+ * @returns object
+ */
+export function getBaseInfo(data = {}, refresh = false) {
+ return new Promise((resolve, reject) => {
+ if (!refresh && baseInfo) {
+ resolve(baseInfo)
+ } else {
+ http.get({ url: '/yyt-uec/get/base-info', data }, { hideLoading: true }).then((res) => {
+ if (res) {
+ baseInfo = res
+ resolve(res)
+ } else {
+ resolve(null)
+ }
+ })
+ }
+ })
+}
+
+/**
+ * 获取当前账号的企业实名认证地址
+ * @param {object} data 参数 enterpriseId
+ */
+export function getVerifyUrl(data = {}) {
+ return http.post({ url: '/yyt-uec/get/fdd-enterprise-verify-url?enterpriseId=' + data.enterpriseId, data })
+}
+
+/**
+ * 生成担保合同的签约地址,同意纸盘商只需要签约一次即可
+ * @param {object} data 参数 mallSupplierId
+ */
+export function getGuaranteeContract(data = {}) {
+ return http.post({ url: '/yyt-uec/create/supplier/guarantee-contract?mallSupplierId=' + data.mallSupplierId, data })
+}
diff --git a/apis/enterpriseInfoApi.js b/apis/enterpriseInfoApi.js
new file mode 100644
index 0000000..d8b53f7
--- /dev/null
+++ b/apis/enterpriseInfoApi.js
@@ -0,0 +1,49 @@
+import http from '../utils/http/index.js'
+
+/**
+ * 完善企业信息
+ * @param {*} data
+ * @returns
+ */
+export function completeInfo(data) {
+ return http.post({
+ url: '/yyt-uec/save/my/enterprise',
+ data
+ })
+}
+
+/**
+ * 根据名称模糊查询企业列表
+ * @param {*} data
+ * @returns
+ */
+export function getCompanyList(data) {
+ return http.get({
+ url: '/base-paper-trading/get/customers/enterprise/basic/list',
+ data
+ })
+}
+
+/**
+ * 根据id查询企业详细信息
+ * @param {*} data
+ * @returns
+ */
+export function getCompanyInfoById(data) {
+ return http.get({
+ url: '/yyt-uec/get/enterprise-detail',
+ data
+ })
+}
+
+/**
+ * 根据企业名称查询企业坐标列表
+ * @param {*} data
+ * @returns
+ */
+export function getCompanyLocationList(data) {
+ return http.get({
+ url: '/yyt-uec/get/enterprise/geographic/position/address',
+ data
+ })
+}
diff --git a/apis/mineApi.js b/apis/mineApi.js
new file mode 100644
index 0000000..f76e9bc
--- /dev/null
+++ b/apis/mineApi.js
@@ -0,0 +1,14 @@
+import http from '../utils/http/index.js'
+
+/**
+ * 纸掌柜获取纸盘商订单统计
+ * @param {object} data
+ * @returns 订单统计
+ * swagger:http://api-ops-uec-test.qniao.cn/uec/swagger-ui/index.html?urls.primaryName=CustomerApi#/%E7%99%BB%E5%BD%95%E8%AE%A4%E8%AF%81/authorizeByCaptchaUsingPOST
+ */
+export const getOrderStatistics = (data) => {
+ return http.get({
+ url: '/base-paper-trading/get/supplier/order-volume-statistics',
+ data
+ })
+}
diff --git a/common/css/reset.scss b/common/css/reset.scss
index 67d551f..1ce1f6c 100644
--- a/common/css/reset.scss
+++ b/common/css/reset.scss
@@ -1,8 +1,8 @@
page {
- font-size:$uni-font-size-base;
- line-height: 1;
- background-color: #fff;
- -webkit-overflow-scrolling: touch; /* 使ios列表滑动流畅*/
+ font-size: $uni-font-size-base;
+ line-height: 1;
+ background-color: #f7f8fa;
+ -webkit-overflow-scrolling: touch; /* 使ios列表滑动流畅*/
}
page,
@@ -16,32 +16,32 @@ picker,
scroll-view,
cover-view,
open-data {
- box-sizing: border-box;
+ box-sizing: border-box;
}
rich-text,
open-data,
form {
- display: block;
+ display: block;
}
cover-view {
- line-height: 1.5;
- white-space: normal;
+ line-height: 1.5;
+ white-space: normal;
}
::webkit-scrollbar {
- display: none;
+ display: none;
}
button::after {
- border: 0;
+ border: 0;
}
/* 清除浮动 */
.clearfix:after {
- content: ".";
- display: block;
- height: 0;
- clear: both;
- visibility: hidden;
-}
\ No newline at end of file
+ content: '.';
+ display: block;
+ height: 0;
+ clear: both;
+ visibility: hidden;
+}
diff --git a/components/qn-data-picker/keypress.js b/components/qn-data-picker/keypress.js
new file mode 100644
index 0000000..6ef26a2
--- /dev/null
+++ b/components/qn-data-picker/keypress.js
@@ -0,0 +1,45 @@
+// #ifdef H5
+export default {
+ name: 'Keypress',
+ props: {
+ disable: {
+ type: Boolean,
+ default: false
+ }
+ },
+ mounted () {
+ const keyNames = {
+ esc: ['Esc', 'Escape'],
+ tab: 'Tab',
+ enter: 'Enter',
+ space: [' ', 'Spacebar'],
+ up: ['Up', 'ArrowUp'],
+ left: ['Left', 'ArrowLeft'],
+ right: ['Right', 'ArrowRight'],
+ down: ['Down', 'ArrowDown'],
+ delete: ['Backspace', 'Delete', 'Del']
+ }
+ const listener = ($event) => {
+ if (this.disable) {
+ return
+ }
+ const keyName = Object.keys(keyNames).find(key => {
+ const keyName = $event.key
+ const value = keyNames[key]
+ return value === keyName || (Array.isArray(value) && value.includes(keyName))
+ })
+ if (keyName) {
+ // 避免和其他按键事件冲突
+ setTimeout(() => {
+ this.$emit(keyName, {})
+ }, 0)
+ }
+ }
+ document.addEventListener('keyup', listener)
+ this.$once('hook:beforeDestroy', () => {
+ document.removeEventListener('keyup', listener)
+ })
+ },
+ render: () => {}
+}
+// #endif
diff --git a/components/qn-data-picker/qn-data-picker.vue b/components/qn-data-picker/qn-data-picker.vue
new file mode 100644
index 0000000..56a5b22
--- /dev/null
+++ b/components/qn-data-picker/qn-data-picker.vue
@@ -0,0 +1,566 @@
+
+
+
+
+
+ {{ errorMessage }}
+
+
+
+
+
+
+ {{ item.text }}
+ {{ split }}
+
+
+
+ {{ placeholder }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ popupTitle }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/components/qn-data-pickerview/qn-data-picker.js b/components/qn-data-pickerview/qn-data-picker.js
new file mode 100644
index 0000000..c12fd54
--- /dev/null
+++ b/components/qn-data-pickerview/qn-data-picker.js
@@ -0,0 +1,563 @@
+export default {
+ props: {
+ localdata: {
+ type: [Array, Object],
+ default () {
+ return []
+ }
+ },
+ spaceInfo: {
+ type: Object,
+ default () {
+ return {}
+ }
+ },
+ collection: {
+ type: String,
+ default: ''
+ },
+ action: {
+ type: String,
+ default: ''
+ },
+ field: {
+ type: String,
+ default: ''
+ },
+ orderby: {
+ type: String,
+ default: ''
+ },
+ where: {
+ type: [String, Object],
+ default: ''
+ },
+ pageData: {
+ type: String,
+ default: 'add'
+ },
+ pageCurrent: {
+ type: Number,
+ default: 1
+ },
+ pageSize: {
+ type: Number,
+ default: 20
+ },
+ getcount: {
+ type: [Boolean, String],
+ default: false
+ },
+ getone: {
+ type: [Boolean, String],
+ default: false
+ },
+ gettree: {
+ type: [Boolean, String],
+ default: false
+ },
+ manual: {
+ type: Boolean,
+ default: false
+ },
+ value: {
+ type: [Array, String, Number],
+ default () {
+ return []
+ }
+ },
+ modelValue: {
+ type: [Array, String, Number],
+ default () {
+ return []
+ }
+ },
+ preload: {
+ type: Boolean,
+ default: false
+ },
+ stepSearh: {
+ type: Boolean,
+ default: true
+ },
+ selfField: {
+ type: String,
+ default: ''
+ },
+ parentField: {
+ type: String,
+ default: ''
+ },
+ multiple: {
+ type: Boolean,
+ default: false
+ },
+ map: {
+ type: Object,
+ default() {
+ return {
+ text: "text",
+ value: "value"
+ }
+ }
+ }
+ },
+ data() {
+ return {
+ loading: false,
+ errorMessage: '',
+ loadMore: {
+ contentdown: '',
+ contentrefresh: '',
+ contentnomore: ''
+ },
+ dataList: [],
+ selected: [],
+ selectedIndex: 0,
+ page: {
+ current: this.pageCurrent,
+ size: this.pageSize,
+ count: 0
+ }
+ }
+ },
+ computed: {
+ isLocaldata() {
+ return !this.collection.length
+ },
+ postField() {
+ let fields = [this.field];
+ if (this.parentField) {
+ fields.push(`${this.parentField} as parent_value`);
+ }
+ return fields.join(',');
+ },
+ dataValue() {
+ let isModelValue = Array.isArray(this.modelValue) ? (this.modelValue.length > 0) : (this.modelValue !== null || this.modelValue !== undefined)
+ return isModelValue ? this.modelValue : this.value
+ },
+ hasValue() {
+ if (typeof this.dataValue === 'number') {
+ return true
+ }
+ return (this.dataValue != null) && (this.dataValue.length > 0)
+ }
+ },
+ created() {
+ this.$watch(() => {
+ var al = [];
+ ['pageCurrent',
+ 'pageSize',
+ 'spaceInfo',
+ 'value',
+ 'modelValue',
+ 'localdata',
+ 'collection',
+ 'action',
+ 'field',
+ 'orderby',
+ 'where',
+ 'getont',
+ 'getcount',
+ 'gettree'
+ ].forEach(key => {
+ al.push(this[key])
+ });
+ return al
+ }, (newValue, oldValue) => {
+ let needReset = false
+ for (let i = 2; i < newValue.length; i++) {
+ if (newValue[i] != oldValue[i]) {
+ needReset = true
+ break
+ }
+ }
+ if (newValue[0] != oldValue[0]) {
+ this.page.current = this.pageCurrent
+ }
+ this.page.size = this.pageSize
+
+ this.onPropsChange()
+ })
+ this._treeData = []
+ },
+ methods: {
+ onPropsChange() {
+ this._treeData = []
+ },
+ getCommand(options = {}) {
+ /* eslint-disable no-undef */
+ let db = uniCloud.database(this.spaceInfo)
+
+ const action = options.action || this.action
+ if (action) {
+ db = db.action(action)
+ }
+
+ const collection = options.collection || this.collection
+ db = db.collection(collection)
+
+ const where = options.where || this.where
+ if (!(!where || !Object.keys(where).length)) {
+ db = db.where(where)
+ }
+
+ const field = options.field || this.field
+ if (field) {
+ db = db.field(field)
+ }
+
+ const orderby = options.orderby || this.orderby
+ if (orderby) {
+ db = db.orderBy(orderby)
+ }
+
+ const current = options.pageCurrent !== undefined ? options.pageCurrent : this.page.current
+ const size = options.pageSize !== undefined ? options.pageSize : this.page.size
+ const getCount = options.getcount !== undefined ? options.getcount : this.getcount
+ const getTree = options.gettree !== undefined ? options.gettree : this.gettree
+
+ const getOptions = {
+ getCount,
+ getTree
+ }
+ if (options.getTreePath) {
+ getOptions.getTreePath = options.getTreePath
+ }
+
+ db = db.skip(size * (current - 1)).limit(size).get(getOptions)
+
+ return db
+ },
+ getNodeData(callback) {
+ if (this.loading) {
+ return
+ }
+ this.loading = true
+ this.getCommand({
+ field: this.postField,
+ where: this._pathWhere()
+ }).then((res) => {
+ this.loading = false
+ this.selected = res.result.data
+ callback && callback()
+ }).catch((err) => {
+ this.loading = false
+ this.errorMessage = err
+ })
+ },
+ getTreePath(callback) {
+ if (this.loading) {
+ return
+ }
+ this.loading = true
+
+ this.getCommand({
+ field: this.postField,
+ getTreePath: {
+ startWith: `${this.selfField}=='${this.dataValue}'`
+ }
+ }).then((res) => {
+ this.loading = false
+ let treePath = []
+ this._extractTreePath(res.result.data, treePath)
+ this.selected = treePath
+ callback && callback()
+ }).catch((err) => {
+ this.loading = false
+ this.errorMessage = err
+ })
+ },
+ loadData() {
+ if (this.isLocaldata) {
+ this._processLocalData()
+ return
+ }
+
+ if (this.dataValue != null) {
+ this._loadNodeData((data) => {
+ this._treeData = data
+ this._updateBindData()
+ this._updateSelected()
+ })
+ return
+ }
+
+ if (this.stepSearh) {
+ this._loadNodeData((data) => {
+ this._treeData = data
+ this._updateBindData()
+ })
+ } else {
+ this._loadAllData((data) => {
+ this._treeData = []
+ this._extractTree(data, this._treeData, null)
+ this._updateBindData()
+ })
+ }
+ },
+ _loadAllData(callback) {
+ if (this.loading) {
+ return
+ }
+ this.loading = true
+
+ this.getCommand({
+ field: this.postField,
+ gettree: true,
+ startwith: `${this.selfField}=='${this.dataValue}'`
+ }).then((res) => {
+ this.loading = false
+ callback(res.result.data)
+ this.onDataChange()
+ }).catch((err) => {
+ this.loading = false
+ this.errorMessage = err
+ })
+ },
+ _loadNodeData(callback, pw) {
+ if (this.loading) {
+ return
+ }
+ this.loading = true
+
+ this.getCommand({
+ field: this.postField,
+ where: pw || this._postWhere(),
+ pageSize: 500
+ }).then((res) => {
+ this.loading = false
+ callback(res.result.data)
+ this.onDataChange()
+ }).catch((err) => {
+ this.loading = false
+ this.errorMessage = err
+ })
+ },
+ _pathWhere() {
+ let result = []
+ let where_field = this._getParentNameByField();
+ if (where_field) {
+ result.push(`${where_field} == '${this.dataValue}'`)
+ }
+
+ if (this.where) {
+ return `(${this.where}) && (${result.join(' || ')})`
+ }
+
+ return result.join(' || ')
+ },
+ _postWhere() {
+ let result = []
+ let selected = this.selected
+ let parentField = this.parentField
+ if (parentField) {
+ result.push(`${parentField} == null || ${parentField} == ""`)
+ }
+ if (selected.length) {
+ for (var i = 0; i < selected.length - 1; i++) {
+ result.push(`${parentField} == '${selected[i].value}'`)
+ }
+ }
+
+ let where = []
+ if (this.where) {
+ where.push(`(${this.where})`)
+ }
+ if (result.length) {
+ where.push(`(${result.join(' || ')})`)
+ }
+
+ return where.join(' && ')
+ },
+ _nodeWhere() {
+ let result = []
+ let selected = this.selected
+ if (selected.length) {
+ result.push(`${this.parentField} == '${selected[selected.length - 1].value}'`)
+ }
+
+ if (this.where) {
+ return `(${this.where}) && (${result.join(' || ')})`
+ }
+
+ return result.join(' || ')
+ },
+ _getParentNameByField() {
+ const fields = this.field.split(',');
+ let where_field = null;
+ for (let i = 0; i < fields.length; i++) {
+ const items = fields[i].split('as');
+ if (items.length < 2) {
+ continue;
+ }
+ if (items[1].trim() === 'value') {
+ where_field = items[0].trim();
+ break;
+ }
+ }
+ return where_field
+ },
+ _isTreeView() {
+ return (this.parentField && this.selfField)
+ },
+ _updateSelected() {
+ var dl = this.dataList
+ var sl = this.selected
+ let textField = this.map.text
+ let valueField = this.map.value
+ for (var i = 0; i < sl.length; i++) {
+ var value = sl[i].value
+ var dl2 = dl[i]
+ for (var j = 0; j < dl2.length; j++) {
+ var item2 = dl2[j]
+ if (item2[valueField] === value) {
+ sl[i].text = item2[textField]
+ break
+ }
+ }
+ }
+ },
+ _updateBindData(node) {
+ const {
+ dataList,
+ hasNodes
+ } = this._filterData(this._treeData, this.selected)
+
+ let isleaf = this._stepSearh === false && !hasNodes
+
+ if (node) {
+ node.isleaf = isleaf
+ }
+
+ this.dataList = dataList
+ this.selectedIndex = dataList.length - 1
+
+ if (!isleaf && this.selected.length < dataList.length) {
+ this.selected.push({
+ value: null,
+ text: "请选择"
+ })
+ }
+
+ return {
+ isleaf,
+ hasNodes
+ }
+ },
+ _filterData(data, paths) {
+ let dataList = []
+ let hasNodes = true
+
+ dataList.push(data.filter((item) => {
+ return (item.parent_value === null || item.parent_value === undefined || item.parent_value === '')
+ }))
+ for (let i = 0; i < paths.length; i++) {
+ var value = paths[i].value
+ var nodes = data.filter((item) => {
+ return item.parent_value === value
+ })
+
+ if (nodes.length) {
+ dataList.push(nodes)
+ } else {
+ hasNodes = false
+ }
+ }
+
+ return {
+ dataList,
+ hasNodes
+ }
+ },
+ _extractTree(nodes, result, parent_value) {
+ let list = result || []
+ let valueField = this.map.value
+ for (let i = 0; i < nodes.length; i++) {
+ let node = nodes[i]
+
+ let child = {}
+ for (let key in node) {
+ if (key !== 'children') {
+ child[key] = node[key]
+ }
+ }
+ if (parent_value !== null && parent_value !== undefined && parent_value !== '') {
+ child.parent_value = parent_value
+ }
+ result.push(child)
+
+ let children = node.children
+ if (children) {
+ this._extractTree(children, result, node[valueField])
+ }
+ }
+ },
+ _extractTreePath(nodes, result) {
+ let list = result || []
+ for (let i = 0; i < nodes.length; i++) {
+ let node = nodes[i]
+
+ let child = {}
+ for (let key in node) {
+ if (key !== 'children') {
+ child[key] = node[key]
+ }
+ }
+ result.push(child)
+
+ let children = node.children
+ if (children) {
+ this._extractTreePath(children, result)
+ }
+ }
+ },
+ _findNodePath(key, nodes, path = []) {
+ let textField = this.map.text
+ let valueField = this.map.value
+ for (let i = 0; i < nodes.length; i++) {
+ let node = nodes[i]
+ let children = node.children
+ let text = node[textField]
+ let value = node[valueField]
+
+ path.push({
+ value,
+ text
+ })
+
+ if (value === key) {
+ return path
+ }
+
+ if (children) {
+ const p = this._findNodePath(key, children, path)
+ if (p.length) {
+ return p
+ }
+ }
+
+ path.pop()
+ }
+ return []
+ },
+ _processLocalData() {
+ this._treeData = []
+ this._extractTree(this.localdata, this._treeData)
+
+ var inputValue = this.dataValue
+ if (inputValue === undefined) {
+ return
+ }
+
+ if (Array.isArray(inputValue)) {
+ inputValue = inputValue[inputValue.length - 1]
+ if (typeof inputValue === 'object' && inputValue[this.map.value]) {
+ inputValue = inputValue[this.map.value]
+ }
+ }
+
+ this.selected = this._findNodePath(inputValue, this.localdata)
+ }
+ }
+}
diff --git a/components/qn-data-pickerview/qn-data-pickerview.vue b/components/qn-data-pickerview/qn-data-pickerview.vue
new file mode 100644
index 0000000..ffbe9f9
--- /dev/null
+++ b/components/qn-data-pickerview/qn-data-pickerview.vue
@@ -0,0 +1,334 @@
+
+
+
+
+
+
+ {{ item.text }}
+
+
+
+
+
+
+
+
+ {{ item[map.text] }}
+
+
+
+
+
+
+
+
+
+ {{ errorMessage }}
+
+
+
+
+
+
+
diff --git a/components/qn-datetime-picker/calendar-item.vue b/components/qn-datetime-picker/calendar-item.vue
new file mode 100644
index 0000000..b57610f
--- /dev/null
+++ b/components/qn-datetime-picker/calendar-item.vue
@@ -0,0 +1,185 @@
+
+
+
+
+ {{weeks.date}}
+
+
+
+
+
+
+
+
diff --git a/components/qn-datetime-picker/calendar.vue b/components/qn-datetime-picker/calendar.vue
new file mode 100644
index 0000000..c48a096
--- /dev/null
+++ b/components/qn-datetime-picker/calendar.vue
@@ -0,0 +1,898 @@
+
+
+
+
+
+
+
+ {{nowDate.month}}
+
+
+
+ {{SUNText}}
+
+
+ {{monText}}
+
+
+ {{TUEText}}
+
+
+ {{WEDText}}
+
+
+ {{THUText}}
+
+
+ {{FRIText}}
+
+
+ {{SATText}}
+
+
+
+
+
+
+
+
+
+
+ {{tempSingleDate ? tempSingleDate : selectDateText}}
+
+
+
+
+
+
+ {{tempRange.before ? tempRange.before : startDateText}}
+
+
+
+
+
+
+ {{tempRange.after ? tempRange.after : endDateText}}
+
+
+
+
+
+
+ 确认
+
+
+
+
+
+
+
+
diff --git a/components/qn-datetime-picker/i18n/en.json b/components/qn-datetime-picker/i18n/en.json
new file mode 100644
index 0000000..cc76311
--- /dev/null
+++ b/components/qn-datetime-picker/i18n/en.json
@@ -0,0 +1,19 @@
+{
+ "uni-datetime-picker.selectDate": "select date",
+ "uni-datetime-picker.selectTime": "select time",
+ "uni-datetime-picker.selectDateTime": "select datetime",
+ "uni-datetime-picker.startDate": "start date",
+ "uni-datetime-picker.endDate": "end date",
+ "uni-datetime-picker.startTime": "start time",
+ "uni-datetime-picker.endTime": "end time",
+ "uni-datetime-picker.ok": "ok",
+ "uni-datetime-picker.clear": "clear",
+ "uni-datetime-picker.cancel": "cancel",
+ "uni-calender.MON": "MON",
+ "uni-calender.TUE": "TUE",
+ "uni-calender.WED": "WED",
+ "uni-calender.THU": "THU",
+ "uni-calender.FRI": "FRI",
+ "uni-calender.SAT": "SAT",
+ "uni-calender.SUN": "SUN"
+}
diff --git a/components/qn-datetime-picker/i18n/index.js b/components/qn-datetime-picker/i18n/index.js
new file mode 100644
index 0000000..de7509c
--- /dev/null
+++ b/components/qn-datetime-picker/i18n/index.js
@@ -0,0 +1,8 @@
+import en from './en.json'
+import zhHans from './zh-Hans.json'
+import zhHant from './zh-Hant.json'
+export default {
+ en,
+ 'zh-Hans': zhHans,
+ 'zh-Hant': zhHant
+}
diff --git a/components/qn-datetime-picker/i18n/zh-Hans.json b/components/qn-datetime-picker/i18n/zh-Hans.json
new file mode 100644
index 0000000..7bc7405
--- /dev/null
+++ b/components/qn-datetime-picker/i18n/zh-Hans.json
@@ -0,0 +1,19 @@
+{
+ "uni-datetime-picker.selectDate": "选择日期",
+ "uni-datetime-picker.selectTime": "选择时间",
+ "uni-datetime-picker.selectDateTime": "选择日期时间",
+ "uni-datetime-picker.startDate": "开始日期",
+ "uni-datetime-picker.endDate": "结束日期",
+ "uni-datetime-picker.startTime": "开始时间",
+ "uni-datetime-picker.endTime": "结束时间",
+ "uni-datetime-picker.ok": "确定",
+ "uni-datetime-picker.clear": "清除",
+ "uni-datetime-picker.cancel": "取消",
+ "uni-calender.SUN": "日",
+ "uni-calender.MON": "一",
+ "uni-calender.TUE": "二",
+ "uni-calender.WED": "三",
+ "uni-calender.THU": "四",
+ "uni-calender.FRI": "五",
+ "uni-calender.SAT": "六"
+}
diff --git a/components/qn-datetime-picker/i18n/zh-Hant.json b/components/qn-datetime-picker/i18n/zh-Hant.json
new file mode 100644
index 0000000..7d37043
--- /dev/null
+++ b/components/qn-datetime-picker/i18n/zh-Hant.json
@@ -0,0 +1,19 @@
+{
+ "uni-datetime-picker.selectDate": "選擇日期",
+ "uni-datetime-picker.selectTime": "選擇時間",
+ "uni-datetime-picker.selectDateTime": "選擇日期時間",
+ "uni-datetime-picker.startDate": "開始日期",
+ "uni-datetime-picker.endDate": "結束日期",
+ "uni-datetime-picker.startTime": "開始时间",
+ "uni-datetime-picker.endTime": "結束时间",
+ "uni-datetime-picker.ok": "確定",
+ "uni-datetime-picker.clear": "清除",
+ "uni-datetime-picker.cancel": "取消",
+ "uni-calender.SUN": "日",
+ "uni-calender.MON": "一",
+ "uni-calender.TUE": "二",
+ "uni-calender.WED": "三",
+ "uni-calender.THU": "四",
+ "uni-calender.FRI": "五",
+ "uni-calender.SAT": "六"
+}
diff --git a/components/qn-datetime-picker/keypress.js b/components/qn-datetime-picker/keypress.js
new file mode 100644
index 0000000..9601aba
--- /dev/null
+++ b/components/qn-datetime-picker/keypress.js
@@ -0,0 +1,45 @@
+// #ifdef H5
+export default {
+ name: 'Keypress',
+ props: {
+ disable: {
+ type: Boolean,
+ default: false
+ }
+ },
+ mounted () {
+ const keyNames = {
+ esc: ['Esc', 'Escape'],
+ tab: 'Tab',
+ enter: 'Enter',
+ space: [' ', 'Spacebar'],
+ up: ['Up', 'ArrowUp'],
+ left: ['Left', 'ArrowLeft'],
+ right: ['Right', 'ArrowRight'],
+ down: ['Down', 'ArrowDown'],
+ delete: ['Backspace', 'Delete', 'Del']
+ }
+ const listener = ($event) => {
+ if (this.disable) {
+ return
+ }
+ const keyName = Object.keys(keyNames).find(key => {
+ const keyName = $event.key
+ const value = keyNames[key]
+ return value === keyName || (Array.isArray(value) && value.includes(keyName))
+ })
+ if (keyName) {
+ // 避免和其他按键事件冲突
+ setTimeout(() => {
+ this.$emit(keyName, {})
+ }, 0)
+ }
+ }
+ document.addEventListener('keyup', listener)
+ this.$once('hook:beforeDestroy', () => {
+ document.removeEventListener('keyup', listener)
+ })
+ },
+ render: () => {}
+}
+// #endif
\ No newline at end of file
diff --git a/components/qn-datetime-picker/qn-datetime-picker.vue b/components/qn-datetime-picker/qn-datetime-picker.vue
new file mode 100644
index 0000000..7c8d4f4
--- /dev/null
+++ b/components/qn-datetime-picker/qn-datetime-picker.vue
@@ -0,0 +1,1008 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ rangeSeparator }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/components/qn-datetime-picker/time-picker.vue b/components/qn-datetime-picker/time-picker.vue
new file mode 100644
index 0000000..699aa63
--- /dev/null
+++ b/components/qn-datetime-picker/time-picker.vue
@@ -0,0 +1,927 @@
+
+
+
+
+
+ {{time}}
+
+ {{selectTimeText}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/components/qn-datetime-picker/util.js b/components/qn-datetime-picker/util.js
new file mode 100644
index 0000000..efa5773
--- /dev/null
+++ b/components/qn-datetime-picker/util.js
@@ -0,0 +1,410 @@
+class Calendar {
+ constructor({
+ date,
+ selected,
+ startDate,
+ endDate,
+ range,
+ // multipleStatus
+ } = {}) {
+ // 当前日期
+ this.date = this.getDate(new Date()) // 当前初入日期
+ // 打点信息
+ this.selected = selected || [];
+ // 范围开始
+ this.startDate = startDate
+ // 范围结束
+ this.endDate = endDate
+ this.range = range
+ // 多选状态
+ this.cleanMultipleStatus()
+ // 每周日期
+ this.weeks = {}
+ // this._getWeek(this.date.fullDate)
+ // this.multipleStatus = multipleStatus
+ this.lastHover = false
+ }
+ /**
+ * 设置日期
+ * @param {Object} date
+ */
+ setDate(date) {
+ this.selectDate = this.getDate(date)
+ this._getWeek(this.selectDate.fullDate)
+ }
+
+ /**
+ * 清理多选状态
+ */
+ cleanMultipleStatus() {
+ this.multipleStatus = {
+ before: '',
+ after: '',
+ data: []
+ }
+ }
+
+ /**
+ * 重置开始日期
+ */
+ resetSatrtDate(startDate) {
+ // 范围开始
+ this.startDate = startDate
+
+ }
+
+ /**
+ * 重置结束日期
+ */
+ resetEndDate(endDate) {
+ // 范围结束
+ this.endDate = endDate
+ }
+
+ /**
+ * 获取任意时间
+ */
+ getDate(date, AddDayCount = 0, str = 'day') {
+ if (!date) {
+ date = new Date()
+ }
+ if (typeof date !== 'object') {
+ date = date.replace(/-/g, '/')
+ }
+ const dd = new Date(date)
+ switch (str) {
+ case 'day':
+ dd.setDate(dd.getDate() + AddDayCount) // 获取AddDayCount天后的日期
+ break
+ case 'month':
+ if (dd.getDate() === 31) {
+ dd.setDate(dd.getDate() + AddDayCount)
+ } else {
+ dd.setMonth(dd.getMonth() + AddDayCount) // 获取AddDayCount天后的日期
+ }
+ break
+ case 'year':
+ dd.setFullYear(dd.getFullYear() + AddDayCount) // 获取AddDayCount天后的日期
+ break
+ }
+ const y = dd.getFullYear()
+ const m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1 // 获取当前月份的日期,不足10补0
+ const d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate() // 获取当前几号,不足10补0
+ return {
+ fullDate: y + '-' + m + '-' + d,
+ year: y,
+ month: m,
+ date: d,
+ day: dd.getDay()
+ }
+ }
+
+
+ /**
+ * 获取上月剩余天数
+ */
+ _getLastMonthDays(firstDay, full) {
+ let dateArr = []
+ for (let i = firstDay; i > 0; i--) {
+ const beforeDate = new Date(full.year, full.month - 1, -i + 1).getDate()
+ dateArr.push({
+ date: beforeDate,
+ month: full.month - 1,
+ disable: true
+ })
+ }
+ return dateArr
+ }
+ /**
+ * 获取本月天数
+ */
+ _currentMonthDys(dateData, full) {
+ let dateArr = []
+ let fullDate = this.date.fullDate
+ for (let i = 1; i <= dateData; i++) {
+ let isinfo = false
+ let nowDate = full.year + '-' + (full.month < 10 ?
+ full.month : full.month) + '-' + (i < 10 ?
+ '0' + i : i)
+ // 是否今天
+ let isDay = fullDate === nowDate
+ // 获取打点信息
+ let info = this.selected && this.selected.find((item) => {
+ if (this.dateEqual(nowDate, item.date)) {
+ return item
+ }
+ })
+
+ // 日期禁用
+ let disableBefore = true
+ let disableAfter = true
+ if (this.startDate) {
+ // let dateCompBefore = this.dateCompare(this.startDate, fullDate)
+ // disableBefore = this.dateCompare(dateCompBefore ? this.startDate : fullDate, nowDate)
+ disableBefore = this.dateCompare(this.startDate, nowDate)
+ }
+
+ if (this.endDate) {
+ // let dateCompAfter = this.dateCompare(fullDate, this.endDate)
+ // disableAfter = this.dateCompare(nowDate, dateCompAfter ? this.endDate : fullDate)
+ disableAfter = this.dateCompare(nowDate, this.endDate)
+ }
+ let multiples = this.multipleStatus.data
+ let checked = false
+ let multiplesStatus = -1
+ if (this.range) {
+ if (multiples) {
+ multiplesStatus = multiples.findIndex((item) => {
+ return this.dateEqual(item, nowDate)
+ })
+ }
+ if (multiplesStatus !== -1) {
+ checked = true
+ }
+ }
+ let data = {
+ fullDate: nowDate,
+ year: full.year,
+ date: i,
+ multiple: this.range ? checked : false,
+ beforeMultiple: this.isLogicBefore(nowDate, this.multipleStatus.before, this.multipleStatus.after),
+ afterMultiple: this.isLogicAfter(nowDate, this.multipleStatus.before, this.multipleStatus.after),
+ month: full.month,
+ disable: !(disableBefore && disableAfter),
+ isDay,
+ userChecked: false
+ }
+ if (info) {
+ data.extraInfo = info
+ }
+
+ dateArr.push(data)
+ }
+ return dateArr
+ }
+ /**
+ * 获取下月天数
+ */
+ _getNextMonthDays(surplus, full) {
+ let dateArr = []
+ for (let i = 1; i < surplus + 1; i++) {
+ dateArr.push({
+ date: i,
+ month: Number(full.month) + 1,
+ disable: true
+ })
+ }
+ return dateArr
+ }
+
+ /**
+ * 获取当前日期详情
+ * @param {Object} date
+ */
+ getInfo(date) {
+ if (!date) {
+ date = new Date()
+ }
+ const dateInfo = this.canlender.find(item => item.fullDate === this.getDate(date).fullDate)
+ return dateInfo
+ }
+
+ /**
+ * 比较时间大小
+ */
+ dateCompare(startDate, endDate) {
+ // 计算截止时间
+ startDate = new Date(startDate.replace('-', '/').replace('-', '/'))
+ // 计算详细项的截止时间
+ endDate = new Date(endDate.replace('-', '/').replace('-', '/'))
+ if (startDate <= endDate) {
+ return true
+ } else {
+ return false
+ }
+ }
+
+ /**
+ * 比较时间是否相等
+ */
+ dateEqual(before, after) {
+ // 计算截止时间
+ before = new Date(before.replace('-', '/').replace('-', '/'))
+ // 计算详细项的截止时间
+ after = new Date(after.replace('-', '/').replace('-', '/'))
+ if (before.getTime() - after.getTime() === 0) {
+ return true
+ } else {
+ return false
+ }
+ }
+
+ /**
+ * 比较真实起始日期
+ */
+
+ isLogicBefore(currentDay, before, after) {
+ let logicBefore = before
+ if (before && after) {
+ logicBefore = this.dateCompare(before, after) ? before : after
+ }
+ return this.dateEqual(logicBefore, currentDay)
+ }
+
+ isLogicAfter(currentDay, before, after) {
+ let logicAfter = after
+ if (before && after) {
+ logicAfter = this.dateCompare(before, after) ? after : before
+ }
+ return this.dateEqual(logicAfter, currentDay)
+ }
+
+ /**
+ * 获取日期范围内所有日期
+ * @param {Object} begin
+ * @param {Object} end
+ */
+ geDateAll(begin, end) {
+ var arr = []
+ var ab = begin.split('-')
+ var ae = end.split('-')
+ var db = new Date()
+ db.setFullYear(ab[0], ab[1] - 1, ab[2])
+ var de = new Date()
+ de.setFullYear(ae[0], ae[1] - 1, ae[2])
+ var unixDb = db.getTime() - 24 * 60 * 60 * 1000
+ var unixDe = de.getTime() - 24 * 60 * 60 * 1000
+ for (var k = unixDb; k <= unixDe;) {
+ k = k + 24 * 60 * 60 * 1000
+ arr.push(this.getDate(new Date(parseInt(k))).fullDate)
+ }
+ return arr
+ }
+
+ /**
+ * 获取多选状态
+ */
+ setMultiple(fullDate) {
+ let {
+ before,
+ after
+ } = this.multipleStatus
+ if (!this.range) return
+ if (before && after) {
+ if (!this.lastHover) {
+ this.lastHover = true
+ return
+ }
+ this.multipleStatus.before = fullDate
+ this.multipleStatus.after = ''
+ this.multipleStatus.data = []
+ this.multipleStatus.fulldate = ''
+ this.lastHover = false
+ } else {
+ if (!before) {
+ this.multipleStatus.before = fullDate
+ this.lastHover = false
+ } else {
+ this.multipleStatus.after = fullDate
+ if (this.dateCompare(this.multipleStatus.before, this.multipleStatus.after)) {
+ this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus
+ .after);
+ } else {
+ this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus
+ .before);
+ }
+ this.lastHover = true
+ }
+ }
+ this._getWeek(fullDate)
+ }
+
+ /**
+ * 鼠标 hover 更新多选状态
+ */
+ setHoverMultiple(fullDate) {
+ let {
+ before,
+ after
+ } = this.multipleStatus
+
+ if (!this.range) return
+ if (this.lastHover) return
+
+ if (!before) {
+ this.multipleStatus.before = fullDate
+ } else {
+ this.multipleStatus.after = fullDate
+ if (this.dateCompare(this.multipleStatus.before, this.multipleStatus.after)) {
+ this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus.after);
+ } else {
+ this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus.before);
+ }
+ }
+ this._getWeek(fullDate)
+ }
+
+ /**
+ * 更新默认值多选状态
+ */
+ setDefaultMultiple(before, after) {
+ this.multipleStatus.before = before
+ this.multipleStatus.after = after
+ if (before && after) {
+ if (this.dateCompare(before, after)) {
+ this.multipleStatus.data = this.geDateAll(before, after);
+ this._getWeek(after)
+ } else {
+ this.multipleStatus.data = this.geDateAll(after, before);
+ this._getWeek(before)
+ }
+ }
+ }
+
+ /**
+ * 获取每周数据
+ * @param {Object} dateData
+ */
+ _getWeek(dateData) {
+ const {
+ fullDate,
+ year,
+ month,
+ date,
+ day
+ } = this.getDate(dateData)
+ let firstDay = new Date(year, month - 1, 1).getDay()
+ let currentDay = new Date(year, month, 0).getDate()
+ let dates = {
+ lastMonthDays: this._getLastMonthDays(firstDay, this.getDate(dateData)), // 上个月末尾几天
+ currentMonthDys: this._currentMonthDys(currentDay, this.getDate(dateData)), // 本月天数
+ nextMonthDays: [], // 下个月开始几天
+ weeks: []
+ }
+ let canlender = []
+ const surplus = 42 - (dates.lastMonthDays.length + dates.currentMonthDys.length)
+ dates.nextMonthDays = this._getNextMonthDays(surplus, this.getDate(dateData))
+ canlender = canlender.concat(dates.lastMonthDays, dates.currentMonthDys, dates.nextMonthDays)
+ let weeks = {}
+ // 拼接数组 上个月开始几天 + 本月天数+ 下个月开始几天
+ for (let i = 0; i < canlender.length; i++) {
+ if (i % 7 === 0) {
+ weeks[parseInt(i / 7)] = new Array(7)
+ }
+ weeks[parseInt(i / 7)][i % 7] = canlender[i]
+ }
+ this.canlender = canlender
+ this.weeks = weeks
+ }
+
+ //静态方法
+ // static init(date) {
+ // if (!this.instance) {
+ // this.instance = new Calendar(date);
+ // }
+ // return this.instance;
+ // }
+}
+
+
+export default Calendar
diff --git a/components/qn-easyinput/qn-easyinput.vue b/components/qn-easyinput/qn-easyinput.vue
new file mode 100644
index 0000000..27936eb
--- /dev/null
+++ b/components/qn-easyinput/qn-easyinput.vue
@@ -0,0 +1,514 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/components/qn-footer/qn-footer.vue b/components/qn-footer/qn-footer.vue
new file mode 100644
index 0000000..991d0a8
--- /dev/null
+++ b/components/qn-footer/qn-footer.vue
@@ -0,0 +1,74 @@
+
+
+
+
+
+
+
diff --git a/components/qn-form-item/qn-form-item.vue b/components/qn-form-item/qn-form-item.vue
new file mode 100644
index 0000000..4b0febf
--- /dev/null
+++ b/components/qn-form-item/qn-form-item.vue
@@ -0,0 +1,87 @@
+
+
+
+ {{ label }}
+
+
+
+
+ {{ label }}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/components/qn-header/qn-header.vue b/components/qn-header/qn-header.vue
new file mode 100644
index 0000000..01f3c4a
--- /dev/null
+++ b/components/qn-header/qn-header.vue
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
diff --git a/components/scroll-list/images.js b/components/scroll-list/images.js
new file mode 100644
index 0000000..ed8007a
--- /dev/null
+++ b/components/scroll-list/images.js
@@ -0,0 +1,5 @@
+export default {
+ empty: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHoAAABoCAYAAAA+R+R0AAAG50lEQVR4Xu2df1PURhjHn71fOQ8ZsKIoWioWsHcOLU49O53OqbwDfQm+AugraN+B+grad1D7CkDPzrSeHbAM54+2YLHiyGAL43DclSTb2UgwQC7Zu01ySfbJPzdym2ef5/vJdzeX7KwE8JBCASJFlVgkIGhJLgIEjaAlUUCSMtHRCFoSBSQpEx2NoCVRQJIy0dEBgi5XqtOlYmEiwC53u0LQAalersxfBUhOA2gTpeLYTEDdIuighUbQQSsecH/vAJvHO0eb/wrS2Th0+wiezckAYAF9oLOZoOZsBO0jaBYaHe2zwGELj3N02Ij4lA+Ctgg7PTvbO3Hhwrr56ZPmHQuLv6MBgMFNqcocAPkOgN4oFQtnOkYkhh2H6masXFn4FoB8Qym5cflS/vsY6t2xkkIDmjk6qSrPgZIpAvpU6dL58Y6pEsOOQwM6htqGqiQEHSoc/iWDoP3TNlSREXSocPiXDIL2T9tQRUbQocLhXzII2j9tQxUZQYcKh3/JIGj/tA1VZGlAsydvaS1zk1JiPEMnhD7fTv73NXuJEioiPiUjBeifHiyM64TMJBKkK3com2Ja1rbqqq7TzQSlV7+6dH7OJ31DEzZ2oO89rF4jFCatChOAz0kikTt3diB5KKsYX23VG/B0cUWjul6jAL9a21MCty9fLNwJDSUPEokV6B3IP6TTSVXJZAznskNJp+B4Xw+YkM2/M9iraxvQ2FZ3pdyqN3RN0xOUwPU4wY4U6PKD6iQQuOZwgY9n0qme/PCHJJlMtO2Dueoi6Dplc3fTIZ0CzGkquT3xZf552x0FeGJkQN9/+Pg3SulYJp1SD2Xfu9Wq1WatDtmsAqNDA0ISPltagXq9AV25rG2czVpDVzUtAUDXVTVxIQqwIwH6fqU6RQFuDg70weDAsaYQ55/+BVuNbch/fBpEHP3o8RL0dndBfvh0075WXv8Diy9eAxC4XbpYmBK6sgI42TPQd39hq0MArnxx3vj08ihXqjNKJl0qfjrsOB6/WX8Lj//4GzKZtDEvt3PU6g3QNN2AfLS32zHEz7PPmLPLpWLBae12O2l4fo5noHcWq4MfC9IZ6J7u3JWxcx+5CsBgM7eJHAP9H7hCZvHZCLLxtnYXQYuobTm3FdAedckVRhrQbLhOJMgVO1V0nd71ahhH0FzXnWMjoaEbQePQLX4J4tDtqYZCjrZmEpabMU/VcQkmzRxt1cHvn1e8d90I2l4Bzxztp8B4MyauLoIW0FDKoVtAL9dTvXJ0vbENvy+9goH+I3D0iPNTL9ekZH1gwiNMu228Ar38cg2WV9bAeGZ+qq/ddHbPQ0cLS7g3AIIWF1SqOboVR2+8rUFPd85RYXS0+AW4JwKPo2cXluBwLgtDg8chlUzaZsADWtU0mH/yAti77fzwKce5HEEHDJrBqTz603i9yBYLjA6dsF008OZf9hrzJRztPQz5kYPvmhlcBpnFUzJpGPtkELJKumk1CDpg0Kw7BunZ0ivYrDUMR48MnTjgRjYczz9ZNu66zw7278ny9doGLC2vGpC7cooBudnIYJ6IoDsAmnXJIC0urxoL/tgxMnQS+vt69mTD2uwHaDqdNWSLCEeHTnJVgKC5ZOJvxDNHW6MZy3yWV22da9er6XS7C8MpSwTNz5CrZaugWVD2cMRpfuXq2KURgvZCRUuMdkB7nIJtOATtscoIWlxQqR6YiMu1NwI62mNF0dHigqKjBTQUcbSfCzXsSkLQHQLt59IrBC0A1e5UEUcjaBtF4zJHB7U8Gh3dYUcjaBcAcXG0tUwcumM8dCNoCR2NP68kcbTHtwuu4QL7HX2vUr1DgNwCoJOlYuG6a2b4UqMViVzbBgba3J6CAvx4uVhw2nDmQNLsZiyrpEsXx5x3PHCt1uMGUu544KZh+cHCHBCyTgHGtVTjTCs79r3fw+SYsSY7DIe0e5i4ic9272M79Jmfbu33f79zoXymZFJqVrHflajVmO22N3clogAbmkrGcVeidpVsct6Os1sa9j1O4X04AnPqNrkVBcgs6cDmaN8Ex8BcCiBoLpmi3whBR58hVwUImkum6DdC0NFnyFWBEOi9/9s5V39SNCoVx2ashVp12v+d2Y5Hy2bn8ojaNuid12yh3wOTRwQf2syYW2Ue1EmbOHghVKcBgEfL3bit5tw2aNYRz1XYakJxaB8rR8cBiEw1CDlaJqGiXiuCjjpBzvwRNKdQUW+GoKNOkDP/UIJ2WhbL6tq/F7i5opKzZk+bebkvuaeJ7QuGoAXVRdCCAuLp3ioQSkd7WyJGYwogaEmuAwSNoCVRQJIy0dEIWhIFJCkTHY2gJVFAkjLR0QhaEgUkKRMdjaAlUUCSMtHRkoD+H39JyZZ6zcs+AAAAAElFTkSuQmCC',
+ success: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48c3ZnIHdpZHRoPSIxOCIgaGVpZ2h0PSIxOCIgdmlld0JveD0iMCAwIDQ4IDQ4IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxyZWN0IHdpZHRoPSI0OCIgaGVpZ2h0PSI0OCIgZmlsbD0id2hpdGUiIGZpbGwtb3BhY2l0eT0iMC4wMSIvPjxwYXRoIGQ9Ik0xMCAyNEwyMCAzNEw0MCAxNCIgc3Ryb2tlPSIjMzAzMTMzIiBzdHJva2Utd2lkdGg9IjMiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==',
+ error: 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48c3ZnIHdpZHRoPSIxOCIgaGVpZ2h0PSIxOCIgdmlld0JveD0iMCAwIDQ4IDQ4IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxyZWN0IHdpZHRoPSI0OCIgaGVpZ2h0PSI0OCIgZmlsbD0id2hpdGUiIGZpbGwtb3BhY2l0eT0iMC4wMSIvPjxwYXRoIGQ9Ik0xNCAxNEwzNCAzNCIgc3Ryb2tlPSIjMzAzMTMzIiBzdHJva2Utd2lkdGg9IjMiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjxwYXRoIGQ9Ik0xNCAzNEwzNCAxNCIgc3Ryb2tlPSIjMzAzMTMzIiBzdHJva2Utd2lkdGg9IjMiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg=='
+}
diff --git a/components/scroll-list/scroll-list.vue b/components/scroll-list/scroll-list.vue
new file mode 100644
index 0000000..40d82a4
--- /dev/null
+++ b/components/scroll-list/scroll-list.vue
@@ -0,0 +1,668 @@
+
+
+
+
+
+
+
+
+ {{ refreshStateText }}
+
+
+
+
+
+
+ {{ emptyText }}
+
+
+
+
+
+
+
+ {{ loadStateText }}
+
+
+
+
+
+
+
+
+
+
diff --git a/enums/index.js b/enums/index.js
index ab00116..790632f 100644
--- a/enums/index.js
+++ b/enums/index.js
@@ -1,3 +1,6 @@
+import env from '@/env/index.js'
+const urlEnv = env === 'production' ? '' : `-${env}`
+
/**
* 账号类型
*/
@@ -27,3 +30,80 @@ export const verificationType = {
PHONE: 1,
EMAIL: 2
}
+/**
+ * 法大大企业认证状态 1:未认证 2:认证中 3:已认证 4:认证失败
+ */
+export const fddEnterpriseStatus = {
+ UNCERTIFIED: 1,
+ CERTIFIED_ING: 2,
+ CERTIFIED_SUCCESS: 3,
+ CERTIFIED_FAIL: 4
+}
+/**
+ * 上传地址
+ */
+export const uploadUrl = {
+ image: `https://api-ops-yyt${urlEnv}.qniao.cn/yyt-uec/file-uploading/upload/image`,
+ file: `https://api-ops-yyt${urlEnv}.qniao.cn/yyt-uec/file-uploading/upload/file`
+}
+/**
+ * 结算周期:1:月结30(飞算1期),2:月结45,3:月结60(飞算2期),4:月结75,5:月结90(飞算3期)
+ */
+export const settlementPeriodEnum = [
+ {
+ value: 1,
+ label: '月结30'
+ },
+ {
+ value: 2,
+ label: '月结45'
+ },
+ {
+ value: 3,
+ label: '月结60'
+ },
+ {
+ value: 4,
+ label: '月结75'
+ },
+ {
+ value: 5,
+ label: '月结90'
+ }
+]
+/**
+ * 结算周期:1:1期,2:2期,3:3期
+ */
+export const fsSettlementPeriodEnum = [
+ {
+ value: 1,
+ label: '1期'
+ },
+ {
+ value: 2,
+ label: '2期'
+ },
+ {
+ value: 3,
+ label: '3期'
+ }
+]
+/**
+ * 飞算结算方式: 1: 先息后本
+ */
+export const fsSettlementMethodEnum = [
+ {
+ value: 1,
+ label: '先息后本'
+ }
+]
+
+/**
+ * 飞算授信审核状态 0: 待客户申请 1: 审核中 2: 通过 3: 拒绝
+ */
+export const fsAuditStatus = {
+ WAIT_APPLY: 0,
+ AUDITING: 1,
+ PASS: 2,
+ REJECT: 3
+}
diff --git a/env/index.js b/env/index.js
new file mode 100644
index 0000000..a0bfcb1
--- /dev/null
+++ b/env/index.js
@@ -0,0 +1,8 @@
+/**
+ * @description 唯一环境变量
+ */
+const env = 'test'
+// const env = 'dev'
+// const env = 'production'
+
+export default env
diff --git a/pages.json b/pages.json
index 6ebbc62..2edb7e1 100644
--- a/pages.json
+++ b/pages.json
@@ -3,18 +3,21 @@
{
"path": "pages/store/index",
"style": {
- "navigationBarTitleText": "店铺首页"
+ "navigationBarTitleText": "店铺首页",
+ "navigationStyle": "custom"
}
},
{
"path": "pages/cart/index",
"style": {
+ "navigationStyle": "custom",
"navigationBarTitleText": "购物车"
}
},
{
"path": "pages/mine/index",
"style": {
+ "navigationStyle": "custom",
"navigationBarTitleText": "个人中心"
}
},
@@ -22,14 +25,39 @@
"path": "pages/login/index",
"style": {
"navigationBarTitleText": "登录",
+ "navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/agreement/index",
"style": {
+ "navigationStyle": "custom",
"navigationBarTitleText": "用户与隐私协议"
}
+ },
+ {
+ "path": "pages/page-view/index",
+ "style": {
+ "navigationBarTitleText": "统一第三方页面",
+ "enablePullDownRefresh": false
+ }
+ },
+ {
+ "path": "pages/enterprise-info/index",
+ "style": {
+ "navigationBarTitleText": "完善企业信息",
+ "enablePullDownRefresh": false,
+ "navigationStyle": "custom"
+ }
+ },
+ {
+ "path": "pages/error/index",
+ "style": {
+ "navigationBarTitleText": "页面不存在",
+ "enablePullDownRefresh": false,
+ "navigationStyle": "custom"
+ }
}
],
"globalStyle": {
diff --git a/pages/enterprise-info/index.vue b/pages/enterprise-info/index.vue
new file mode 100644
index 0000000..b6881ee
--- /dev/null
+++ b/pages/enterprise-info/index.vue
@@ -0,0 +1,566 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ `${form.locProvinceName || ''}/${form.locCityName || ''}/${form.locDistrictName || ''}/${form.locStreetName || ''}` }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 点击上传
+
+
+ 重新上传
+
+ 预览
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 取消
+
+
+ 保存信息
+
+
+
+
+
+
+
+
+
diff --git a/pages/error/index.vue b/pages/error/index.vue
new file mode 100644
index 0000000..4a36246
--- /dev/null
+++ b/pages/error/index.vue
@@ -0,0 +1,18 @@
+
+ error
+
+
+
+
+
diff --git a/pages/login/index.vue b/pages/login/index.vue
index 77bd238..1a1eb14 100644
--- a/pages/login/index.vue
+++ b/pages/login/index.vue
@@ -1,14 +1,6 @@
-
-
+
+
纸掌柜
@@ -25,44 +17,22 @@
/>
-
+
{{ `(${timer}S后) ` }}
重新获取
-
- 获取验证码
-
-
-
- 登录
+ 获取验证码
+ 登录
-
+
已阅读并同意纸掌柜
-
- 《用户与隐私协议》
-
+ 《用户与隐私协议》
+
+
+ mine
+ client-credit
+ enterprise-info
+
-
diff --git a/pages/page-view/index.vue b/pages/page-view/index.vue
new file mode 100644
index 0000000..53b1071
--- /dev/null
+++ b/pages/page-view/index.vue
@@ -0,0 +1,66 @@
+
+
+
+
+
+
+
+
+
diff --git a/static/icon/iconfont.css b/static/icon/iconfont.css
new file mode 100644
index 0000000..2b63389
--- /dev/null
+++ b/static/icon/iconfont.css
@@ -0,0 +1,17 @@
+@font-face {
+ font-family: "iconfont"; /* Project id 3120523 */
+ src: url('/static/icon/iconfont.ttf') format('truetype');
+}
+
+.iconfont {
+ font-family: "iconfont" !important;
+ font-size: 16px;
+ font-style: normal;
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+}
+
+.icon-required:before {
+ content: "\e60e";
+}
+
diff --git a/static/icon/iconfont.ttf b/static/icon/iconfont.ttf
new file mode 100644
index 0000000..d2e3b90
Binary files /dev/null and b/static/icon/iconfont.ttf differ
diff --git a/static/imgs/enterpriseInfo/location-icon.png b/static/imgs/enterpriseInfo/location-icon.png
new file mode 100644
index 0000000..5184a40
Binary files /dev/null and b/static/imgs/enterpriseInfo/location-icon.png differ
diff --git a/static/imgs/mine/certified-icon.png b/static/imgs/mine/certified-icon.png
new file mode 100644
index 0000000..8ad38cf
Binary files /dev/null and b/static/imgs/mine/certified-icon.png differ
diff --git a/static/imgs/mine/contract-icon.png b/static/imgs/mine/contract-icon.png
new file mode 100644
index 0000000..13dc629
Binary files /dev/null and b/static/imgs/mine/contract-icon.png differ
diff --git a/static/imgs/mine/credit-icon.png b/static/imgs/mine/credit-icon.png
new file mode 100644
index 0000000..fa4b43c
Binary files /dev/null and b/static/imgs/mine/credit-icon.png differ
diff --git a/static/imgs/mine/default-avatar.png b/static/imgs/mine/default-avatar.png
new file mode 100644
index 0000000..8976eb6
Binary files /dev/null and b/static/imgs/mine/default-avatar.png differ
diff --git a/static/imgs/mine/finance-icon.png b/static/imgs/mine/finance-icon.png
new file mode 100644
index 0000000..b26f8f1
Binary files /dev/null and b/static/imgs/mine/finance-icon.png differ
diff --git a/static/imgs/mine/mine-top-bg.png b/static/imgs/mine/mine-top-bg.png
new file mode 100644
index 0000000..ec34e1e
Binary files /dev/null and b/static/imgs/mine/mine-top-bg.png differ
diff --git a/static/imgs/mine/money-icon.png b/static/imgs/mine/money-icon.png
new file mode 100644
index 0000000..8cc76fc
Binary files /dev/null and b/static/imgs/mine/money-icon.png differ
diff --git a/static/imgs/mine/msg-icon.png b/static/imgs/mine/msg-icon.png
new file mode 100644
index 0000000..f06043c
Binary files /dev/null and b/static/imgs/mine/msg-icon.png differ
diff --git a/static/imgs/mine/non-certified-icon.png b/static/imgs/mine/non-certified-icon.png
new file mode 100644
index 0000000..aa5c772
Binary files /dev/null and b/static/imgs/mine/non-certified-icon.png differ
diff --git a/static/imgs/mine/order-icon.png b/static/imgs/mine/order-icon.png
new file mode 100644
index 0000000..27b06a6
Binary files /dev/null and b/static/imgs/mine/order-icon.png differ
diff --git a/static/imgs/mine/setting-icon.png b/static/imgs/mine/setting-icon.png
new file mode 100644
index 0000000..20d3b34
Binary files /dev/null and b/static/imgs/mine/setting-icon.png differ
diff --git a/static/imgs/mine/toggle-icon.png b/static/imgs/mine/toggle-icon.png
new file mode 100644
index 0000000..7b943e4
Binary files /dev/null and b/static/imgs/mine/toggle-icon.png differ
diff --git a/static/imgs/mine/user-avatar.png b/static/imgs/mine/user-avatar.png
new file mode 100644
index 0000000..4df69c8
Binary files /dev/null and b/static/imgs/mine/user-avatar.png differ
diff --git a/static/imgs/mine/vip-icon.png b/static/imgs/mine/vip-icon.png
new file mode 100644
index 0000000..2917916
Binary files /dev/null and b/static/imgs/mine/vip-icon.png differ
diff --git a/static/logo.png b/static/logo.png
index b5771e2..2b6d783 100644
Binary files a/static/logo.png and b/static/logo.png differ
diff --git a/store/index.js b/store/index.js
index c958662..e93f135 100644
--- a/store/index.js
+++ b/store/index.js
@@ -1,21 +1,44 @@
import Vue from 'vue'
import Vuex from 'vuex'
-import { isObject } from '@/utils/is'
+import { isObject, isArray } from '@/utils/is'
let qnToken = null,
+ /**
+ * @value avatar 头像
+ * @value name 当前账号职员名称
+ * @value userId 用户id
+ * @value mobile 手机号
+ */
userInfo = null,
- supplierInfo = null,
- uecToken = null
+ /**
+ * @value id 企业id
+ * @value name 企业名称
+ * @value fddEnterpriseStatus 法大大认证状态 。1未认证,2认证进行中,3认证成功,4认证失败
+ */
+ companyInfo = null,
+ uecToken = null,
+ searchHistory = null,
+ /**
+ * @value supplierId 当前被分析的供应商id
+ */
+ supplierId = null
+const companyInfoParams = ['id', 'name', 'fddEnterpriseStatus']
+const userInfoParams = ['name', 'userId', 'mobile', 'avatar']
try {
uecToken = uni.getStorageSync('uecToken')
qnToken = uni.getStorageSync('qnToken')
+ supplierId = uni.getStorageSync('supplierId')
userInfo = uni.getStorageSync('userInfo')
+ searchHistory = uni.getStorageSync('searchHistory')
+ if (searchHistory) {
+ searchHistory = JSON.parse(searchHistory)
+ }
if (userInfo) {
userInfo = JSON.parse(userInfo)
}
- supplierInfo = uni.getStorageSync('supplierInfo')
- if (supplierInfo) {
- supplierInfo = JSON.parse(supplierInfo)
+ companyInfo = uni.getStorageSync('companyInfo')
+ if (companyInfo) {
+ companyInfo = JSON.parse(companyInfo)
}
} catch (e) {
console.error('初始化错误:', e)
@@ -26,12 +49,14 @@ const store = new Vuex.Store({
state: {
uecToken: uecToken || '',
qnToken: qnToken || '', // token
+ supplierId: supplierId || '', // 供应商id
userInfo: userInfo || {}, // 用户信息
- supplierInfo: supplierInfo || {}, // 纸盘商信息
+ companyInfo: companyInfo || {}, // 纸盘商信息
nextPage: {
name: '',
data: {}
- }
+ },
+ searchHistory: searchHistory || []
},
mutations: {
setUecToken(state, token) {
@@ -71,6 +96,37 @@ const store = new Vuex.Store({
console.error('userInfo必须是对象')
return
}
+ for (let i = 0; i < userInfoParams.length; i++) {
+ if (userInfo[userInfoParams[i]] === undefined) {
+ console.error('userInfo必须包含' + userInfoParams[i] + '属性')
+ return
+ }
+ }
+ try {
+ uni.setStorageSync('userInfo', JSON.stringify(userInfo))
+ state.userInfo = userInfo
+ } catch (e) {
+ console.error('设置userInfo失败:', e)
+ }
+ },
+ /**
+ * 更改当前用户信息
+ * @param {*} state 状态
+ * @param {arr} map 以key-value形式存储的数组
+ * @value key 需要更改的key
+ * @value value 更改后的值
+ */
+ changeUserInfo(state, map) {
+ if (!isArray(map)) {
+ console.error('map必须是数组')
+ return
+ }
+ let userInfo = state.userInfo
+ map.forEach((item) => {
+ if (userInfoParams.includes(item.key)) {
+ userInfo[item.key] = item.value
+ }
+ })
try {
uni.setStorageSync('userInfo', JSON.stringify(userInfo))
state.userInfo = userInfo
@@ -86,24 +142,55 @@ const store = new Vuex.Store({
console.error('删除userInfo失败:', e)
}
},
- setSupplierInfo(state, supplierInfo) {
- if (!isObject(supplierInfo)) {
- console.error('supplierInfo必须是对象')
+ setCompanyInfo(state, companyInfo) {
+ if (!isObject(companyInfo)) {
+ console.error('companyInfo必须是对象')
+ return
+ }
+ for (let i = 0; i < companyInfoParams.length; i++) {
+ if (companyInfo[companyInfoParams[i]] === undefined) {
+ console.error(`companyInfo必须包含${companyInfoParams[i]}`)
+ return
+ }
+ }
+ try {
+ uni.setStorageSync('companyInfo', JSON.stringify(companyInfo))
+ state.companyInfo = companyInfo
+ } catch (e) {
+ console.error('设置companyInfo失败:', e)
+ }
+ },
+ /**
+ * 更改当前供应商信息
+ * @param {*} state 状态
+ * @param {arr} map 以key-value形式存储的数组
+ * @value key 需要更改的key
+ * @value value 更改后的值
+ */
+ changeCompanyInfo(state, map) {
+ if (!isArray(map)) {
+ console.error('map必须是数组')
return
}
+ let companyInfo = state.companyInfo
+ map.forEach((item) => {
+ if (companyInfoParams.includes(item.key)) {
+ companyInfo[item.key] = item.value
+ }
+ })
try {
- uni.setStorageSync('supplierInfo', JSON.stringify(supplierInfo))
- state.supplierInfo = supplierInfo
+ uni.setStorageSync('companyInfo', JSON.stringify(companyInfo))
+ state.companyInfo = companyInfo
} catch (e) {
- console.error('更改supplierInfo失败:', e)
+ console.error('更改companyInfo失败:', e)
}
},
- removeSupplierInfo(state) {
+ removeCompanyInfo(state) {
try {
- uni.removeStorageSync('supplierInfo')
- state.supplierInfo = {}
+ uni.removeStorageSync('companyInfo')
+ state.companyInfo = {}
} catch (e) {
- console.error('删除supplierInfo失败:', e)
+ console.error('删除companyInfo失败:', e)
}
},
setNextPage(state, nextPage) {
@@ -117,6 +204,42 @@ const store = new Vuex.Store({
removeNextPage(state) {
state.nextPage.name = ''
state.nextPage.data = {}
+ },
+ setSearchHistory(state, searchHistory) {
+ if (!isArray(searchHistory)) {
+ console.error('searchHistory必须是数组')
+ return
+ }
+ try {
+ uni.setStorageSync('searchHistory', JSON.stringify(searchHistory))
+ state.searchHistory = searchHistory
+ } catch (e) {
+ console.error('更改searchHistory失败:', e)
+ }
+ },
+ clearSearchHistory(state) {
+ try {
+ uni.removeStorageSync('searchHistory')
+ state.searchHistory = []
+ } catch (e) {
+ console.error('删除searchHistory失败:', e)
+ }
+ },
+ setSupplierId(state, id) {
+ try {
+ uni.setStorageSync('supplierId', id)
+ state.supplierId = id
+ } catch (e) {
+ console.error('更改supplierId失败:', e)
+ }
+ },
+ removeSupplierId(state) {
+ try {
+ uni.removeStorageSync('supplierId')
+ state.supplierId = ''
+ } catch (e) {
+ console.error('删除supplierId失败:', e)
+ }
}
},
actions: {
@@ -124,7 +247,19 @@ const store = new Vuex.Store({
commit('removeUecToken')
commit('removeToken')
commit('removeUserInfo')
- commit('removeSupplierInfo')
+ commit('removeCompanyInfo')
+ },
+ addSearchHistory({ commit, state }, searchHistory) {
+ const arr = [...state.searchHistory] // 单层数组直接解构
+ let index = arr.findIndex((item) => item === searchHistory)
+ if (index > -1) {
+ arr.splice(index, 1)
+ }
+ arr.unshift(searchHistory)
+ if (arr.length > 10) {
+ arr = arr.slice(0, 10)
+ }
+ commit('setSearchHistory', arr)
}
}
})
diff --git a/uni_modules/uni-popup/changelog.md b/uni_modules/uni-popup/changelog.md
new file mode 100644
index 0000000..cb5adea
--- /dev/null
+++ b/uni_modules/uni-popup/changelog.md
@@ -0,0 +1,44 @@
+## 1.7.2(2021-11-26)
+- 优化 组件示例
+## 1.7.1(2021-11-26)
+- 修复 vuedoc 文字错误
+## 1.7.0(2021-11-19)
+- 优化 组件UI,并提供设计资源,详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource)
+- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-popup](https://uniapp.dcloud.io/component/uniui/uni-popup)
+## 1.6.2(2021-08-24)
+- 新增 支持国际化
+## 1.6.1(2021-07-30)
+- 优化 vue3下事件警告的问题
+## 1.6.0(2021-07-13)
+- 组件兼容 vue3,如何创建vue3项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
+## 1.5.0(2021-06-23)
+- 新增 mask-click 遮罩层点击事件
+## 1.4.5(2021-06-22)
+- 修复 nvue 平台中间弹出后,点击内容,再点击遮罩无法关闭的Bug
+## 1.4.4(2021-06-18)
+- 修复 H5平台中间弹出后,点击内容,再点击遮罩无法关闭的Bug
+## 1.4.3(2021-06-08)
+- 修复 错误的 watch 字段
+- 修复 safeArea 属性不生效的问题
+- 修复 点击内容,再点击遮罩无法关闭的Bug
+## 1.4.2(2021-05-12)
+- 新增 组件示例地址
+## 1.4.1(2021-04-29)
+- 修复 组件内放置 input 、textarea 组件,无法聚焦的问题
+## 1.4.0 (2021-04-29)
+- 新增 type 属性的 left\right 值,支持左右弹出
+- 新增 open(String:type) 方法参数 ,可以省略 type 属性 ,直接传入类型打开指定弹窗
+- 新增 backgroundColor 属性,可定义主窗口背景色,默认不显示背景色
+- 新增 safeArea 属性,是否适配底部安全区
+- 修复 App\h5\微信小程序底部安全区占位不对的Bug
+- 修复 App 端弹出等待的Bug
+- 优化 提升低配设备性能,优化动画卡顿问题
+- 优化 更简单的组件自定义方式
+## 1.2.9(2021-02-05)
+- 优化 组件引用关系,通过uni_modules引用组件
+## 1.2.8(2021-02-05)
+- 调整为uni_modules目录规范
+## 1.2.7(2021-02-05)
+- 调整为uni_modules目录规范
+- 新增 支持 PC 端
+- 新增 uni-popup-message 、uni-popup-dialog扩展组件支持 PC 端
diff --git a/uni_modules/uni-popup/components/uni-popup-dialog/keypress.js b/uni_modules/uni-popup/components/uni-popup-dialog/keypress.js
new file mode 100644
index 0000000..6ef26a2
--- /dev/null
+++ b/uni_modules/uni-popup/components/uni-popup-dialog/keypress.js
@@ -0,0 +1,45 @@
+// #ifdef H5
+export default {
+ name: 'Keypress',
+ props: {
+ disable: {
+ type: Boolean,
+ default: false
+ }
+ },
+ mounted () {
+ const keyNames = {
+ esc: ['Esc', 'Escape'],
+ tab: 'Tab',
+ enter: 'Enter',
+ space: [' ', 'Spacebar'],
+ up: ['Up', 'ArrowUp'],
+ left: ['Left', 'ArrowLeft'],
+ right: ['Right', 'ArrowRight'],
+ down: ['Down', 'ArrowDown'],
+ delete: ['Backspace', 'Delete', 'Del']
+ }
+ const listener = ($event) => {
+ if (this.disable) {
+ return
+ }
+ const keyName = Object.keys(keyNames).find(key => {
+ const keyName = $event.key
+ const value = keyNames[key]
+ return value === keyName || (Array.isArray(value) && value.includes(keyName))
+ })
+ if (keyName) {
+ // 避免和其他按键事件冲突
+ setTimeout(() => {
+ this.$emit(keyName, {})
+ }, 0)
+ }
+ }
+ document.addEventListener('keyup', listener)
+ this.$once('hook:beforeDestroy', () => {
+ document.removeEventListener('keyup', listener)
+ })
+ },
+ render: () => {}
+}
+// #endif
diff --git a/uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog.vue b/uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog.vue
new file mode 100644
index 0000000..86f7e59
--- /dev/null
+++ b/uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog.vue
@@ -0,0 +1,263 @@
+
+
+
+
+
+
+
diff --git a/uni_modules/uni-popup/components/uni-popup-message/uni-popup-message.vue b/uni_modules/uni-popup/components/uni-popup-message/uni-popup-message.vue
new file mode 100644
index 0000000..f4c85e2
--- /dev/null
+++ b/uni_modules/uni-popup/components/uni-popup-message/uni-popup-message.vue
@@ -0,0 +1,143 @@
+
+
+
+
+
+
diff --git a/uni_modules/uni-popup/components/uni-popup-share/uni-popup-share.vue b/uni_modules/uni-popup/components/uni-popup-share/uni-popup-share.vue
new file mode 100644
index 0000000..212cf5f
--- /dev/null
+++ b/uni_modules/uni-popup/components/uni-popup-share/uni-popup-share.vue
@@ -0,0 +1,187 @@
+
+
+
+
+
+
diff --git a/uni_modules/uni-popup/components/uni-popup/i18n/en.json b/uni_modules/uni-popup/components/uni-popup/i18n/en.json
new file mode 100644
index 0000000..7f1bd06
--- /dev/null
+++ b/uni_modules/uni-popup/components/uni-popup/i18n/en.json
@@ -0,0 +1,7 @@
+{
+ "uni-popup.cancel": "cancel",
+ "uni-popup.ok": "ok",
+ "uni-popup.placeholder": "pleace enter",
+ "uni-popup.title": "Hint",
+ "uni-popup.shareTitle": "Share to"
+}
diff --git a/uni_modules/uni-popup/components/uni-popup/i18n/index.js b/uni_modules/uni-popup/components/uni-popup/i18n/index.js
new file mode 100644
index 0000000..de7509c
--- /dev/null
+++ b/uni_modules/uni-popup/components/uni-popup/i18n/index.js
@@ -0,0 +1,8 @@
+import en from './en.json'
+import zhHans from './zh-Hans.json'
+import zhHant from './zh-Hant.json'
+export default {
+ en,
+ 'zh-Hans': zhHans,
+ 'zh-Hant': zhHant
+}
diff --git a/uni_modules/uni-popup/components/uni-popup/i18n/zh-Hans.json b/uni_modules/uni-popup/components/uni-popup/i18n/zh-Hans.json
new file mode 100644
index 0000000..5e3003c
--- /dev/null
+++ b/uni_modules/uni-popup/components/uni-popup/i18n/zh-Hans.json
@@ -0,0 +1,7 @@
+{
+ "uni-popup.cancel": "取消",
+ "uni-popup.ok": "确定",
+ "uni-popup.placeholder": "请输入",
+ "uni-popup.title": "提示",
+ "uni-popup.shareTitle": "分享到"
+}
diff --git a/uni_modules/uni-popup/components/uni-popup/i18n/zh-Hant.json b/uni_modules/uni-popup/components/uni-popup/i18n/zh-Hant.json
new file mode 100644
index 0000000..13e39eb
--- /dev/null
+++ b/uni_modules/uni-popup/components/uni-popup/i18n/zh-Hant.json
@@ -0,0 +1,7 @@
+{
+ "uni-popup.cancel": "取消",
+ "uni-popup.ok": "確定",
+ "uni-popup.placeholder": "請輸入",
+ "uni-popup.title": "提示",
+ "uni-popup.shareTitle": "分享到"
+}
diff --git a/uni_modules/uni-popup/components/uni-popup/keypress.js b/uni_modules/uni-popup/components/uni-popup/keypress.js
new file mode 100644
index 0000000..62dda46
--- /dev/null
+++ b/uni_modules/uni-popup/components/uni-popup/keypress.js
@@ -0,0 +1,45 @@
+// #ifdef H5
+export default {
+ name: 'Keypress',
+ props: {
+ disable: {
+ type: Boolean,
+ default: false
+ }
+ },
+ mounted () {
+ const keyNames = {
+ esc: ['Esc', 'Escape'],
+ tab: 'Tab',
+ enter: 'Enter',
+ space: [' ', 'Spacebar'],
+ up: ['Up', 'ArrowUp'],
+ left: ['Left', 'ArrowLeft'],
+ right: ['Right', 'ArrowRight'],
+ down: ['Down', 'ArrowDown'],
+ delete: ['Backspace', 'Delete', 'Del']
+ }
+ const listener = ($event) => {
+ if (this.disable) {
+ return
+ }
+ const keyName = Object.keys(keyNames).find(key => {
+ const keyName = $event.key
+ const value = keyNames[key]
+ return value === keyName || (Array.isArray(value) && value.includes(keyName))
+ })
+ if (keyName) {
+ // 避免和其他按键事件冲突
+ setTimeout(() => {
+ this.$emit(keyName, {})
+ }, 0)
+ }
+ }
+ document.addEventListener('keyup', listener)
+ // this.$once('hook:beforeDestroy', () => {
+ // document.removeEventListener('keyup', listener)
+ // })
+ },
+ render: () => {}
+}
+// #endif
diff --git a/uni_modules/uni-popup/components/uni-popup/popup.js b/uni_modules/uni-popup/components/uni-popup/popup.js
new file mode 100644
index 0000000..c4e5781
--- /dev/null
+++ b/uni_modules/uni-popup/components/uni-popup/popup.js
@@ -0,0 +1,26 @@
+
+export default {
+ data() {
+ return {
+
+ }
+ },
+ created(){
+ this.popup = this.getParent()
+ },
+ methods:{
+ /**
+ * 获取父元素实例
+ */
+ getParent(name = 'uniPopup') {
+ let parent = this.$parent;
+ let parentName = parent.$options.name;
+ while (parentName !== name) {
+ parent = parent.$parent;
+ if (!parent) return false
+ parentName = parent.$options.name;
+ }
+ return parent;
+ },
+ }
+}
diff --git a/uni_modules/uni-popup/components/uni-popup/uni-popup.vue b/uni_modules/uni-popup/components/uni-popup/uni-popup.vue
new file mode 100644
index 0000000..94e5054
--- /dev/null
+++ b/uni_modules/uni-popup/components/uni-popup/uni-popup.vue
@@ -0,0 +1,403 @@
+
+
+
+
+
+
diff --git a/uni_modules/uni-popup/package.json b/uni_modules/uni-popup/package.json
new file mode 100644
index 0000000..90fc204
--- /dev/null
+++ b/uni_modules/uni-popup/package.json
@@ -0,0 +1,90 @@
+{
+ "id": "uni-popup",
+ "displayName": "uni-popup 弹出层",
+ "version": "1.7.2",
+ "description": " Popup 组件,提供常用的弹层",
+ "keywords": [
+ "uni-ui",
+ "弹出层",
+ "弹窗",
+ "popup",
+ "弹框"
+ ],
+ "repository": "https://github.com/dcloudio/uni-ui",
+ "engines": {
+ "HBuilderX": ""
+ },
+ "directories": {
+ "example": "../../temps/example_temps"
+ },
+ "dcloudext": {
+ "category": [
+ "前端组件",
+ "通用组件"
+ ],
+ "sale": {
+ "regular": {
+ "price": "0.00"
+ },
+ "sourcecode": {
+ "price": "0.00"
+ }
+ },
+ "contact": {
+ "qq": ""
+ },
+ "declaration": {
+ "ads": "无",
+ "data": "无",
+ "permissions": "无"
+ },
+ "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui"
+ },
+ "uni_modules": {
+ "dependencies": [
+ "uni-scss",
+ "uni-transition"
+ ],
+ "encrypt": [],
+ "platforms": {
+ "cloud": {
+ "tcb": "y",
+ "aliyun": "y"
+ },
+ "client": {
+ "App": {
+ "app-vue": "y",
+ "app-nvue": "y"
+ },
+ "H5-mobile": {
+ "Safari": "y",
+ "Android Browser": "y",
+ "微信浏览器(Android)": "y",
+ "QQ浏览器(Android)": "y"
+ },
+ "H5-pc": {
+ "Chrome": "y",
+ "IE": "y",
+ "Edge": "y",
+ "Firefox": "y",
+ "Safari": "y"
+ },
+ "小程序": {
+ "微信": "y",
+ "阿里": "y",
+ "百度": "y",
+ "字节跳动": "y",
+ "QQ": "y"
+ },
+ "快应用": {
+ "华为": "u",
+ "联盟": "u"
+ },
+ "Vue": {
+ "vue2": "y",
+ "vue3": "y"
+ }
+ }
+ }
+ }
+}
diff --git a/uni_modules/uni-popup/readme.md b/uni_modules/uni-popup/readme.md
new file mode 100644
index 0000000..fdad4b3
--- /dev/null
+++ b/uni_modules/uni-popup/readme.md
@@ -0,0 +1,17 @@
+
+
+## Popup 弹出层
+> **组件名:uni-popup**
+> 代码块: `uPopup`
+> 关联组件:`uni-transition`
+
+
+弹出层组件,在应用中弹出一个消息提示窗口、提示框等
+
+### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-popup)
+#### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839
+
+
+
+
+
diff --git a/uni_modules/uni-transition/changelog.md b/uni_modules/uni-transition/changelog.md
new file mode 100644
index 0000000..b1a824b
--- /dev/null
+++ b/uni_modules/uni-transition/changelog.md
@@ -0,0 +1,20 @@
+## 1.3.1(2021-11-23)
+- 修复 init 方法初始化问题
+## 1.3.0(2021-11-19)
+- 优化 组件UI,并提供设计资源,详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource)
+- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-transition](https://uniapp.dcloud.io/component/uniui/uni-transition)
+## 1.2.1(2021-09-27)
+- 修复 init 方法不生效的 Bug
+## 1.2.0(2021-07-30)
+- 组件兼容 vue3,如何创建 vue3 项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
+## 1.1.1(2021-05-12)
+- 新增 示例地址
+- 修复 示例项目缺少组件的 Bug
+## 1.1.0(2021-04-22)
+- 新增 通过方法自定义动画
+- 新增 custom-class 非 NVUE 平台支持自定义 class 定制样式
+- 优化 动画触发逻辑,使动画更流畅
+- 优化 支持单独的动画类型
+- 优化 文档示例
+## 1.0.2(2021-02-05)
+- 调整为 uni_modules 目录规范
diff --git a/uni_modules/uni-transition/components/uni-transition/createAnimation.js b/uni_modules/uni-transition/components/uni-transition/createAnimation.js
new file mode 100644
index 0000000..5f54365
--- /dev/null
+++ b/uni_modules/uni-transition/components/uni-transition/createAnimation.js
@@ -0,0 +1,128 @@
+// const defaultOption = {
+// duration: 300,
+// timingFunction: 'linear',
+// delay: 0,
+// transformOrigin: '50% 50% 0'
+// }
+// #ifdef APP-NVUE
+const nvueAnimation = uni.requireNativePlugin('animation')
+// #endif
+class MPAnimation {
+ constructor(options, _this) {
+ this.options = options
+ this.animation = uni.createAnimation(options)
+ this.currentStepAnimates = {}
+ this.next = 0
+ this.$ = _this
+
+ }
+
+ _nvuePushAnimates(type, args) {
+ let aniObj = this.currentStepAnimates[this.next]
+ let styles = {}
+ if (!aniObj) {
+ styles = {
+ styles: {},
+ config: {}
+ }
+ } else {
+ styles = aniObj
+ }
+ if (animateTypes1.includes(type)) {
+ if (!styles.styles.transform) {
+ styles.styles.transform = ''
+ }
+ let unit = ''
+ if(type === 'rotate'){
+ unit = 'deg'
+ }
+ styles.styles.transform += `${type}(${args+unit}) `
+ } else {
+ styles.styles[type] = `${args}`
+ }
+ this.currentStepAnimates[this.next] = styles
+ }
+ _animateRun(styles = {}, config = {}) {
+ let ref = this.$.$refs['ani'].ref
+ if (!ref) return
+ return new Promise((resolve, reject) => {
+ nvueAnimation.transition(ref, {
+ styles,
+ ...config
+ }, res => {
+ resolve()
+ })
+ })
+ }
+
+ _nvueNextAnimate(animates, step = 0, fn) {
+ let obj = animates[step]
+ if (obj) {
+ let {
+ styles,
+ config
+ } = obj
+ this._animateRun(styles, config).then(() => {
+ step += 1
+ this._nvueNextAnimate(animates, step, fn)
+ })
+ } else {
+ this.currentStepAnimates = {}
+ typeof fn === 'function' && fn()
+ this.isEnd = true
+ }
+ }
+
+ step(config = {}) {
+ // #ifndef APP-NVUE
+ this.animation.step(config)
+ // #endif
+ // #ifdef APP-NVUE
+ this.currentStepAnimates[this.next].config = Object.assign({}, this.options, config)
+ this.currentStepAnimates[this.next].styles.transformOrigin = this.currentStepAnimates[this.next].config.transformOrigin
+ this.next++
+ // #endif
+ return this
+ }
+
+ run(fn) {
+ // #ifndef APP-NVUE
+ this.$.animationData = this.animation.export()
+ this.$.timer = setTimeout(() => {
+ typeof fn === 'function' && fn()
+ }, this.$.durationTime)
+ // #endif
+ // #ifdef APP-NVUE
+ this.isEnd = false
+ let ref = this.$.$refs['ani'] && this.$.$refs['ani'].ref
+ if(!ref) return
+ this._nvueNextAnimate(this.currentStepAnimates, 0, fn)
+ this.next = 0
+ // #endif
+ }
+}
+
+
+const animateTypes1 = ['matrix', 'matrix3d', 'rotate', 'rotate3d', 'rotateX', 'rotateY', 'rotateZ', 'scale', 'scale3d',
+ 'scaleX', 'scaleY', 'scaleZ', 'skew', 'skewX', 'skewY', 'translate', 'translate3d', 'translateX', 'translateY',
+ 'translateZ'
+]
+const animateTypes2 = ['opacity', 'backgroundColor']
+const animateTypes3 = ['width', 'height', 'left', 'right', 'top', 'bottom']
+animateTypes1.concat(animateTypes2, animateTypes3).forEach(type => {
+ MPAnimation.prototype[type] = function(...args) {
+ // #ifndef APP-NVUE
+ this.animation[type](...args)
+ // #endif
+ // #ifdef APP-NVUE
+ this._nvuePushAnimates(type, args)
+ // #endif
+ return this
+ }
+})
+
+export function createAnimation(option, _this) {
+ if(!_this) return
+ clearTimeout(_this.timer)
+ return new MPAnimation(option, _this)
+}
diff --git a/uni_modules/uni-transition/components/uni-transition/uni-transition.vue b/uni_modules/uni-transition/components/uni-transition/uni-transition.vue
new file mode 100644
index 0000000..0d739bd
--- /dev/null
+++ b/uni_modules/uni-transition/components/uni-transition/uni-transition.vue
@@ -0,0 +1,277 @@
+
+
+
+
+
+
+
diff --git a/uni_modules/uni-transition/package.json b/uni_modules/uni-transition/package.json
new file mode 100644
index 0000000..d15fdf0
--- /dev/null
+++ b/uni_modules/uni-transition/package.json
@@ -0,0 +1,87 @@
+{
+ "id": "uni-transition",
+ "displayName": "uni-transition 过渡动画",
+ "version": "1.3.1",
+ "description": "元素的简单过渡动画",
+ "keywords": [
+ "uni-ui",
+ "uniui",
+ "动画",
+ "过渡",
+ "过渡动画"
+],
+ "repository": "https://github.com/dcloudio/uni-ui",
+ "engines": {
+ "HBuilderX": ""
+ },
+ "directories": {
+ "example": "../../temps/example_temps"
+ },
+ "dcloudext": {
+ "category": [
+ "前端组件",
+ "通用组件"
+ ],
+ "sale": {
+ "regular": {
+ "price": "0.00"
+ },
+ "sourcecode": {
+ "price": "0.00"
+ }
+ },
+ "contact": {
+ "qq": ""
+ },
+ "declaration": {
+ "ads": "无",
+ "data": "无",
+ "permissions": "无"
+ },
+ "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui"
+ },
+ "uni_modules": {
+ "dependencies": ["uni-scss"],
+ "encrypt": [],
+ "platforms": {
+ "cloud": {
+ "tcb": "y",
+ "aliyun": "y"
+ },
+ "client": {
+ "App": {
+ "app-vue": "y",
+ "app-nvue": "y"
+ },
+ "H5-mobile": {
+ "Safari": "y",
+ "Android Browser": "y",
+ "微信浏览器(Android)": "y",
+ "QQ浏览器(Android)": "y"
+ },
+ "H5-pc": {
+ "Chrome": "y",
+ "IE": "y",
+ "Edge": "y",
+ "Firefox": "y",
+ "Safari": "y"
+ },
+ "小程序": {
+ "微信": "y",
+ "阿里": "y",
+ "百度": "y",
+ "字节跳动": "y",
+ "QQ": "y"
+ },
+ "快应用": {
+ "华为": "u",
+ "联盟": "u"
+ },
+ "Vue": {
+ "vue2": "y",
+ "vue3": "y"
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/uni_modules/uni-transition/readme.md b/uni_modules/uni-transition/readme.md
new file mode 100644
index 0000000..2f8a77e
--- /dev/null
+++ b/uni_modules/uni-transition/readme.md
@@ -0,0 +1,11 @@
+
+
+## Transition 过渡动画
+> **组件名:uni-transition**
+> 代码块: `uTransition`
+
+
+元素过渡动画
+
+### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-transition)
+#### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839
\ No newline at end of file
diff --git a/utils/hook.js b/utils/hook.js
index cf61bb1..88cc5ef 100644
--- a/utils/hook.js
+++ b/utils/hook.js
@@ -1,4 +1,5 @@
import store from '@/store/index'
+import { uploadUrl } from '@/enums/index.js'
// 框架方法封装
const tabList = ['store', 'cart', 'mine']
@@ -23,7 +24,7 @@ export function back() {
delta: 1
})
} else {
- go2('client')
+ go2('store')
}
}
@@ -80,3 +81,52 @@ export function loginGo2(url, data = {}, isRedirect) {
go2('login')
}
}
+
+/**
+ * 退出登录并跳转到登录页面
+ * @return {null}
+ */
+export function exit() {
+ store.dispatch('logout')
+ go2('login')
+}
+
+/**
+ * 文件上传
+ * @param {array} sourceType 上传的方式 album:相册 camera:相机
+ * @return {Promise} 以数组的形式返回对应的文件地址
+ */
+export function uploadImage(sourceType = ['album', 'camera']) {
+ return new Promise((resolve, reject) => {
+ uni.chooseImage({
+ count: 1,
+ sizeType: ['original', 'compressed'],
+ sourceType: sourceType,
+ success: (res) => {
+ const tempFilePaths = res.tempFilePaths
+ uni.uploadFile({
+ url: uploadUrl.image,
+ filePath: tempFilePaths[0],
+ name: 'image',
+ fileType: 'image',
+ success: (res) => {
+ let result = JSON.parse(res.data)
+ if (result.data) {
+ resolve(result.data)
+ } else {
+ reject(result.message)
+ }
+ },
+ fail: (err) => {
+ console.error('uploadFile error:', err)
+ reject(err)
+ }
+ })
+ },
+ fail: (err) => {
+ console.error('chooseImage error:', err)
+ reject(err)
+ }
+ })
+ })
+}
diff --git a/utils/http/http.js b/utils/http/http.js
index 6146aa1..3d8600c 100644
--- a/utils/http/http.js
+++ b/utils/http/http.js
@@ -1,6 +1,7 @@
import { isFunction } from '../is.js'
-const urlEnv = process.env.NODE_ENV === 'production' ? '' : '-test'
-const uplaodUrl = `https://api-ops-yyt${urlEnv}.qniao.cn/cloud-print-user-center/utils/uploadImage`
+import env from '@/env/index.js'
+const urlEnv = env === 'production' ? '' : `-${env}`
+const uploadUrl = `https://api-ops-yyt${urlEnv}.qniao.cn/cloud-print-user-center/utils/uploadImage`
export default class Http {
constructor(
config = {},
@@ -68,14 +69,14 @@ export default class Http {
}).catch((err) => {
// 吃掉请求产生的异常
// 后期可以记录
- console.log('native response error', err)
+ console.error('native response error', err)
})
}
// config:{}
uploadFile(config, options) {
return new Promise((resolve, rejetc) => {
let conf = Object.assign({}, config)
- conf.url = uplaodUrl
+ conf.url = uploadUrl
const { reqInterceptor } = this
let opt = Object.assign({}, this.requestOption, options)
if (reqInterceptor && isFunction(reqInterceptor)) {
@@ -103,7 +104,7 @@ export default class Http {
}
})
}).catch((err) => {
- console.log('upload native err', err)
+ console.error('upload native err', err)
})
}
}
diff --git a/utils/http/index.js b/utils/http/index.js
index d861b01..533ff4f 100644
--- a/utils/http/index.js
+++ b/utils/http/index.js
@@ -1,8 +1,9 @@
import Http from './http.js'
+import env from '@/env/index.js'
// 请求封装文件
-const urlEnv = process.env.NODE_ENV === 'production' ? '' : '-test'
-const xappid = '503258978847966403'
+const urlEnv = env === 'production' ? '' : `-${env}`
+const xappid = '503258978847966404'
// 请求url列表
const prefixList = {
'/yyt-uec': `https://api-client-yyt${urlEnv}.qniao.cn`,
@@ -79,7 +80,8 @@ const resInterceptor = (response, options) => {
const res = response.data
if (statusCode >= 200 && statusCode < 300) {
if (res.code == 0) {
- return res.data
+ // 将成功的null置位1
+ return res.data || 1
} else {
uni.showToast({
title: res.message,
diff --git a/utils/index.js b/utils/index.js
new file mode 100644
index 0000000..ad47f00
--- /dev/null
+++ b/utils/index.js
@@ -0,0 +1,114 @@
+import env from '@/env/index.js'
+import store from '@/store/index.js'
+/**
+ * 日期格式化,样例 yyyy-mm-dd hh:MM:ss
+ * @param date Date 需要转换的日期
+ * @param fmt string 转化的格式 yyyy-mm-dd hh:MM:ss
+ */
+export const dateTimeFormat = (date, fmt) => {
+ if (!date) {
+ throw new Error('日期不正确')
+ }
+ let ret
+ const opt = {
+ 'y+': date.getFullYear().toString(), // 年
+ 'm+': (date.getMonth() + 1).toString(), // 月
+ 'd+': date.getDate().toString(), // 日
+ 'h+': date.getHours().toString(), // 时
+ 'M+': date.getMinutes().toString(), // 分
+ 's+': date.getSeconds().toString() // 秒
+ }
+ for (let k in opt) {
+ ret = new RegExp('(' + k + ')').exec(fmt)
+ if (ret) {
+ fmt = fmt.replace(ret[1], ret[1].length == 1 ? opt[k] : opt[k].padStart(ret[1].length, '0'))
+ }
+ }
+ return fmt
+}
+
+/**
+ * 创建websocket
+ * @param {*} data
+ * @value {string} pageInfo 页面信息
+ * @value {true} retry 是否重连,默认false
+ * @returns 一个websocket实例
+ */
+export const makeSocket = async ({ pageInfo = '', retry = false }) => {
+ const socket = {
+ sockTask: null,
+ close: function () {
+ this.sockTask.close({ code: 1000 })
+ closeFlag = true
+ },
+ onMessage: function () {}
+ }
+
+ let limitedNum = 0
+ let closeFlag = false
+ let timer = null
+
+ async function createSocket() {
+ let url = ''
+ // if (env == 'production') {
+ // url = 'wss://api-client-yyt.qniao.cn/qn-websocket-service/wechatwebsock?token='
+ // } else if (env == 'test') {
+ // url = 'wss://api-client-yyt-test.qniao.cn/qn-websocket-service/wechatwebsock?token='
+ // }
+ if (env == 'production') {
+ url = 'wss://api-client-yyt.qniao.cn/trading-center/wechatwebsock?token='
+ } else if (env == 'test') {
+ url = 'wss://api-client-yyt-test.qniao.cn/trading-center/wechatwebsock?token='
+ }
+ const token = store.state.qnToken
+ const socketTask = await uni.connectSocket({
+ url: `${url}${token}`,
+ header: {
+ 'content-type': 'application/json'
+ },
+ success: () => {
+ console.log('websocket连接成功')
+ },
+ fail: () => {
+ console.log('websocket连接失败')
+ }
+ })
+ socketTask.onOpen(() => {
+ console.log(pageInfo + ' onOpen')
+ timer = setInterval(() => {
+ socketTask.send({ data: 'ping' })
+ }, 10000)
+ })
+ socketTask.onClose(() => {
+ console.log(pageInfo + ' onClose')
+ clearInterval(timer)
+ timer = null
+ if (!closeFlag && retry && limitedNum < 20) {
+ limitedNum++
+ console.log('重连次数:' + limitedNum)
+ createSocket()
+ }
+ })
+
+ socketTask.onError(() => {
+ console.log(pageInfo + ' error')
+ })
+
+ socket.sockTask = socketTask
+ }
+
+ await createSocket()
+ if (socket) {
+ socket.onMessage = (fn) => {
+ socket.sockTask.onMessage((res) => {
+ let data = JSON.parse(res.data)
+ console.log(pageInfo + '接收到消息:', data)
+ if (data.type != 'heartbeat') {
+ fn(data)
+ }
+ })
+ }
+ }
+
+ return socket
+}
diff --git a/utils/is.js b/utils/is.js
index 0475f31..fa7bb45 100644
--- a/utils/is.js
+++ b/utils/is.js
@@ -5,5 +5,13 @@ export function is(val, type) {
}
export function isFunction(val) {
- return is(val,'Function')
-}
\ No newline at end of file
+ return is(val, 'Function')
+}
+
+export function isObject(val) {
+ return is(val, 'Object')
+}
+
+export function isArray(val) {
+ return is(val, 'Array')
+}