Commit 9931f68a by 王志慧
2 parents 6a47e684 69401d72
......@@ -18,6 +18,7 @@
"glsx-common": "^1.4.8",
"lib-flexible": "^0.3.2",
"postcss-loader": "^6.2.0",
"sass-loader": "^7.3.1",
"sha1": "^1.1.1",
"storejs": "^1.1.0",
"vant": "^2.12.21",
......@@ -41,7 +42,6 @@
"node-sass": "^4.14.1",
"postcss-px-to-viewport": "^1.1.1",
"postcss-pxtorem": "^5.1.1",
"sass-loader": "^8.0.2",
"script-ext-html-webpack-plugin": "^2.1.4",
"vue-loader": "^15.9.8",
"vue-template-compiler": "^2.6.11",
......
<template>
<div id="app">
<router-view />
<template v-if="showWindow">
<router-view />
</template>
</div>
</template>
<script>
export default {
name: 'App'
name: 'App',
data() {
return {
showWindow: false
}
},
watch: {
watchFlag: {
immediate: true,
handler(newval) {
this.showWindow = newval
this.hideLoading()
}
}
},
computed: {
watchFlag() {
return this.$store.state.app.showWindow
}
}
}
</script>
<style lang="scss"></style>
......@@ -5,7 +5,6 @@ export default {
/**获取详情信息 */
getDetail(data) {
data.method = 'scrm.api.live.merchant.get.task'
data.taskId = '1'
return window.$HTTP({
url,
data,
......
......@@ -35,8 +35,6 @@ const mutations = {
SET_LAST_PATH(state, path) {
state.lastPath = path
}
}
const actions = {
// 设置name
......@@ -65,70 +63,75 @@ const actions = {
},
login({ dispatch }) {
let [redirectUrl] = window.location.href.split('?')
// 以下是 本地调试
// 以下是 本地调试
if (process.env.NODE_ENV == 'development') {
const code = getParams('code')
if (code) {
const { corpId } = util.getLocalStorage('dj_scrm_corpId')
ssoApi.login({
code,
corpId
}).then(({ code, data, message }) => {
console.log(data)
// const { baseURL } = window.$fetchConfig.request
const [baseURL] = redirectUrl.split('/dj-scrm-wx-work-main/')
let url = `${baseURL}/dj-scrm-wx-work-main/#/`
let route = state.lastPath == 'coupon' ? '' : state.lastPath || ''
route = route.replace('.', '/')
state.showWindow = true
if (code == '0') {
if (data.loginList.length) {
if (data.loginList.length > 1) {
let userInfo = data.loginList[0]
let { merchantId, accountName } = userInfo
let loginAccount = accountName
ssoApi.selectAccount({
loginAccount,
merchantId,
loginToken: data.loginToken,
loginSource: 'WW',
loginType: 3
}).then(res => {
util.removeLocalStorage('dj_scrm_loginToken')
util.removeLocalStorage('dj_scrm_accountList')
util.setLocalStorage('dj_scrm_userInfo', res.data)
util.setSessionId(res.data.sessionId)
dispatch('registerHttp', res.data.sessionId)
window.location.replace(`${url}${route}`)
})
ssoApi
.login({
code,
corpId
})
.then(({ code, data, message }) => {
console.log(data)
// const { baseURL } = window.$fetchConfig.request
const [baseURL] = redirectUrl.split('/dj-scrm-wx-work-main/')
let url = `${baseURL}/dj-scrm-wx-work-main/#/`
let route = state.lastPath == 'coupon' ? '' : state.lastPath || ''
route = route.replace('.', '/')
if (code == '0') {
if (data.loginList.length) {
if (data.loginList.length > 1) {
let userInfo = data.loginList[0]
let { merchantId, accountName } = userInfo
let loginAccount = accountName
ssoApi
.selectAccount({
loginAccount,
merchantId,
loginToken: data.loginToken,
loginSource: 'WW',
loginType: 3
})
.then(res => {
util.removeLocalStorage('dj_scrm_loginToken')
util.removeLocalStorage('dj_scrm_accountList')
util.setLocalStorage('dj_scrm_userInfo', res.data)
util.setSessionId(res.data.sessionId)
dispatch('registerHttp', res.data.sessionId)
state.showWindow = true
window.location.replace(`${url}${route}`)
})
} else {
let [userInfo] = data.loginList
util.setLocalStorage('dj_scrm_userInfo', userInfo)
util.setSessionId(userInfo.sessionId)
dispatch('registerHttp', userInfo.sessionId)
// 只有一个账号 history.back()
console.log(`${redirectUrl}${route}`)
state.showWindow = true
window.location.replace(`${redirectUrl}${route}`)
}
} else {
let [userInfo] = data.loginList
util.setLocalStorage('dj_scrm_userInfo', userInfo)
util.setSessionId(userInfo.sessionId)
dispatch('registerHttp', userInfo.sessionId)
// 只有一个账号 history.back()
console.log(`${redirectUrl}${route}`)
// window.location.replace(`${redirectUrl}${route}`)
/**没有账号 */
// window.location.href = `${url}common/nothing`
Notify('没有账号')
}
} else {
/**没有账号 */
// window.location.href = `${url}common/nothing`
/**账号过期 (暂时没有字段判断是否过期) */
Notify(message)
// window.location.href = `${url}common/overdue`
}
} else {
/**账号过期 (暂时没有字段判断是否过期) */
Notify(message)
// window.location.href = `${url}common/overdue`
}
})
})
} else {
util.showLoading()
let appid = getParams('corpId') //从链接获取
let dj_scrm = util.getLocalStorage('dj_scrm_corpId')
if (!appid) appid = dj_scrm && dj_scrm.corpId || 'ww7ee69c648ae1b7e6'
//
if (!appid) appid = (dj_scrm && dj_scrm.corpId) || 'ww7ee69c648ae1b7e6'
//
util.setLocalStorage('dj_scrm_corpId', { corpId: appid })
// 'ww657a2d4ae89a4424'
// 'ww657a2d4ae89a4424'
const wxUrl = 'https://open.weixin.qq.com/connect/oauth2/authorize'
window.location.href = `${wxUrl}?appid=${appid}&redirect_uri=${encodeURIComponent(redirectUrl)}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`
}
......@@ -138,13 +141,12 @@ const actions = {
let url = `${baseURL}/dj-scrm-wx-work-main/#/`
window.location.href = `${url}?redirect_uri=${redirectUrl}&corpId=${storage_corpId.corpId}`
}
},
navigation({ dispatch }) {
let { sessionId, corpId } = getParams()
const storage_sessionId = util.getSessionId()
const storage_corpId = util.getLocalStorage('dj_scrm_corpId')
if (!corpId) corpId = storage_corpId && storage_corpId.corpId || 'ww7ee69c648ae1b7e6'
if (!corpId) corpId = (storage_corpId && storage_corpId.corpId) || 'ww7ee69c648ae1b7e6'
util.setLocalStorage('dj_scrm_corpId', { corpId })
if (sessionId || storage_sessionId) {
state.showWindow = true
......@@ -159,7 +161,7 @@ const actions = {
state.showWindow = true
},
registerHttp({}, sessionId = '') {
window.$HTTP = new Http({...window.$fetchConfig, alert: Notify, headers: { token: sessionId } })
window.$HTTP = new Http({ ...window.$fetchConfig, alert: Notify, headers: { token: sessionId } })
}
}
const getParams = name => {
......
......@@ -152,6 +152,9 @@ const toTop = () => {
const getParams = () => {
return window.vm.$route.params
}
const getQuery = () => {
return window.vm.$route.query
}
const watchPageBack = () => {
return new Promise(resolve => {
if (window.$back) {
......@@ -183,7 +186,8 @@ const utils = {
throttle,
decimal,
dialog,
toTop
toTop,
getQuery
}
Object.keys(utils).map(key => {
......
<template>
<div class="container">
<div class="box">
<div class="box" v-if="showBox">
<div class="top">
<div class="top-title">{{ detail.name }}直播活动</div>
<div class="iconBox" @click="copyMessage(this.massMessage)">
......@@ -13,46 +13,61 @@
<img :src="detail.postImgUrl" alt="" />
</div>
</div>
<div class="fixedButtom">
<!-- <div class="item-container"> -->
<div class="icon-container">
<div class="icon-box" @click="shareWechat">
<img src="@/assets/images/wechat.png" alt="" />
<div class="fixedButtom" v-if="showBox">
<div class="item-container">
<div class="icon-container">
<div class="icon-box" @click="share('wechat')">
<img src="@/assets/images/wechat.png" alt="" />
</div>
</div>
<div class="icon-instruction">分享朋友圈</div>
</div>
<!-- <div class="icon-instruction">分享到朋友圈</div> -->
<!-- </div> -->
<div class="icon-container" style="margin-left: 75px" @click="shareCustomer">
<div class="icon-box">
<img src="@/assets/images/customer.png" alt="" />
<div class="item-container" style="margin-left: 61px">
<div class="icon-container" @click="share('customer')">
<div class="icon-box">
<img src="@/assets/images/customer.png" alt="" />
</div>
</div>
<div class="icon-instruction">分享客户</div>
</div>
<div class="icon-container" style="margin-left: 75px" @click="shareGroup">
<div class="icon-box">
<img src="@/assets/images/group.png" alt="" />
<div class="item-container" style="margin-left: 61px">
<div class="icon-container" @click="share('group')">
<div class="icon-box">
<img src="@/assets/images/group.png" alt="" />
</div>
</div>
<div class="icon-instruction">分享客户群</div>
</div>
</div>
</div>
</template>
<script type='text/ecmascript-6'>
import { liveBroadcast, wxConfig } from '@/api'
import { Notify } from 'vant'
export default {
name: 'mass',
data() {
return {
detail: {},
date: ''
date: '',
showBox: true
}
},
activated() {},
deactivated() {},
mounted() {
let { taskId } = this.getQuery()
//获取界面详情数据
liveBroadcast.getDetail({}).then(res => {
this.detail = res.data
console.log(this.detail.startTime, 'this.detail.startTime')
this.formatDate(this.detail.startTime, this.detail.endTime)
liveBroadcast.getDetail({ taskId }).then(res => {
console.log(res,'789')
if (res.code !== '0') {
this.showBox = false
Notify(res.message)
} else if (res.code == '0') {
this.detail = res.data
console.log(this.detail.startTime, 'this.detail.startTime')
this.formatDate(this.detail.startTime, this.detail.endTime)
}
})
//初始化微信方法
window.$wx = wxConfig
......@@ -66,29 +81,31 @@ export default {
// cloneText(val)
// Toast('复制成功')
// }
//分享到朋友圈
shareWechat() {
share(object) {
console.log(object)
let text = {
content: this.detail.promotion + '直播时间' + ' ' + this.date
content: this.detail.promotion + '\n' + '直播时间' + ' ' + this.date
}
let attachments = [
{
msgtype: 'image',
image: {
imgUrl: ''
imgUrl: this.detail.postImgUrl
}
}
]
// let text = this.detail.promotion +'直播时间' + ' ' + this.date
window.$wx.shareToExternalMoments({ content: text }).then(res => {})
},
//分享给客户
shareCustomer() {
window.$wx.shareToExternalContact().then(res => {})
},
//分享给客户群
shareGroup() {
window.$wx.shareToExternalChat().then(res => {})
//分享到朋友圈
if (object == 'wechat') {
window.$wx.shareToExternalMoments({ text, attachments }).then(res => {})
}
//分享给客户
if (object == 'customer') {
window.$wx.shareToExternalContact({ text, attachments }).then(res => {})
}
//分享给客户群
if (object == 'group') {
window.$wx.shareToExternalChat({ text, attachments }).then(res => {})
}
},
//更改日期格式
formatDate(startTime, endTime) {
......@@ -109,16 +126,17 @@ export default {
display: flex;
flex-direction: row;
position: -webkit-sticky;
position: sticky;
position: fixed;
bottom: 0;
opacity: 1;
z-index: 99;
box-sizing: border-box;
text-align: center;
padding: 20px 38px 20px 37px;
height: 76px;
padding: 20px 33px 20px 32px;
background: #ffffff;
box-shadow: 0px -2px 8px 0px rgba(224, 224, 224, 0.5);
border-radius: 16px 16px 0px 0px;
width: 100%;
}
.buttomLine {
width: 134px;
......@@ -200,6 +218,7 @@ export default {
height: 50px;
background-color: #e9e8ff;
border-radius: 50%;
margin: 0px 5px 0px 5px;
}
.icon-box {
width: 26px;
......
<!-- home -->
<template>
<div class="container">
<template v-if="showWindow">
<transition name="fade">
<keep-alive v-if="$route.meta.keepAlive">
<router-view></router-view>
</keep-alive>
</transition>
<transition name="fade">
<router-view v-if="!$route.meta.keepAlive"></router-view>
</transition>
<template v-if="$route.meta.isTab">
<tab-bar :data="tabList"></tab-bar>
</template>
</template>
</div>
</template>
<script>
export default {
data () {
return {
showWindow: false
}
},
watch: {
watchFlag: {
immediate: true,
handler (newval) {
this.showWindow = newval
this.hideLoading()
}
}
},
computed: {
watchFlag () {
return this.$store.state.app.showWindow
}
},
mounted () {
},
methods: {
}
}
</script>
<style lang="scss" scoped>
</style>
......@@ -49,8 +49,8 @@ const spritesmithFunction = data => {
return `${shared}\n${perSprite}`
}
module.exports = {
publicPath: IS_PROD ? './' : '/dj-scrm-wx-work-main/', // 署应用包时的基本 URL。 vue-router hash 模式使用
publicPath: IS_PROD ? './' : '/dj-scrm-wx-group-chat/',
// publicPath: IS_PROD ? './' : '/dj-scrm-wx-work-main/', // 署应用包时的基本 URL。 vue-router hash 模式使用
// publicPath: IS_PROD ? './' : '/dj-scrm-wx-work-attachment-customer/', // 署应用包时的基本 URL。 vue-router hash 模式使用
// publicPath: '/dj-scrm-wx-work-attachment-customer/', // 署应用包时的基本 URL。 vue-router history模式使用
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!