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