Commit 8bd4b7dc by 李伟康

commit

1 parent 1d3871fb
import util from '@/utils/util'
import { Notify } from 'vant'
const IS_PROD = ['production', 'prod'].includes(process.env.NODE_ENV)
const url = '/rop-scrm-wechat/router'
const WxConfig = {
init(jsApiList) {
return new Promise((resolve, reject) => {
......@@ -17,7 +19,7 @@ const WxConfig = {
}
window
.$HTTP({
url: '/rop-scrm-wechat/router',
url,
data
})
.then(obj => {
......@@ -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() {
/**
* entry String 场景值
......@@ -107,12 +128,13 @@ const WxConfig = {
/**分享消息到当前会话 */
sendChatMessage(params) {
console.log(params)
return new Promise(resolve => {
return new Promise((resolve,reject) => {
wx.invoke('sendChatMessage', params, res => {
util.hideLoading()
console.log(res)
if (res.err_msg == 'sendChatMessage:ok') {
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
export default {
data() {
......@@ -7,7 +7,8 @@ export default {
}
},
mounted() {
if (this.$route.meta.isTab) this.wxInit()
// if (this.$route.meta.isTab || this.$route.meta.isIndex)
this.wxInit()
},
methods: {
wxInit() {
......@@ -19,10 +20,15 @@ export default {
})
})
},
showShareModel(i) {
let { tabIndex } = this
if (tabIndex == 0 && i.remainAmount < 1) return
if (tabIndex == 1 && i.residueAmount < 1) return
showShareModel(i = {}) {
let {
tabIndex,
$route: { name }
} = this
if (name != 'merchant') {
if (tabIndex == 0 && i.remainAmount < 1) return
if (tabIndex == 1 && i.residueAmount < 1) return
}
wxConfig
.getCurExternalContact()
.then(res => {
......@@ -35,10 +41,10 @@ export default {
})
},
sendMessage(i) {
let { merchantId } = this.getLocalStorage('dj_scrm_userInfo')
let { merchantId, merchantName } = this.getLocalStorage('dj_scrm_userInfo')
let { tabIndex, entry, tabList } = this
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 dj_appId = 'wx06d1198e751435d1'
this.showLoading()
......@@ -98,6 +104,30 @@ export default {
/**店铺 */
case 'merchant': {
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'
if (entry != 'normal')
this.sendChatMessage({
......@@ -139,7 +169,8 @@ export default {
.then(() => {
this.hideLoading()
})
.catch(() => {
.catch(err => {
console.log('当前会话', err)
this.hideLoading()
})
},
......
const pages = [{
const pages = [
{
name: 'coupon',
meta: {
isTab: true,
keepAlive: true,
backgroundColor: '#F7F7F7'
},
children: [{
name: 'verificationList',
meta: {
backgroundColor: '#F7F7F7'
}
}, {
name: 'verificationDetail',
meta: {
backgroundColor: '#F7F7F7'
children: [
{
name: 'verificationList',
meta: {
backgroundColor: '#F7F7F7'
}
},
{
name: 'verificationDetail',
meta: {
backgroundColor: '#F7F7F7'
}
}
}]
]
},
{
name: 'activity',
......@@ -24,26 +28,17 @@ const pages = [{
keepAlive: true,
backgroundColor: '#F7F7F7'
},
children: [
]
children: []
},
{
name: 'merchant',
meta: {
isTab: true,
keepAlive: true,
backgroundColor: '#F7F7F7'
isIndex: true,
backgroundColor: '#F7F7F7',
title: '店铺中心'
},
children: [
{
name:'goods',
meta: {
backgroundColor: '#F7F7F7',
title:'商品中心'
},
}
]
children: []
}
]
const keepAlives = []
......@@ -65,12 +60,12 @@ const setChildren = (e, parent) => {
})
return arr
}
const getPages = _ => {
const getPages = () => {
let router = {
path: '/',
name: 'home',
redirect: '/coupon',
component: resolve => require([`views/home.vue`], resolve),
component: resolve => require([`views/home.vue`], resolve)
}
router.children = pages.map(e => {
let name = `${e.name}`
......@@ -87,4 +82,4 @@ const getPages = _ => {
return [router]
}
export const keeps = keepAlives
export default getPages()
\ No newline at end of file
export default getPages()
......@@ -49,7 +49,6 @@ const showLoading = (title = '加载中...') => {
})
}
const hideLoading = () => {
console.log('清除')
Toast.clear()
}
/**num:要转换的数值,fixed:精确几位小数 */
......
......@@ -34,12 +34,6 @@ export default {
name: 'activity',
active: require('@/assets/images/tabbar/activity_active.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
<template>
<div>
<template v-if="$route.meta.isTab">
<template v-if="$route.meta.isIndex">
<tab
:list="['会员套餐','门店商品']"
:list="tabList"
@change="change"
sticky
:index="tabIndex"
:updata="updata"
></tab>
<template v-if="flag">
<template v-if="list.length">
<scroll-view
class="list-box"
@ReachBottom="onReachBottom"
ref="scrollView"
>
<div :class="[`type-${tabIndex}`]">
<template v-for="(i,index) in list">
<div
:key="index"
class="item"
>
<template v-if="tabIndex == 0">
<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>
<template v-if="tabIndex == 0">
<div class="bg-box">
<div class="bg">
<div class="item item-1"></div>
<div class="item item-2"></div>
<div class="item item-3"></div>
<div class="item item-4"></div>
</div>
<div class="btn x-center text-center" @click="showShareModel()">一键分享</div>
</div>
</template>
<template v-else>
<template v-if="flag">
<template v-if="list.length">
<scroll-view
class="list-box"
@ReachBottom="onReachBottom"
ref="scrollView"
>
<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
class="btn text-center"
@click="showVipDialog(i)"
class="btn text-center y-center"
@click="showShareModel(i)"
>分享给客户</div>
</template>
<template v-else>
<div
@click="showShareModel(i)"
class="goods"
>
查看套餐
</div>
</div>
<div
class="btn text-center y-center"
@click="showShareModel(i)"
>分享给客户</div>
</template>
<template v-else>
<div @click="showShareModel(i)">
<div class="icon">
<img :src="i.goodsImage || ''">
<div class="icon">
<img :src="i.goodsImage || ''">
</div>
<div class="info">
<div class="name text-two-line">{{i.goodsName}}</div>
<div class="stock">库存:{{i.goodsStock}}</div>
<template v-if="i.price">
<div class="price">¥{{i.price.toFixed(2)}}</div>
</template>
<div class="btn text-center">分享给客户</div>
</div>
</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 class="sprite-icon icon-share"></div> -->
</div>
</template>
</div>
</template>
</div>
</scroll-view>
</template>
<template v-else>
<van-empty description="暂无内容" />
</template>
</div>
</template>
</div>
</scroll-view>
</template>
<template v-else>
<van-empty description="暂无内容" />
</template>
</template>
</template>
<!-- <share
:value="showShare"
:apiName="tabIndex == 0 ?'equityApi':'shopmallApi'"
@cancel="showShare = false"
:currentItem="currentItem"
/> -->
<vip-dialog
v-model="showVip"
@cancel="showVip = false"
......@@ -85,17 +95,23 @@
<script type='text/ecmascript-6'>
import { shareMixin, pageMixin } from '@/mixins'
import { shopmallApi, equityApi } from '@/api'
const tabList = ['我的店铺', '会员套餐', '门店商品']
export default {
name: 'merchant',
mixins: [shareMixin, pageMixin],
data() {
return {
showVip: false,
equity_id: null
equity_id: null,
tabList
}
},
methods: {
getList_0(pageNum) {
getList_0() {
this.flag = true
this.hideLoading()
},
getList_1(pageNum) {
let { list } = this
equityApi.getEquityList({ pageNum }).then(res => {
this.flag = true
......@@ -104,7 +120,7 @@ export default {
this.hideLoading()
})
},
getList_1(pageNum) {
getList_2(pageNum) {
let { list } = this
shopmallApi.getGoodsList({ currentPage: pageNum }).then(res => {
this.flag = true
......@@ -164,7 +180,7 @@ export default {
margin-right: auto;
font-size: 12px;
padding: 0 10px;
height: 20px;
height: 24px;
border-radius: 39px;
border: 1px solid #b3b3b3;
box-sizing: border-box;
......@@ -183,16 +199,11 @@ export default {
flex-wrap: wrap;
.item {
width: 164px;
height: 208px;
height: 229px;
box-shadow: 0px 4px 8px 0px rgba(224, 224, 224, 0.5);
.icon {
height: 120px;
}
.icon-share {
position: absolute;
right: 10px;
bottom: 10px;
}
.info {
height: calc(100% - 120px);
box-sizing: border-box;
......@@ -203,22 +214,79 @@ export default {
position: relative;
.name {
color: #3a3a3a;
line-height: 17px;
line-height: 20px;
height: 40px;
}
.stock {
font-size: 12px;
color: #a9a9a9;
}
.price {
color: var(--themeColor);
font-weight: 500;
font-size: 16px;
}
.btn{
.btn {
position: absolute;
bottom: 10px;
right: 8px;
border-radius:12px ;
border-radius: 12px;
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>
\ 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!