Browse Source

Merge branch 'devlop' of http://git.qniao.cn/qniao/paper-shopkeeper-H5 into devlop

devlop
buffeyu 4 years ago
parent
commit
015ddfbee0
39 changed files with 851 additions and 349 deletions
  1. 1
      App.vue
  2. 28
      apis/commonApi.js
  3. 14
      apis/orderApi.js
  4. 40
      apis/testApi.js
  5. 7
      components/scroll-list/scroll-list.vue
  6. 84
      enums/index.js
  7. 6
      manifest.json
  8. 24
      pages.json
  9. 37
      pages/address-manage/index.vue
  10. 31
      pages/enterprise-info/index.vue
  11. 18
      pages/error/index.vue
  12. 24
      pages/login/index.vue
  13. 450
      pages/mine/index.vue
  14. 263
      pages/order-list/index.vue
  15. 55
      pages/test/index.vue
  16. BIN
      static/imgs/mine/account-icon.png
  17. BIN
      static/imgs/mine/address-icon.png
  18. BIN
      static/imgs/mine/contract-icon.png
  19. BIN
      static/imgs/mine/credit-icon.png
  20. BIN
      static/imgs/mine/enquiry-icon.png
  21. BIN
      static/imgs/mine/finance-icon.png
  22. BIN
      static/imgs/mine/logout-icon.png
  23. BIN
      static/imgs/mine/money-icon.png
  24. BIN
      static/imgs/mine/msg-icon.png
  25. BIN
      static/imgs/mine/order-all-icon.png
  26. BIN
      static/imgs/mine/order-done-icon.png
  27. BIN
      static/imgs/mine/order-icon.png
  28. BIN
      static/imgs/mine/order-ing-icon.png
  29. BIN
      static/imgs/mine/order-ready-icon.png
  30. BIN
      static/imgs/mine/order-supplier-ready-icon.png
  31. BIN
      static/imgs/mine/setting-icon.png
  32. BIN
      static/imgs/mine/toggle-icon.png
  33. BIN
      static/imgs/mine/vip-icon.png
  34. BIN
      static/imgs/order/order-empty.png
  35. BIN
      static/imgs/order/paper-default-icon.png
  36. 21
      store/index.js
  37. 87
      utils/hook.js
  38. 6
      utils/index.js
  39. 4
      utils/is.js

1
App.vue

@ -13,7 +13,6 @@ export default {
store.commit('setSupplierId', supplierId) store.commit('setSupplierId', supplierId)
} }
} else { } else {
console.log('非分享进入', store.state.supplierId)
if (!store.state.supplierId) { if (!store.state.supplierId) {
// go2('error') // go2('error')
} }

28
apis/commonApi.js

@ -1,4 +1,5 @@
import http from '../utils/http/index.js' import http from '../utils/http/index.js'
import store from '@/store/index'
let areaCache = null let areaCache = null
/** /**
* 获取省市区街道 * 获取省市区街道
@ -21,6 +22,24 @@ export function getArea(data = {}) {
}) })
} }
// 处理store同步问题
function syncStore(res) {
if (res.enterpriseList && res.enterpriseList.length > 0) {
let companyInfo = res.enterpriseList[0]
store.commit('setCompanyInfo', {
id: companyInfo.id,
name: companyInfo.name,
fddEnterpriseStatus: companyInfo.fddEnterpriseStatus
})
store.commit('setUserInfo', {
name: companyInfo.employeeName,
userId: res.userId,
mobile: res.mobile,
avatar: null
})
}
}
let baseInfo = null let baseInfo = null
/** /**
* 获取当前账号的基础信息 * 获取当前账号的基础信息
@ -36,6 +55,7 @@ export function getBaseInfo(data = {}, refresh = false) {
http.get({ url: '/yyt-uec/get/base-info', data }, { hideLoading: true }).then((res) => { http.get({ url: '/yyt-uec/get/base-info', data }, { hideLoading: true }).then((res) => {
if (res) { if (res) {
baseInfo = res baseInfo = res
syncStore(res)
resolve(res) resolve(res)
} else { } else {
resolve(null) resolve(null)
@ -60,3 +80,11 @@ export function getVerifyUrl(data = {}) {
export function getGuaranteeContract(data = {}) { export function getGuaranteeContract(data = {}) {
return http.post({ url: '/yyt-uec/create/supplier/guarantee-contract?mallSupplierId=' + data.mallSupplierId, data }) return http.post({ url: '/yyt-uec/create/supplier/guarantee-contract?mallSupplierId=' + data.mallSupplierId, data })
} }
/**
* 获取当前账号企业的飞算额度
* @param {object} data 参数 enterpriseId
*/
export function getFsCredit(data = {}) {
return http.get({ url: '/yyt-uec/credit/get/enterprise-feisuan-credit', data })
}

14
apis/orderApi.js

@ -0,0 +1,14 @@
import http from '../utils/http/index.js'
/**
* 获取客户订单列表
* @param {object} data 获取验证码参数
* @returns {Promise<object[]>}
* swagger: http://api-ops-yyt-test.qniao.cn//base-paper-trading/swagger-ui/index.html?urls.primaryName=CustomerApi#/%E5%8E%9F%E7%BA%B8%E8%AE%A2%E5%8D%95/getCustomerOrderListPageUsingGET
*/
export const getOrderList = (data) => {
return http.get({
url: '/base-paper-trading/get/customer/order/list/page',
data
})
}

40
apis/testApi.js

@ -0,0 +1,40 @@
import http from '../utils/http/index.js'
/**
* 获取店铺纸品列表
* @param {object} data 参数
* @returns {Promise<object[]>}
* swagger: http://api-ops-yyt-test.qniao.cn//base-paper-trading/swagger-ui/index.html?urls.primaryName=CustomerApi#/%E5%95%86%E5%93%81%E7%AE%A1%E7%90%86/getStoreProductListForCustomerUsingGET
*/
export const getPaperList = (data = {}) => {
return http.get({
url: '/base-paper-trading/get/store/product-list/for/customer',
data
})
}
/**
* 获取店铺纸品详情
* @param {object} data 参数
* @returns {Promise<object[]>}
* swagger: http://api-ops-yyt-test.qniao.cn//base-paper-trading/swagger-ui/index.html?urls.primaryName=CustomerApi#/%E5%95%86%E5%93%81%E7%AE%A1%E7%90%86/getProductDetailForCustomerUsingGET
*/
export const getPaperDetail = (data = {}) => {
return http.get({
url: '/base-paper-trading/get/product-detail/for/customer',
data
})
}
/**
* 立即订购
* @param {object} data 参数
* @returns {Promise<object[]>}
* swagger: http://api-ops-yyt-test.qniao.cn//base-paper-trading/swagger-ui/index.html?urls.primaryName=CustomerApi#/%E5%8E%9F%E7%BA%B8%E8%AE%A2%E5%8D%95/buyerPaperGoodsReserveUsingPOST
*/
export const purchasePaper = (data = {}) => {
return http.post({
url: '/base-paper-trading/buyer/paper/goods/reserve',
data
})
}

7
components/scroll-list/scroll-list.vue

@ -580,7 +580,7 @@ export default {
.scroll-content { .scroll-content {
height: 100%; height: 100%;
display: flex; display: flex;
will-change: transform;
// will-change: transform;
flex-direction: column; flex-direction: column;
.pull-down-wrap { .pull-down-wrap {
left: 0; left: 0;
@ -627,10 +627,11 @@ export default {
margin: auto; margin: auto;
display: flex; display: flex;
align-items: center; align-items: center;
margin-bottom: 400rpx;
flex-direction: column; flex-direction: column;
.empty-image { .empty-image {
width: 200rpx;
height: 200rpx;
width: 600rpx;
height: 600rpx;
} }
.empty-text { .empty-text {
color: #606266; color: #606266;

84
enums/index.js

@ -107,3 +107,87 @@ export const fsAuditStatus = {
PASS: 2, PASS: 2,
REJECT: 3 REJECT: 3
} }
/**
* 客户订单状态 0: 全部 ; 30100: 待确认 ; 30204: 待供应商确认 ; 30101: 已下单 ; 30104: 已完成 ; 30105: 已取消
*/
export const orderStatusEnum = {
ALL: 0,
WAIT_CONFIRM: 30100,
WAIT_SUPPLIER_CONFIRM: 30204,
ORDERED: 30101,
FINISHED: 30104,
CANCELED: 30105
}
/**
* 客户订单状态 0: 全部 ; 30100: 待确认 ; 30204: 待供应商确认 ; 30101: 已下单 ; 30104: 已完成 ;
*/
export const orderStatusArray = [
{
value: orderStatusEnum.ALL,
label: '全部'
},
{
value: orderStatusEnum.WAIT_CONFIRM,
label: '待确认'
},
{
value: orderStatusEnum.WAIT_SUPPLIER_CONFIRM,
label: '待供应商确认'
},
{
value: orderStatusEnum.ORDERED,
label: '已下单'
},
{
value: orderStatusEnum.FINISHED,
label: '已完成'
},
{
value: orderStatusEnum.CANCELED,
label: '已取消'
}
]
export const orderStatusMap = {
[orderStatusEnum.ALL]: '全部',
[orderStatusEnum.WAIT_CONFIRM]: '待确认',
[orderStatusEnum.WAIT_SUPPLIER_CONFIRM]: '待供应商确认',
[orderStatusEnum.ORDERED]: '已下单',
[orderStatusEnum.FINISHED]: '已完成',
[orderStatusEnum.CANCELED]: '已取消'
}
/**
* 供应商订单状态 待客户确认订单/30202,待供应商确认订单/30205,待发货/30106,已发货/30107 已发货在H5客户端显示 待收货/30107 ,待客户借款/30207,支付中/30208,待客户支付/30214,付款失败/30211,已完成/30213,待客户还款/30217,已取消/30212,还款中/30216
*/
export const supplierOrderStatusEnum = {
WAIT_CLIENT_CONFIRM: 30202,
WAIT_SUPPLIER_CONFIRM: 30205,
WAIT_DELIVERY: 30106,
WAIT_RECEIVE: 30107,
WAIT_CLIENT_LOAN: 30207,
PAYING: 30208,
WAIT_CLIENT_PAY: 30214,
PAY_FAIL: 30211,
FINISHED: 30213,
WAIT_CLIENT_REPAY: 30217,
REPAYING: 30216,
CANCELED: 30212
}
export const supplierOrderStatusMap = {
[supplierOrderStatusEnum.WAIT_CLIENT_CONFIRM]: '待客户确认',
[supplierOrderStatusEnum.WAIT_SUPPLIER_CONFIRM]: '待供应商确认',
[supplierOrderStatusEnum.WAIT_DELIVERY]: '待发货',
[supplierOrderStatusEnum.WAIT_RECEIVE]: '待收货',
[supplierOrderStatusEnum.WAIT_CLIENT_LOAN]: '待客户借款',
[supplierOrderStatusEnum.PAYING]: '支付中',
[supplierOrderStatusEnum.WAIT_CLIENT_PAY]: '待客户支付',
[supplierOrderStatusEnum.PAY_FAIL]: '付款失败',
[supplierOrderStatusEnum.FINISHED]: '已完成',
[supplierOrderStatusEnum.WAIT_CLIENT_REPAY]: '待客户还款',
[supplierOrderStatusEnum.REPAYING]: '还款中',
[supplierOrderStatusEnum.CANCELED]: '已取消'
}

6
manifest.json

@ -1,6 +1,6 @@
{ {
"name" : "uniapp-demo",
"appid" : "",
"name" : "纸掌柜",
"appid" : "__UNI__34A22DC",
"description" : "", "description" : "",
"versionName" : "1.0.0", "versionName" : "1.0.0",
"versionCode" : "100", "versionCode" : "100",
@ -85,7 +85,7 @@
"vueVersion" : "2", "vueVersion" : "2",
"h5" : { "h5" : {
"router" : { "router" : {
"mode" : "history"
"mode" : "hash"
} }
} }
} }

24
pages.json

@ -51,6 +51,14 @@
"navigationStyle": "custom" "navigationStyle": "custom"
} }
}, },
{
"path": "pages/address-manage/index",
"style": {
"navigationBarTitleText": "收货地址",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
},
{ {
"path": "pages/error/index", "path": "pages/error/index",
"style": { "style": {
@ -66,6 +74,22 @@
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
} }
{
"path": "pages/order-list/index",
"style": {
"navigationBarTitleText": "订单列表",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
},
{
"path": "pages/test/index",
"style": {
"navigationBarTitleText": "测试页面",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
}
], ],
"globalStyle": { "globalStyle": {
"navigationBarTextStyle": "black", "navigationBarTextStyle": "black",

37
pages/address-manage/index.vue

@ -0,0 +1,37 @@
<template>
<view>
<uni-nav-bar left-icon="back" @clickLeft="back" statusBar fixed title="收货地址"></uni-nav-bar>
</view>
</template>
<script>
import { go2, back, setCache } from '@/utils/hook.js'
export default {
data() {
return {
/**
* 页面操作类型 none: 无操作, select: 选择
*/
operation: 'none'
}
},
methods: {
go2,
back,
//
selectAddress(item) {
if (this.operation === 'select') {
setCache('address', item)
back()
}
}
},
onLoad(option) {
if (option) {
this.operation = option.operation
}
}
}
</script>
<style lang="scss" scoped></style>

31
pages/enterprise-info/index.vue

@ -1,6 +1,8 @@
<template> <template>
<view class="content"> <view class="content">
<uni-nav-bar left-icon="back" @clickLeft="back" statusBar fixed title="完善信息"></uni-nav-bar>
<uni-nav-bar left-icon="back" @clickLeft="back" statusBar fixed title="完善信息">
<text @click="jump" v-if="operation === 'add'" style="color: #007aff" slot="right">跳过</text>
</uni-nav-bar>
<view> <view>
<qn-form-item label="基础信息" type="title"></qn-form-item> <qn-form-item label="基础信息" type="title"></qn-form-item>
<qn-form-item label="企业名称" required> <qn-form-item label="企业名称" required>
@ -120,7 +122,7 @@
<text <text
v-if="form.businessLicenseImg" v-if="form.businessLicenseImg"
@click="!hasSelected && selectedImage('businessLicenseImg')" @click="!hasSelected && selectedImage('businessLicenseImg')"
:style="`font-size: 28rpx;margin-right: 16rpx; color: ${hasSelected ? '#eee' : '#007aff'}`"
:style="`font-size: 28rpx;margin-right: 16rpx; color: ${hasSelected ? '#eee' : '#F5222D'}`"
> >
重新上传 重新上传
</text> </text>
@ -171,7 +173,7 @@
</uni-popup> </uni-popup>
<qn-footer fixed height="120rpx"> <qn-footer fixed height="120rpx">
<view class="button-area"> <view class="button-area">
<view class="button button__cancel" @click="back">
<view class="button button__cancel" @click="cancel">
<text class="text">取消</text> <text class="text">取消</text>
</view> </view>
<view class="button button__submit" @click="saveInfo"> <view class="button button__submit" @click="saveInfo">
@ -209,6 +211,7 @@ const validateFields = [
export default { export default {
data() { data() {
return { return {
operation: 'add',
form: { form: {
id: null, id: null,
name: null, name: null,
@ -250,6 +253,17 @@ export default {
}, },
methods: { methods: {
back, back,
jump() {
go2('store')
},
cancel() {
//
if (this.operation === 'add') {
go2('store', {}, true)
} else {
back()
}
},
showLocationList() { showLocationList() {
if (!this.form.name || !this.form.name.trim()) { if (!this.form.name || !this.form.name.trim()) {
uni.showToast({ uni.showToast({
@ -345,9 +359,9 @@ export default {
}, },
selectedImage(type) { selectedImage(type) {
uploadImage() uploadImage()
.then((url) => {
if (url) {
this.form[type] = url
.then((urls) => {
if (urls) {
this.form[type] = urls[0]
} }
}) })
.catch((e) => { .catch((e) => {
@ -423,6 +437,11 @@ export default {
} }
return this.form.legalPersonIdCardBackImg return this.form.legalPersonIdCardBackImg
} }
},
onLoad(option) {
if (option) {
this.operation = option.operation
}
} }
} }
</script> </script>

18
pages/error/index.vue

@ -1,5 +1,11 @@
<template> <template>
<view>error</view>
<view>
<uni-nav-bar left-icon="back" @clickLeft="back" statusBar fixed title="未授权页面"></uni-nav-bar>
<view class="container">
<image style="width: 560rpx; height: 320rpx; margin-bottom: 50rpx" src="https://qncloud.oss-cn-shenzhen.aliyuncs.com/paper_shopkeeper/error.png"></image>
<text style="font-size: 32px; color: #333333">请联系纸盘商获取正确地址</text>
</view>
</view>
</template> </template>
<script> <script>
@ -15,4 +21,12 @@ export default {
} }
</script> </script>
<style lang="scss" scoped></style>
<style lang="scss" scoped>
.container {
display: flex;
justify-content: center;
align-items: center;
width: 750rpx;
margin-top: 240rpx;
}
</style>

24
pages/login/index.vue

@ -139,12 +139,12 @@ export default {
store.commit('setToken', token) store.commit('setToken', token)
// //
const nextPage = store.state.nextPage const nextPage = store.state.nextPage
let page = null
if (nextPage.name) { if (nextPage.name) {
go2(nextPage.name, nextPage.data, true)
} else {
//
this.setAccountInfo()
page = { url: nextPage.name, data: nextPage.data, isRedirect: true }
} }
//
this.setAccountInfo(page)
store.commit('removeNextPage') store.commit('removeNextPage')
}, 1000) }, 1000)
} }
@ -154,25 +154,13 @@ export default {
} }
}) })
}, },
setAccountInfo() {
setAccountInfo(page = { url: 'store', data: {}, isRedirect: true }) {
getBaseInfo({}, true).then((res) => { getBaseInfo({}, true).then((res) => {
if (res) { if (res) {
if (!res.enterpriseList || res.enterpriseList.length === 0) { if (!res.enterpriseList || res.enterpriseList.length === 0) {
go2('enterprise-info', { operation: 'add' }, true) go2('enterprise-info', { operation: 'add' }, true)
} else { } else {
let companyInfo = res.enterpriseList[0]
store.commit('setCompanyInfo', {
id: companyInfo.id,
name: companyInfo.name,
fddEnterpriseStatus: companyInfo.fddEnterpriseStatus
})
store.commit('setUserInfo', {
name: companyInfo.employeeName,
userId: res.userId,
mobile: res.mobile,
avatar: null
})
go2('store')
go2(page.url, page.data, page.isRedirect)
} }
} }
}) })

450
pages/mine/index.vue

@ -17,7 +17,7 @@
<view v-else> <view v-else>
<view class="user__name"> <view class="user__name">
<text class="name">{{ userInfo.name }}</text> <text class="name">{{ userInfo.name }}</text>
<image v-if="userInfo.fddEnterpriseStatus === fddStatus.UNCERTIFIED" class="image" src="/static/imgs/mine/certified-icon.png"></image>
<image v-if="userInfo.fddEnterpriseStatus === fddStatus.CERTIFIED_SUCCESS" class="image" src="/static/imgs/mine/certified-icon.png"></image>
<image v-else class="image" @click="certifyCompany()" src="/static/imgs/mine/non-certified-icon.png"></image> <image v-else class="image" @click="certifyCompany()" src="/static/imgs/mine/non-certified-icon.png"></image>
</view> </view>
<view style="margin-top: 10rpx"> <view style="margin-top: 10rpx">
@ -27,168 +27,114 @@
</view> </view>
</view> </view>
</view> </view>
<view class="operation">
<view class="box">
<view class="container" @click="go2('message')">
<image class="icon" src="/static/imgs/mine/msg-icon.png"></image>
<view v-if="messageNum > 0" class="number">
<text class="text">{{ messageNum }}</text>
</view>
</view>
<image class="icon" @click="go2('setting')" src="/static/imgs/mine/setting-icon.png"></image>
</view>
<view v-if="companyNum > 1" class="box" @click="go2('toggle-supplier')">
<text style="font-size: 24rpx; color: #fff; flex-shrink: 0">切换账号</text>
<image class="icon" style="width: 24rpx; height: 24rpx; margin-left: 8rpx" src="/static/imgs/mine/toggle-icon.png"></image>
</view>
</view>
</view>
<view class="vip-area">
<view class="vip-content">
<view class="left">
<image class="icon" src="/static/imgs/mine/vip-icon.png"></image>
<text class="text">VIP会员</text>
</view>
<text class="center">立即开通会员 尊享特权</text>
<view class="right">
<text class="text">开通会员</text>
</view>
<view class="logout" @click="logout">
<text class="text">退出登录</text>
<image class="icon" src="/static/imgs/mine/logout-icon.png"></image>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
<view class="card-area">
<view class="card-area" style="margin-top: -94rpx; z-index: 10">
<view class="header"> <view class="header">
<view class="item" style="justify-content: flex-start">
<image class="icon" style="width: 32rpx; height: 32rpx" src="/static/imgs/mine/money-icon.png"></image>
<text class="text">掌柜收入</text>
</view>
<view class="item" style="justify-content: flex-end">
<qn-data-picker
v-model="tradeDate"
text="right"
:border="false"
placeholder="交易区间"
popup-title="请选择时间"
:localdata="tradeRange"
:clear-icon="false"
v-slot:default="{ data }"
>
<view class="time-range">
<text style="font-size: 24rpx; color: rgba(0, 0, 0, 0.65); margin-right: 8rpx">
{{ data[0] ? data[0].value : '' }}
</text>
<text style="font-size: 24rpx; color: #333333; font-weight: 500; margin-right: 8rpx">
{{ data[0] ? data[0].text : '' }}
</text>
<uni-icons type="bottom" size="14" color="rgba(0,0,0,0.65)"></uni-icons>
</view>
</qn-data-picker>
<text style="font-size: 30rpx; color: rgba(0, 0, 0, 0.85); font-weight: 600">我的订单</text>
<view class="item" @click="loginGo2('order-list', { status: orderStatusEnum.ALL })">
<text style="font-size: 26rpx; color: #000000">查看更多订单</text>
<uni-icons style="margin-left: 16rpx" type="right" size="10"></uni-icons>
</view> </view>
</view> </view>
<view class="order-area"> <view class="order-area">
<view class="order-item">
<text class="value">{{ tradeData.tradingVolume }}</text>
<text class="label">交易额()</text>
<view class="icon-item" @click="loginGo2('order-list', { status: orderStatusEnum.ALL })">
<image class="icon" src="/static/imgs/mine/order-all-icon.png"></image>
<text class="label">全部订单</text>
</view>
<view class="icon-item" @click="loginGo2('order-list', { status: orderStatusEnum.WAIT_CONFIRM })">
<image class="icon" src="/static/imgs/mine/order-ready-icon.png"></image>
<text class="label">待确认</text>
</view>
<view class="icon-item" @click="loginGo2('order-list', { status: orderStatusEnum.WAIT_SUPPLIER_CONFIRM })">
<image class="icon" src="/static/imgs/mine/order-supplier-ready-icon.png"></image>
<text class="label">待供应商确认</text>
</view> </view>
<view class="order-item">
<text class="value">{{ tradeData.volumeOfBusiness }}</text>
<text class="label">交易量()</text>
<view class="icon-item" @click="loginGo2('order-list', { status: orderStatusEnum.ORDERED })">
<image class="icon" src="/static/imgs/mine/order-ing-icon.png"></image>
<text class="label">已下单</text>
</view> </view>
<view class="order-item">
<text class="value">{{ tradeData.orderQuantity }}</text>
<text class="label">成交订单()</text>
<view class="icon-item" @click="loginGo2('order-list', { status: orderStatusEnum.FINISHED })">
<image class="icon" src="/static/imgs/mine/order-done-icon.png"></image>
<text class="label">已完成</text>
</view>
</view>
</view>
<view class="card-area" v-if="fsInfo.status !== -1" style="border-radius: 16rpx">
<image
class="poster"
v-if="fsInfo.status == fsAuditStatus.WAIT_APPLY || fsInfo.status == fsAuditStatus.REJECT"
src="https://qncloud.oss-cn-shenzhen.aliyuncs.com/paper_shopkeeper/fs-to-apply.png"
></image>
<image
class="poster"
v-if="fsInfo.status == fsAuditStatus.AUDITING"
src="https://qncloud.oss-cn-shenzhen.aliyuncs.com/paper_shopkeeper/fs-to-apply.png"
></image>
<view class="fs-card" v-if="fsInfo.status == fsAuditStatus.PASS">
<view class="left">
<text style="font-size: 30rpx; color: rgba(0, 0, 0, 0.85); font-weight: 600">可用采购额度</text>
<!-- 下面这行不要换行 -->
<!-- prettier-ignore -->
<view style="margin:24rpx 0 16rpx;"><text class="pre"></text><text class="next">{{fsInfo.availableCreditLine}}</text></view>
<text style="font-size: 24rpx; color: rgba(0, 0, 0, 0.75)">{{ `已使用: ¥ ${fsInfo.usedCreditLine}` }}</text>
</view>
<view class="right">
<text>{{ `授信额度: ${fsInfo.creditLine / 10000}` }}</text>
<uni-icons style="margin-left: 16rpx" type="right" size="10"></uni-icons>
</view> </view>
</view> </view>
</view> </view>
<view class="card-area"> <view class="card-area">
<view class="header"> <view class="header">
<text style="font-size: 30rpx; color: rgba(0, 0, 0, 0.85); font-weight: 500">其他工具</text>
<text style="font-size: 30rpx; color: rgba(0, 0, 0, 0.85); font-weight: 600">其他工具</text>
</view> </view>
<view class="icon-area"> <view class="icon-area">
<view class="icon-item">
<image class="icon" src="/static/imgs/mine/order-icon.png"></image>
<text class="label">订单管理</text>
</view>
<view class="icon-item">
<image class="icon" src="/static/imgs/mine/finance-icon.png"></image>
<text class="label">账期订单融资</text>
<view class="icon-item" style="margin-right: 64rpx">
<image class="icon" src="/static/imgs/mine/account-icon.png"></image>
<text class="label">账号管理</text>
</view> </view>
<view class="icon-item">
<image class="icon" src="/static/imgs/mine/contract-icon.png"></image>
<text class="label">合同管理</text>
<view class="icon-item" style="margin-right: 64rpx">
<image class="icon" src="/static/imgs/mine/enquiry-icon.png"></image>
<text class="label">我的询价</text>
</view> </view>
<view class="icon-item">
<image class="icon" src="/static/imgs/mine/credit-icon.png"></image>
<text class="label">征信管理</text>
<view class="icon-item" style="margin-right: 64rpx">
<image class="icon" src="/static/imgs/mine/address-icon.png"></image>
<text class="label">收货地址</text>
</view> </view>
<view class="icon-item" @click="go2('client-credit-list')">
<image class="icon" src="/static/imgs/mine/credit-icon.png"></image>
<text class="label">授信记录</text>
</view>
<!-- <view class="icon-item">
<image class="icon" src="/static/imgs/mine/contract-icon.png"></image>
<text class="label">服务区域</text>
</view> -->
</view> </view>
</view> </view>
<view @click="logout">mine</view>
<view @click="go2('client-credit')">client-credit</view>
<view @click="go2('enterprise-info')">enterprise-info</view>
<view @click="loginGo2('test')">test</view>
<view @click="loginGo2('enterprise-info')">enterprise-info</view>
</view> </view>
</template> </template>
<script> <script>
import { exit, go2 } from '@/utils/hook.js'
import { fddEnterpriseStatus } from '@/enums/index.js'
import { getBaseInfo } from '@/apis/commonApi.js'
import qnDataPicker from '@/components/qn-data-picker/qn-data-picker.vue'
import { dateTimeFormat } from '@/utils/index.js'
import { getOrderStatistics } from '@/apis/mineApi.js'
//
const currentMonth = (() => {
let endDate = new Date()
let beginDate = new Date(endDate.getFullYear(), endDate.getMonth(), 1)
return [dateTimeFormat(beginDate, 'yyyy-mm-dd'), dateTimeFormat(endDate, 'yyyy-mm-dd')]
})()
import { exit, go2, loginGo2 } from '@/utils/hook.js'
import { fddEnterpriseStatus, fsAuditStatus, orderStatusEnum } from '@/enums/index.js'
import { getVerifyUrl, getFsCredit } from '@/apis/commonApi.js'
//
const lastMonth = (() => {
let now = new Date()
let endDate = new Date(now.getFullYear(), now.getMonth(), 0)
let beginDate = new Date(now.getFullYear(), now.getMonth() - 1, 1)
return [dateTimeFormat(beginDate, 'yyyy-mm-dd'), dateTimeFormat(endDate, 'yyyy-mm-dd')]
})()
export default { export default {
components: { qnDataPicker },
data() { data() {
return { return {
fddStatus: Object.freeze(fddEnterpriseStatus), fddStatus: Object.freeze(fddEnterpriseStatus),
messageNum: 0,
companyNum: 0,
tradeRange: [
{
text: '本月',
value: currentMonth.join('~')
},
{
text: '上月',
value: lastMonth.join('~')
},
{
text: '总计',
value: ''
}
],
tradeDate: currentMonth.join('~'),
tradeData: {
tradingVolume: 0,
volumeOfBusiness: 0,
orderQuantity: 0
}
fsInfo: {
status: -1, //
availableCreditLine: 0,
usedCreditLine: 0,
creditLine: 0
},
fsAuditStatus: Object.freeze(fsAuditStatus),
orderStatusEnum: Object.freeze(orderStatusEnum)
} }
}, },
methods: { methods: {
loginGo2,
logout() { logout() {
exit() exit()
}, },
@ -216,30 +162,11 @@ export default {
}) })
} }
}, },
go2,
go2
// //
getStatistics() {}
},
watch: {
tradeDate(val) {
console.log('val:', val)
},
'$store.state.supplierInfo.supplierId': {
handler(val) {
console.log('切换了供应商:', val)
if (val) {
this.getStatistics()
}
},
immediate: true
},
tradeDate() {
this.getStatistics()
}
}, },
computed: { computed: {
hasLogin() { hasLogin() {
console.log('token:', this.$store.state.qnToken)
return this.$store.state.qnToken != '' return this.$store.state.qnToken != ''
}, },
curAvatar() { curAvatar() {
@ -253,6 +180,8 @@ export default {
} }
}, },
userInfo() { userInfo() {
console.log('userInfo:', this.$store.state.userInfo)
console.log('companyInfo:', this.$store.state.companyInfo)
return { return {
avatar: this.$store.state.userInfo.avatar || '', avatar: this.$store.state.userInfo.avatar || '',
name: this.$store.state.userInfo.name || this.$store.state.userInfo.mobile || '', name: this.$store.state.userInfo.name || this.$store.state.userInfo.mobile || '',
@ -262,14 +191,14 @@ export default {
} }
}, },
onShow() { onShow() {
getBaseInfo().then((res) => {
if (res) {
this.companyNum = res.enterpriseList.length
}
})
},
created() {
this.getStatistics()
this.hasLogin &&
getFsCredit({
enterpriseId: this.$store.state.companyInfo.id
}).then((res) => {
if (res.status) {
this.fsInfo = res
}
})
} }
} }
</script> </script>
@ -310,7 +239,7 @@ export default {
padding: 0 32rpx; padding: 0 32rpx;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: flex-start;
align-items: center;
justify-content: space-between; justify-content: space-between;
.user { .user {
z-index: 5; z-index: 5;
@ -335,7 +264,7 @@ export default {
align-items: center; align-items: center;
justify-content: flex-start; justify-content: flex-start;
.name { .name {
font-size: 40rpx;
font-size: 38rpx;
color: #fff; color: #fff;
font-weight: 600; font-weight: 600;
margin-right: 16rpx; margin-right: 16rpx;
@ -349,106 +278,24 @@ export default {
} }
} }
} }
.operation {
.logout {
z-index: 5; z-index: 5;
margin-top: 18rpx;
margin-left: 20rpx;
flex-grow: 0;
flex-shrink: 0;
.box {
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-end;
margin-bottom: 36rpx;
.container {
width: 40rpx;
height: 40rpx;
flex-grow: 0;
flex-shrink: 0;
margin-right: 26rpx;
position: relative;
.number {
position: absolute;
top: -12rpx;
right: -12rpx;
// width:32rpx;
// height: 32rpx;
padding: 6rpx 10rpx;
background-color: #f5222d;
border-radius: 16rpx;
display: flex;
align-items: center;
justify-content: center;
.text {
font-size: 20rpx;
color: #fff;
font-weight: 500;
}
}
}
.icon {
width: 40rpx;
height: 40rpx;
flex-grow: 0;
flex-shrink: 0;
}
}
}
}
.vip-area {
z-index: 5;
position: absolute;
bottom: 0;
left: 0;
width: 686rpx;
height: 90rpx;
margin: 0 32rpx;
background-image: linear-gradient(90deg, #333333 0%, #696c6b 99%);
border-radius: 10rpx;
.vip-content {
width: 686rpx;
padding: 18rpx 24rpx 0;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
justify-content: space-between;
.left {
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-start;
.icon {
width: 28rpx;
height: 28rpx;
flex-grow: 0;
flex-shrink: 0;
}
.text {
font-size: 26rpx;
color: #dbc189;
font-weight: 500;
}
}
.center {
justify-content: flex-end;
flex-grow: 0;
flex-shrink: 0;
.text {
font-size: 24rpx; font-size: 24rpx;
color: #e7e1be;
font-weight: 600;
color: #ffffff;
} }
.right {
position: relative;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
width: 128rpx;
height: 44rpx;
border-radius: 14rpx;
background-image: linear-gradient(90deg, #f4edce 1%, #f3d99e 98%);
.text {
font-size: 24rpx;
color: #443015;
}
.icon {
margin-left: 8rpx;
width: 24rpx;
height: 24rpx;
flex-grow: 0;
flex-shrink: 0;
} }
} }
} }
@ -458,7 +305,7 @@ export default {
margin: 20rpx 32rpx 0; margin: 20rpx 32rpx 0;
background-color: #fff; background-color: #fff;
box-shadow: 0 2rpx 14rpx 0 rgba(220, 220, 220, 0.5); box-shadow: 0 2rpx 14rpx 0 rgba(220, 220, 220, 0.5);
border-radius: 10px;
border-radius: 10rpx;
.header { .header {
padding: 20rpx 24rpx 14rpx; padding: 20rpx 24rpx 14rpx;
border-bottom: 2rpx solid #f8f8f8; border-bottom: 2rpx solid #f8f8f8;
@ -479,65 +326,82 @@ export default {
font-size: 30rpx; font-size: 30rpx;
color: rgba(0, 0, 0, 0.85); color: rgba(0, 0, 0, 0.85);
letter-spacing: 1.5rpx; letter-spacing: 1.5rpx;
font-weight: 500;
font-weight: 600;
} }
} }
} }
} }
.order-area { .order-area {
padding: 20rpx 20rpx 30rpx;
padding: 40rpx 32rpx;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
.order-item {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.value {
font-size: 36rpx;
color: rgba(0, 0, 0, 0.85);
font-weight: 500;
}
.label {
font-size: 26rpx;
color: #666666;
margin-top: 10rpx;
}
}
flex-wrap: nowrap;
} }
.icon-area { .icon-area {
padding: 40rpx 32rpx; padding: 40rpx 32rpx;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
justify-content: space-between;
justify-content: flex-start;
flex-wrap: wrap; flex-wrap: wrap;
.icon-item {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-width: 140rpx;
margin-bottom: 36rpx;
.icon {
width: 68rpx;
height: 68rpx;
flex-grow: 0;
flex-shrink: 0;
}
.label {
font-size: 26rpx;
color: #666666;
margin-top: 10rpx;
}
}
.icon-item {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
margin-bottom: 36rpx;
.icon {
width: 68rpx;
height: 68rpx;
flex-grow: 0;
flex-shrink: 0;
}
.label {
font-size: 26rpx;
color: #666666;
margin-top: 10rpx;
} }
} }
.time-range {
.poster {
width: 686rpx;
height: 140rpx;
}
.fs-card {
width: 686rpx;
padding: 24rpx 32rpx 32rpx;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
justify-content: flex-end;
justify-content: space-between;
flex-wrap: nowrap;
.left {
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: flex-start;
.pre {
font-size: 36rpx;
color: rgba(0, 0, 0, 0.85);
font-weight: 500;
}
.next {
font-size: 56rpx;
color: rgba(0, 0, 0, 0.85);
font-weight: 700;
}
}
.right {
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-end;
font-size: 32rpx;
color: #333333;
font-weight: 500;
}
} }
</style> </style>

263
pages/order-list/index.vue

@ -0,0 +1,263 @@
<template>
<view class="content">
<uni-nav-bar left-icon="back" @clickLeft="back" statusBar fixed title="订单列表"></uni-nav-bar>
<view class="status-bar">
<view
v-for="item in statusBarArray"
:key="item.value"
:class="{ box: true, 'box--selected': condition.status == item.value }"
@click="selectStatus(item.value)"
>
{{ item.label }}
</view>
</view>
<view class="list-area">
<scroll-list ref="list" :option="option" @load="upCallback" @refresh="downCallback">
<view v-for="item in list" :key="item.orderId" class="order-area">
<view class="order-header">
<view class="left">
<text style="font-size: 30rpx; color: #000000; font-weight: 600">{{ item.orderId }}</text>
<text style="font-size: 26rpx; color: #888888; margin-top: 16rpx">{{ dateTimeFormat(item.createTime, 'yyyy/mm/dd') }}</text>
</view>
<view class="right">
<text style="font-size: 30rpx; color: #ff5368; font-weight: 500">{{ orderStatusMap[item.status] }}</text>
</view>
</view>
<view class="order-content" v-for="order in item.supplierOrderList" :key="order.supplierOrderId">
<view class="header">
<text style="font-size: 30rpx; color: #000000">{{ order.supplierEnterpriseName }}</text>
<text style="font-size: 30rpx; color: #888888; font-weight: 500">{{ supplierOrderStatusMap[order.status] }}</text>
</view>
<view v-for="(target, index) in order.orderItems" :key="target.productId" :class="{ 'order-item': true, border: index > 0 }">
<image class="img" :src="target.productImg || '/static/imgs/order/paper-default-icon.png'"></image>
<view class="right">
<text style="font-size: 30rpx; color: #000000">{{ target.productName }}</text>
<text style="font-size: 26rpx; color: #888888; margin-top: 26rpx; word-break: break-all">{{ transformTarget(target) }}</text>
</view>
</view>
</view>
<view class="order-footer">
<view class="left">
<text style="font-size: 26rpx; color: #888888; margin-right: 8rpx">交货时间:</text>
<text style="font-size: 26rpx; color: #333333">{{ item.deliveryLeadtime || '-' }}</text>
</view>
<view class="right">
<text style="font-size: 30rpx; color: #ff5368"> {{ item.totalOfferPrice }}</text>
</view>
</view>
</view>
</scroll-list>
</view>
</view>
</template>
<script>
import { go2, back } from '@/utils/hook.js'
import { dateTimeFormat } from '@/utils/index.js'
import { orderStatusArray, orderStatusEnum, orderStatusMap, supplierOrderStatusMap } from '@/enums/index.js'
import { getOrderList } from '@/apis/orderApi.js'
export default {
data() {
return {
condition: {
status: orderStatusEnum.ALL,
pageNum: 0, //
pageSize: 10
},
option: {
size: 10,
auto: true,
emptyText: '暂无订单~',
background: '#F7F8FA',
emptyImage: '/static/imgs/order/order-empty.png'
},
list: [],
statusBarArray: Object.freeze(orderStatusArray.filter((item) => item.value !== orderStatusEnum.CANCELED)),
orderStatusMap: Object.freeze(orderStatusMap),
supplierOrderStatusMap: Object.freeze(supplierOrderStatusMap)
}
},
methods: {
go2,
back,
dateTimeFormat,
getList() {
return new Promise((resolve, reject) => {
getOrderList({ ...this.condition })
.then((res) => {
if (res) {
if (this.condition.pageNum == 1) {
this.list = res.records
} else {
this.list = this.list.concat(res.records)
}
resolve({ list: this.list, total: res.total })
} else {
reject()
}
})
.catch((err) => {
reject(err)
})
})
},
downCallback() {
this.condition.pageNum = 1
this.getList()
.then(({ list, total }) => {
this.$refs.list.refreshSuccess({ list, total })
})
.catch(() => {
this.$refs.list.refreshFail()
})
},
upCallback(page) {
this.condition.pageNum++
this.getList()
.then(({ list, total }) => {
this.$refs.list.loadSuccess({ list, total })
})
.catch(() => {
this.$refs.list.loadFail()
})
},
selectStatus(status) {
this.condition.status = status
this.downCallback()
},
transformTarget(target) {
let result = ''
if (target.categoryName) {
result += `${target.categoryName}`
}
if (target.brandName) {
result += `/${target.brandName}`
}
if (target.gramWeight) {
result += `/${target.gramWeight}g`
}
if (target.length && target.width) {
result += `/${target.width}*${target.length}`
}
if (target.pieceQuantity) {
result += `/${target.pieceQuantity}`
}
return result
}
},
onLoad(option) {
if (option.status) {
this.condition.status = option.status
}
}
}
</script>
<style lang="scss" scoped>
.content {
display: flex;
flex-direction: column;
flex: 1;
height: 100vh;
.status-bar {
flex-grow: 0;
flex-shrink: 0;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 32rpx;
border-bottom: 2rpx solid #f8f8f8;
background-color: #fff;
height: 90rpx;
.box {
height: 86rpx;
flex-grow: 0;
flex-shrink: 0;
color: #000000;
font-size: 28rpx;
display: flex;
align-items: center;
justify-content: center;
border-bottom: 4rpx solid #f8f8f8;
}
.box--selected {
border-bottom: 4rpx solid #007aff;
color: #007aff;
}
}
.list-area {
flex-grow: 1;
overflow: hidden;
.order-area {
width: 750rpx;
margin-bottom: 20rpx;
background-color: #fff;
.order-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
padding: 18rpx 32rpx;
border-bottom: 2rpx solid #f8f8f8;
.left {
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: flex-start;
}
}
.order-content {
border-bottom: 2rpx solid #f8f8f8;
.header {
display: flex;
align-items: flex-start;
justify-content: space-between;
padding: 24rpx 32rpx;
border-bottom: 2rpx solid #f8f8f8;
}
.order-item {
display: flex;
align-items: center;
justify-content: flex-start;
width: 686rpx;
margin: 24rpx 32rpx;
.img {
width: 100rpx;
height: 100rpx;
margin-right: 20rpx;
flex-grow: 0;
flex-shrink: 0;
}
.right {
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: flex-start;
}
}
.border {
border-top: 2rpx solid #f8f8f8;
}
}
.order-footer {
display: flex;
align-items: center;
justify-content: space-between;
padding: 24rpx 32rpx;
border-bottom: 2rpx solid #f8f8f8;
.left {
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-start;
}
.right {
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-end;
}
}
}
}
}
</style>

55
pages/test/index.vue

@ -0,0 +1,55 @@
<template>
<view>
<uni-nav-bar left-icon="back" @clickLeft="back" statusBar fixed title="测试"></uni-nav-bar>
<view @click="getList">list</view>
<view @click="getDetail">detail</view>
<view @click="purchase">purchase</view>
</view>
</template>
<script>
import { go2, back } from '@/utils/hook.js'
import { getPaperList, getPaperDetail, purchasePaper } from '@/apis/testApi.js'
export default {
data() {
return {}
},
methods: {
go2,
back,
//
getList() {
getPaperList({ supplierId: this.$store.state.supplierId }).then((res) => {
console.log(res)
})
},
getDetail() {
getPaperDetail({ productId: '678972506887032832' })
},
purchase() {
let form = {
orderGoodsList: [
{
buyTon: 2,
gramWeight: 200,
length: 1000,
mallSupplierId: '678289470268772352',
pieceQuantity: 10000,
productId: '678972506887032832',
productSkuId: '678972507222577152',
unitPrice: 10000,
width: 1000
}
],
otherFee: 0,
purchaserEnterpriseId: '807704'
}
purchasePaper(form).then((res) => {
console.log(res)
})
}
}
}
</script>
<style lang="scss" scoped></style>

BIN
static/imgs/mine/account-icon.png

Before After
Width: 68  |  Height: 68  |  Size: 7.2 KiB

BIN
static/imgs/mine/address-icon.png

Before After
Width: 68  |  Height: 68  |  Size: 7.1 KiB

BIN
static/imgs/mine/contract-icon.png

Before After
Width: 74  |  Height: 74  |  Size: 8.6 KiB

BIN
static/imgs/mine/credit-icon.png

Before After
Width: 68  |  Height: 73  |  Size: 5.9 KiB

BIN
static/imgs/mine/enquiry-icon.png

Before After
Width: 68  |  Height: 68  |  Size: 5.5 KiB

BIN
static/imgs/mine/finance-icon.png

Before After
Width: 74  |  Height: 73  |  Size: 8.4 KiB

BIN
static/imgs/mine/logout-icon.png

Before After
Width: 24  |  Height: 25  |  Size: 541 B

BIN
static/imgs/mine/money-icon.png

Before After
Width: 32  |  Height: 32  |  Size: 1.6 KiB

BIN
static/imgs/mine/msg-icon.png

Before After
Width: 40  |  Height: 40  |  Size: 1.2 KiB

BIN
static/imgs/mine/order-all-icon.png

Before After
Width: 68  |  Height: 68  |  Size: 3.9 KiB

BIN
static/imgs/mine/order-done-icon.png

Before After
Width: 68  |  Height: 68  |  Size: 3.9 KiB

BIN
static/imgs/mine/order-icon.png

Before After
Width: 68  |  Height: 68  |  Size: 5.2 KiB

BIN
static/imgs/mine/order-ing-icon.png

Before After
Width: 68  |  Height: 68  |  Size: 4.4 KiB

BIN
static/imgs/mine/order-ready-icon.png

Before After
Width: 68  |  Height: 68  |  Size: 3.6 KiB

BIN
static/imgs/mine/order-supplier-ready-icon.png

Before After
Width: 68  |  Height: 68  |  Size: 3.3 KiB

BIN
static/imgs/mine/setting-icon.png

Before After
Width: 40  |  Height: 40  |  Size: 1.2 KiB

BIN
static/imgs/mine/toggle-icon.png

Before After
Width: 24  |  Height: 24  |  Size: 382 B

BIN
static/imgs/mine/vip-icon.png

Before After
Width: 28  |  Height: 26  |  Size: 1.3 KiB

BIN
static/imgs/order/order-empty.png

Before After
Width: 560  |  Height: 560  |  Size: 45 KiB

BIN
static/imgs/order/paper-default-icon.png

Before After
Width: 100  |  Height: 100  |  Size: 16 KiB

21
store/index.js

@ -19,7 +19,7 @@ let qnToken = null,
uecToken = null, uecToken = null,
searchHistory = null, searchHistory = null,
/** /**
* @value supplierId 当前被分的供应商id
* @value supplierId 当前被分的供应商id
*/ */
supplierId = null supplierId = null
const companyInfoParams = ['id', 'name', 'fddEnterpriseStatus'] const companyInfoParams = ['id', 'name', 'fddEnterpriseStatus']
@ -51,14 +51,29 @@ const store = new Vuex.Store({
qnToken: qnToken || '', // token qnToken: qnToken || '', // token
supplierId: supplierId || '', // 供应商id supplierId: supplierId || '', // 供应商id
userInfo: userInfo || {}, // 用户信息 userInfo: userInfo || {}, // 用户信息
companyInfo: companyInfo || {}, // 纸盘商信息
companyInfo: companyInfo || {}, // 印包厂信息
nextPage: { nextPage: {
name: '', name: '',
data: {} data: {}
}, },
searchHistory: searchHistory || []
searchHistory: searchHistory || [],
/**
* 监听cache的type即可,每次取值后都必须调用commit('resetCache')
*/
cache: {
type: 'none',
data: null
}
}, },
mutations: { mutations: {
setCache(state, { type, data }) {
state.cache.type = type
state.cache.data = data
},
resetCache(state) {
state.cache.type = 'none'
state.cache.data = null
},
setUecToken(state, token) { setUecToken(state, token) {
try { try {
uni.setStorageSync('uecToken', token) uni.setStorageSync('uecToken', token)

87
utils/hook.js

@ -94,9 +94,10 @@ export function exit() {
/** /**
* 文件上传 * 文件上传
* @param {array} sourceType 上传的方式 album:相册 camera:相机 * @param {array} sourceType 上传的方式 album:相册 camera:相机
* @return {Promise} 以数组的形式返回对应的文件地址
* @param {number} count 上传的数量
* @return {Promise<string[]>} 以数组的形式返回对应的文件地址
*/ */
export function uploadImage(sourceType = ['album', 'camera']) {
export function uploadImage(sourceType = ['album', 'camera'], count = 1) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
uni.chooseImage({ uni.chooseImage({
count: 1, count: 1,
@ -104,24 +105,16 @@ export function uploadImage(sourceType = ['album', 'camera']) {
sourceType: sourceType, sourceType: sourceType,
success: (res) => { success: (res) => {
const tempFilePaths = res.tempFilePaths 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)
}
let cache = tempFilePaths.map((path) => {
return uploadFile(path, 'image')
}) })
Promise.all(cache)
.then((res) => {
resolve(res)
})
.catch((err) => {
reject(err)
})
}, },
fail: (err) => { fail: (err) => {
console.error('chooseImage error:', err) console.error('chooseImage error:', err)
@ -130,3 +123,59 @@ export function uploadImage(sourceType = ['album', 'camera']) {
}) })
}) })
} }
/**
* 单文件上传
* @param {string} path 文件路径
* @param {string} type 文件类型 image | file默认为image
* @returns {Promise<string>} 返回单文件上传地址
*/
export function uploadFile(path, type = 'image') {
return new Promise((resolve, reject) => {
uni.uploadFile({
url: uploadUrl[type],
filePath: path,
name: type,
// fileType: type,
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)
}
})
})
}
/**
* 根据类型获取缓存
* @param {string} type 缓存类型
* @returns 缓存数据
*/
export function getCache(type) {
let data = null
if (store.state.cache.type === type) {
data = store.state.cache.data
// 防止同一事件循环的数据竞争
setTimeout(() => {
store.commit('resetCache')
})
}
return data
}
/**
* 设置缓存
* @param {string} type 缓存类型
* @param {object} data 缓存数据
* @returns null
*/
export function setCache(type, data) {
store.commit('setCache', { type, data })
}

6
utils/index.js

@ -1,12 +1,16 @@
import env from '@/env/index.js' import env from '@/env/index.js'
import store from '@/store/index.js' import store from '@/store/index.js'
import { isDate } from './is.js'
/** /**
* 日期格式化样例 yyyy-mm-dd hh:MM:ss * 日期格式化样例 yyyy-mm-dd hh:MM:ss
* @param date Date 需要转换的日期 * @param date Date 需要转换的日期
* @param fmt string 转化的格式 yyyy-mm-dd hh:MM:ss * @param fmt string 转化的格式 yyyy-mm-dd hh:MM:ss
*/ */
export const dateTimeFormat = (date, fmt) => { export const dateTimeFormat = (date, fmt) => {
if (!date) {
if (!isDate(date)) {
date = new Date(date)
}
if (!date || isNaN(date.getTime())) {
throw new Error('日期不正确') throw new Error('日期不正确')
} }
let ret let ret

4
utils/is.js

@ -15,3 +15,7 @@ export function isObject(val) {
export function isArray(val) { export function isArray(val) {
return is(val, 'Array') return is(val, 'Array')
} }
export function isDate(val) {
return is(val, 'Date')
}
Loading…
Cancel
Save