Commit a9f4c14d by xinla

--no commit message

1 parent 71f28655
......@@ -143,8 +143,11 @@ export function getReceiveStatus(params) {
* @param {*}
{
"orderNo": "1494182309006471169", // 订单id
"openId": "76", // 客户公众号id
"appld": 17, // 微信公众号id
receiveName: 领取人姓名
avalar: 领取人头像
"chatId": 17, // 群id
"externalUserid": "76", // 客户id
}
* @returns
*/
......
......@@ -65,7 +65,7 @@ export async function getWxCode() {
} catch (error) {
alert(error)
}
return userinfo.openId
return userinfo
}
//缓存中没有用户信息,进入授权流程
......@@ -87,21 +87,15 @@ export async function getWxCode() {
// window.location.href =
// `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${encodeURIComponent(local)}&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect`;
}
let data = ''
try {
data = await getUserOpenid(code)
let { data } = await getUserOpenid(code)
let { data: dataUser } = await getWechatUserInfo(data.openId)
localStorage.setItem('userinfo', JSON.stringify(dataUser))
return dataUser
} catch (error) {
alert(error)
}
data = data.data
if (data && data.openId) {
localStorage.setItem('userinfo', JSON.stringify(data))
return data.openId
// return getWechatUserInfo(data.openId)
}
// .then(({ data }) => {
// let unionId = data.unionId
// })
return {}
}
// 日期时间格式化
......
......@@ -11,6 +11,7 @@ export default {
name: '',
components: {},
data() {
let that = this
return {
loading: false,
finished: false,
......@@ -33,16 +34,42 @@ export default {
redEnvelopeAmount: [
{
required: true,
},
{
// formatter: (value) => +(+value).toFixed(2),
pattern: /(^[1-9]\d{0,2}(\.\d{1,2})?$|^200$)/,
pattern: /(^([1-9]\d{0,1}|1\d{2})(\.\d{1,2})?$|^200$)/,
message: '输入错误',
},
],
redEnvelopeNum: [
{
required: true,
// formatter: (value) => Math.round(value.replace(/\D/g, '')),
pattern: /(^[1-9]{1}\d*$)/,
},
// {
// // formatter: (value) => Math.round(value.replace(/\D/g, '')),
// pattern: /(^[1-9]{1}\d*$)/,
// message: '输入错误',
// },
{
validator(val) {
if (that.form.redEnvelopesType == 1) {
if (!/(^([1-9]\d{0,1}|[1-5]\d{2})$|^600$)/.test(val)) {
return false
}
if (that.form.redEnvelopeAmount) {
let max = that.form.redEnvelopeAmount * 3
let boolean = max >= val
if (!boolean) {
that.$notify({ type: 'danger', message: `当前红包金额最多可发${max}个红包` })
}
return boolean
} else {
return true
}
} else {
return /(^([1-9]\d{0,1}|1\d{2})(\.\d{1,2})?$|^200$)/.test(val)
}
},
message: '输入错误',
},
],
......@@ -132,11 +159,12 @@ export default {
this.loadFail = true
})
},
showDialog(type, row = {}) {
showDialog(type, row = { redEnvelopeNum: 1, money: 1 }) {
Object.assign(this.form, {
redEnvelopeAmount: row.money,
redenvelopesId: row.id,
redEnvelopeName: row.name,
redEnvelopeNum: row.redEnvelopeNum,
})
this.redPacketType = type
this.visible = true
......
......@@ -51,9 +51,11 @@ export default {
forbidClick: true,
})
getWxCode()
.then((openId) => {
.then(({ openId, nickName, headImgUrl }) => {
if (openId) {
this.openId = openId
this.receiveName = nickName
this.avalar = headImgUrl
this.getRedPacketInfo()
this.getReceiveStatus()
} else {
......@@ -79,7 +81,7 @@ export default {
openId: this.openId, // 客户公众号id
}
getReceiveStatus(form).then(({ data }) => {
data && this.getReceiveList(true)
data ? this.getReceiveList(true) : this.$toast.clear()
})
},
receive() {
......@@ -113,8 +115,10 @@ export default {
orderNo: this.redPacket.orderId, // 订单id
openId: this.openId, // 客户公众号id
appId: window.CONFIG.appId, // 微信公众号id
receiveName: this.receiveName,
avalar: this.avalar,
chatId: this.redPacket.chatId, // 客户群企微id
externalUserid: this.redPacket.externalUserid, // 客户企微id
// externalUserid: this.redPacket.externalUserid, // 客户企微id
}
getReceiveList(form).then(({ data }) => {
data.currentAcceptMoney /= 100
......@@ -134,7 +138,7 @@ export default {
setTimeout(() => {
this.opened = true
Object.assign(this.redPacket, data)
}, 1500)
}, 1000)
}
})
},
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!