Commit 87cb41e5 by liimin

Merge branch 'kuangyq_v2.10.0' of http://192.168.3.233:8090/saas/mini-program/ai…

…-card into kuangyq_v2.10.0
2 parents f99a71f1 fe2f40ab
import api from './request' import api from './request'
import ssoApi from './ssoApi' import ssoApi from './ssoApi'
import wechantApi from './wechantApi' import wechatApi from './wechatApi'
import entmicroApi from './entmicroApi' import entmicroApi from './entmicroApi'
const common = 'scrm.api.carlife.common.' const common = 'scrm.api.carlife.common.'
module.exports = { module.exports = {
ssoApi, ssoApi,
entmicroApi, entmicroApi,
wechantApi, wechatApi,
commonApi: { commonApi: {
/**上传图片 /**上传图片
*/ */
......
...@@ -38,7 +38,7 @@ const domain = { ...@@ -38,7 +38,7 @@ const domain = {
const pathEnum = { const pathEnum = {
sso: '/rop-scrm-sso/', sso: '/rop-scrm-sso/',
wechat: '/rop-scrm-sso/', wechat: '/rop-scrm-wechat/',
business: '/rop-scrm-entmicro/' business: '/rop-scrm-entmicro/'
} }
module.exports = { module.exports = {
......
...@@ -22,6 +22,13 @@ module.exports = { ...@@ -22,6 +22,13 @@ module.exports = {
...data ...data
}, true) }, true)
}, },
/**根据openId获取用户信息 */
getUserInfo(data) {
return api.post({
method: `${path}userProfile.getUserInfo`,
...data
}, true)
},
/**退出 */ /**退出 */
logout() { logout() {
return api.post({ return api.post({
......
import api from './request' import api from './request'
const path = 'scrm.api.wechat.' const path = 'scrm.api.wechat.'
module.exports = { module.exports = {
/**根据openId获取用户信息 */ /** 解析scene */
getUserInfo(data) { getSceneById(data) {
return api.post({ return api.post({
method: `${path}weapp.userProfile.getUserInfo`, method: `${path}get.scene.by.id`,
...data ...data
}, true) }, true)
}, }
} }
...@@ -4,8 +4,9 @@ import util from './utils/util.js' ...@@ -4,8 +4,9 @@ import util from './utils/util.js'
import './utils/Track' import './utils/Track'
import { import {
ssoApi, ssoApi,
wechantApi wechatApi
} from './api/api' } from './api/api'
import {trackData} from './utils/data'
App({ App({
onLaunch: function (options) { onLaunch: function (options) {
/**挂载到wx对象 */ /**挂载到wx对象 */
...@@ -13,6 +14,7 @@ App({ ...@@ -13,6 +14,7 @@ App({
wx.$router = router wx.$router = router
wx.$imgUrl = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/ai-card/' wx.$imgUrl = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/ai-card/'
wx.$appId = wx.getAccountInfoSync().miniProgram.appId wx.$appId = wx.getAccountInfoSync().miniProgram.appId
wx.$trackData = options.query
this.globalData.appId = wx.getAccountInfoSync().miniProgram.appId this.globalData.appId = wx.getAccountInfoSync().miniProgram.appId
const systemInfo = wx.getStorageSync('srcm_shopmall_system_info') const systemInfo = wx.getStorageSync('srcm_shopmall_system_info')
if (!systemInfo) wx.getSystemInfo({ if (!systemInfo) wx.getSystemInfo({
...@@ -20,8 +22,10 @@ App({ ...@@ -20,8 +22,10 @@ App({
util.setStorageSync('srcm_shopmall_system_info', res) util.setStorageSync('srcm_shopmall_system_info', res)
} }
}) })
console.log(options) if (options.path != 'pages/tab/index/index') {
this.login() this.login()
}
}, },
login(returnResponse) { login(returnResponse) {
let _this = this let _this = this
...@@ -34,16 +38,13 @@ App({ ...@@ -34,16 +38,13 @@ App({
code, code,
appId: _this.globalData.appId appId: _this.globalData.appId
}).then(res => { }).then(res => {
console.log(res)
wx.$authStatus = res.code != 0 wx.$authStatus = res.code != 0
util.setSessionId(res.data.sessionId) util.setSessionId(res.data.sessionId)
const openId = res.data.openId const openId = res.data.openId
wechantApi.getUserInfo({ ssoApi.getUserInfo({
openId openId
}).then(result => { }).then(result => {
console.log(result)
if (returnResponse) { if (returnResponse) {
console.log(result,' ====')
resolve(result) resolve(result)
} else { } else {
if (result.code != -1) { if (result.code != -1) {
...@@ -63,10 +64,30 @@ App({ ...@@ -63,10 +64,30 @@ App({
wx.$authStatus = true wx.$authStatus = true
reject() reject()
}) })
if (wx.$trackData.scene) {
_this.getScene(wx.$trackData.scene).then(res => {
wx.$trackData.merchant = res.merchantId
})
wx.$Track.sendTrack(trackData.COMPANY)
}
} }
}) })
}) })
}, },
getScene(scene) {
return new Promise((resolve, reject) => {
wechatApi.getSceneById({
id: decodeURIComponent(scene).split('=')[1]
}).then(({data}) => {
let op = {}
data.scene.split('&').map(item => {
const [key, val] = item.split("=")
op[key] = val
})
resolve(op)
})
})
},
globalData: { globalData: {
} }
}) })
\ No newline at end of file \ No newline at end of file
// components/Login/Login.js // components/Login/Login.js
import { import { ssoApi } from "../../api/api";
ssoApi import { componentsMixin } from "../../mixins/index";
} from '../../api/api'
import {
componentsMixin
} from '../../mixins/index'
Component({ Component({
behaviors: [componentsMixin], behaviors: [componentsMixin],
/** /**
* 组件的属性列表 * 组件的属性列表
*/ */
properties: { properties: {},
}, observers: {},
observers: {
},
/** /**
* 组件的初始数据 * 组件的初始数据
*/ */
data: { data: {},
},
/** /**
* 组件的方法列表 * 组件的方法列表
*/ */
methods: { methods: {
// 获取手机号 // 获取手机号
getPhoneNumber ({detail}) { getPhoneNumber({ detail }) {
console.log(detail) console.log(detail);
this.triggerEvent("getPhoneNumber") getApp()
getApp().login(true).then(({ .login(true)
data .then(({ data }) => {
}) => { console.log(data, "----------");
console.log(data, '----------') // wx.$util.setSessionId(data.sessionId)
// wx.$util.setSessionId(data.sessionId) if (
if (detail.errMsg && detail.errMsg == 'getPhoneNumber:fail user deny') { detail.errMsg &&
return detail.errMsg == "getPhoneNumber:fail user deny"
} ) {
delete detail.errMsg return;
if (detail.iv && detail.encryptedData) { }
console.log('1111') delete detail.errMsg;
detail.sessionId = data.sessionId if (detail.iv && detail.encryptedData) {
console.log(detail); console.log("1111");
ssoApi.authUserPhone(detail).then(({ detail.sessionId = data.sessionId;
data, console.log(detail);
code ssoApi.authUserPhone(detail).then(({ data, code }) => {
}) => { console.log(data);
console.log(data) wx.$util.setUserInfo(data);
wx.$util.setUserInfo(data) wx.$util.setSessionId(data.sessionId);
wx.$util.setSessionId(data.sessionId) // 其他操作
// 其他操作 this.triggerEvent("getPhoneNumber");
});
}) }
} });
})
}, },
}
})
\ No newline at end of file \ No newline at end of file
},
});
// components/UserInfo/UserInfo.js // components/UserInfo/UserInfo.js
import { import { componentsMixin } from "../../mixins/index";
componentsMixin import util from "../../utils/util";
} from '../../mixins/index'
Component({ Component({
behaviors: [componentsMixin], behaviors: [componentsMixin],
/** /**
* 组件的属性列表 * 组件的属性列表
*/ */
properties: {}, properties: {
cardInfo: {
type: Object,
observer(n) {
this.setData({
cardInfo: n,
});
},
},
},
/** /**
* 组件的初始数据 * 组件的初始数据
*/ */
data: { data: {
showWechant: false showWechant: false,
}, },
/** /**
...@@ -22,60 +30,66 @@ Component({ ...@@ -22,60 +30,66 @@ Component({
methods: { methods: {
// 添加微信 // 添加微信
addWechat() { addWechat() {
console.log(112, this.data.showWechant) console.log(112, this.data.showWechant);
this.setData({ this.setData({
showWechant: !this.data.showWechant showWechant: !this.data.showWechant,
}) });
console.log(this.data.showWechant) console.log(this.data.showWechant);
}, },
// 保存名片 // 保存名片
addPhone() { addPhone() {
let _this = this, let _this = this,
{ { clickCount } = this.data;
clickCount const { staffName, phoneNumber, operation, address, agentName } =
} = this.data this.data.cardInfo;
wx.addPhoneContact({ wx.addPhoneContact({
firstName: '石文', firstName: staffName,
mobilePhoneNumber: '13274150220', mobilePhoneNumber: phoneNumber,
title: '市场总监', title: operation,
organization: '广联数科', organization: agentName,
workAddressCountry: '中国', workAddressCountry: "中国",
workAddressState: '广东省', workAddressState: "广东省",
workAddressCity: '深圳市', workAddressCity: "深圳市",
workAddressStreet: '留仙大道3370号', workAddressStreet: address,
fail({ fail({ errMsg }) {
errMsg if (clickCount)
}) { _this.setData({
if (clickCount) _this.setData({ showAuth: errMsg == "addPhoneContact:fail auth deny",
showAuth: errMsg == 'addPhoneContact:fail auth deny' });
}) else
else _this.setData({ _this.setData({
clickCount: 1 clickCount: 1,
}) });
} },
}) });
}, },
/**授权通讯录成功 */ /**授权通讯录成功 */
authSuccess() { authSuccess() {
this.setData({ this.setData({
flag: true, flag: true,
unauthorized: false unauthorized: false,
}) });
this.addPhone() this.addPhone();
}, },
/**授权失败 */ /**授权失败 */
authFail() { authFail() {
this.setData({ this.setData({
unauthorized: true, unauthorized: true,
flag: true flag: true,
}) });
}, },
/** 拨打电话 */ /** 拨打电话 */
callPhone() { callPhone() {
console.log(this.data.cardInfo);
const { phoneNumber } = this.data.cardInfo;
if (!phoneNumber) {
util.showToast("手机号不存在");
return;
}
wx.makePhoneCall({ wx.makePhoneCall({
phoneNumber: '18925261040',
})
}
}
})
\ No newline at end of file \ No newline at end of file
phoneNumber: phoneNumber,
});
},
},
});
<view class="user-wrapper"> <view class="user-wrapper">
<view class="user-box"> <view class="user-box">
<view class="user-info"> <view class="user-info" data-item="{{cardInfo}}">
<block wx:if="{{!showWechant}}"> <block wx:if="{{!showWechant}}">
<view class="user-company"> <view class="user-company">
<image class="company-logo" src="{{IMGURL}}home/logo.png"></image> <image class="company-logo" src="{{IMGURL}}home/logo.png"></image>
<text>汽车流通行业数字化运营服务商</text> <text>汽车流通行业数字化运营服务商</text>
</view> </view>
<view class="user-name"> <view class="user-name">
<view class="name">石文</view> <view class="name">{{cardInfo.staffName}}</view>
<view class="position">市场总监</view> <view class="position">{{cardInfo.operation}}</view>
</view> </view>
<view class="user-phone"> <view class="user-phone">
<image class="user-icon" webp src="{{IMGURL}}home/icon-phone.png"></image> <image class="user-icon" webp src="{{IMGURL}}home/icon-phone.png"></image>
<view>13274150220</view> <view>{{cardInfo.agentPhone}}</view>
</view> </view>
<view class="user-address"> <view class="user-address">
<image class="user-icon" webp src="{{IMGURL}}home/icon-address.png"></image> <image class="user-icon" webp src="{{IMGURL}}home/icon-address.png"></image>
<view class="address">深圳市南山区留仙大道3370号南山智园崇文园区1号楼14层</view> <view class="address">深圳市南山区留仙大道3370号南山智园崇文园区1号楼14层</view>
</view> </view>
<image class="user-avatar" src="https://img.zcool.cn/community/01e47e60ab5b4011013eaf70962e3f.jpg@520w_390h_1c_1e_2o_100sh.jpg"></image> <image class="user-avatar" src="{{cardInfo.image}}" lazy-load></image>
<image bindtap="addWechat" class="add-wechat" webp src="{{IMGURL}}home/add-wechat.png"></image> <image bindtap="addWechat" class="add-wechat" webp src="{{IMGURL}}home/add-wechat.png"></image>
</block> </block>
<view class="scrm" wx:else> <view class="scrm" wx:else>
<image class="srcm-img" src="https://img.zcool.cn/community/01e47e60ab5b4011013eaf70962e3f.jpg@520w_390h_1c_1e_2o_100sh.jpg"></image> <image class="srcm-img" webp src="{{cardInfo.wechatCode}}" lazy-load></image>
<view class="scrm-text">长按识别二维码,免费体验嘀加SCRM</view> <view class="scrm-text">长按识别二维码,免费体验嘀加SCRM</view>
<image bindtap="addWechat" class="add-wechat" webp src="{{IMGURL}}home/back-user.png"></image> <image bindtap="addWechat" class="add-wechat" webp src="{{IMGURL}}home/back-user.png"></image>
</view> </view>
...@@ -38,5 +38,4 @@ ...@@ -38,5 +38,4 @@
<button class="btn-primary btn" open-type="share">分享名片</button> <button class="btn-primary btn" open-type="share">分享名片</button>
</view> </view>
</view> </view>
<authorize buttonType="openSetting" show="{{showAuth}}" isShowCheck="{{false}}">
</authorize>
\ No newline at end of file \ No newline at end of file
<authorize buttonType="openSetting" show="{{showAuth}}" isShowCheck="{{false}}"></authorize>
\ No newline at end of file \ No newline at end of file
...@@ -10,7 +10,7 @@ import { menuMixin } from "../../../mixins/index"; ...@@ -10,7 +10,7 @@ import { menuMixin } from "../../../mixins/index";
import Draw from "../../../utils/Draw"; import Draw from "../../../utils/Draw";
import { ssoApi, entmicroApi } from "../../../api/api"; import { ssoApi, entmicroApi } from "../../../api/api";
import util from "../../../utils/util"; import util from "../../../utils/util";
import {trackData} from '../../../utils/data' import { trackData } from "../../../utils/data";
Page({ Page({
behaviors: [menuMixin], behaviors: [menuMixin],
/** /**
...@@ -49,7 +49,7 @@ Page({ ...@@ -49,7 +49,7 @@ Page({
hasPhoneNumber: false, hasPhoneNumber: false,
curTab: [trackData.COMPANY, trackData.CUBE], curTab: [trackData.COMPANY, trackData.CUBE],
// 员工名片信息 // 员工名片信息
cardInfo: [] cardInfo: {},
}, },
introduce(e) { introduce(e) {
const curTabIndex = e.currentTarget.dataset.index; const curTabIndex = e.currentTarget.dataset.index;
...@@ -59,13 +59,13 @@ Page({ ...@@ -59,13 +59,13 @@ Page({
switch (curTabIndex) { switch (curTabIndex) {
case 2: case 2:
console.log("跳转直播"); console.log("跳转直播");
wx.$Track.sendTrack(trackData.VIDEO) wx.$Track.sendTrack(trackData.VIDEO);
break; break;
default: default:
this.setData({ this.setData({
curTabIndex: curTabIndex, curTabIndex: curTabIndex,
}); });
wx.$Track.sendTrack(this.data.curTab[this.data.curTabIndex]) wx.$Track.sendTrack(this.data.curTab[this.data.curTabIndex]);
} }
}, },
...@@ -78,44 +78,45 @@ Page({ ...@@ -78,44 +78,45 @@ Page({
getPhoneNumber() { getPhoneNumber() {
console.log(11111111); console.log(11111111);
this.setData({ this.setData({
hasPhoneNumber: true hasPhoneNumber: true,
}) });
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { onLoad(options) {
console.log(this.data.hasUserInfo); console.log(this.data.hasUserInfo);
getApp().login().then(({data}) => { getApp()
console.log(data); .login()
if (data) { .then(({ data }) => {
this.setData({ console.log(data);
hasUserInfo: true if (data) {
}) this.setData({
} hasUserInfo: true,
if (data.phone) { });
this.setData({ }
hasPhoneNumber: true if (data.phone) {
}) this.setData({
} else { hasPhoneNumber: true,
this.getCardDetail() });
} } else {
}) this.getCardDetail();
}
});
}, },
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
onReady() { onReady() {},
},
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow() { onShow() {
this.setShareInfo(); this.setShareInfo();
console.log(wx.$util.getUserInfo()) console.log(wx.$util.getUserInfo());
wx.$Track.sendTrack(this.data.curTab[this.data.curTabIndex]) wx.$Track.sendTrack(this.data.curTab[this.data.curTabIndex]);
}, },
/** /**
...@@ -269,48 +270,46 @@ Page({ ...@@ -269,48 +270,46 @@ Page({
}, },
// 获取用户昵称 // 获取用户昵称
getUserProfile(e) { getUserProfile(e) {
console.log(e) console.log(e);
this.setData({ this.setData({
hasUserInfo: true hasUserInfo: true,
}) });
// 推荐使用 wx.getUserProfile 获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认 // 推荐使用 wx.getUserProfile 获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认
// 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗 // 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
wx.getUserProfile({ wx.getUserProfile({
desc: "用于完善资料", // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写 desc: "用于完善资料", // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: (res) => { success: (res) => {
console.log(this.data.hasUserInfo) console.log(this.data.hasUserInfo);
ssoApi.authUserInfo({ ssoApi
...res .authUserInfo({
}).then(({ ...res,
code })
}) => { .then(({ code }) => {
if (code == '0') { if (code == "0") {
getApp().login().then(({ getApp()
data .login()
}) => { .then(({ data }) => {
this.setData({ this.setData({
userInfo: data, userInfo: data,
// hasUserInfo: true // hasUserInfo: true
}) });
}) });
} }
}) });
} },
}) });
}, },
// 获取员工名片信息 // 获取员工名片信息
getCardDetail() { getCardDetail() {
const sessionId = util.getSessionId(); const sessionId = util.getSessionId();
let params = {}; let params = {};
params.cardId = 21; params.cardId = 21;
params.sessionId = sessionId; params.sessionId = sessionId;
console.log(params, "+++"); console.log(params, "+++");
entmicroApi.getCardDetail(params).then((res) => { entmicroApi.getCardDetail(params).then((res) => {
console.log(res); console.log(res);
if (res.data) { if (res.data) {
}
} });
}); },
} });
})
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<import src="../../template/equity/equity" /> <import src="../../template/equity/equity" />
<import src="../../template/clue/clue" /> --> <import src="../../template/clue/clue" /> -->
<view class="main-box"> <view class="main-box">
<user-info data="{{cardInfo}}"></user-info> <user-info cardInfo="{{cardInfo}}"></user-info>
<view class="main-bottom"> <view class="main-bottom">
<!-- 面向渠道 --> <!-- 面向渠道 -->
<template is="channel"></template> <template is="channel"></template>
......
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
<view>智能线索</view> <view>智能线索</view>
<image class="m-t-md" src="https://b.zol-img.com.cn/sjbizhi/images/11/320x510/1592967802496.jpg"></image> <image class="m-t-md" src="https://b.zol-img.com.cn/sjbizhi/images/11/320x510/1592967802496.jpg"></image>
</view> </view>
<phone-number></phone-number> <phone-number bind:getPhoneNumber="getPhoneNumber" wx:if="{{!hasPhoneNumber}}"></phone-number>
</template> </template>
\ No newline at end of file \ No newline at end of file
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
<view>数字化权益</view> <view>数字化权益</view>
<image class="m-t-md" src="https://hzyly.com/upload/201908/26/201908261930139956.jpg"></image> <image class="m-t-md" src="https://hzyly.com/upload/201908/26/201908261930139956.jpg"></image>
</view> </view>
<phone-number></phone-number> <phone-number bind:getPhoneNumber="getPhoneNumber" wx:if="{{!hasPhoneNumber}}"></phone-number>
</template> </template>
\ No newline at end of file \ No newline at end of file
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
{ {
"name": "", "name": "",
"pathName": "pages/tab/index/index", "pathName": "pages/tab/index/index",
"query": "scene=sceneId%3D563", "query": "scene=sceneId%3D563&cardId=1",
"launchMode": "default", "launchMode": "default",
"scene": null "scene": null
} }
......
...@@ -124,6 +124,7 @@ class TRACK { ...@@ -124,6 +124,7 @@ class TRACK {
} }
/**定时发送埋点数据 */ /**定时发送埋点数据 */
sendTrack(p) { sendTrack(p) {
console.log(wx.$trackData)
let params = { let params = {
method: 'entmicro.api.business.card.cardRecord' method: 'entmicro.api.business.card.cardRecord'
} }
...@@ -133,10 +134,13 @@ class TRACK { ...@@ -133,10 +134,13 @@ class TRACK {
openId: '123445', openId: '123445',
unionId: '', unionId: '',
phone: '18873336682', phone: '18873336682',
merchant: '12121', // merchant: '12121',
cardId: '1' // cardId: '1'
} }
params = Object.assign(params, userInfo, p) if (!wx.$trackData.merchant) {
}
params = Object.assign(params, userInfo, p, wx.$trackData)
console.log(params) console.log(params)
api.reportTrack(params).then(({ api.reportTrack(params).then(({
code, code,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!