Commit 3d81c261 by 李伟康

commit

1 parent ff5aea9f
...@@ -14,8 +14,7 @@ export default { ...@@ -14,8 +14,7 @@ export default {
data.method = 'scrm.api.shopmall.activity.get.shared' data.method = 'scrm.api.shopmall.activity.get.shared'
return window.$HTTP({ return window.$HTTP({
url, url,
data, data
returnAll: true
}) })
}, },
} }
\ No newline at end of file \ No newline at end of file
...@@ -13,8 +13,7 @@ export default { ...@@ -13,8 +13,7 @@ export default {
data.method = 'scrm.api.live.get.shared.code' data.method = 'scrm.api.live.get.shared.code'
return window.$HTTP({ return window.$HTTP({
url, url,
data, data
returnAll: true
}) })
}, },
} }
\ No newline at end of file \ No newline at end of file
...@@ -302,11 +302,13 @@ const WxConfig = { ...@@ -302,11 +302,13 @@ const WxConfig = {
// desc: '', // 分享描述 // desc: '', // 分享描述
// link: '', // 分享链接 // link: '', // 分享链接
// imgUrl: '' // 分享封面 // imgUrl: '' // 分享封面
return new Promise((resolve) => { return new Promise((resolve,reject) => {
wx.invoke("shareAppMessage", obj, wx.invoke("shareAppMessage", obj,
function(res) { function(res) {
if (res.err_msg == "shareAppMessage:ok") { if (res.err_msg == "shareAppMessage:ok") {
resolve(res)
}else{
reject(res)
} }
} }
) )
...@@ -322,7 +324,9 @@ const WxConfig = { ...@@ -322,7 +324,9 @@ const WxConfig = {
wx.invoke('shareWechatMessage', obj, wx.invoke('shareWechatMessage', obj,
function(res) { function(res) {
if (res.err_msg == 'shareWechatMessage:ok') { if (res.err_msg == 'shareWechatMessage:ok') {
resolve(res)
}else{
reject(res)
} }
} }
) )
......
...@@ -11,7 +11,6 @@ export default { ...@@ -11,7 +11,6 @@ export default {
}, },
mounted() { mounted() {
let { tabIndex } = this.getQuery() let { tabIndex } = this.getQuery()
console.log(tabIndex)
if (tabIndex) { if (tabIndex) {
this.tabIndex = Number(tabIndex) this.tabIndex = Number(tabIndex)
this.updata = new Date().getTime() this.updata = new Date().getTime()
......
import { wxConfig } from '@/api' import { shopmallApi, activityApi, couponApi, liveApi, boutiquecouponApi, equityApi, wxConfig } from '@/api'
const { environment } = window.$fetchConfig
import { Notify } from 'vant'
export default { export default {
data() { data() {
return { return {
...@@ -11,23 +13,171 @@ export default { ...@@ -11,23 +13,171 @@ export default {
}, },
methods: { methods: {
wxInit() { wxInit() {
window.$wx = wxConfig wxConfig.init(['shareAppMessage', 'sendChatMessage', 'getCurExternalContact'])
window.$wx.init(['shareAppMessage', 'sendChatMessage', 'getCurExternalContact', 'setClipboardData'])
}, },
showShareModel(i) { showShareModel(i) {
let { tabIndex } = this let { tabIndex } = this
if (tabIndex == 0 && i.remainAmount < 1) return if (tabIndex == 0 && i.remainAmount < 1) return
if (tabIndex == 1 && i.residueAmount < 1) return if (tabIndex == 1 && i.residueAmount < 1) return
window.$wx.getCurExternalContact().then(res => { wxConfig
console.log('当前外部联系人', res) .getCurExternalContact()
i.userId = res .then(res => {
this.currentItem = i console.log('当前外部联系人', res)
this.showShare = true i.is_contact = res
}).catch(err => { this.sendMessage(i)
console.log(i) })
this.currentItem = i .catch(err => {
this.showShare = true this.sendMessage(i)
})
},
sendMessage(i) {
let { merchantId } = this.getLocalStorage('dj_scrm_userInfo')
let { tabIndex } = this
let { name } = this.$route
let { is_contact, userId, id, couponName, activityName, packageName, goodsName, goodsImage } = i
let shopmall_appId = environment == 'beta' ? 'wx9f91c1ec493eb425' : 'wxe10067a63c1856ac'
let dj_appId = 'wx06d1198e751435d1'
this.showLoading()
/**is_contact 是否从侧边栏进入 */
switch (name) {
/**卡券 */
case 'coupon': {
let desc = '您的专属服务顾问为您发来了优惠券,请点击领取~'
let imgUrl = 'http://img01.glsx.com.cn/upload/biz/dracMini-yh-10004.png'
if (tabIndex == 0) {
if (is_contact)
this.sendChatMessage({
appid: dj_appId,
title: couponName,
imgUrl,
page: `/packagePersonal/pages/boutiquePages/gift/gift.html?id=${id}&userId=${userId}&employName=${this.toUnicode(i.employeeName)}`
})
else {
boutiquecouponApi.getBoutiqueCoupon({ id }).then(res => {
this.shareAppMessage(res, desc, couponName, imgUrl)
})
}
} else {
this.couponShare(i, res => {
if (is_contact)
this.sendChatMessage({
appid: shopmall_appId,
title: packageName,
imgUrl,
page: `/packageMall/pages/coupon/coupon.html?couponId=${id}&merchantId=${merchantId}`
})
else this.shareAppMessage(res, desc, couponName, imgUrl)
})
}
break
}
/**活动 */
case 'activity': {
if (tabIndex == 0) {
let imgUrl = 'http://img01.glsx.com.cn/upload/biz/dracMini-ms-10004.png'
if (is_contact)
this.sendChatMessage({
appid: shopmall_appId,
title: activityName,
imgUrl,
page: `/packageMall/pages/detail/detail.html?isActivity=true&id=${id}&merchantId=${merchantId}`
})
else {
activityApi.getShared({ id }).then(res => {
this.shareAppMessage(res, '您有一个秒杀活动可参加', activityName, imgUrl)
})
}
} else {
}
break
}
/**店铺 */
case 'merchant': {
if (tabIndex == 0) {
let imgUrl = 'http://img01.glsx.com.cn/upload/biz/dracMini-qy-10004.png'
if (is_contact)
this.sendChatMessage({
appid: shopmall_appId,
title: packageName,
imgUrl,
page: `/packageEquity/pages/package/package?id=${id}&merchantId=${merchantId}`
})
else {
equityApi.getEquityShared({ id }).then(res => {
this.shareAppMessage(res.url, '您的专属客服顾问为您发来了会员套餐,点击查看哦', packageName, imgUrl)
})
}
} else {
if (is_contact)
this.sendChatMessage({
appid: shopmall_appId,
title: goodsName,
imgUrl: goodsImage,
page: `/packageMall/pages/detail/detail.html?id=${id}&merchantId=${merchantId}`
})
else {
shopmallApi.getGoodsLink({ id }).then(res => {
this.shareAppMessage(res, '', goodsName, goodsImage)
})
}
}
break
}
}
},
sendChatMessage(params) {
wxConfig
.sendChatMessage({
msgtype: 'miniprogram',
miniprogram: params,
enterChat: false
})
.then(() => {
this.hideLoading()
})
.catch(() => {
this.hideLoading()
})
},
shareAppMessage(link, desc, title, imgUrl) {
wxConfig
.shareAppMessage({
title,
desc,
link,
imgUrl
})
.then(() => {
this.hideLoading()
})
.catch(() => {
this.hideLoading()
})
},
toUnicode(chineseStr = '') {
let unicodeStr = ''
for (let i = 0, iLength = chineseStr.length; i < iLength; i++) {
unicodeStr += '@' + chineseStr.charCodeAt(i).toString(16)
}
return unicodeStr
},
couponShare(item, callBack) {
let { userId, id } = item
let obj = {
couponId: id,
shareType: 1
}
if (userId)
obj.userList = [
{
userId
}
]
else obj.shareType = 0
couponApi.getCouponShared(obj).then(res => {
callBack(res.url)
}) })
} }
} }
}
\ No newline at end of file \ No newline at end of file
}
import Vue from 'vue' import Vue from 'vue'
import { import { Toast, Dialog } from 'vant'
Toast,
Dialog
} from 'vant'
/** /**
* 日期格式化 * 日期格式化
* let time = new Date().format('yyyy-MM-dd hh:mm:ss') * let time = new Date().format('yyyy-MM-dd hh:mm:ss')
*/ */
Date.prototype.format = function(fmt) { Date.prototype.format = function (fmt) {
let o = { let o = {
'M+': this.getMonth() + 1, //月份 'M+': this.getMonth() + 1, //月份
'd+': this.getDate(), //日 'd+': this.getDate(), //日
'h+': this.getHours(), //小时 'h+': this.getHours(), //小时
'm+': this.getMinutes(), //分 'm+': this.getMinutes(), //分
's+': this.getSeconds(), //秒 's+': this.getSeconds(), //秒
//季度 //季度
'q+': Math.floor((this.getMonth() + 3) / 3), 'q+': Math.floor((this.getMonth() + 3) / 3),
'S': this.getMilliseconds() //毫秒 S: this.getMilliseconds() //毫秒
}; }
if (/(y+)/.test(fmt)) { if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length))
} }
for (let k in o) { for (let k in o) {
if (new RegExp(`(${k})`).test(fmt)) { if (new RegExp(`(${k})`).test(fmt)) {
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length))) fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length))
} }
} }
return fmt return fmt
} }
const throttle = (fn, gapTime) => { const throttle = (fn, gapTime) => {
if (gapTime == null || gapTime == undefined) { if (gapTime == null || gapTime == undefined) {
gapTime = 1500 gapTime = 1500
} }
let _lastTime = null let _lastTime = null
return function() { return function () {
let _nowTime = +new Date() let _nowTime = +new Date()
if (_nowTime - _lastTime > gapTime || !_lastTime) { if (_nowTime - _lastTime > gapTime || !_lastTime) {
fn.apply(this, arguments) fn.apply(this, arguments)
_lastTime = _nowTime _lastTime = _nowTime
}
} }
} }
/**防止重复点击 */ }
/**防止重复点击 */
const showLoading = (title = '加载中...') => { const showLoading = (title = '加载中...') => {
Toast({ Toast({
type: 'loading', type: 'loading',
...@@ -52,27 +49,29 @@ const showLoading = (title = '加载中...') => { ...@@ -52,27 +49,29 @@ const showLoading = (title = '加载中...') => {
}) })
} }
const hideLoading = () => { const hideLoading = () => {
Toast.clear() console.log('清除')
} Toast.clear()
/**num:要转换的数值,fixed:精确几位小数 */ }
/**num:要转换的数值,fixed:精确几位小数 */
const decimal = (num, fixed) => { const decimal = (num, fixed) => {
let pow = Math.pow(10, fixed) let pow = Math.pow(10, fixed)
return Math.round(num * pow) / pow return Math.round(num * pow) / pow
} }
const showToast = (message = '', callBack) => { const showToast = (message = '', callBack) => {
let params = { hideLoading()
message, let params = {
forbidClick: true, message,
duration: 1500 forbidClick: true,
} duration: 1500
Toast(params) }
if (callBack && typeof callBack == 'function') { Toast(params)
setTimeout(() => { if (callBack && typeof callBack == 'function') {
callBack() setTimeout(() => {
}, 1500) callBack()
} }, 1500)
} }
/**触摸样式 */ }
/**触摸样式 */
const touchstart = e => { const touchstart = e => {
e.target.classList.add('btn-on-leave') e.target.classList.add('btn-on-leave')
} }
...@@ -98,28 +97,28 @@ const removeLocalStorage = key => { ...@@ -98,28 +97,28 @@ const removeLocalStorage = key => {
window.localStorage.removeItem(key) window.localStorage.removeItem(key)
} }
const dialog = (params = {}) => { const dialog = (params = {}) => {
if (!params.confirmButtonColor) params.confirmButtonColor = '#FF7336' if (!params.confirmButtonColor) params.confirmButtonColor = '#FF7336'
return Dialog.confirm(params) return Dialog.confirm(params)
} }
/**拨打电话 */ /**拨打电话 */
const makePhoneCall = phoneNumber => { const makePhoneCall = phoneNumber => {
window.location.href = `tel://${phoneNumber}` window.location.href = `tel://${phoneNumber}`
} }
/**是否全面屏 */ /**是否全面屏 */
const isFullSucreen = () => { const isFullSucreen = () => {
let result = false; let result = false
const rate = window.screen.height / window.screen.width const rate = window.screen.height / window.screen.width
let limit = window.screen.height == window.screen.availHeight ? 1.8 : 1.65 // 临界判断值 let limit = window.screen.height == window.screen.availHeight ? 1.8 : 1.65 // 临界判断值
result = rate > limit result = rate > limit
return result return result
} }
const jumpChildrenPage = (to, params) => { const jumpChildrenPage = (to, params) => {
let { name } = window.vm._route let { name } = window.vm._route
window.vm.$router.push({ name: `${name}.${to}`, params }) window.vm.$router.push({ name: `${name}.${to}`, params })
} }
/**拷贝 */ /**拷贝 */
const setClipboardData = data => { const setClipboardData = data => {
wx.setClipboardData({ wx.setClipboardData({
data, data,
...@@ -162,7 +161,6 @@ const watchPageBack = () => { ...@@ -162,7 +161,6 @@ const watchPageBack = () => {
resolve() resolve()
} }
}) })
} }
const utils = { const utils = {
removeLocalStorage, removeLocalStorage,
...@@ -193,4 +191,4 @@ const utils = { ...@@ -193,4 +191,4 @@ const utils = {
Object.keys(utils).map(key => { Object.keys(utils).map(key => {
Vue.prototype[key] = utils[key] Vue.prototype[key] = utils[key]
}) })
export default utils
\ No newline at end of file \ No newline at end of file
export default utils
...@@ -77,12 +77,12 @@ ...@@ -77,12 +77,12 @@
<van-empty description="暂无内容" /> <van-empty description="暂无内容" />
</template> </template>
</template> </template>
<share <!-- <share
:value="showShare" :value="showShare"
:apiName="tabIndex == 0 ? 'activityApi':'liveApi'" :apiName="tabIndex == 0 ? 'activityApi':'liveApi'"
@cancel="showShare = false" @cancel="showShare = false"
:currentItem="currentItem" :currentItem="currentItem"
/> /> -->
</template> </template>
<template v-else> <template v-else>
<router-view></router-view> <router-view></router-view>
...@@ -94,16 +94,13 @@ ...@@ -94,16 +94,13 @@
import { shareMixin, pageMixin } from '@/mixins' import { shareMixin, pageMixin } from '@/mixins'
import { activityApi, liveApi } from '@/api' import { activityApi, liveApi } from '@/api'
export default { export default {
name: '', name: 'activity',
mixins: [shareMixin, pageMixin], mixins: [shareMixin, pageMixin],
data() { data() {
return { return {
tabList: ['秒杀活动'] tabList: ['秒杀活动']
} }
}, },
mounted() {},
activated() {},
deactivated() {},
methods: { methods: {
getList_0(pageNum) { getList_0(pageNum) {
let { list } = this let { list } = this
......
...@@ -59,12 +59,12 @@ ...@@ -59,12 +59,12 @@
<van-empty description="暂无内容" /> <van-empty description="暂无内容" />
</template> </template>
</template> </template>
<share <!-- <share
:value="showShare" :value="showShare"
:apiName="tabIndex == 0?'boutiquecouponApi':'couponApi'" :apiName="tabIndex == 0?'boutiquecouponApi':'couponApi'"
@cancel="showShare = false" @cancel="showShare = false"
:currentItem="currentItem" :currentItem="currentItem"
/> /> -->
</template> </template>
<template v-else> <template v-else>
<router-view></router-view> <router-view></router-view>
...@@ -76,20 +76,11 @@ ...@@ -76,20 +76,11 @@
import { shareMixin, pageMixin, discountTypeMixin } from '@/mixins' import { shareMixin, pageMixin, discountTypeMixin } from '@/mixins'
import { couponApi, boutiquecouponApi } from '@/api' import { couponApi, boutiquecouponApi } from '@/api'
export default { export default {
name: '', name: 'coupon',
mixins: [shareMixin, pageMixin, discountTypeMixin], mixins: [shareMixin, pageMixin, discountTypeMixin],
data() { data() {
return {} return {}
}, },
activated() {
console.log('卡券activated')
this.watchPageBack().then(() => {
console.log('子页面返回')
})
},
deactivated() {
console.log('离开卡券页')
},
mounted() {}, mounted() {},
methods: { methods: {
getList_0(pageNum) { getList_0(pageNum) {
......
...@@ -64,12 +64,12 @@ ...@@ -64,12 +64,12 @@
<van-empty description="暂无内容" /> <van-empty description="暂无内容" />
</template> </template>
</template> </template>
<share <!-- <share
:value="showShare" :value="showShare"
:apiName="tabIndex == 0 ?'equityApi':'shopmallApi'" :apiName="tabIndex == 0 ?'equityApi':'shopmallApi'"
@cancel="showShare = false" @cancel="showShare = false"
:currentItem="currentItem" :currentItem="currentItem"
/> /> -->
<vip-dialog <vip-dialog
v-model="showVip" v-model="showVip"
@cancel="showVip = false" @cancel="showVip = false"
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
import { shareMixin, pageMixin } from '@/mixins' import { shareMixin, pageMixin } from '@/mixins'
import { shopmallApi, equityApi } from '@/api' import { shopmallApi, equityApi } from '@/api'
export default { export default {
name: '', name: 'merchant',
mixins: [shareMixin, pageMixin], mixins: [shareMixin, pageMixin],
data() { data() {
return { return {
...@@ -94,9 +94,6 @@ export default { ...@@ -94,9 +94,6 @@ export default {
equity_id: null equity_id: null
} }
}, },
mounted() {},
activated() {},
deactivated() {},
methods: { methods: {
getList_0(pageNum) { getList_0(pageNum) {
let { list } = this let { list } = this
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!