Commit 32ed831d by 匡雅琴

埋点

1 parent 8bb53f92
import { preReleaseAppId } from '~/config' import { preReleaseAppId } from '~/config'
const target = ['ip', 'dev', 'uat', 'prod', 'preRelease'] const target = ['ip', 'dev', 'uat', 'prod', 'preRelease']
let index = 2 let index = 1
/** /**
* *
......
// import api from '~/utils/request/request'
import api from '../request/http'
// const { appId } = wx.getAccountInfoSync().miniProgram
import {
appId
} from '~/utils/constantData'
// console.log(appId, 'appId')
let loginCount = null,
loginCache = null,
loginTimer = null
class UsersApi {
/**调用后台接口获取用户信息 */
async login() {
const appEnter = wx.getEnterOptionsSync()
try {
if (appEnter.scene === 1154 && appEnter.mode === 'singlePage') throw 'login:fail rejected due to no permission currently'
if (!loginCount) {
loginCache = null
loginCount = Date.now()
const {
code
} = await this.getWxCode(),
data = await api.post({
method: 'scrm.api.sso.weapp.jscode.login',
appId,
code,
delSessionId: true
},
true
)
loginCache = data
loginCount = null
return Promise.resolve(data)
} else {
return new Promise((resolve) => {
loginTimer = setInterval(() => {
if (loginCache) {
clearInterval(loginTimer)
loginCount = null
resolve(loginCache)
}
}, 1e3)
})
}
} catch (error) {
if (loginTimer) clearInterval(loginTimer)
loginCount = null
return Promise.reject(error)
}
}
/**调用接口获取登录凭证(code)。通过凭证进而换取用户登录态信息,包括用户在当前小程序的唯一标识(openid)、微信开放平台帐号下的唯一标识(unionid,若当前小程序已绑定到微信开放平台帐号)及本次登录的会话密钥(session_key)等。用户数据的加解密通讯需要依赖会话密钥完成。 */
getWxCode() {
return new Promise((resolve, reject) => {
wx.login({
success: res => resolve(res),
fail: err => reject(err)
})
})
}
/**授权手机号 */
async authUserPhone(detail, sessionId) {
if (!sessionId) {
wx.$api.showToast('缺少sessionId')
Promise.reject({
errMsg: '缺少sessionId'
})
}
if (detail.errMsg && detail.errMsg == 'getPhoneNumber:fail user deny') Promise.reject()
delete detail.errMsg
if (detail.iv && detail.encryptedData) {
wx.$api.showLoading()
detail.sessionId = sessionId
wx.p.storage.rm('userInfo')
wx.p.storage.rm('sessionId')
return api.post({
method: 'scrm.api.sso.weapp.auth.phone',
...detail
},
true
)
} else Promise.reject(detail.errMsg)
}
/**更新客户手机号 */
updataCustomerPhone() {
let customerId = wx.p.storage.get('srcm_shopmall_customer_id'),
merchantId = wx.p.storage.get('srcm_shopmall_merchant_id')
api
.post({
method: 'scrm.api.sso.weapp.mark.phone',
customerId,
merchantId
})
.then(() => {
wx.p.storage.rm('srcm_shopmall_customer_id')
})
}
/**调用后台接口获取用户信息js_code换取sessionId */
async wxCodeLogin() {
const appEnter = wx.getEnterOptionsSync()
try {
if (appEnter.scene === 1154 && appEnter.mode === 'singlePage') throw 'login:fail rejected due to no permission currently'
const {
code
} = await this.getWxCode()
return await api.post({
method: 'scrm.api.sso.wechat.applets.jscode.login',
appId,
code
},
true
)
} catch (error) {
return Promise.reject(error)
}
}
register(data = {}) {
return api.post({
method: 'scrm.api.sso.wechat.account.register',
...data,
platformEntrance: 'STORE_ASSISTANT'
},
true
)
}
/**退出登录 */
logout() {
return api.post({
method: 'scrm.api.sso.wechat.applets.logout'
},
true
)
}
/**授权手机号登录 */
async authStorePhone(detail, loginToken) {
if (!loginToken) {
wx.$api.showToast('缺少loginToken')
Promise.reject({
errMsg: '缺少loginToken'
})
return
}
if (detail.errMsg && detail.errMsg == 'getPhoneNumber:fail user deny') Promise.reject()
delete detail.errMsg
if (detail.iv && detail.encryptedData) {
detail.loginToken = loginToken
return api.post({
method: 'scrm.api.sso.wechat.applets.auth.phone',
...detail,
platformEntrance: 'STORE_ASSISTANT' // 平台标识:生意助手-BUSINESS_ASSISTANT,门店助手-STORE_ASSISTANT
},
true
)
} else Promise.reject(detail.errMsg)
}
/**账号密码登录 */
accountLogin(data = {}) {
return api.post({
method: 'scrm.api.sso.wechat.applets.password.login',
...data,
platformEntrance: 'STORE_ASSISTANT'
},
true
)
}
/** 手机号获取短信验证码 */
getSmsCode(mobile) {
return api.post({
method: 'scrm.api.sso.wechat.applets.sms.get.code',
mobile
},
true
)
}
/** 手机号短信验证码登录 */
phoneSmsLogin(data = {}) {
return api.post({
method: 'scrm.api.sso.wechat.applets.sms.login',
...data,
source: 'MINIAPP',
platformEntrance: 'STORE_ASSISTANT'
},
true
)
}
/** 获取登录账号列表 */
getAccountList(sessionId) {
return api.post({
method: 'scrm.api.sso.wechat.applets.listSelectAccount',
platformEntrance: 'STORE_ASSISTANT',
sessionId
},
true
)
}
/**
* 选择账号登录(手机绑定多个账号时) */
selectAccountLogin(data) {
return api.post({
method: 'scrm.api.sso.wechat.applets.selectAccountLogin',
platformEntrance: 'STORE_ASSISTANT',
...data
},
true
)
}
/**检查sessionId 是否过期 */
checkSession(data = {}) {
return api.post({
method: 'scrm.api.sso.login.status.check',
...data
},
true
)
}
/**获取微信用户信息 */
async getWXUserInfo() {
let wx_user_info = wx.p.storage.get('wx_user_info')
if (!wx_user_info) {
try {
const data = await this.getUserProfile()
wx.p.storage.set('wx_user_info', data)
return data
} catch (error) {
return {}
}
} else return wx_user_info
}
/** 手机号授权解析(单纯解析内容返回前端)
* 只传loginToken就返回unionId和openid
* 传加密信息就解析手机号
*/
async getUserProfile(loginToken, detail = {}) {
if (detail.errMsg && detail.errMsg == 'getPhoneNumber:fail user deny') Promise.reject()
delete detail.errMsg
if (!loginToken) {
let res = await this.wxCodeLogin()
loginToken = res.data
}
detail.loginToken = loginToken
return api.post({
method: 'scrm.api.sso.wechat.applets.phone.grant.analysis',
...detail,
platformEntrance: 'STORE_ASSISTANT'
})
}
/**微信登录检查是否有门店账号
* single ? 手机号 : 加密信息
*
*/
checkUserPhone(data, single) {
const method = single ? 'scrm.api.sso.user.login.account.isStaffPhone' : 'scrm.api.sso.wechat.check.phone.have.store.assistant.account'
return api.post({
method,
...data,
}, true)
}
/**更新C端用户信息 */
//
async updateUserInfo(userInfo) {
try {
const {
openId,
unionId
} = await this.getWXUserInfo()
userInfo.openId = openId
userInfo.appId = appId
userInfo.unionId = unionId
return api.post({
method: 'scrm.api.wechat.auth.userProfile.updateUserInfo',
userInfo
})
} catch (error) {
return Promise.reject()
}
}
/**
* 选择账号登录(手机绑定多个账号时) */
selectAccountLoginByPassword(data) {
return api.post({
method: 'scrm.api.sso.wechat.applets.password.selectAccountLogin',
platformEntrance: 'STORE_ASSISTANT',
...data
},
true
)
}
/*
*C端手机号短信登录
*/
phoneLogin(data) {
return api.post({
method: 'scrm.api.sso.weapp.auth.phone.mini',
source: 'MINIAPP',
...data
}, true)
}
}
export default UsersApi
\ No newline at end of file \ No newline at end of file
import UsersApi from './UsersApi.js'
export default new UsersApi()
\ No newline at end of file \ No newline at end of file
...@@ -487,7 +487,7 @@ Page({ ...@@ -487,7 +487,7 @@ Page({
}) })
}, },
requestSubscribeMessage() { requestSubscribeMessage() {
let systemInfo = wx.$storage.get('system_info') let systemInfo = wx.p.storage.get('system_info')
if (systemInfo && systemInfo.environment != 'wxwork') { if (systemInfo && systemInfo.environment != 'wxwork') {
wx.p.router.go('/packageMine/pages/order/complete/complete', { wx.p.router.go('/packageMine/pages/order/complete/complete', {
success: true, success: true,
......
...@@ -39,7 +39,7 @@ Page({ ...@@ -39,7 +39,7 @@ Page({
item_type, item_type,
view view
} = query } = query
const userInfo = wx.$util.getUserInfo() || {}, const userInfo = wx.p.cache.userInfo.getUserInfo() || {},
{ {
openId openId
} = await USERAPI.getWXUserInfo() } = await USERAPI.getWXUserInfo()
...@@ -50,11 +50,11 @@ Page({ ...@@ -50,11 +50,11 @@ Page({
item_type, item_type,
customer_phone: userInfo.phone || null, customer_phone: userInfo.phone || null,
action_type: view, action_type: view,
staff_uuid: wx.$storage.get('scrm_shopmall_staff_uuid'), staff_uuid: wx.p.storage.get('scrm_shopmall_staff_uuid'),
item_id: id, item_id: id,
business_type: 1, business_type: 1,
add_way: 104, add_way: 104,
merchant_id: wx.$storage.get('srcm_shopmall_merchant_id'), merchant_id: wx.p.storage.get('srcm_shopmall_merchant_id'),
guest_no: wx.$Track.getGuestNo(), //游客ID, guest_no: wx.$Track.getGuestNo(), //游客ID,
user_open_id:this.shareOpenId || '' user_open_id:this.shareOpenId || ''
} }
...@@ -457,13 +457,13 @@ Page({ ...@@ -457,13 +457,13 @@ Page({
options.action_type = 1 options.action_type = 1
options.item_id = options.id options.item_id = options.id
wx.$util.reportData(options, false, false, true) wx.$util.reportData(options, false, false, true)
wx.$storage.set('shareStaff', JSON.stringify(shareStaff)) wx.p.storage.set('shareStaff', JSON.stringify(shareStaff))
wx.$storage.set('shareStaffTracker', JSON.stringify(options)) wx.p.storage.set('shareStaffTracker', JSON.stringify(options))
} }
// 埋点 // 埋点
if (options.activity_id) { if (options.activity_id) {
this.data.options = options this.data.options = options
wx.$storage.set('miaoshatrack', encodeURIComponent(JSON.stringify(options))) wx.p.storage.set('miaoshatrack', encodeURIComponent(JSON.stringify(options)))
wx.$util.reportData(options, true, false) wx.$util.reportData(options, true, false)
} }
// 配置升级 // 配置升级
...@@ -491,7 +491,7 @@ Page({ ...@@ -491,7 +491,7 @@ Page({
const [key, val] = item.split('=') const [key, val] = item.split('=')
op[key] = val op[key] = val
}) })
if (op.merchantId) wx.$storage.set('srcm_shopmall_merchant_id', op.merchantId) if (op.merchantId) wx.p.storage.set('srcm_shopmall_merchant_id', op.merchantId)
if (op.isActivity) { if (op.isActivity) {
this.setData({ this.setData({
isActivity: true isActivity: true
...@@ -810,8 +810,8 @@ Page({ ...@@ -810,8 +810,8 @@ Page({
* 用户点击右上角分享 * 用户点击右上角分享
*/ */
onShareAppMessage: function () { onShareAppMessage: function () {
const merchantId = wx.$storage.get('srcm_shopmall_merchant_id') const merchantId = wx.p.storage.get('srcm_shopmall_merchant_id')
const userInfo = wx.$util.getUserInfo() const userInfo = wx.p.cache.userInfo.getUserInfo()
let { let {
isActivity, isActivity,
isLive, isLive,
......
...@@ -84,7 +84,8 @@ Page({ ...@@ -84,7 +84,8 @@ Page({
}) })
}, },
getAllMerchantList() { getAllMerchantList() {
let merchantId = wx.$storage.get('srcm_shopmall_merchant_id') // let merchantId = wx.p.storage.get('srcm_shopmall_merchant_id')
let merchantId = wx.$merchant_id
let para = { let para = {
merchantId merchantId
} }
...@@ -119,7 +120,7 @@ Page({ ...@@ -119,7 +120,7 @@ Page({
} else if (item.supplier == 'GL_ROAD_RESCUE') { } else if (item.supplier == 'GL_ROAD_RESCUE') {
url = '/packageShopmall/packageEquity/pages/road/index/index' url = '/packageShopmall/packageEquity/pages/road/index/index'
} else if (item.supplier == 'EDJ') { } else if (item.supplier == 'EDJ') {
let para = wx.$storage.get('edjurl') || '' let para = wx.p.storage.get('edjurl') || ''
para = encodeURIComponent(para) para = encodeURIComponent(para)
url = '/pages/webView/webView?url=' + para url = '/pages/webView/webView?url=' + para
} else if (item.appearance == 1) { } else if (item.appearance == 1) {
......
{
"navigationBarTitleText": "权益中心",
"usingComponents": {
"coupons-list": "../components/couponsList/index"
}
}
\ No newline at end of file \ No newline at end of file
page {
background: white;
}
.goods_scroll_wrapper {
padding: 46rpx 0 40rpx 40rpx;
position: relative;
overflow: hidden;
white-space: nowrap;
}
.scroll_element {
width: 288rpx;
height: 380rpx;
border-radius: 16rpx;
border: 2rpx solid #FFFFFF;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
margin-right: 10rpx;
display: inline-block;
position: relative;
vertical-align: top;
}
.image_icon_wrapper {
position: relative;
}
.image_icon {
width: 288rpx;
height: 178rpx;
border-radius: 16rpx 16rpx 0 0;
}
.image_vip {
position: absolute;
right: 0rpx;
top: 0rpx;
width: 120rpx;
height: 28rpx;
}
.vip_text {
position: absolute;
right: 16rpx;
top: 0rpx;
z-index: 3;
font-size: 20rpx;
font-weight: 500;
color: #FFFFFF;
}
.element_title {
box-sizing: border-box;
padding: 18rpx 14rpx 0 18rpx;
min-height: 88rpx;
font-size: 32rpx;
font-weight: 400;
color: #999999;
line-height: 44rpx;
white-space: pre-wrap;
text-overflow: -o-ellipsis-lastline;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
line-clamp: 2;
-webkit-box-orient: vertical;
}
.element_sale_price {
box-sizing: border-box;
padding: 10rpx 0 0 18rpx;
display: flex;
font-size: 40rpx;
font-weight: 600;
color: #999999;
line-height: 56rpx;
/* align-items: flex-end; */
}
.price_min_icon {
font-size: 24rpx;
font-weight: 400;
line-height: 60rpx;
margin-right: 6rpx;
}
.element_o_price {
font-size: 24rpx;
font-weight: 400;
line-height: 34rpx;
text-decoration: line-through;
box-sizing: border-box;
/* padding: 0 0 0 18rpx; */
color: #999999;
position: absolute;
left: 18rpx;
bottom: 4rpx;
}
.scroll_element_active {
box-shadow: 0px 4rpx 8rpx 0px #ffebe6;
border: 2rpx solid #fc5b32;
}
.selected {
color: #fc5b32;
}
.selected1 {
color: #282829;
font-size: 500;
}
.flex_cc {
display: flex;
align-items: center;
justify-content: center;
}
.more_btn {
width: 80rpx;
height: 348rpx;
background: rgba(228, 228, 228, 0.95);
border-radius: 12rpx;
position: absolute;
right: 0;
top: 56rpx;
font-size: 28rpx;
font-weight: 600;
color: #666666;
line-height: 40rpx;
flex-direction: column;
}
.roate {
width: 0;
height: 0;
border-right: 10rpx solid transparent;
border-left: 10rpx solid transparent;
border-top: 10rpx solid #666666;
margin-top: 20rpx;
}
.goods_desc_wrapper {
box-sizing: border-box;
padding: 0 40rpx;
}
.line_wrapper {
border-bottom: 2rpx solid #DEDEDE;
padding: 28rpx 0;
display: flex;
align-items: center;
justify-content: space-between;
}
.line_label {
font-size: 28rpx;
font-weight: 500;
color: #282829;
line-height: 40rpx;
display: flex;
align-items: center;
}
.line_label > .logo{
width: 40rpx;
height: 40rpx;
margin-right: 8rpx;
}
.line_tip {
font-size: 24rpx;
font-weight: 400;
color: #717171;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
margin-left: 16rpx;
width: 350rpx;
}
.line_con {
font-size: 24rpx;
font-weight: 400;
color: #656566;
}
.line_con > .logo {
width: 16rpx;
height: 24rpx;
margin-left: 8rpx;
}
.line_icon {
width: 40rpx;
height: 40rpx;
margin-left: 10rpx;
}
.class1 {
font-size: 28rpx;
font-weight: 400;
color: #666666;
}
.class2 {
font-size: 28rpx;
font-weight: 400;
color: #F13C3D;
}
.class3 {
display: flex;
align-items: center;
font-size: 28rpx;
font-weight: 400;
color: #666666;
}
.class4 {
color: #FC5B32;
font-weight: 500;
}
.class5{
font-weight: 400;
color: #F10016;
}
.class6{
font-weight: 600;
font-size: 40rpx;
color: #FC5B32;
}
.rich_title {
margin-top: 30rpx;
padding-left: 40rpx;
display: flex;
align-items: center;
margin-bottom: 18rpx;
}
.title_icon {
width: 6rpx;
height: 32rpx;
background: #FC5B32;
}
.title_text {
font-size: 32rpx;
font-weight: 600;
color: #282829;
margin-left: 16rpx;
}
.rich_wrapper {
padding: 0 40rpx;
}
.rich_text {
font-size: 28rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #282829 !important;
line-height: 44rpx;
background: white !important;
}
.fixed_btn {
position: fixed;
left: 0;
right: 0;
bottom: 0;
min-height: 100rpx;
display: flex;
align-items: center;
justify-content: space-between;
background: white;
box-sizing: border-box;
padding: 0 32rpx 0 90rpx;
}
.buy_btn {
width: 468rpx;
height: 80rpx;
background: #FC5B32;
border-radius: 200rpx;
font-size: 28rpx;
font-weight: 600;
color: #FFFFFF;
}
.icon_text {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.card_icon {
width: 52rpx;
height: 52rpx;
}
.card_text {
font-size: 24rpx;
font-weight: 400;
color: #666666;
line-height: 34rpx;
}
.disableBtn {
background-color: #999 !important;
}
.noStorck {
padding: 28rpx 0;
font-size: 32rpx;
font-weight: 600;
color: #fc5b32;
background: rgba(252, 91, 50, 0.2);
}
.overlay {
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, .7);
z-index: 999;
}
.overlay_boxs {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
}
.box_body {
width: 72%;
height: 612rpx;
display: flex;
flex-direction: column;
align-items: center;
}
.boxs_icon {
width: 288rpx;
height: 60rpx;
margin: 0 auto;
}
.boxs_content {
border-radius: 8rpx;
height: 438rpx;
position: relative;
width: 100%;
}
.box_title {
position: absolute;
left: 50%;
top: 0;
transform: translate(-50%, 0);
height: 56rpx;
width: 320rpx;
background-image: linear-gradient(142deg, #ffead1 0%, #e6bb8a 100%);
border-radius: 36rpx;
z-index: 1;
text-align: center;
line-height: 56rpx;
}
.box_title_text::before {
content: "";
position: absolute;
top: 50%;
left: -70%;
transform: translate(0, -50%);
width: 62rpx;
height: 2rpx;
background: #683800;
}
.box_title_text {
color: #683800;
font-size: 28rpx;
position: relative;
}
.box_title_text::after {
content: "";
position: absolute;
top: 50%;
right: -70%;
transform: translate(0, -50%);
width: 62rpx;
height: 2rpx;
background: #683800;
}
.box_container {
position: absolute;
left: 0;
right: 0;
bottom: 0;
height: 410rpx;
background: #ffffff;
width: 100%;
border-radius: 8px;
}
.box_content_text {
width: 100%;
box-sizing: border-box;
padding: 68rpx 48rpx 40rpx 48rpx;
font-size: 28rpx;
color: #606060;
line-height: 56rpx;
}
.info_diff{
color: #333;
font-size: 28rpx;
text-align: center;
text-align: center;
}
.info_open_btn{
color: #19c34e;
font-size: 24rpx;
text-decoration: underline;
margin-top: 6rpx;
text-align: center;
}
.box_btn_groups {
position: absolute;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 88rpx;
display: flex;
border-top: 2px solid #e5e5e5;
}
.btn_wrap {
text-align: center;
line-height: 88rpx;
color: #333333;
font-size: 28rpx;
width: 50%;
}
.dr_line {
position: absolute;
left: 50%;
top: 0;
bottom: 0;
width: 1px;
transform: translate(-50%, 0);
background: #e5e5e5;
}
.spc_text {
color: #ee6723;
}
.bottom_modal {
position: absolute;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 80%;
background: white;
display: flex;
flex-direction: column;
}
.bottom_title_wrapper {
position: absolute;
left: 0;
right: 0;
top: 0;
width: 100%;
height: 88rpx;
display: flex;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
padding: 0 40rpx;
background: white;
z-index: 1000;
}
.title_label {
font-size: 32rpx;
color: #282829;
}
.bottom_scoll_wrap {
width: 100%;
height: calc(100% - 19rpx);
overflow: hidden;
overflow-y: scroll;
box-sizing: border-box;
padding: 20rpx;
}
.bottem_item_width {
width: 224rpx;
}
.bottem_item_title_height {
height: 98rpx;
}
.check_icon_sty {
width: 36rpx;
height: 36rpx;
position: absolute;
right: 20rpx;
bottom: 20rpx;
}
.check_icon_sty_max {
position: absolute;
right: 20rpx;
bottom: 45rpx;
}
\ No newline at end of file \ No newline at end of file
import USERAPI from '~/api/usersApi/index'
Page({ Page({
data: { data: {
strategyDetailObj: {}, strategyDetailObj: {},
}, },
onLoad(options) { onLoad(options) {
console.log(options);
this.getStrategyDetail(options.id); this.getStrategyDetail(options.id);
// 触发埋点
this.heartbeatFn({
id: options.id,
item_type: 1,
view: 1
})
}, },
getStrategyDetail(id) { getStrategyDetail(id) {
wx.p.api.strategyApi wx.p.api.strategyApi
...@@ -18,4 +24,94 @@ Page({ ...@@ -18,4 +24,94 @@ Page({
}); });
}); });
}, },
/**添加埋点开始 */
/**
* 商品-活动id,
* 物品类型item_type 1 商品 3活动,
* view 动作类型 1浏览 4分享 5离开页面 6心跳
* */
async addTrack(query) {
const {
id,
item_type,
view
} = query
const userInfo = wx.p.cache.userInfo.getUserInfo() || {},
{
openId
} = await USERAPI.getWXUserInfo()
let data = {
open_id: openId || null,
create_time: this.firstEnter ? this.data.enter_time : new Date().format('yyyy-MM-dd hh:mm:ss'), // 离开时间
enter_time: this.data.enter_time, // 进入时间
item_type,
customer_phone: userInfo.phone || null,
action_type: view,
staff_uuid: wx.p.storage.get('scrm_shopmall_staff_uuid'),
item_id: id,
business_type: 1,
add_way: 104,
merchant_id: wx.p.storage.get('srcm_shopmall_merchant_id'),
guest_no: wx.$Track.getGuestNo(), //游客ID,
user_open_id:this.shareOpenId || ''
}
this.firstEnter = false
const jsonList = [JSON.stringify(data)]
const res = await wx.p.api.shopmallApi.trackHttp({
jsonList
})
},
heartbeatFn(query) {
this.trackQuery = query
this.addTrack(query)
this.timer = setInterval(() => {
this.trackQuery.view = 6
this.addTrack(this.trackQuery)
}, 60 * 1e3)
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
if (this.timer) clearInterval(this.timer)
this.trackQuery.view = 5
this.addTrack(this.trackQuery)
wx.$util.customerbehavior(2)
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
const merchantId = wx.p.storage.get('srcm_shopmall_merchant_id')
const userInfo = wx.p.cache.userInfo.getUserInfo()
let {
isActivity,
isLive,
goodsInfo
} = this.data,open_id = ''
this.trackQuery.view = 4
this.addTrack(this.trackQuery)
if(userInfo)open_id = userInfo.openId
let title = goodsInfo.goodsName
let path = `${this.route}?id=${goodsInfo.id}&openId=${open_id}`
let imageUrl = ''
goodsInfo.goodsDetailImageList.map(e => {
if (e.resType == 1 && !imageUrl) imageUrl = e.content
})
if (isActivity) {
title = goodsInfo.activityName
path = `${path}&isActivity=true`
}
if (isLive) path = `${path}&isLive=true`
if (merchantId) path = `${path}&merchantId=${merchantId}&isUpgrade=${this.isUpgrade || false}&isCarOwner=${this.isCarOwner || false}`
return {
imageUrl,
title,
path
}
},
}); });
const baseUrl = 'https://img01.glsx.com.cn/weapp/resource/equity-h5-new/mini/'
// import {componentsMixin} from '../../mixins/index'
Component({
// behaviors: [componentsMixin],
/**
* 组件的属性列表
*/
properties: {
businessInfo: Object,
address: Object
},
/**
* 组件的初始数据
*/
data: {
errImage:baseUrl+'loading_icon.gif',
curErrorIndex:-1,
IMGURL:wx.$imgUrl
},
/**
* 组件的方法列表
*/
methods: {
toDetail() {
const { businessInfo, address } = this.data
let query = {
supplier: businessInfo.supplier,
brandName: businessInfo.brandName,
lat: address.location.lat,
lng: address.location.lng,
}
const temp = JSON.stringify(query)
wx.navigateTo({
url: '/packageSaveMoney/pages/detail/detail?param=' + temp
})
},
toDetailPage(e) {
const { item } = e.currentTarget.dataset
const { businessInfo, address } = this.data
let query = {
supplier: businessInfo.supplier,
brandName: businessInfo.brandName,
lat: address.location.lat,
lng: address.location.lng,
id: item.id
}
const temp = JSON.stringify(query)
wx.navigateTo({
url: '/packageSaveMoney/pages/detail/detail?param=' + temp
})
},
// 图片报错
binderror(e){
// const {index} = e.currentTarget.dataset
// let {businessInfo,errImage} = this.data
// businessInfo.couponsGoodsList[index].goodsImage = errImage
// this.setData({
// businessInfo
// })
},
// 打开地图
openMap() {
const { businessInfo } = this.data
wx.openLocation({
latitude: parseFloat(businessInfo.lat),
longitude: parseFloat(businessInfo.lng),
address: businessInfo.localAddress
})
},
}
})
\ No newline at end of file \ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
<view class="element_wrapper" catchtap="toDetail">
<view class="header_wrap">
<image webp class="header_icon" src="{{businessInfo.icon}}" />
<view class="header_desc">
<view class="desc_title_wrap">
<view class="desc_title hide-text">{{businessInfo.localShopName}}</view>
<view class="latest_sign">最近</view>
</view>
<view class="desc_address">
<view class="address_text hide-text">{{businessInfo.localAddress}}</view>
<view class="flex_sc" catchtap="openMap">
<view class="address_line"></view>
<view class="address_num">{{businessInfo.localAddressDistance}}km</view>
<image webp class="address_icon" src="{{IMGURL}}equity/scrm_loca_icon_new.png?v={{img_version}}" />
</view>
</view>
</view>
</view>
<view class="scroll_wrap">
<scroll-view scroll-x="{{true}}" style="height:216rpx">
<block wx:for="{{businessInfo.couponsGoodsList}}" wx:key="index">
<view class="scroll_item" data-item="{{item}}" catchtap="toDetailPage">
<view wx:if="{{!item.noMemberPrice}}" class="vip_sign flex_ccc">
<view class="vip_text">会员专属</view>
<image webp class="vip_icon" src="{{IMGURL}}equity/member.png?v={{img_version}}" />
</view>
<image webp bind:error="binderror" data-index="{{index}}" class="item_banner" src="{{item.goodsImage}}" />
<view class="item_text">
<view class="color_text"><text class="min_color_text">¥</text>{{item.salesPrice}}</view>
<view class="line_color_text">¥{{item.lineationPrice}}</view>
</view>
</view>
</block>
</scroll-view>
</view>
</view>
\ No newline at end of file \ No newline at end of file
.element_wrapper {
background: #FFFFFF;
height: 376rpx;
box-shadow: 0px 4rpx 16rpx 0px rgba(239, 240, 242, 1);
border-radius: 8rpx;
border: 1rpx solid #EFF0F2;
margin-bottom: 20rpx;
}
.header_wrap {
display: flex;
justify-content: space-between;
box-sizing: border-box;
padding: 32rpx 32rpx 0 32rpx;
}
.header_icon {
width: 82rpx;
height: 82rpx;
border-radius: 50%;
background: #FA8A59;
}
.header_desc {
width: calc(100% - 82rpx);
box-sizing: border-box;
padding-left: 22rpx;
}
.desc_title_wrap {
display: flex;
align-items: center;
}
.desc_title {
font-size: 28rpx;
font-weight: 600;
color: #282829;
line-height: 40rpx;
max-width: 392rpx;
}
.desc_address {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 8rpx;
width: 100%;
}
.address_text {
font-size: 24rpx;
font-weight: 400;
color: #656566;
line-height: 34rpx;
}
.address_line {
width: 2rpx;
height: 24rpx;
opacity: 0.24;
margin-right: 12rpx;
background-color: #656566;
}
.address_num {
font-size: 24rpx;
font-weight: 400;
color: #656566;
line-height: 34rpx;
}
.address_icon {
width: 40rpx;
height: 40rpx;
background: linear-gradient(129deg, #FFC08B 0%, #FA8A59 100%);
border-radius: 50%;
margin-left: 12rpx;
}
.hide-text {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.latest_sign {
border-radius: 4rpx;
border: 2rpx solid #FC5B32;
padding: 6rpx 8rpx;
font-size: 20rpx;
font-weight: 400;
color: #FC5B32;
margin-left: 14rpx;
}
.scroll_wrap {
margin-top: 26rpx;
box-sizing: border-box;
padding: 0 2rpx 20rpx 32rpx;
overflow: hidden;
white-space: nowrap;
vertical-align: top;
}
.scroll_item {
width: 256rpx;
height: 216rpx;
display: inline-block;
margin-right: 20rpx;
position: relative;
}
.vip_sign {
position: absolute;
right: 0;
top: 0;
width: 120rpx;
height: 28rpx;
}
.vip_icon {
width: 120rpx;
height: 28rpx;
position: absolute;
right: 0;
top: 0;
z-index: 2;
}
.vip_text {
position: relative;
z-index: 3;
font-size: 20rpx;
font-weight: 500;
color: #FFFFFF;
}
.item_banner {
width: 256rpx;
height: 158rpx;
border-radius: 16rpx;
}
.item_text {
display: flex;
align-items: flex-end;
justify-content: center;
}
.color_text {
font-size: 36rpx;
font-weight: 600;
color: #FC5B32;
}
.min_color_text {
font-size: 24rpx;
font-weight: 400;
}
.line_color_text {
font-size: 24rpx;
font-weight: 400;
color: #666666;
text-decoration: line-through;
margin-left: 10rpx;
padding-bottom: 5rpx;
}
.flex_sc {
display: flex;
align-items: center;
}
.flex_ccc {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
\ No newline at end of file \ No newline at end of file
...@@ -35,6 +35,34 @@ Page({ ...@@ -35,6 +35,34 @@ Page({
goMorePage() { goMorePage() {
wx.p.router.go('/packageSaveMoney/pages/allEquity/allEquity') wx.p.router.go('/packageSaveMoney/pages/allEquity/allEquity')
}, },
/**授权成功 */
authSuccess() {
this.getLocation()
},
/**授权失败 */
authFail() {
wx.p.storage.set('unauthorized', true)
this.setData({
unauthorized: true
})
},
// 定位
async getLocation() {
try {
const res = await wx.$Track.getAddressInfo()
this.toGetCommodity(res.location.lat, res.location.lng, 1)
this.setData({
currentAddress: res,
unauthorized: false
})
wx.p.storage.set('unauthorized', false)
} catch (error) {
console.log(error)
}
},
// 获取附近优惠数据 // 获取附近优惠数据
toGetCommodity(lat, lng, page) { toGetCommodity(lat, lng, page) {
...@@ -79,6 +107,13 @@ Page({ ...@@ -79,6 +107,13 @@ Page({
}) })
}, },
// 重新收起获取定位
relocation() {
this.setData({
showAuth: true
})
},
onReachBottom() { onReachBottom() {
if (this.data.unauthorized) { if (this.data.unauthorized) {
return return
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
"usingComponents": { "usingComponents": {
"main-title": "../../../components/MainTitle/MainTitle", "main-title": "../../../components/MainTitle/MainTitle",
"menu-box": "./components/MenuBox/MenuBox", "menu-box": "./components/MenuBox/MenuBox",
"gl-icon": "glsx-applet-component/GLIcon/index" "gl-icon": "glsx-applet-component/GLIcon/index",
"commodityItem": "./components/commodityItem/index"
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -73,4 +73,33 @@ ...@@ -73,4 +73,33 @@
.flex { .flex {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
}
.commodity_list_widget {
margin-top: 20rpx;
box-sizing: border-box;
padding: 32rpx;
}
.reLocation_wrap {
width: 100%;
height: 240rpx;
}
.loca_icon {
width: 40rpx;
height: 48rpx;
}
.loca_text {
margin-left: 8rpx;
font-size: 24rpx;
color: #282828;
text-decoration: underline;
}
.flex_cc {
display: flex;
align-items: center;
justify-content: center;
} }
\ No newline at end of file \ No newline at end of file
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
<view class="more-text" bind:tap="goMorePage">更多 <gl-icon iconName="{{'gl-icon-the-arrow'}}" fontSize="26" color="#666666"></gl-icon></view> <view class="more-text" bind:tap="goMorePage">更多 <gl-icon iconName="{{'gl-icon-the-arrow'}}" fontSize="26" color="#666666"></gl-icon></view>
</view> </view>
<menu-box menuList="{{carMenuList}}"></menu-box> <menu-box menuList="{{carMenuList}}"></menu-box>
<view class="title-box"> <view class="title-box">
<view class="near-title">附近优惠</view> <view class="near-title">附近优惠</view>
<view class="near-subTitle">为您精选附近热销商品</view> <view class="near-subTitle">为您精选附近热销商品</view>
......
// export const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/store-assistant/'
import getAppId from '~/utils/utils_wx'
import util from '~/utils/util'
export const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/'
// 缓存get方法为空的默认指定值
export const DEFAULT_GET_STORAGEKEY = ['sessionId', 'merchantId', 'userInfo']
export const appId = getAppId.getAppId()
// 缓存get方法key的对应才映射值
export const STORAGE_OBJECTkEY = {
DEFAULT_GET_STORAGEKEY,
sessionId: 'sessionId',
userInfo: 'userInfo',
system_info: 'system_info',
app_title: 'appTitle',
auto_login_object: 'auto_login_object',
address_info: 'address_info',
wx_user_info: 'wx_user_info',
isVIP: 'isVIP',
edjurl: 'edjurl',
isNeedShowModal: 'isNeedShowModal',
bindInfo: 'bindInfo',
isShowPreModal: 'isShowPreModal',
unauthorized: 'unauthorized',
activityId: 'activityId',
shareStaff: 'shareStaff',
miaoshatrack: 'miaoshatrack',
lastCouponIds: 'lastCouponIds',
merchant_info: 'merchant_info',
refresh_oil_oage: 'refresh_oil_oage',
shareStaffTracker: 'shareStaffTracker',
srcm_shopmall_merchant_id: 'srcm_shopmall_merchant_id',
srcm_shopmall_city_list: 'srcm_shopmall_city_list',
srcm_shopmall_brand_list: 'srcm_shopmall_brand_list',
newCarBrandList: 'newCarBrandList',
scrm_shopmall_car_brand_list: 'scrm_shopmall_car_brand_list',
srcm_shopmall_user_info: 'srcm_shopmall_user_info',
scrm_shopmall_sessionId: 'scrm_shopmall_sessionId',
closeMask: 'closeMask',
activity_options: 'activity_options',
closePYQTip: 'closePYQTip',
user_profile: 'user_profile',
srcm_shopmall_customer_id: 'srcm_shopmall_customer_id',
mock_data: 'mock_data'
}
export const IMG_VERSION = async () => {
const accountInfo = await util.getMockData()
return accountInfo?.version || Date.now()
}
\ 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!