diff --git a/pages/add-paper/index.vue b/pages/add-paper/index.vue
index bc26f31..8eb31c0 100644
--- a/pages/add-paper/index.vue
+++ b/pages/add-paper/index.vue
@@ -14,7 +14,7 @@
纸品名称
-
+
@@ -30,6 +30,7 @@
v-model="form.manufacturerName"
:inputBorder="false"
text="right"
+ :maxlength="100"
placeholder="请输入纸厂信息"
>
@@ -47,7 +48,8 @@
v-model="form.brandName"
:inputBorder="false"
text="right"
- placeholder="请输入纸品品牌名称"
+ :maxlength="50"
+ placeholder="请输入品牌信息"
>
@@ -63,6 +65,7 @@
v-model="form.categoryName"
:inputBorder="false"
text="right"
+ :maxlength="50"
placeholder="请输入纸种信息"
>
@@ -102,11 +105,12 @@
@@ -174,6 +178,7 @@
v-model="item.minimum"
:inputBorder="false"
text="right"
+ :maxlength="9999999999"
placeholder="请输入最低起送量"
>
{{ item.stockUnit === '1' ? '张' : '吨' }}
@@ -191,7 +196,7 @@
file-mediatype="image"
mode="grid"
file-extname="png,jpg"
- :limit="6"
+ :limit="5"
:image-styles="imageStyles"
@progress="progress"
@success="success"
@@ -260,7 +265,7 @@
v-model="form.otherNote"
:inputBorder="false"
type="textarea"
- placeholder="请输入其他说明"
+ placeholder="请输入"
>
@@ -308,7 +313,11 @@ export default {
isMainProductRep: 0,
manufacturerName: null,
brandName: null,
- categoryName: null
+ categoryName: null,
+ sellingProposition:'月结30天价格,不加服务费!',
+ description:'售价全部为含税价,支持先用后付,欢迎来电查询!近期价格波动较大,请下单前先咨询价格。',
+ shippingNote:'分切纸不足重量的,另加调机费;低于送货重量或超出送货范围的,运费另计。'
+
},
imageStyles: {
width: 100,
@@ -333,16 +342,7 @@ export default {
}
],
paperList: [],
- skuList: [
- {
- isPromoting: 0,
- listPrice: null,
- minimum: null,
- stock: null,
- stockUnit: '1',
- weight: null
- }
- ],
+ skuList: [],
imgList: [],
priceIndex: 0,
eidtFor: 0,
@@ -429,11 +429,11 @@ export default {
//新增售价
addPriceClick() {
this.skuList.push({
- isPromoting: 0,
+ isPromoting: 1,
listPrice: null,
minimum: null,
stock: null,
- stockUnit: '1',
+ stockUnit: '2',
weight: null,
categoryName: null
})
diff --git a/pages/mall/index.vue b/pages/mall/index.vue
index 718ce5e..8a04442 100644
--- a/pages/mall/index.vue
+++ b/pages/mall/index.vue
@@ -39,9 +39,9 @@
- {{ item.updateTime }}
+ {{item.updateTime | timeFilter }}
- 编辑
+ 编辑
{{ item.status === 30111 ? '下架' : '上架' }}
@@ -59,11 +59,21 @@
+
diff --git a/utils/index.js b/utils/index.js
index 1ac58bb..72c5503 100644
--- a/utils/index.js
+++ b/utils/index.js
@@ -6,25 +6,59 @@ import store from '@/store/index.js'
* @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
+ 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
+}
+/**
+ * 日期格式化文字描述,样例 yyyy-mm-dd hh:MM:ss
+ * @param stringTime 需要转换的日期
+ */
+export const getTimer = (stringTime) => {
+ var minute = 1000 * 60;
+ var hour = minute * 60;
+ var day = hour * 24;
+ var week = day * 7;
+ var month = day * 30;
+ var time1 = new Date().getTime(); //当前的时间戳
+ console.log(time1);
+ var time2 = Date.parse(new Date(stringTime)); //指定时间的时间戳
+ console.log(time2);
+ var time = time1 - time2;
+
+ var result = null;
+ if (time < 0) {
+
+ } else if (time / month >= 1) {
+ result = parseInt(time / month) + "月前";
+ } else if (time / week >= 1) {
+ result = parseInt(time / week) + "周前";
+ } else if (time / day >= 1) {
+ result = parseInt(time / day) + "天前";
+ } else if (time / hour >= 1) {
+ result = parseInt(time / hour) + "小时前";
+ } else if (time / minute >= 1) {
+ result = parseInt(time / minute) + "分钟前";
+ } else {
+ result = "刚刚";
+ }
+ return result;
}
/**
@@ -34,81 +68,88 @@ export const dateTimeFormat = (date, fmt) => {
* @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 () {}
- }
+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
+ 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()
- }
- })
+ 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')
- })
+ socketTask.onError(() => {
+ console.log(pageInfo + ' error')
+ })
- socket.sockTask = socketTask
- }
+ 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)
- }
- })
- }
- }
+ 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
+ return socket
}