Commit 8bd4b7dc by 李伟康

commit

1 parent 1d3871fb
import util from '@/utils/util' import util from '@/utils/util'
import { Notify } from 'vant' import { Notify } from 'vant'
const IS_PROD = ['production', 'prod'].includes(process.env.NODE_ENV)
const url = '/rop-scrm-wechat/router'
const WxConfig = { const WxConfig = {
init(jsApiList) { init(jsApiList) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
...@@ -17,7 +19,7 @@ const WxConfig = { ...@@ -17,7 +19,7 @@ const WxConfig = {
} }
window window
.$HTTP({ .$HTTP({
url: '/rop-scrm-wechat/router', url,
data data
}) })
.then(obj => { .then(obj => {
...@@ -44,6 +46,25 @@ const WxConfig = { ...@@ -44,6 +46,25 @@ const WxConfig = {
}) })
}) })
}, },
/**生成小程序短链 */
createMiniprogramUrlLink(data = {}) {
data.method = 'scrm.api.wechat.miniprogram.geturllink'
data.envVersion = IS_PROD ? 'release' : 'trial'
/**path 页面路径
* query 页面参数
* isExpire 过期类型 到期失效:true,永久有效:false
* expireType 失效类型 失效时间:0,失效间隔天数:1
* expireTime 失效时间
* expireInterval 失效间隔
* appId 微信应用ID
* envVersion 要打开的小程序版本。正式版为:release,体验版为:trial,开发版为:develop,仅在微信外打开时生效
*/
console.log('请求',data)
return window.$HTTP({
url,
data
})
},
getContext() { getContext() {
/** /**
* entry String 场景值 * entry String 场景值
...@@ -107,12 +128,13 @@ const WxConfig = { ...@@ -107,12 +128,13 @@ const WxConfig = {
/**分享消息到当前会话 */ /**分享消息到当前会话 */
sendChatMessage(params) { sendChatMessage(params) {
console.log(params) console.log(params)
return new Promise(resolve => { return new Promise((resolve,reject) => {
wx.invoke('sendChatMessage', params, res => { wx.invoke('sendChatMessage', params, res => {
util.hideLoading() util.hideLoading()
console.log(res)
if (res.err_msg == 'sendChatMessage:ok') { if (res.err_msg == 'sendChatMessage:ok') {
resolve() resolve()
}else{
reject(res)
} }
}) })
}) })
......
import { shopmallApi, activityApi, couponApi, liveApi, boutiquecouponApi, equityApi, wxConfig } from '@/api' import { shopmallApi, activityApi, couponApi, boutiquecouponApi, equityApi, wxConfig } from '@/api'
const { environment } = window.$fetchConfig const { environment } = window.$fetchConfig
export default { export default {
data() { data() {
...@@ -7,7 +7,8 @@ export default { ...@@ -7,7 +7,8 @@ export default {
} }
}, },
mounted() { mounted() {
if (this.$route.meta.isTab) this.wxInit() // if (this.$route.meta.isTab || this.$route.meta.isIndex)
this.wxInit()
}, },
methods: { methods: {
wxInit() { wxInit() {
...@@ -19,10 +20,15 @@ export default { ...@@ -19,10 +20,15 @@ export default {
}) })
}) })
}, },
showShareModel(i) { showShareModel(i = {}) {
let { tabIndex } = this let {
if (tabIndex == 0 && i.remainAmount < 1) return tabIndex,
if (tabIndex == 1 && i.residueAmount < 1) return $route: { name }
} = this
if (name != 'merchant') {
if (tabIndex == 0 && i.remainAmount < 1) return
if (tabIndex == 1 && i.residueAmount < 1) return
}
wxConfig wxConfig
.getCurExternalContact() .getCurExternalContact()
.then(res => { .then(res => {
...@@ -35,10 +41,10 @@ export default { ...@@ -35,10 +41,10 @@ export default {
}) })
}, },
sendMessage(i) { sendMessage(i) {
let { merchantId } = this.getLocalStorage('dj_scrm_userInfo') let { merchantId, merchantName } = this.getLocalStorage('dj_scrm_userInfo')
let { tabIndex, entry, tabList } = this let { tabIndex, entry, tabList } = this
let { name } = this.$route let { name } = this.$route
let { userId, id, couponName, activityName, packageName, goodsName, goodsImage ,discountType} = i let { userId, id, couponName, activityName, packageName, goodsName, goodsImage, discountType } = i
let shopmall_appId = environment == 'beta' ? 'wx9f91c1ec493eb425' : 'wxe10067a63c1856ac' let shopmall_appId = environment == 'beta' ? 'wx9f91c1ec493eb425' : 'wxe10067a63c1856ac'
let dj_appId = 'wx06d1198e751435d1' let dj_appId = 'wx06d1198e751435d1'
this.showLoading() this.showLoading()
...@@ -98,6 +104,30 @@ export default { ...@@ -98,6 +104,30 @@ export default {
/**店铺 */ /**店铺 */
case 'merchant': { case 'merchant': {
if (tabIndex == 0) { if (tabIndex == 0) {
let path = 'pages/tab/index/index'
let query = `merchantId=${merchantId}`
const imgUrl = 'https://img01.glsx.com.cn/weapp/resource/scrm-mobile/activity/miniprogram-cover.jpg'
if (entry != 'normal')
this.sendChatMessage({
appid: shopmall_appId,
title: merchantName,
imgUrl,
page: `/${path}.html?${query}`
})
else {
console.log('query', query)
wxConfig
.createMiniprogramUrlLink({
path,
query: `merchantId%3D${merchantId}`,
appId: shopmall_appId
})
.then(res => {
console.log(res)
this.shareAppMessage(res, '', merchantName, imgUrl)
})
}
} else if (tabIndex == 1) {
let imgUrl = 'http://img01.glsx.com.cn/upload/biz/dracMini-qy-10004.png' let imgUrl = 'http://img01.glsx.com.cn/upload/biz/dracMini-qy-10004.png'
if (entry != 'normal') if (entry != 'normal')
this.sendChatMessage({ this.sendChatMessage({
...@@ -139,7 +169,8 @@ export default { ...@@ -139,7 +169,8 @@ export default {
.then(() => { .then(() => {
this.hideLoading() this.hideLoading()
}) })
.catch(() => { .catch(err => {
console.log('当前会话', err)
this.hideLoading() this.hideLoading()
}) })
}, },
......
const pages = [{ const pages = [
{
name: 'coupon', name: 'coupon',
meta: { meta: {
isTab: true, isTab: true,
keepAlive: true, keepAlive: true,
backgroundColor: '#F7F7F7' backgroundColor: '#F7F7F7'
}, },
children: [{ children: [
name: 'verificationList', {
meta: { name: 'verificationList',
backgroundColor: '#F7F7F7' meta: {
} backgroundColor: '#F7F7F7'
}, { }
name: 'verificationDetail', },
meta: { {
backgroundColor: '#F7F7F7' name: 'verificationDetail',
meta: {
backgroundColor: '#F7F7F7'
}
} }
}] ]
}, },
{ {
name: 'activity', name: 'activity',
...@@ -24,26 +28,17 @@ const pages = [{ ...@@ -24,26 +28,17 @@ const pages = [{
keepAlive: true, keepAlive: true,
backgroundColor: '#F7F7F7' backgroundColor: '#F7F7F7'
}, },
children: [ children: []
]
}, },
{ {
name: 'merchant', name: 'merchant',
meta: { meta: {
isTab: true,
keepAlive: true, keepAlive: true,
backgroundColor: '#F7F7F7' isIndex: true,
backgroundColor: '#F7F7F7',
title: '店铺中心'
}, },
children: [ children: []
{
name:'goods',
meta: {
backgroundColor: '#F7F7F7',
title:'商品中心'
},
}
]
} }
] ]
const keepAlives = [] const keepAlives = []
...@@ -65,12 +60,12 @@ const setChildren = (e, parent) => { ...@@ -65,12 +60,12 @@ const setChildren = (e, parent) => {
}) })
return arr return arr
} }
const getPages = _ => { const getPages = () => {
let router = { let router = {
path: '/', path: '/',
name: 'home', name: 'home',
redirect: '/coupon', redirect: '/coupon',
component: resolve => require([`views/home.vue`], resolve), component: resolve => require([`views/home.vue`], resolve)
} }
router.children = pages.map(e => { router.children = pages.map(e => {
let name = `${e.name}` let name = `${e.name}`
...@@ -87,4 +82,4 @@ const getPages = _ => { ...@@ -87,4 +82,4 @@ const getPages = _ => {
return [router] return [router]
} }
export const keeps = keepAlives export const keeps = keepAlives
export default getPages()
\ No newline at end of file \ No newline at end of file
export default getPages()
...@@ -49,7 +49,6 @@ const showLoading = (title = '加载中...') => { ...@@ -49,7 +49,6 @@ const showLoading = (title = '加载中...') => {
}) })
} }
const hideLoading = () => { const hideLoading = () => {
console.log('清除')
Toast.clear() Toast.clear()
} }
/**num:要转换的数值,fixed:精确几位小数 */ /**num:要转换的数值,fixed:精确几位小数 */
......
...@@ -34,12 +34,6 @@ export default { ...@@ -34,12 +34,6 @@ export default {
name: 'activity', name: 'activity',
active: require('@/assets/images/tabbar/activity_active.png'), active: require('@/assets/images/tabbar/activity_active.png'),
inactive: require('@/assets/images/tabbar/activity.png') inactive: require('@/assets/images/tabbar/activity.png')
},
{
title: '店铺',
name: 'merchant',
active: require('@/assets/images/tabbar/merchant_active.png'),
inactive: require('@/assets/images/tabbar/merchant.png')
} }
] ]
} }
......
<template>
<div class="layout">
<template v-if="flag">
<template v-if="list.length">
<scroll-view
class="list-box"
@ReachBottom="onReachBottom"
ref="scrollView"
>
<div class="type-1">
<template v-for="(i,index) in list">
<div
:key="index"
class="item"
@click="choose(i)"
>
<div class="icon">
<img :src="i.goodsImage || ''">
</div>
<div class="info">
<div class="name text-two-line">{{i.goodsName}}</div>
<template v-if="i.price">
<div class="price">¥{{i.price.toFixed(2)}}</div>
</template>
<div class="btn text-center">发送</div>
</div>
</div>
</template>
</div>
</scroll-view>
</template>
<template v-else>
<van-empty description="暂无内容" />
</template>
</template>
</div>
</template>
<script type='text/ecmascript-6'>
import { shopmallApi, wxConfig } from '@/api'
export default {
name: '',
data() {
return {
pageNum: 1,
list: [],
flag: false,
total: 0
}
},
mounted() {
this.getList()
wxConfig.init(['shareAppMessage'])
},
methods: {
getList() {
let { list, pageNum } = this
shopmallApi.getGoodsList({ currentPage: pageNum }).then(res => {
this.flag = true
this.list = list.concat(res.list)
this.total = res.total
this.hideLoading()
})
},
choose(e) {
let { id, goodsName, goodsImage } = e
shopmallApi.getGoodsLink({ id }).then(data => {
console.log('链接_________', data)
wxConfig
.shareAppMessage({
title: goodsName,
desc: '',
link: data,
imgUrl: goodsImage
})
.then(res => {
this.showToast('发送成功')
})
})
},
onReachBottom() {
let { total, pageNum, list } = this
this.$refs.scrollView.loading = false
if (list.length == total) {
this.$refs.scrollView.finished = true
return
}
if (Math.ceil(total / 10) > pageNum) {
this.pageNum = pageNum + 1
this.getList()
} else {
this.$refs.scrollView.finished = true
}
}
}
}
</script>
<style scoped lang='scss'>
.list-box {
height: 100vh;
.type-1 {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
.item {
width: 164px;
height: 208px;
box-shadow: 0px 4px 8px 0px rgba(224, 224, 224, 0.5);
position: relative;
margin-bottom: 10px;
.icon {
height: 120px;
}
.icon-share {
position: absolute;
right: 10px;
bottom: 10px;
}
.info {
height: calc(100% - 120px);
box-sizing: border-box;
padding: 12px 8px 10px;
display: flex;
justify-content: space-between;
flex-direction: column;
position: relative;
.name {
color: #3a3a3a;
line-height: 17px;
}
.price {
color: var(--themeColor);
font-weight: 500;
font-size: 16px;
}
.btn{
position: absolute;
bottom: 10px;
right: 8px;
border-radius:12px ;
height: 20px;
}
}
}
}
}
</style>
\ No newline at end of file \ No newline at end of file
<template> <template>
<div> <div>
<template v-if="$route.meta.isTab"> <template v-if="$route.meta.isIndex">
<tab <tab
:list="['会员套餐','门店商品']" :list="tabList"
@change="change" @change="change"
sticky sticky
:index="tabIndex" :index="tabIndex"
:updata="updata" :updata="updata"
></tab> ></tab>
<template v-if="flag"> <template v-if="tabIndex == 0">
<template v-if="list.length"> <div class="bg-box">
<scroll-view <div class="bg">
class="list-box" <div class="item item-1"></div>
@ReachBottom="onReachBottom" <div class="item item-2"></div>
ref="scrollView" <div class="item item-3"></div>
> <div class="item item-4"></div>
<div :class="[`type-${tabIndex}`]"> </div>
<template v-for="(i,index) in list"> <div class="btn x-center text-center" @click="showShareModel()">一键分享</div>
<div </div>
:key="index" </template>
class="item" <template v-else>
> <template v-if="flag">
<template v-if="tabIndex == 0"> <template v-if="list.length">
<div class="sprite-icon icon-vip"></div> <scroll-view
<div class="info"> class="list-box"
<div> @ReachBottom="onReachBottom"
<div class="title text-hide">{{i.packageName}}</div> ref="scrollView"
<div class="decoration">价值{{i.totalMerchantPrice}}元的{{i.list.length || 0}}项权益</div> >
<div :class="[`type-${tabIndex - 1}`]">
<template v-for="(i,index) in list">
<div
:key="index"
class="item"
>
<template v-if="tabIndex == 1">
<div class="sprite-icon icon-vip"></div>
<div class="info">
<div>
<div class="title text-hide">{{i.packageName}}</div>
<div class="decoration">价值{{i.totalMerchantPrice}}元的{{i.list.length || 0}}项权益</div>
</div>
<div
class="btn text-center"
@click="showVipDialog(i)"
>
查看套餐
</div>
</div> </div>
<div <div
class="btn text-center" class="btn text-center y-center"
@click="showVipDialog(i)" @click="showShareModel(i)"
>分享给客户</div>
</template>
<template v-else>
<div
@click="showShareModel(i)"
class="goods"
> >
查看套餐 <div class="icon">
</div> <img :src="i.goodsImage || ''">
</div> </div>
<div <div class="info">
class="btn text-center y-center" <div class="name text-two-line">{{i.goodsName}}</div>
@click="showShareModel(i)" <div class="stock">库存:{{i.goodsStock}}</div>
>分享给客户</div> <template v-if="i.price">
</template> <div class="price">¥{{i.price.toFixed(2)}}</div>
<template v-else> </template>
<div @click="showShareModel(i)"> <div class="btn text-center">分享给客户</div>
<div class="icon"> </div>
<img :src="i.goodsImage || ''">
</div> </div>
<div class="info"> </template>
<div class="name text-two-line">{{i.goodsName}}</div> </div>
<template v-if="i.price"> </template>
<div class="price">¥{{i.price.toFixed(2)}}</div> </div>
</template> </scroll-view>
<div class="btn text-center">发送</div> </template>
</div> <template v-else>
<!-- <div class="sprite-icon icon-share"></div> --> <van-empty description="暂无内容" />
</div> </template>
</template>
</div>
</template>
</div>
</scroll-view>
</template>
<template v-else>
<van-empty description="暂无内容" />
</template> </template>
</template> </template>
<!-- <share
:value="showShare"
:apiName="tabIndex == 0 ?'equityApi':'shopmallApi'"
@cancel="showShare = false"
:currentItem="currentItem"
/> -->
<vip-dialog <vip-dialog
v-model="showVip" v-model="showVip"
@cancel="showVip = false" @cancel="showVip = false"
...@@ -85,17 +95,23 @@ ...@@ -85,17 +95,23 @@
<script type='text/ecmascript-6'> <script type='text/ecmascript-6'>
import { shareMixin, pageMixin } from '@/mixins' import { shareMixin, pageMixin } from '@/mixins'
import { shopmallApi, equityApi } from '@/api' import { shopmallApi, equityApi } from '@/api'
const tabList = ['我的店铺', '会员套餐', '门店商品']
export default { export default {
name: 'merchant', name: 'merchant',
mixins: [shareMixin, pageMixin], mixins: [shareMixin, pageMixin],
data() { data() {
return { return {
showVip: false, showVip: false,
equity_id: null equity_id: null,
tabList
} }
}, },
methods: { methods: {
getList_0(pageNum) { getList_0() {
this.flag = true
this.hideLoading()
},
getList_1(pageNum) {
let { list } = this let { list } = this
equityApi.getEquityList({ pageNum }).then(res => { equityApi.getEquityList({ pageNum }).then(res => {
this.flag = true this.flag = true
...@@ -104,7 +120,7 @@ export default { ...@@ -104,7 +120,7 @@ export default {
this.hideLoading() this.hideLoading()
}) })
}, },
getList_1(pageNum) { getList_2(pageNum) {
let { list } = this let { list } = this
shopmallApi.getGoodsList({ currentPage: pageNum }).then(res => { shopmallApi.getGoodsList({ currentPage: pageNum }).then(res => {
this.flag = true this.flag = true
...@@ -164,7 +180,7 @@ export default { ...@@ -164,7 +180,7 @@ export default {
margin-right: auto; margin-right: auto;
font-size: 12px; font-size: 12px;
padding: 0 10px; padding: 0 10px;
height: 20px; height: 24px;
border-radius: 39px; border-radius: 39px;
border: 1px solid #b3b3b3; border: 1px solid #b3b3b3;
box-sizing: border-box; box-sizing: border-box;
...@@ -183,16 +199,11 @@ export default { ...@@ -183,16 +199,11 @@ export default {
flex-wrap: wrap; flex-wrap: wrap;
.item { .item {
width: 164px; width: 164px;
height: 208px; height: 229px;
box-shadow: 0px 4px 8px 0px rgba(224, 224, 224, 0.5); box-shadow: 0px 4px 8px 0px rgba(224, 224, 224, 0.5);
.icon { .icon {
height: 120px; height: 120px;
} }
.icon-share {
position: absolute;
right: 10px;
bottom: 10px;
}
.info { .info {
height: calc(100% - 120px); height: calc(100% - 120px);
box-sizing: border-box; box-sizing: border-box;
...@@ -203,22 +214,79 @@ export default { ...@@ -203,22 +214,79 @@ export default {
position: relative; position: relative;
.name { .name {
color: #3a3a3a; color: #3a3a3a;
line-height: 17px; line-height: 20px;
height: 40px;
}
.stock {
font-size: 12px;
color: #a9a9a9;
} }
.price { .price {
color: var(--themeColor); color: var(--themeColor);
font-weight: 500; font-weight: 500;
font-size: 16px; font-size: 16px;
} }
.btn{ .btn {
position: absolute; position: absolute;
bottom: 10px; bottom: 10px;
right: 8px; right: 8px;
border-radius:12px ; border-radius: 12px;
height: 20px; height: 20px;
} }
} }
} }
} }
} }
.bg-box {
width: 347px;
height: 1354px;
margin: 16px 14px 0;
padding-bottom: 70px;
.bg {
width: 100%;
height: 100%;
background-image: url('https://img01.glsx.com.cn/weapp/resource/scrm-mobile/activity/merchant-bg.png');
background-size: cover;
box-sizing: border-box;
padding-top: 28px;
.item {
margin-bottom: 12px;
background-size: cover;
}
.item-1 {
width: 298px;
height: 312px;
background-image: url('https://img01.glsx.com.cn/weapp/resource/scrm-mobile/activity/merchant-1.png');
margin-left: 19px;
}
.item-2 {
width: 298px;
height: 268px;
background-image: url('https://img01.glsx.com.cn/weapp/resource/scrm-mobile/activity/merchant-2.png');
margin-left: 20px;
}
.item-3 {
width: 296px;
height: 345px;
background-image: url('https://img01.glsx.com.cn/weapp/resource/scrm-mobile/activity/merchant-3.png');
margin-left: 21px;
}
.item-4 {
width: 287px;
height: 358px;
background-image: url('https://img01.glsx.com.cn/weapp/resource/scrm-mobile/activity/merchant-4.png');
margin-left: 25px;
}
}
.btn {
position: fixed !important;
width: 343px;
height: 42px;
background: #3875c5;
border-radius: 22px;
left: 50%;
bottom: 10px;
font-size: 16px;
}
}
</style> </style>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!