Commit 31ce98f4 by xinla

--no commit message

1 parent 21fc1735
const config = {
/**
* @description token在Cookie中存储的天数,默认1天
*/
cookieExpires: 1,
/**
* @description 默认打开的首页的路由name值,默认为home
*/
homeName: 'home',
}
config.services = {
wecom: '/wecom',
appId: 'wx863c031a74f589a0', // 微信公众号id
cookieExpires: 1, //token在Cookie中存储的天数,默认1天
homeName: 'home', //默认打开的首页的路由name值,默认为home
services = {
wecom: '/wecom',
}
}
export default config
......@@ -56,7 +56,7 @@ export function getQueryValue(name) {
return ''
}
export function getWxCode() {
export async function getWxCode() {
let userinfo = localStorage.getItem('userinfo')
//取缓存中的用户信息
if (userinfo) {
......@@ -86,13 +86,12 @@ export 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`;
}
// getUserOpenid(code)
// .then(({ data }) => {
// if (data && data.openId) {
// localStorage.setItem('userinfo', JSON.stringify(data))
// return getWechatUserInfo(data.openId)
// }
// })
let { data } = getUserOpenid(code)
if (data && data.openId) {
localStorage.setItem('userinfo', JSON.stringify(data))
return data.openId
// return getWechatUserInfo(data.openId)
}
// .then(({ data }) => {
// let unionId = data.unionId
// })
......
......@@ -27,7 +27,7 @@ export default {
methods: {
getWxCode() {
try {
let appid = 'wx863c031a74f589a0' // 公众号appid
let appid = window.CONFIG.appId // 公众号appid
// let appid = 'wx8bfe6bc2ca5c45ae' // 公众号appid
alert(2)
let code = getQueryValue('code') //是否存在code
......
<script>
import {
getList,
sendCustomerPersonalRedPacket,
sendCustomerEnterpriseRedPacket,
sendCustomerGroupPersonalRedPacket,
sendCustomerGroupEnterpriseRedPacket,
} from '@/api/redPacket.js'
import { getList } from '@/api/redPacket.js'
import { obj2query, param2Obj } from '@/utils/index.js'
export default {
name: '',
......@@ -85,6 +79,7 @@ export default {
wx.invoke('getCurExternalContact', {}, (res) => {
if (res.err_msg == 'getCurExternalContact:ok') {
that.form.externalUserid = res.userId //返回当前外部联系人userId
that.form.chatId = res.chatId //返回当前客户群的群聊ID
} else {
//错误处理
that.$dialog({ message: '进入失败:' + JSON.stringify(res) })
......@@ -129,8 +124,8 @@ export default {
this.loadFail = true
})
},
showDialog(type, row) {
this.form = Object.assign({ redEnvelopeAmount: row.money }, row || {})
showDialog(type, row = {}) {
this.form = { redEnvelopeAmount: row.money, redenvelopesId: row.id }
this.redPacketType = type
this.visible = true
},
......@@ -142,14 +137,13 @@ export default {
let mes = {}
try {
let form = Object.assign({}, this.form)
form.sendUserId = this.userId
// 单位换算 元转分
form.redEnvelopeAmount *= 100
let query = param2Obj(window.location.search)
let hash = param2Obj(window.location.hash)
Object.assign(
form,
{ sceneType: this.sceneType, redPacketType: this.redPacketType },
{ sendUserId: this.userId, sceneType: this.sceneType, redPacketType: this.redPacketType },
query,
hash
)
......
......@@ -16,6 +16,12 @@ export default {
list: [],
opened: false,
redPacket: {},
form: {
orderNo: '', // 订单id
openId: '', // 客户公众号id
appId: window.CONFIG.appId, // 微信公众号id
externalUserid: '', // 客户企微id
},
}
},
computed: {},
......@@ -27,31 +33,31 @@ export default {
mounted() {},
methods: {
init() {
getWxCode()
getWxCode().then((openId) => (this.form.openId = openId))
},
sendRedPacket() {
this.$toast.loading({
duration: 0,
forbidClick: true,
})
let form = {}
let query = param2Obj(window.location.search)
let hash = param2Obj(window.location.hash)
Object.assign(form, query, hash)
this.redPacket = form
Object.assign(query, hash)
this.redPacket = query
this.form.externalUserid = query.externalUserid
let request = ''
if (form.sceneType == 1) {
if (query.sceneType == 1) {
request = {
personal: sendCustomerPersonalRedPacket,
enterprise: sendCustomerEnterpriseRedPacket,
}[form.redPacketType]
}[query.redPacketType]
} else {
request = {
personal: sendCustomerGroupPersonalRedPacket,
enterprise: sendCustomerGroupEnterpriseRedPacket,
}[form.redPacketType]
}[query.redPacketType]
}
request(form).then((res) => {
request(query).then((res) => {
this.$toast.clear()
})
},
......
......@@ -8,8 +8,8 @@ export function getUrlParam(name) {
return null
}
export function getWxCode() {
let appid = 'wx863c031a74f589a0' // 公众号appid
// let appid = 'wx8bfe6bc2ca5c45ae' // 公众号appid
// let appid = 'wx863c031a74f589a0' // 公众号appid
let appid = 'wx8bfe6bc2ca5c45ae' // 公众号appid
let code = getUrlParam('code') //是否存在code
let local = window.location.origin.includes('localhost')
? 'http://h5.linkwechat.cn/test.html'
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!