Browse Source

消息点击

devlop
邓雄飞 4 years ago
parent
commit
3080cc9a6a
5 changed files with 140 additions and 17 deletions
  1. 4
      pages/mine/index.vue
  2. 8
      pages/trade/index.vue
  3. 142
      utils/handlePushMsg.js
  4. 1
      utils/hook.js
  5. 2
      utils/is.js

4
pages/mine/index.vue

@ -125,6 +125,10 @@
<image class="icon" src="/static/imgs/mine/credit-icon.png"></image>
<text class="label">授信记录</text>
</view>
<view class="icon-item" @click="loginGo2('trade')">
<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/contract-icon.png"></image>
<text class="label">服务区域</text>

8
pages/trade/index.vue

@ -59,10 +59,10 @@ export default {
this.refresh = !this.refresh
},
computed: {
hasLogin() {
return this.$store.state.qnToken != ''
}
},
hasLogin() {
return this.$store.state.qnToken != ''
}
},
methods: {
loginChange() {
go2('login')

142
utils/handlePushMsg.js

@ -1,20 +1,140 @@
import { isObject } from './is.js'
import { loginGo2 } from './hook.js'
/**
* 消息类型 4:提交询价1:客户下单88:订单取消87:订单超时86:客户订单融资提醒85:客户融资逾期提醒84:客户合同签署提醒83:客户订单融资完成
*/
const messageTypes = {
4: {
title: '提交询价',
fn: handleEnquiry
},
1: {
title: '客户下单',
fn: handleOrderMake
},
88: {
title: '订单取消',
fn: handleOrderCancel
},
87: {
title: '订单超时',
fn: handleOrderTimingEnd
},
86: {
title: '客户订单融资提醒',
fn: handleOrderRepaying
},
85: {
title: '客户融资逾期提醒',
fn: handleOrderOverdue
},
84: {
title: '客户合同签署提醒',
fn: handleOrderContract
},
83: {
title: '客户订单融资完成',
fn: handleOrderCompleted
}
}
/**
* 统一处理push消息
* @param {Object} msg 消息对象
* @value {string} msg.title 消息标题
* @value {string} msg.content 消息内容
* @value {object} msg.payload 消息参数
* @value {string} msg.payload.messageType
*/
export default function handlePushMsg(msg) {
uni.showModal({
title: '测试',
content: JSON.stringify(msg),
success: function (res) {
if (res.confirm) {
console.log('用户点击确定')
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
if (!isObject(msg.payload)) {
msg.payload = JSON.parse(msg.payload)
}
const data = msg.payload
const target = messageTypes[data.messageType]
if (target) {
target.fn(data)
}
// uni.showModal({
// title: '测试',
// content: JSON.stringify(msg),
// success: function (res) {
// if (res.confirm) {
// console.log('用户点击确定')
// } else if (res.cancel) {
// console.log('用户点击取消')
// }
// }
// })
}
/**
* 提交询价
* @param {object} params replyId
*/
function handleEnquiry(params) {
let replyId = params.replyId || ''
loginGo2('submit-quotation', { id: replyId })
}
/**
* 提交订单
* @param {object} params replyId
*/
function handleOrderMake(params) {
let replyId = params.replyId || ''
loginGo2('order-detail', { orderId: replyId })
}
/**
* 取消订单
* @param {object} params replyId
*/
function handleOrderCancel(params) {
let replyId = params.replyId || ''
loginGo2('order-detail', { orderId: replyId })
}
/**
* 订单超时
* @param {object} params replyId
*/
function handleOrderTimingEnd(params) {
let replyId = params.replyId || ''
loginGo2('order-detail', { orderId: replyId })
}
/**
* 客户订单融资提醒
* @param {object} params replyId
*/
function handleOrderRepaying(params) {
let replyId = params.replyId || ''
loginGo2('order-detail', { orderId: replyId })
}
/**
* 客户融资逾期提醒
* @param {object} params replyId
*/
function handleOrderOverdue(params) {
let replyId = params.replyId || ''
loginGo2('order-detail', { orderId: replyId })
}
/**
* 客户合同签署提醒
* @param {object} params replyId
*/
function handleOrderContract(params) {
let replyId = params.replyId || ''
loginGo2('order-detail', { orderId: replyId })
}
/**
* 客户订单融资完成
* @param {object} params replyId
*/
function handleOrderCompleted(params) {
let replyId = params.replyId || ''
loginGo2('order-detail', { orderId: replyId })
}

1
utils/hook.js

@ -75,7 +75,6 @@ export function go2(url, data = {}, isRedirect = false) {
*/
export function loginGo2(url, data = {}, isRedirect) {
const token = store.state.qnToken
console.log('token', token)
if (token) {
go2(url, data, isRedirect)
} else {

2
utils/is.js

@ -22,4 +22,4 @@ export function isDate(val) {
export function isString(val) {
return is(val, 'String')
}
}
Loading…
Cancel
Save